/* Atlas Portal · layout: แถบบนบาง + เนื้อหากว้าง 1120 · การ์ดแอปแถวเดียวเท่ากัน · โทน Atlas (กรมท่า/เขียวหัวเป็ด/ทอง) */
:root {
  --bg: #EEF2F4;
  --surface: #FFFFFF;
  --sunk: #F5F7F9;
  --ink: #0F1B2D;
  --muted: #56657A;
  --line: #D5DDE4;
  --accent: #0E6B66;
  --accent-ink: #FFFFFF;
  --gold: #A8822F;
  --app-cf: #0E6B66; --app-ins: #1F4E8C; --app-wf: #9A6B12; --app-oo: #6A3E8F;
  --tint-cf: #E3F1EF; --tint-ins: #E4ECF7; --tint-wf: #F6EEDC; --tint-oo: #EFE7F6;
  --ok: #1E7A46; --ok-bg: #E2F3E9;
  --warn: #9A6400; --warn-bg: #FBF0D9;
  --bad: #B3261E; --bad-bg: #FBE4E2;
  --wait: #6B7787; --wait-bg: #E8EDF1;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 8px 24px rgba(15, 27, 45, .06);
  --f-display: "Kanit", "IBM Plex Sans Thai", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Thai", "Kanit", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B131D; --surface: #121D2A; --sunk: #0F1824; --ink: #E6EDF3; --muted: #93A3B6; --line: #23324A;
    --accent: #43B6AD; --accent-ink: #06201E; --gold: #D9B45E;
    --app-cf: #43B6AD; --app-ins: #6FA3E8; --app-wf: #D9B45E; --app-oo: #B996E0;
    --tint-cf: #12302F; --tint-ins: #15263E; --tint-wf: #2E2715; --tint-oo: #261C35;
    --ok: #5FCB8C; --ok-bg: #143023; --warn: #E6B450; --warn-bg: #33280F;
    --bad: #F08A80; --bad-bg: #3A1A18; --wait: #93A3B6; --wait-bg: #1C2836;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); }
code { font: 400 .86em/1.5 var(--f-mono); }
[hidden] { display: none !important; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 32px 40px;
  display: grid;
  gap: 24px;
}
body.center .wrap { min-height: 100vh; align-content: center; justify-items: center; }

/* top bar */
.bar { background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar-in {
  max-width: 1120px; margin: 0 auto; padding: 10px 20px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 17px/1 var(--f-display); }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--ink); color: var(--gold); font: 600 17px/1 var(--f-display);
}
.logo-mark.big { width: 48px; height: 48px; border-radius: 12px; font-size: 26px; }
.bar-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 14px; }
.bar-nav a { color: var(--muted); text-decoration: none; }
.bar-nav a:hover { color: var(--ink); }
.who { font-weight: 500; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

form.inline { display: inline; margin: 0; }
.link-btn {
  font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* type */
h1 { margin: 0; font: 600 clamp(26px, 4vw, 36px)/1.15 var(--f-display); letter-spacing: -.01em; text-wrap: balance; }
h2 { margin: 0; font: 600 20px/1.25 var(--f-display); }
.eyebrow { font: 500 12px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.muted { color: var(--muted); margin: 0; }
.fine { font-size: 12.5px; color: var(--muted); margin: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
  font: 500 15px/1 var(--f-display);
}
.btn:hover { filter: brightness(1.07); }
.btn.wide { width: 100%; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 13px/1 var(--f-body); color: var(--accent); background: transparent;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; cursor: pointer; text-decoration: none;
}
.ghost-btn:hover { border-color: var(--accent); }
.ghost-btn:disabled { opacity: .55; cursor: progress; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* notice */
.notice {
  width: 100%; max-width: 1120px; padding: 12px 16px; border-radius: 10px; font-weight: 500;
  background: var(--wait-bg); color: var(--ink); border: 1px solid var(--line);
}
body.center .notice { max-width: 420px; }
.notice[data-kind="ok"] { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.notice[data-kind="warn"] { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.notice[data-kind="bad"] { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

/* panels & forms */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; display: grid; gap: 16px; min-width: 0;
}
.panel.narrow { width: 100%; max-width: 420px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.count { font: 500 14px/1 var(--f-mono); color: var(--muted); vertical-align: middle; margin-left: 6px; }
.login-head { display: flex; align-items: center; gap: 14px; }
.login-head > div { display: grid; gap: 6px; }

.form { display: grid; gap: 8px; }
.form label, .form legend { font-size: 13.5px; font-weight: 500; }
.form input[type="email"], .form input[type="password"], .form input:not([type]), .form select {
  width: 100%; font: 400 15px/1.4 var(--f-body); color: var(--ink);
  background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
}
.form .btn { margin-top: 10px; }
.form.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form .field { display: grid; gap: 6px; min-width: 0; margin: 0; }
.form .full { grid-column: 1 / -1; }
.form fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; }
.actions { display: flex; justify-content: flex-end; }
.actions .btn { margin-top: 0; }
@media (max-width: 680px) { .form.grid2 { grid-template-columns: 1fr; } }

.acc-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 12px; }
.acc-row select { max-width: 100%; }
@media (max-width: 560px) { .acc-row { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 400 !important; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.fine-form { justify-self: center; }

.danger-zone { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; border-top: 1px dashed var(--line); }

.onetime { border-color: var(--gold); background: var(--tint-wf); }
.onetime p { margin: 0; }
.secret code {
  display: inline-block; font: 500 22px/1.2 var(--f-mono); letter-spacing: .06em;
  background: var(--surface); padding: 10px 16px; border-radius: 10px; border: 1px dashed var(--gold);
  user-select: all;
}

/* chips & tags */
.chip {
  display: inline-block; font: 500 12px/1 var(--f-body); padding: 5px 9px; border-radius: 999px;
  background: var(--tint-cf); color: var(--app-cf);
}
.chip[data-app="insurance"] { background: var(--tint-ins); color: var(--app-ins); }
.chip[data-app="workflow"] { background: var(--tint-wf); color: var(--app-wf); }
.chip[data-app="owneroffice"] { background: var(--tint-oo); color: var(--app-oo); }
.tag { display: inline-block; font: 500 11.5px/1 var(--f-body); padding: 4px 7px; border-radius: 6px; background: var(--wait-bg); color: var(--ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }

/* table */
.table-wrap { overflow-x: auto; margin-inline: -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font: 500 12px/1.3 var(--f-body); color: var(--muted); text-transform: none; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { color: var(--muted); }
.tbl .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl.compact td { padding: 7px 10px; }
.chips { white-space: nowrap; }

/* portal home */
.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 20px; }
.brand { display: grid; gap: 6px; min-width: 0; }
.summary {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.summary-text { display: grid; gap: 2px; }
.summary-main { font: 500 15px/1.3 var(--f-display); }
.summary-time { font: 400 12px/1.3 var(--f-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--wait); flex: none; }
.dot[data-s="ok"] { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }
.dot[data-s="warn"] { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.dot[data-s="bad"] { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-bg); }

.apps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.apps[data-count="2"], .apps[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.apps[data-count="1"] { grid-template-columns: minmax(0, 420px); }
@media (max-width: 900px) { .apps, .apps[data-count] { grid-template-columns: 1fr; } }

.app {
  --c: var(--app-cf); --t: var(--tint-cf);
  display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 16px;
  padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); min-width: 0;
}
.app[data-app="insurance"] { --c: var(--app-ins); --t: var(--tint-ins); }
.app[data-app="workflow"] { --c: var(--app-wf); --t: var(--tint-wf); }
.app[data-app="owneroffice"] { --c: var(--app-oo); --t: var(--tint-oo); }
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.glyph { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--t); color: var(--c); }
.glyph svg { width: 26px; height: 26px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--f-body);
  padding: 6px 10px; border-radius: 999px; background: var(--wait-bg); color: var(--wait); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill[data-s="ok"] { background: var(--ok-bg); color: var(--ok); }
.pill[data-s="warn"] { background: var(--warn-bg); color: var(--warn); }
.pill[data-s="bad"] { background: var(--bad-bg); color: var(--bad); }
.app-title { display: grid; gap: 2px; }
.app h2 { font-size: 22px; }
.app .en { font: 400 12px/1.4 var(--f-mono); color: var(--muted); letter-spacing: .02em; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.open {
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px; border-radius: 10px;
  background: var(--c); color: var(--surface); font: 500 15px/1 var(--f-display); text-decoration: none;
  transition: filter .15s ease, transform .15s ease;
}
.open:hover { filter: brightness(1.08); transform: translateY(-1px); }
.open svg { width: 16px; height: 16px; }
.empty { text-align: center; justify-items: center; padding-block: 48px; }

/* การ์ดที่ยังไม่มีสิทธิ์: จางลง ไม่มีสีแอป ปุ่มเป็นแบบเส้น */
.app.locked { background: var(--sunk); border-style: dashed; box-shadow: none; }
.app.locked .glyph { background: var(--wait-bg); color: var(--wait); }
.app.locked h2, .app.locked .meta dd { color: var(--muted); }
.lock-pill svg { width: 12px; height: 12px; }
.lock-pill::before { display: none; }
.open.grant { background: transparent; color: var(--accent); border: 1px dashed var(--accent); }
.open.grant:hover { background: var(--tint-cf); transform: none; filter: none; }
.open.muted-cta { margin: 0; background: transparent; color: var(--muted); border: 1px dashed var(--line); font: 400 14px/1 var(--f-body); }

.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 20px;
  padding-top: 18px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}

/* สถานะเซิร์ฟเวอร์ (admin) */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: 1fr; } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: grid; gap: 8px; min-width: 0; }
.stat-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-val { font: 600 22px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.stat-big { font: 600 20px/1.2 var(--f-display); }
.stat-detail { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 999px; background: var(--wait-bg); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ok); transition: width .4s ease; }
.meter[data-s="warn"] span { background: var(--warn); }
.meter[data-s="bad"] span { background: var(--bad); }
.grid2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid2col { grid-template-columns: 1fr; } }
.meta.wide { border-top: 0; padding-top: 0; }
.sub-h { margin: 6px 0 0; font: 500 14px/1.3 var(--f-display); color: var(--muted); }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 14px; }
/* โหลดเครื่อง (admin) · สีกราฟ 2 เส้นจากชุดอ้างอิงที่ผ่านตัวตรวจ (ฟ้า/ส้ม · โหมดมืดใช้เฉดของตัวเอง) */
:root { --s1: #2a78d6; --s2: #eb6834; --p1: #2a78d6; --p2: #9cc3ef; --p3: var(--wait-bg); }
@media (prefers-color-scheme: dark) { :root { --s1: #3987e5; --s2: #d95926; --p1: #3987e5; --p2: #1f4f86; } }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-btn { font: 500 13px/1 var(--f-body); padding: 8px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn[aria-pressed="true"] { background: var(--sunk); color: var(--ink); }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart { margin: 0; min-width: 0; display: grid; gap: 6px; }
.chart figcaption { font: 500 14px/1.3 var(--f-display); }
.chart-plot { position: relative; min-height: 170px; color: var(--muted); font-size: 13px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .axis { fill: var(--muted); font: 400 11px var(--f-mono); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s1, .chart .dot.s1 { stroke: var(--s1); } .chart .line.s2, .chart .dot.s2 { stroke: var(--s2); }
.chart .dot { fill: var(--surface); stroke-width: 2; }
.chart .area.s1 { fill: var(--s1); opacity: .12; stroke: none; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .tip { position: absolute; top: 4px; min-width: 130px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); font-size: 12.5px; display: grid; gap: 3px; pointer-events: none; z-index: 2; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.key::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--s1); }
.key.s2::before { background: var(--s2); }
.cores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.core { display: grid; grid-template-columns: 34px minmax(0, 1fr) 54px; align-items: center; gap: 4px 10px; font-size: 13px; }
.core .fine { grid-column: 2 / -1; }
.core-id { font: 500 12px var(--f-mono); color: var(--muted); }
.stack { display: flex; gap: 2px; height: 14px; border-radius: 7px; overflow: hidden; background: var(--sunk); }
.stack span { display: block; height: 100%; }
.stack .p1, .swatch.p1 { background: var(--p1); } .stack .p2, .swatch.p2 { background: var(--p2); } .stack .p3, .swatch.p3 { background: var(--p3); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bar-cell { min-width: 120px; } .bar-cell .meter { margin-bottom: 4px; }
.meter[data-s="info"] span { background: var(--s1); }

/* terminal (admin) */
.term-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.term-head > div:first-child { display: grid; gap: 4px; }
.term-meta { display: flex; align-items: center; gap: 10px; }
.term-box { height: calc(100vh - 290px); min-height: 360px; background: #0B131D; border: 1px solid var(--line); border-radius: 12px; padding: 10px; overflow: hidden; }
.term-gate { margin: 0 auto; }
.btn.danger { background: var(--bad); color: var(--surface); }
.btn:disabled, .form input:disabled { opacity: .5; cursor: not-allowed; }
.restart-form { padding: 14px 16px; border: 1px dashed var(--line); border-radius: 12px; }
.checks li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) { .open { transition: none; } .open:hover { transform: none; } .meter span { transition: none; } }
