:root {
  --ground: #F3F5F8; --surface: #FFFFFF; --surface-2: #F8FAFB; --ink: #111827; --ink-2: #2B323C; --muted: #5B6573;
  --line: #E1E6EC; --line-2: #EBEFF3; --field: #CDD4DC; --hover: #F4F7F9;
  --accent: #0B7A6B; --accent-ink: #075A4F; --accent-soft: #DDF2EC; --accent-line: #A9DACE;
  --crit: #C2410C; --crit-soft: #FEE7DA; --high-bg: #FDEBD8; --high-ink: #8A3A06;
  --info: #2563EB; --info-soft: #DCE8FD; --info-ink: #1E3A8A;
  --warn-bg: #FFF5E5; --warn-line: #F5CB95; --warn-ink: #7A3605;
  --side: #0F1720; --side-2: #1A2430; --side-ink: #C9D1DA; --side-muted: #8793A1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0B1016; --surface: #131A22; --surface-2: #0F151C; --ink: #E7ECF1; --ink-2: #C9D1DA; --muted: #8E99A6;
    --line: #233040; --line-2: #1C2734; --field: #33414F; --hover: #18212B;
    --accent: #2BB39E; --accent-ink: #5FD3C0; --accent-soft: #10302B; --accent-line: #1E5A50;
    --crit: #F97316; --crit-soft: #3A1C0C; --high-bg: #3A2410; --high-ink: #FDBA74;
    --info: #60A5FA; --info-soft: #14284A; --info-ink: #BFDBFE;
    --warn-bg: #2E2110; --warn-line: #6B4A1C; --warn-ink: #FCD9A8;
    --side: #080C11; --side-2: #141C25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif; color: var(--ink); background: var(--ground); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .92em; }
.muted { color: var(--muted); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { flex: none; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 22px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #10B981, #0B7A6B); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 12px rgba(16, 185, 129, .3); }
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand small { color: var(--side-muted); font-size: 12px; }
.side .sec { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--side-muted); padding: 14px 12px 6px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-ink); text-decoration: none; font-size: 14px; min-height: 44px; transition: background .15s, color .15s; }
.side nav a .ic { opacity: .75; }
.side nav a:hover { background: var(--side-2); color: #fff; }
.side nav a.on { background: var(--side-2); color: #fff; font-weight: 600; }
.side nav a.on::before { content: ""; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: #10B981; }
.side nav a.on .ic { opacity: 1; color: #34D399; }
.side .pill { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 11.5px; font-weight: 600; background: #EA580C; color: #fff; padding: 1px 8px; border-radius: 999px; line-height: 18px; }
.side .pill.soft { background: #334155; }
.who { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--side-2); display: flex; align-items: center; gap: 10px; }
.who .name { flex: 1; min-width: 0; font-size: 13.5px; color: #fff; line-height: 1.3; }
.who .name small { display: block; color: var(--side-muted); font-size: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: none; color: inherit; cursor: pointer; }
.who .icon-btn { color: var(--side-muted); border-color: #2A3542; }
.who .icon-btn:hover { color: #fff; background: var(--side-2); }

.topbar { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 8px 12px; background: var(--side); color: #fff; }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; }
  .topbar .icon-btn { color: #fff; }
  .top-pill { margin-left: auto; text-decoration: none; color: #fff; background: #EA580C; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
  .top-pill:hover { color: #fff; }
}

.content { min-width: 0; padding: 28px 36px 48px; display: flex; flex-direction: column; gap: 22px; max-width: 1480px; width: 100%; }
@media (max-width: 720px) { .content { padding: 18px 14px 40px; gap: 16px; } }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 14px 20px; align-items: flex-end; justify-content: space-between; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.25; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--muted); align-self: flex-start; }
.crumb:hover { color: var(--accent); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--muted); background: var(--hover); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 1px 2px rgba(11, 122, 107, .3); }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }
.btn.dark:hover { opacity: .9; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.danger:hover { border-color: var(--crit); color: var(--crit); background: var(--crit-soft); }
.btn.small { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input[type=text], input[type=search], input[type=password], select, textarea {
  font: inherit; font-size: 14px; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--field); background: var(--surface); color: var(--ink); max-width: 100%; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; width: 100%; line-height: 1.55; }
select { cursor: pointer; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field input, .field select { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.search { position: relative; display: flex; align-items: center; }
.search .ic { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 38px; width: 300px; }
@media (max-width: 720px) { .search, .search input { width: 100%; } .page-head form.row { width: 100%; } .page-head form.row .search { flex: 1; } }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.card-head h2 { margin: 0; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--muted); }
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.count { font-family: "IBM Plex Mono", monospace; font-size: 12px; font-weight: 500; color: var(--muted); background: var(--line-2); padding: 1px 8px; border-radius: 999px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { padding: 18px; display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.kpi:hover { border-color: var(--accent-line); color: inherit; transform: translateY(-1px); }
.kpi .tile { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.kpi .tile.crit { background: var(--crit-soft); color: var(--crit); }
.kpi .tile.info { background: var(--info-soft); color: var(--info); }
.kpi .tile.warn { background: var(--warn-bg); color: var(--warn-ink); }
.kpi .body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.15; font-family: "IBM Plex Mono", monospace; letter-spacing: -.02em; }
.kpi .v small { font-size: 14px; font-weight: 500; font-family: "IBM Plex Sans Thai", sans-serif; color: var(--muted); }
.kpi .v.crit { color: var(--crit); }
.kpi.alert { border-color: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }

/* ---------- toast ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 12px; font-size: 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--accent); box-shadow: var(--shadow-lg); animation: toast-in .25s ease; min-width: 260px; }
.toast .ic { color: var(--accent); }
.toast.error { border-left-color: var(--crit); }
.toast.error .ic { color: var(--crit); }
.toast .icon-btn { width: 30px; height: 30px; margin-left: auto; color: var(--muted); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- notice / empty ---------- */
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.notice-head { display: flex; gap: 12px; align-items: flex-start; color: var(--warn-ink); }
.notice-head h2 { margin: 0; font-size: 16px; }
.notice-head p { margin: 2px 0 0; font-size: 13.5px; opacity: .9; }
.notice .item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.notice .item .info { flex: 1 1 220px; min-width: 0; display: flex; gap: 12px; align-items: center; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--line-2); display: grid; place-items: center; color: var(--muted); margin-bottom: 6px; }
.empty b { color: var(--ink); font-size: 15px; }
.empty p { margin: 0; max-width: 440px; font-size: 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.tabs a:hover { background: var(--hover); color: var(--ink); }
.tabs a.on { background: var(--ink); color: var(--surface); font-weight: 600; }
.tabs a .n { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; padding: 0 6px; border-radius: 999px; background: var(--line-2); color: var(--muted); }
.tabs a.on .n { background: rgba(255, 255, 255, .18); color: inherit; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.filter-chip a { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; color: inherit; }
.filter-chip a:hover { background: var(--accent-line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 10px 16px; white-space: nowrap; background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
td { padding: 14px 16px; border-top: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:first-child td { border-top: 0; }
td .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
td.num { font-family: "IBM Plex Mono", monospace; }
tr[data-href] { cursor: pointer; }
tbody tr:hover td { background: var(--hover); }
tr.urg-Critical td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
tr.urg-High td:first-child { box-shadow: inset 3px 0 0 #F59E0B; }
.t-title { color: var(--ink); text-decoration: none; font-weight: 600; display: block; }
.t-title:hover { color: var(--accent); }
.person { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
@media (max-width: 760px) { .actions { flex-wrap: wrap; } }
.table-foot { padding: 10px 16px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }

/* ตารางเป็นการ์ดบนจอแคบ */
@media (max-width: 760px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 12px 14px; border-top: 1px solid var(--line-2); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  table.stack tbody tr:first-child { border-top: 0; }
  table.stack td { border: 0; padding: 0; background: none !important; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
  table.stack td.wide { grid-column: 1 / -1; }
  table.stack td.end { text-align: right; }
  table.stack td.hide-sm { display: none; }
  tr.urg-Critical, tr.urg-High { box-shadow: inset 3px 0 0 var(--crit); }
  tr.urg-High { box-shadow: inset 3px 0 0 #F59E0B; }
  tr.urg-Critical td:first-child, tr.urg-High td:first-child { box-shadow: none; }
  table.stack .actions { justify-content: flex-start; }
}

/* ---------- avatar / badges ---------- */
.av { --h: 200; width: 30px; height: 30px; flex: none; border-radius: 999px; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; background: hsl(var(--h) 55% 90%); color: hsl(var(--h) 45% 30%); }
@media (prefers-color-scheme: dark) { .btn.primary, .msg.out .bubble, .msg.out .bubble a, .av.me { color: #04201B; } .av { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 60% 82%); } }
.av.lg { width: 38px; height: 38px; font-size: 14px; }
.av.sm { width: 24px; height: 24px; font-size: 11px; }
.av.me { background: var(--accent); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px; }
.u-Critical { background: var(--crit); color: #fff; }
.u-High { background: var(--high-bg); color: var(--high-ink); }
.u-Normal { background: var(--line-2); color: var(--ink-2); }
.st { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px; background: var(--line-2); color: var(--muted); }
.st .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.s-new { background: var(--info-soft); color: var(--info-ink); }
.s-new .dot { background: var(--info); box-shadow: 0 0 0 3px rgba(37, 99, 235, .2); }
.s-in_progress { background: var(--accent-soft); color: var(--accent-ink); }
.s-waiting, .s-pending { background: var(--warn-bg); color: var(--warn-ink); }
.s-active { background: var(--accent-soft); color: var(--accent-ink); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); background: var(--line-2); padding: 1px 8px; border-radius: 6px; white-space: nowrap; }

/* switch (ปุ่มเปิด/ปิด AI) */
.switch { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--field); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch[aria-checked=true] .track { background: var(--accent); }
.switch[aria-checked=true] .track::after { transform: translateX(16px); }
.switch[aria-checked=true] { color: var(--ink); }

/* ---------- ticket detail ---------- */
.ticket-head { padding: 20px 22px; display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; justify-content: space-between; }
.ticket-head .main { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1 1 420px; }
.ticket-head h1 { margin: 0; font-size: 22px; line-height: 1.35; }
.ticket-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--muted); }
.ticket-head .meta span { display: inline-flex; align-items: center; gap: 6px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick form { display: contents; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.split .aside { display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
.summary-box { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 14px; white-space: pre-wrap; }
.summary-box .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }

.thread { padding: 20px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); max-height: 62vh; overflow-y: auto; }
.msg { display: flex; gap: 10px; align-items: flex-end; }
.msg .col { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: min(560px, 80%); }
.msg .bubble { padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg .meta { font-size: 12px; color: var(--muted); padding: 0 4px; }
.msg .meta b { color: var(--ink-2); font-weight: 600; }
.msg.out { flex-direction: row-reverse; }
.msg.out .col { align-items: flex-end; }
.msg.out .bubble { background: var(--accent); color: #fff; border-color: var(--accent); border-radius: 16px 16px 4px 16px; }
.msg.out .bubble a { color: #fff; }
.msg img { max-width: 260px; max-height: 320px; border-radius: 14px; border: 1px solid var(--line); display: block; object-fit: cover; }
.composer { padding: 14px 18px 18px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.composer .bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
kbd { font-family: "IBM Plex Mono", monospace; font-size: 11px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--field); border-bottom-width: 2px; background: var(--surface); }

dl.facts { margin: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px 12px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.conf { display: flex; align-items: center; gap: 8px; }
.conf .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--line-2); overflow: hidden; max-width: 120px; }
.conf .bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.sim { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 14px; }
.sim:hover { border-color: var(--accent-line); background: var(--hover); color: var(--ink); }

/* ---------- forms in cards ---------- */
.form-inline { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-inline .btn { height: 42px; }
details.add > summary { list-style: none; cursor: pointer; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary .btn { display: none; }
.cell-input { width: 100%; min-height: 36px !important; padding: 6px 10px !important; border-color: transparent !important; background: transparent !important; }
.cell-input:hover { border-color: var(--field) !important; background: var(--surface) !important; }
.cell-input:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
tr.dirty td { background: var(--warn-bg) !important; }
.save-btn { visibility: hidden; }
tr.dirty .save-btn { visibility: visible; }

/* ---------- messages ---------- */
.mlist { display: flex; flex-direction: column; }
.mrow { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--line-2); align-items: start; }
.mrow:first-child { border-top: 0; }
.mrow:hover { background: var(--hover); }
.mrow .who-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 13px; color: var(--muted); }
.mrow .who-line b { color: var(--ink); font-size: 14px; }
.mrow .text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.mrow .side-info { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12.5px; }
.mrow.out { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
@media (max-width: 640px) { .mrow { grid-template-columns: 30px minmax(0, 1fr); } .mrow .side-info { grid-column: 2; flex-direction: row; align-items: center; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.login .hero { background: radial-gradient(1200px 600px at -10% -10%, #10B98155, transparent 60%), linear-gradient(160deg, #0F1720, #0B2A26); color: #E5F3EF; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login .hero h2 { font-size: 34px; line-height: 1.3; margin: 0 0 12px; color: #fff; letter-spacing: -.01em; }
.login .hero p { margin: 0; color: #A7C4BD; max-width: 460px; font-size: 15.5px; }
.login .hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 14px; }
.login .hero li { display: flex; gap: 12px; align-items: center; color: #D4E7E2; }
.login .hero li .ic { color: #34D399; }
.login .hero li span.t { width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .07); display: grid; place-items: center; flex: none; }
.login .pane { display: grid; place-items: center; padding: 32px 20px; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login h1 { margin: 0; font-size: 26px; }
.login .btn { min-height: 46px; }
.pw { position: relative; }
.pw input { width: 100%; padding-right: 46px; }
.pw .icon-btn { position: absolute; right: 2px; top: 2px; color: var(--muted); }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login .hero { display: none; } }

/* ---------- ปรับละเอียดสำหรับมือถือ ---------- */
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; flex-direction: column; gap: 8px; }
  .kpi .tile { width: 34px; height: 34px; border-radius: 10px; }
  .kpi .v { font-size: 24px; }
  .kpi .body > .muted:last-child { display: none; }
  .notice .item form.row > select, .notice .item form.row > input { flex: 1 1 100%; }
  .notice .item form.row > .muted { display: none; }
  .notice .item form.row .btn { flex: 1; }
  .page-head h1 { font-size: 22px; }
  .ticket-head { padding: 16px; }
  .ticket-head h1 { font-size: 19px; }
  .quick { width: 100%; }
  .quick .btn { flex: 1; }
  .thread { padding: 14px; max-height: none; }
  .msg .col { max-width: 85%; }
}
table.stack td[data-label]::before { font-family: "IBM Plex Sans Thai", sans-serif; }

/* ---------- เริ่มต้นใช้งาน ---------- */
code { font-family: "IBM Plex Mono", monospace; font-size: .88em; background: var(--line-2); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.progress-card { padding: 20px 22px; display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: center; }
.progress-card > div:nth-child(2) { flex: 1 1 280px; }
.ring { --p: 0; width: 72px; height: 72px; border-radius: 999px; flex: none; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line-2) 0); }
.ring span { width: 56px; height: 56px; border-radius: 999px; background: var(--surface); display: grid; place-items: center; font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); }
.ring b { font-size: 20px; color: var(--ink); }
.ring span { display: flex; align-items: baseline; justify-content: center; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; }
.toc a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-size: 13.5px; }
.toc a:hover { border-color: var(--accent); color: var(--accent); }
.section-title { margin: 12px 0 -6px; font-size: 19px; scroll-margin-top: 70px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; align-items: start; }
.step .mark { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; font-family: "IBM Plex Mono", monospace; background: var(--surface); border: 2px solid var(--field); color: var(--muted); margin-top: 12px; }
.step.ok .mark { background: var(--accent); border-color: var(--accent); color: #fff; }
.step details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.step details[open] { border-color: var(--accent-line); }
.step.ok details[open] { border-color: var(--line); }
.step summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; justify-content: space-between; }
.step summary::-webkit-details-marker { display: none; }
.step summary b { font-size: 15.5px; }
.step summary .state { font-size: 13px; color: var(--muted); }
.step:not(.ok) summary .state { color: var(--warn-ink); }
.step.ok summary .state { color: var(--accent-ink); }
.step-body { padding: 0 18px 18px; border-top: 1px solid var(--line-2); font-size: 14.5px; }
.step-body ol { margin: 12px 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.step-body p { margin: 12px 0 8px; }
.hint { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; }
.hint .ic { margin-top: 3px; }
.code { position: relative; margin: 8px 0; }
.code pre { margin: 0; padding: 12px 48px 12px 14px; background: #0F1720; color: #D7F5EC; border-radius: 10px; font-family: "IBM Plex Mono", monospace; font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre; }
.code .icon-btn { position: absolute; top: 5px; right: 5px; color: #8793A1; width: 34px; height: 34px; }
.code .icon-btn:hover { color: #fff; background: #1A2430; }
.code .icon-btn.copied { color: #34D399; }
.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.flow-step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.flow-step p { margin: 0; font-size: 13.5px; color: var(--muted); }
.flow-step .tile { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.flow-step .tile.info { background: var(--info-soft); color: var(--info); }
.flow-step .tile.warn { background: var(--warn-bg); color: var(--warn-ink); }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.tips p { margin: 0; display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.tips p .ic { color: var(--accent); margin-top: 4px; }
.faq details { border-top: 1px solid var(--line-2); }
.faq details:first-child { border-top: 0; }
.faq summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: "IBM Plex Mono", monospace; color: var(--muted); font-size: 18px; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding: 0 18px 16px; color: var(--ink-2); font-size: 14.5px; }
.faq details > div p { margin: 8px 0 4px; }
.setup-banner { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; padding: 14px 18px; border-radius: var(--radius); background: var(--info-soft); color: var(--info-ink); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); }
.setup-banner > div { flex: 1 1 260px; }
.setup-banner b { display: block; }
.setup-banner span { font-size: 13.5px; }
.hint, .tips p { display: block; position: relative; padding-left: 34px; }
.tips p { padding-left: 24px; }
.hint .ic { position: absolute; left: 12px; top: 13px; margin: 0; }
.tips p .ic { position: absolute; left: 0; top: 4px; margin: 0; }

/* ---------- สัญญา MA ---------- */
.ma-card.none { border-color: var(--warn-line); }
.ma-warn { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 12px; font-size: 13.5px; }
.ma-warn .ic { margin-top: 2px; }
.ma-warn b { display: block; font-size: 14px; }
.ma-item { display: flex; flex-direction: column; gap: 10px; }
.ma-item + .ma-item { border-top: 1px dashed var(--line); padding-top: 14px; }
.ma-item dl.facts { grid-template-columns: 104px minmax(0, 1fr); font-size: 13.5px; gap: 6px 10px; }
.ma-type { background: var(--info-soft); color: var(--info-ink); }
.exp { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.exp-warn { color: var(--warn-ink); font-weight: 600; }
.exp-soon { color: var(--crit); font-weight: 600; }
.exp-over { color: #fff; background: var(--crit); padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.scope summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
.scope pre { margin: 8px 0 0; white-space: pre-wrap; font-family: inherit; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; max-height: 260px; overflow: auto; }
.sync-bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-size: 13.5px; color: var(--muted); }
.sync-bar .ok { color: var(--accent-ink); }
.sync-bar .err { color: var(--crit); }
.ma-cell { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ma-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 5px; background: var(--info-soft); color: var(--info-ink); vertical-align: middle; }

/* ---------- ความครอบคลุมตามสัญญา ---------- */
.cov { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 20px; }
.cov-in_scope { background: var(--accent-soft); color: var(--accent-ink); }
.cov-out_of_scope { background: var(--crit-soft); color: var(--crit); }
.cov-uncertain { background: var(--line-2); color: var(--muted); }
.cov-no_contract { background: var(--warn-bg); color: var(--warn-ink); }
.cov-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; border: 1px solid var(--line-2); background: var(--surface-2); }
.cov-box.cov-out_of_scope { border-color: color-mix(in srgb, var(--crit) 35%, transparent); background: var(--crit-soft); }
.cov-box.cov-no_contract { border-color: var(--warn-line); background: var(--warn-bg); }
.ma-item.covering { background: var(--accent-soft); margin: -6px -8px; padding: 10px 8px; border-radius: 10px; }
