﻿/* =====================================================================
   Social Listening · Thailand Tourism — design system
   Navy rail, cool paper, ultramarine for actions, saffron only for
   "live" things (active filters, running events). Anuphan for Thai+Latin.
   ===================================================================== */
@font-face { font-family: "Anuphan"; font-weight: 400; font-display: swap; src: url(fonts/anuphan-thai-400-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-weight: 400; font-display: swap; src: url(fonts/anuphan-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Anuphan"; font-weight: 500; font-display: swap; src: url(fonts/anuphan-thai-500-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-weight: 500; font-display: swap; src: url(fonts/anuphan-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: "Anuphan"; font-weight: 600; font-display: swap; src: url(fonts/anuphan-thai-600-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-weight: 600; font-display: swap; src: url(fonts/anuphan-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: "Anuphan"; font-weight: 700; font-display: swap; src: url(fonts/anuphan-thai-700-normal.woff2) format("woff2"); unicode-range: U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-weight: 700; font-display: swap; src: url(fonts/anuphan-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

:root {
  --rail: #102A43; --rail-2: #173A5C; --rail-ink: #BCCCDC; --rail-ink-strong: #FFFFFF;
  --bg: #F5F6F8; --surface: #FFFFFF; --surface-2: #F0F2F5;
  --ink: #172033; --muted: #5B6578; --faint: #8A93A3; --line: #E3E7ED; --line-strong: #CBD2DC;
  --primary: #3346C8; --primary-ink: #FFFFFF; --primary-soft: #E8EBFB; --primary-hover: #2836A6;
  --saffron: #E3A008; --saffron-soft: #FDF3D8; --saffron-ink: #7A5200;
  --pos: #13896F; --pos-soft: #E1F3EE; --neg: #D64550; --neg-soft: #FBE7E9; --neu: #94A0B4; --nr: #D5DAE1;
  --map-0: #EEF1F6; --map-1: #C9D1F4; --map-2: #8E9DEA; --map-3: #5165D6; --map-4: #2A39A0;
  --radius-panel: 12px; --radius-control: 8px;
  --focus: 0 0 0 3px rgba(51,70,200,.35);
  --font: "Anuphan", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --rail: #0A1220; --rail-2: #14213A; --rail-ink: #93A1B5;
  --bg: #0E1726; --surface: #152238; --surface-2: #1B2A44;
  --ink: #E6EBF2; --muted: #A3AFC2; --faint: #7B889D; --line: #24324A; --line-strong: #33445F;
  --primary: #8391F5; --primary-ink: #0E1726; --primary-soft: #222D5C; --primary-hover: #A1ACF8;
  --saffron: #F2B632; --saffron-soft: #3A2E10; --saffron-ink: #F7D47C;
  --pos: #3CC29D; --pos-soft: #133A33; --neg: #F0707A; --neg-soft: #46202A; --neu: #7E8AA0; --nr: #34425A;
  --map-0: #1D2A42; --map-1: #2B3B70; --map-2: #3F55B0; --map-3: #6478E8; --map-4: #A5B1FA;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rail: #0A1220; --rail-2: #14213A; --rail-ink: #93A1B5;
    --bg: #0E1726; --surface: #152238; --surface-2: #1B2A44;
    --ink: #E6EBF2; --muted: #A3AFC2; --faint: #7B889D; --line: #24324A; --line-strong: #33445F;
    --primary: #8391F5; --primary-ink: #0E1726; --primary-soft: #222D5C; --primary-hover: #A1ACF8;
    --saffron: #F2B632; --saffron-soft: #3A2E10; --saffron-ink: #F7D47C;
    --pos: #3CC29D; --pos-soft: #133A33; --neg: #F0707A; --neg-soft: #46202A; --neu: #7E8AA0; --nr: #34425A;
    --map-0: #1D2A42; --map-1: #2B3B70; --map-2: #3F55B0; --map-3: #6478E8; --map-4: #A5B1FA;
    color-scheme: dark;
  }
}


* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1 { font-size: 26px; line-height: 1.25; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.35; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
p { max-width: 75ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.up { color: var(--pos); } .down { color: var(--neg); }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s; }
.shell.collapsed { grid-template-columns: 68px minmax(0, 1fr); }
.rail { background: var(--rail); color: var(--rail-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 14px 10px; }
.rail .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--rail-ink-strong); font-weight: 700; line-height: 1.2; }
.rail .brand svg { flex: none; }
.rail .brand small { display: block; font-weight: 400; font-size: 12px; color: var(--rail-ink); }
.rail .grp { font-size: 12px; color: #7F97B0; padding: 16px 12px 4px; }
.rail a { display: flex; align-items: center; gap: 12px; color: var(--rail-ink); padding: 8px 12px; border-radius: var(--radius-control); font-size: 14px; }
.rail a:hover { background: var(--rail-2); color: var(--rail-ink-strong); text-decoration: none; }
.rail a.on { background: var(--rail-2); color: var(--rail-ink-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--saffron); }
.rail a svg { flex: none; opacity: .9; }
.rail .foot { margin-top: auto; padding-top: 12px; }
.shell.collapsed .rail .label, .shell.collapsed .rail .grp, .shell.collapsed .rail .brand span { display: none; }
.shell.collapsed .rail a { justify-content: center; padding: 10px; }
.ico { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.topbar select { min-width: 200px; font-weight: 600; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-control); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); }
.searchbtn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; font-size: 14px; min-width: 220px; }
.searchbtn kbd { margin-left: auto; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.who { font-size: 13px; color: var(--muted); line-height: 1.3; text-align: right; text-decoration: none; padding: 2px 6px; border-radius: 8px; }
a.who:hover { background: var(--surface-2); text-decoration: none; }
.who b { color: var(--ink); font-weight: 600; display: block; }
.content { padding: 24px 28px 56px; max-width: none; }

/* ---------- page header ---------- */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead p { margin: 2px 0 0; color: var(--muted); }

/* ---------- panels & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 20px; margin-bottom: 16px; }
.card.tight { padding: 12px 16px; }
.card > h2:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.span2 { grid-column: span 2; }
.grid > .card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }

.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 32px; font-weight: 700; line-height: 1.15; margin: 6px 0 2px; letter-spacing: -.02em; }
.kpi .sub { font-size: 13px; color: var(--muted); }

/* ---------- forms ---------- */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; font-size: 14px; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--ink); max-width: 100%;
}
textarea { height: auto; padding: 10px 12px; width: 100%; min-height: 90px; line-height: 1.5; }
select[multiple] { height: auto; padding: 6px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; vertical-align: -3px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.form-row label, .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field input[type=text], .field input[type=password], .field select, .field textarea { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; }
.check-list label { margin-right: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600;
  height: 38px; padding: 0 16px; border-radius: var(--radius-control); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.accent:hover { opacity: .9; }
.btn.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- tabs / segmented / chips ---------- */
.tabs { display: inline-flex; gap: 2px; flex-wrap: wrap; padding: 3px; background: var(--surface-2); border-radius: 10px; margin-bottom: 14px; }
.tabs a, .tabs button { padding: 6px 14px; border-radius: 8px; color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; border: 0; background: transparent; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs a.on, .tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,42,67,.12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.chips a { padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 13px; }
.chips a:hover { border-color: var(--line-strong); text-decoration: none; }
.chips a.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chips a .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--nr); vertical-align: 1px; }
.chips a .dot.on { background: var(--pos); }
.chips .grp { font-size: 12px; color: var(--faint); margin: 0 2px 0 10px; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 8px 10px; white-space: nowrap; }
table.t td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.pos, .badge.positive, .badge.done, .badge.completed, .badge.ok, .badge.approved { background: var(--pos-soft); color: var(--pos); }
.badge.neg, .badge.negative, .badge.failed { background: var(--neg-soft); color: var(--neg); }
.badge.running, .badge.pulling, .badge.analyzing, .badge.in_review { background: var(--primary-soft); color: var(--primary); }
.badge.active, .badge.live { background: var(--saffron-soft); color: var(--saffron-ink); }
.badge.paused, .badge.skipped, .badge.warn { background: var(--saffron-soft); color: var(--saffron-ink); }

/* ---------- bars ---------- */
.hbar { display: grid; grid-template-columns: 22px minmax(90px, 170px) 1fr 96px; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.hbar .track { background: var(--surface-2); border-radius: 4px; height: 8px; overflow: hidden; }
.hbar .fill { background: var(--primary); height: 100%; border-radius: 4px; }
.hbar .fill.brand { background: var(--primary); }
.progress { background: var(--surface-2); border-radius: 6px; height: 10px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }
.progress.done > div { background: var(--pos); } .progress.failed > div { background: var(--neg); }
.sentbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--nr); }
.sentbar .p { background: var(--pos); } .sentbar .n { background: var(--neu); } .sentbar .x { background: var(--neg); }

/* ---------- mention cards ---------- */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.mcard { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; display: flex; flex-direction: column; }
.mcard .img { height: 132px; background: var(--surface-2) center/cover no-repeat; }
.mcard .img.blur { filter: blur(8px); }
.mcard .body { padding: 12px 14px; flex: 1; font-size: 14px; }
.mcard .src { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mcard .ttl { font-weight: 600; line-height: 1.45; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mcard .sum { color: var(--muted); font-size: 13px; }
.mcard .foot { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.flash.ok { background: var(--pos-soft); color: var(--pos); }
.flash.err { background: var(--neg-soft); color: var(--neg); }
.flash.live { background: var(--saffron-soft); color: var(--saffron-ink); border-color: color-mix(in srgb, var(--saffron) 40%, transparent); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.pager { display: flex; gap: 6px; margin-top: 14px; align-items: center; flex-wrap: wrap; }
.gallery { display: flex; gap: 12px; flex-wrap: wrap; }
.gallery img { max-height: 220px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
pre.text { white-space: pre-wrap; font: inherit; background: var(--surface-2); border-radius: 10px; padding: 14px; margin: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- dashboard: filter bar ---------- */
.filterbar { position: sticky; top: 57px; z-index: 20; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0 12px; background: var(--bg); margin-bottom: 8px; }
.filterbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--saffron-soft); color: var(--saffron-ink); font-size: 13px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--saffron) 45%, transparent); }
.fchip button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.fchip button:hover { background: color-mix(in srgb, var(--saffron) 25%, transparent); }
.menu { position: relative; display: inline-block; }
.menu-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; min-width: 260px; max-height: 380px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,42,67,.18); padding: 6px; display: none; }
.menu.open .menu-pop { display: block; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; justify-content: space-between; gap: 12px; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .hint { color: var(--faint); font-size: 12px; padding: 6px 10px 2px; }
.menu-pop input { width: 100%; margin-bottom: 6px; }

/* ---------- dashboard: KPI with spark ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.kpis .card { margin: 0; padding: 16px 18px 12px; }
.kpi .delta { font-size: 13px; font-weight: 600; }
.kpi .delta.good { color: var(--pos); } .kpi .delta.bad { color: var(--neg); } .kpi .delta.flat { color: var(--muted); }
.kpi canvas { width: 100% !important; height: 38px !important; margin-top: 8px; }

/* ---------- dashboard: world map ---------- */
.mapwrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.map svg { width: 100%; height: auto; display: block; }
.map path.c { fill: var(--map-0); stroke: var(--surface); stroke-width: .5; cursor: pointer; transition: fill .15s; }
.map path.c:hover { stroke: var(--ink); stroke-width: 1; }
.map path.c.sel { stroke: var(--saffron); stroke-width: 2; }
.map path.th { fill: var(--saffron); cursor: default; }
.maplegend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.maplegend .ramp { display: flex; height: 8px; width: 160px; border-radius: 4px; overflow: hidden; }
.maplegend .ramp i { flex: 1; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li button { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; width: 100%; padding: 7px 8px; border: 0; background: transparent; border-radius: 8px; text-align: left; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.rank li button:hover { background: var(--surface-2); }
.rank li button .n { color: var(--muted); font-size: 13px; }
.rank li .sentbar { grid-column: 2 / 4; margin-top: 2px; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--surface); padding: 8px 10px; border-radius: 8px; font-size: 13px; line-height: 1.4; display: none; max-width: 260px; }

/* ---------- dashboard: breakdown rows (clickable) ---------- */
.brow { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 70px 56px; gap: 12px; align-items: center; width: 100%; padding: 8px 6px; border: 0; background: transparent; border-radius: 8px; text-align: left; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.brow:hover { background: var(--surface-2); }
.brow .num { text-align: right; }
.brow .neg { text-align: right; color: var(--neg); font-size: 13px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; min-height: 18px; }
@keyframes sk { to { background-position: -200% 0; } }
.loadingbar { position: fixed; top: 0; left: 0; height: 3px; background: var(--primary); z-index: 200; width: 0; transition: width .3s; }

/* ---------- command palette ---------- */
.palette { position: fixed; inset: 0; z-index: 300; background: rgba(10,18,32,.45); display: none; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.palette.open { display: flex; }
.palette .box { width: min(620px, 92vw); background: var(--surface); border-radius: 14px; box-shadow: 0 24px 64px rgba(0,0,0,.3); overflow: hidden; }
.palette input { width: 100%; height: 54px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; font-size: 17px; padding: 0 18px; }
.palette input:focus { box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li a { display: flex; justify-content: space-between; padding: 10px 12px; border-radius: 8px; color: var(--ink); }
.palette li a .k { color: var(--faint); font-size: 13px; }
.palette li a.on, .palette li a:hover { background: var(--primary-soft); text-decoration: none; }

/* ---------- login ---------- */
.loginpage { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.loginpage .art { background: var(--rail); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.loginpage .art h1 { font-size: 34px; color: #fff; max-width: 14ch; }
.loginpage .art p { color: var(--rail-ink); }
.loginpage .form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.loginpage .form > div { width: 100%; max-width: 360px; }
.login { max-width: 380px; margin: 9vh auto; }

/* ---------- report / print ---------- */
.report h1 { font-size: 28px; }
.report .section { break-inside: avoid; }
@media print {
  .rail, .topbar, .noprint, .filterbar { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; font-size: 12px; }
  .card { border: 1px solid #ddd; break-inside: avoid; }
  .mgrid { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } .mapwrap { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 820px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 250; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .shell.mobile-open .rail { transform: none; }
  .shell.collapsed .rail .label, .shell.collapsed .rail .grp, .shell.collapsed .rail .brand span { display: initial; }
  .topbar { padding: 10px 16px; } .content { padding: 18px 16px 48px; }
  .searchbtn { min-width: 0; } .searchbtn span, .searchbtn kbd, .who { display: none; }
  .g2, .g3, .g4, .kpis { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .hbar { grid-template-columns: 18px minmax(70px, 120px) 1fr 70px; }
  .brow { grid-template-columns: minmax(90px, 1fr) 1fr 56px; } .brow .neg { display: none; }
  .loginpage { grid-template-columns: 1fr; } .loginpage .art { display: none; }
  .filterbar { top: 57px; }
}
.mobile-only { display: none; }
@media (max-width: 820px) { .mobile-only { display: inline-flex; } }

/* =====================================================================
   v1.2 — shared interaction patterns used by every page
   ===================================================================== */
:root { --shadow-pop: 0 16px 40px rgba(16,42,67,.20); --ok: var(--pos); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* page header: title + one-line purpose on the left, actions on the right */
.pagehead { align-items: center; }
.pagehead h1 { margin: 0; text-wrap: balance; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.back:hover { color: var(--ink); text-decoration: none; }
.back svg { width: 16px; height: 16px; }
.eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 2px; }

/* stat strip: a quiet row of numbers inside a panel */
.statstrip { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.statstrip > div { flex: 1 1 140px; padding: 12px 16px; border-right: 1px solid var(--line); }
.statstrip > div:last-child { border-right: 0; }
.statstrip .l { font-size: 12px; color: var(--muted); }
.statstrip .v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.statstrip .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* empty state: says what is missing and offers the next action */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 16px; }
.empty svg { width: 36px; height: 36px; stroke: var(--faint); fill: none; stroke-width: 1.5; margin-bottom: 4px; }
.empty b { color: var(--ink); font-weight: 600; }
.empty .btn { margin-top: 8px; }

/* tables */
.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t .rowtitle { font-weight: 600; color: var(--ink); }
table.t .rowtitle:hover { color: var(--primary); }
table.t td .actions { display: inline-flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.card > .tablewrap:last-child table.t tr:last-child td, .card > table.t:last-child tr:last-child td { border-bottom: 0; }

/* switch: wrap any asp:CheckBox with CssClass="switch" */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input[type=checkbox]::before { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input[type=checkbox]:checked { background: var(--pos); }
.switch input[type=checkbox]:checked::before { transform: translateX(16px); }
.switch label { cursor: pointer; }

/* checkbox lists rendered by asp:CheckBoxList */
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label, .checks > span { display: inline-flex; }
.checkgrid td { padding: 4px 16px 4px 0; }
.option { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 14px; }

/* buttons: busy state while a postback is running */
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .btn.accent.busy::after { border-color: var(--primary-ink) transparent var(--primary-ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn .ico { width: 16px; height: 16px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btngroup { display: inline-flex; }
.btngroup .btn { border-radius: 0; margin-left: -1px; }
.btngroup .btn:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); margin-left: 0; }
.btngroup .btn:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }

/* toasts (flash messages) */
.toasts { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 400; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 16px; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-pop); font-size: 14px; animation: toastin .2s ease-out; }
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--pos); margin-top: 7px; }
.toast.err::before { background: var(--neg); }
.toast span { flex: 1; }
.toast button { border: 0; background: transparent; color: inherit; opacity: .7; cursor: pointer; width: 24px; height: 24px; border-radius: 6px; font-size: 16px; line-height: 1; }
.toast button:hover { opacity: 1; background: rgba(255,255,255,.12); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* dialog (replaces the browser's confirm box) */
.dialog { position: fixed; inset: 0; z-index: 450; background: rgba(10,18,32,.45); display: none; align-items: center; justify-content: center; padding: 16px; }
.dialog.open { display: flex; }
.dialog .box { width: min(440px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 22px 22px 18px; }
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog p { margin: 0 0 18px; color: var(--muted); }
.dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
.btn.danger.solid { background: var(--neg); border-color: var(--neg); color: #fff; }

/* side navigation used by settings-style pages */
.sidelayout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.sidenav { position: sticky; top: 72px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 8px; max-height: calc(100vh - 90px); overflow-y: auto; }
.sidenav .h { font-size: 12px; color: var(--faint); padding: 10px 10px 4px; }
.sidenav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidenav a .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nr); flex: none; }
.sidenav a .dot.on { background: var(--pos); }
.sidenav a .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.sidenav a.sub { padding-left: 26px; }

/* action bar: sticky strip for the page's primary actions */
.actionbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); margin-bottom: 16px; }
.actionbar .grow { flex: 1; }
.actionbar .hint { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* key/value list */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* file input as a drop zone */
.drop { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; border: 1.5px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.drop input[type=file] { font: inherit; font-size: 13px; color: var(--ink); max-width: 100%; }
.drop input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: 13px; height: 30px; padding: 0 12px; margin-right: 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }

/* library: result list */
.results { display: flex; flex-direction: column; }
.result { display: grid; grid-template-columns: 88px minmax(0, 1fr) 150px; gap: 16px; padding: 14px 6px; border-bottom: 1px solid var(--line); align-items: start; }
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--surface-2); border-radius: 10px; }
.result .thumb { width: 88px; height: 66px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 11px; text-align: center; }
.result .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.result .ttl { display: block; font-weight: 600; color: var(--ink); line-height: 1.45; margin: 3px 0; overflow-wrap: anywhere; }
.result .ttl:hover { color: var(--primary); text-decoration: none; }
.result .sum { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.result .nums { font-size: 13px; text-align: right; color: var(--muted); display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.result .nums b { color: var(--ink); font-weight: 600; }
.filters-more { display: none; }
.filters-more.open { display: flex; }
.searchfield { position: relative; flex: 2 1 280px; }
.searchfield svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--faint); fill: none; stroke-width: 1.8; }
.searchfield input { width: 100%; padding-left: 38px; height: 42px; font-size: 15px; }

/* step list for guided setup */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; }
.steps li::before { counter-increment: s; content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.steps li.done::before { content: "✓"; background: var(--pos-soft); color: var(--pos); }

@media (max-width: 1000px) {
  .sidelayout { grid-template-columns: 1fr; }
  .sidenav { position: static; max-height: none; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 6px; }
  .sidenav .h { display: none; }
  .sidenav a { white-space: nowrap; }
  .sidenav a.sub { padding-left: 10px; }
}
@media (max-width: 820px) {
  .result { grid-template-columns: 64px minmax(0, 1fr); }
  .result .thumb { width: 64px; height: 52px; }
  .result .nums { grid-column: 2; flex-direction: row; flex-wrap: wrap; gap: 4px 12px; text-align: left; }
  .toasts { right: 16px; left: 16px; max-width: none; }
  .pagehead .actions { width: 100%; }
  .statstrip > div { border-right: 0; border-bottom: 1px solid var(--line); }
}
td.empty { display: table-cell; text-align: center; }
.sidenav a.open { font-weight: 600; }

/* login (v1.2) */
.loginpage .art { position: relative; overflow: hidden; }
.loginpage .art .mark { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; }
.loginpage .art .mark svg { width: 28px; height: 28px; stroke: var(--saffron); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.loginpage .art h1 { font-size: 36px; line-height: 1.2; margin: 0 0 14px; }
.loginpage .art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: var(--rail-ink); font-size: 15px; }
.loginpage .art li { display: flex; gap: 10px; align-items: baseline; }
.loginpage .art li b { color: #fff; font-weight: 600; min-width: 4.5ch; font-variant-numeric: tabular-nums; }
.loginpage .art .markets { font-size: 13px; color: #7F97B0; letter-spacing: .02em; }
.loginpage .art .rings { position: absolute; right: -120px; bottom: -120px; width: 300px; height: 300px; border-radius: 50%; border: 1px solid rgba(227,160,8,.30); box-shadow: 0 0 0 48px rgba(227,160,8,.04), 0 0 0 96px rgba(227,160,8,.025); pointer-events: none; }
.loginpage .form { background: var(--surface); }
.loginpage .form h2 { font-size: 24px; margin: 0 0 4px; }
.loginpage .form .btn { width: 100%; height: 44px; margin-top: 6px; }
.loginpage .form input[type=text], .loginpage .form input[type=password] { height: 44px; }
.loginpage .foot { margin-top: 28px; font-size: 13px; color: var(--muted); }
[hidden] { display: none !important; }
kbd { font: inherit; font-size: 12px; padding: 0 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--ink); }
.filtergrid.open { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.filtergrid select, .filtergrid input { width: 100%; }
.progress.skipped > div { background: var(--neu); }

/* v2 TOR: ตัวเลขบนเมนู */
.rail a .navcount { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--neg, #d4483b); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.shell.collapsed .rail a { position: relative; }
.shell.collapsed .rail a .navcount { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.help { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.help .toc { position: sticky; top: 76px; }
.help .toc a { display: block; padding: 6px 10px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.help .toc a:hover { background: var(--surface-2); text-decoration: none; }
.help section { scroll-margin-top: 80px; }
.help section h2 { margin-top: 0; }
.help p, .help li { line-height: 1.75; max-width: 72ch; }
.help code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.help table.t td, .help table.t th { vertical-align: top; }
@media (max-width: 900px) { .help { grid-template-columns: 1fr; } .help .toc { position: static; } }

/* =====================================================================
   ระบบแบบฟอร์ม (v3): แบ่งเป็นหมวด, ช่องกว้างตามข้อมูล, ป้ายชัด, คำแนะนำ, ตรวจข้อมูลก่อนส่ง
   ใช้: <div class="fsec"><div class="fhead"><h3>หัวข้อ</h3><p>คำอธิบาย</p></div>
          <div class="fgrid"><div class="f c6"><label>ชื่อ<span class="req">*</span></label><input data-required> <span class="hint">..</span></div></div></div>
        <div class="formbar">ปุ่ม</div>
   ===================================================================== */
.fsec { display: grid; grid-template-columns: minmax(170px, 250px) minmax(0, 1fr); gap: 10px 36px; padding: 22px 0; border-top: 1px solid var(--line); }
.fsec:first-child, .fsec.first { border-top: 0; padding-top: 2px; }
.fsec.solo { grid-template-columns: minmax(0, 1fr); }
.fhead h3 { font-size: 15px; font-weight: 650; margin: 0 0 4px; }
.fhead p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.fhead .step { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; align-items: center; justify-content: center; margin-bottom: 8px; }
.fgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.fgrid > * { grid-column: span 12; min-width: 0; }
.fgrid > .c2 { grid-column: span 2; } .fgrid > .c3 { grid-column: span 3; } .fgrid > .c4 { grid-column: span 4; }
.fgrid > .c5 { grid-column: span 5; } .fgrid > .c6 { grid-column: span 6; } .fgrid > .c7 { grid-column: span 7; }
.fgrid > .c8 { grid-column: span 8; } .fgrid > .c9 { grid-column: span 9; } .fgrid > .c12 { grid-column: span 12; }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f > label, .f > .lbl { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 0; line-height: 1.4; }
.f .req { color: var(--neg); margin-left: 3px; font-weight: 700; }
.f .opt { font-weight: 400; color: var(--faint); margin-left: 6px; font-size: 12.5px; }
.f .hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.f .err { font-size: 12.5px; color: var(--neg); display: none; font-weight: 500; }
.f input[type=text], .f input[type=password], .f input[type=number], .f input[type=date], .f input[type=datetime-local], .f input[type=email], .f select, .f textarea { width: 100%; height: 40px; }
.f textarea { height: auto; min-height: 84px; }
.f.invalid input, .f.invalid select, .f.invalid textarea { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.f.invalid .err { display: block; }
input[type=datetime-local], input[type=email] { font: inherit; font-size: 14px; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); max-width: 100%; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
/* ช่องพร้อมหน่วยท้าย เช่น "นาที" "บาท" */
.ig { display: flex; align-items: stretch; min-width: 0; }
.ig input, .ig select { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.ig .suf { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--radius-control) var(--radius-control) 0; background: var(--surface-2); color: var(--muted); font-size: 13px; white-space: nowrap; }
.ig.pre input { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.ig .pre { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius-control) 0 0 var(--radius-control); background: var(--surface-2); color: var(--muted); font-size: 13px; }
/* ตัวเลือกแบบปุ่มแบ่งช่อง (RadioButtonList RepeatLayout=Flow CssClass="seg") */
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 10px; max-width: 100%; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 500; line-height: 1.35; margin: 0; }
.seg label:hover { color: var(--ink); }
.seg input:checked + label { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(16,42,67,.14); }
.seg input:focus-visible + label { box-shadow: var(--focus); }
/* ตัวเลือกแบบการ์ด (RadioButtonList/CheckBoxList RepeatLayout=Flow CssClass="choice") */
.choice { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice label { display: block; border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 14px 11px 38px; cursor: pointer; font-size: 14px; line-height: 1.45; position: relative; background: var(--surface); margin: 0; }
.choice label::before { content: ""; position: absolute; left: 13px; top: 13px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
.choice.multi label::before { border-radius: 4px; }
.choice input:checked + label { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked + label::before { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 3px var(--surface); }
.choice input:focus-visible + label { box-shadow: var(--focus); }
.choice label small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.choice br { display: none; }
/* แถบปุ่มท้ายฟอร์ม */
.formbar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding-top: 16px; margin-top: 6px; border-top: 1px solid var(--line); }
.formbar .left, .formbar .note { margin-right: auto; color: var(--muted); font-size: 13px; }
.card > .formbar:last-child { margin: 18px -20px -20px; padding: 14px 20px; background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 var(--radius-panel) var(--radius-panel); }
.formbar.sticky { position: sticky; bottom: 0; z-index: 5; }
/* หัวการ์ดฟอร์ม */
.fcard-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 6px; }
.fcard-head h2 { margin: 0; }
.fcard-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
/* ฟอร์มสั้นในแถวเดียว (ตัวกรอง/ค้นหา) */
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .f { flex: 1 1 180px; }
.inline-form .f.w-sm { flex: 0 1 140px; } .inline-form .f.w-lg { flex: 2 1 320px; }
/* กล่องสรุป/ข้อมูลอ้างอิงในฟอร์ม */
.callout { border: 1px solid var(--line); border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 8px; padding: 10px 14px; font-size: 13.5px; line-height: 1.55; }
.callout.warn { border-left-color: #E3A008; }
.callout.ok { border-left-color: var(--pos); }
.callout b { color: var(--ink); }
@media (max-width: 900px) {
  .fsec { grid-template-columns: 1fr; gap: 12px; }
  .fgrid > [class*="c"] { grid-column: span 12; }
  .fgrid > .c3.keep, .fgrid > .c4.keep, .fgrid > .c6.keep { grid-column: span 6; }
}
.card.collapsible { display: none; }
.card.collapsible.open { display: block; }
.mono, textarea.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.choice.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.choice.compact label { padding: 7px 10px 7px 32px; font-size: 13.5px; }
.choice.compact label::before { left: 10px; top: 9px; width: 14px; height: 14px; }
.choice label.disabled, .choice input:disabled + label { opacity: .55; cursor: not-allowed; }
.choice .cap { margin-left: 4px; }
label.drop { flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px 18px; cursor: pointer; gap: 6px; font-weight: 400; transition: border-color .15s, background .15s; }
label.drop b { font-size: 15px; color: var(--ink); }
label.drop .ico { width: 26px; height: 26px; color: var(--primary); }
label.drop:hover, label.drop.over { border-color: var(--primary); background: var(--primary-soft); }
label.drop input[type=file] { margin-top: 8px; }
.inline-form .f.grow { flex: 1 1 260px; }
.vgroup + .vgroup { margin-top: 14px; }
/* ฟอร์มในการ์ดครึ่งจอ: หัวข้อส่วนอยู่บนช่อง */
.grid.g2 .fsec, .grid.g3 .fsec { grid-template-columns: minmax(0, 1fr); gap: 12px; }
/* แถบสรุปข้อมูลในคลังบน Dashboard */
.datastatus { position: relative; display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; padding: 10px 14px 12px; margin: 0 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 13.5px; text-decoration: none; overflow: hidden; }
.datastatus .more { margin-left: auto; font-weight: 600; white-space: nowrap; }
.datastatus b { color: var(--ink); font-variant-numeric: tabular-nums; }
.datastatus .warn { color: var(--neg); }
.datastatus .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.datastatus .bar i { display: block; height: 100%; background: var(--pos); }
/* ตัวกรองแพลตฟอร์มแยกหมวด (หน้ารายงาน) */
.plgroup + .plgroup { margin-top: 12px; }
.plgroup-h { font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.choice .nodata label { color: var(--muted); border-style: dashed; }
.choice input:checked + label small, .choice .nodata label small { color: var(--faint, var(--muted)); }
#platFilter:not(.showall) .plx { display: none; }
.plall { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin: 2px 0 10px; cursor: pointer; }
/* กล่อง "กำลังโหลด" กลางจอ */
.loadmask { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(1.5px); opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s; }
.loadmask.open { opacity: 1; visibility: visible; }
.loadmask .box { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 240px; padding: 22px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(16, 42, 67, .18); }
.loadmask .box b { font-size: 15px; color: var(--ink); }
.loadmask .box small { font-size: 12.5px; color: var(--muted); }
.loadmask .spinner { width: 34px; height: 34px; margin-bottom: 6px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: lmspin .8s linear infinite; }
@keyframes lmspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loadmask .spinner { animation-duration: 2s; } }
/* ปุ่มลัดเลือกช่วงเวลา */
.quickdates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quickdates button { font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.quickdates button:hover { color: var(--ink); border-color: var(--primary); }
/* ตัวเลือก Project บนแถบบน */
.projpick { position: relative; }
.projpick-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 220px; max-width: 360px; height: 38px; padding: 0 10px 0 12px; font: inherit; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; }
.projpick-btn:hover { border-color: var(--primary); }
.projpick-btn b { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.projpick-btn .r:empty { display: none; }
.projpick-btn .r { font-size: 11.5px; font-weight: 600; color: var(--primary); background: var(--primary-soft); border-radius: 999px; padding: 1px 8px; }
.projpick-btn .ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; color: var(--muted); }
.projpick-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; width: 340px; max-width: calc(100vw - 32px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 42, 67, .18); padding: 8px; }
.projpick-pop input { width: 100%; height: 36px; margin-bottom: 6px; }
.projpick-pop .list { max-height: min(420px, 60vh); overflow-y: auto; }
.projpick-pop .grp { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px 4px; }
.projpick-pop .opt { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; }
.projpick-pop .opt:hover, .projpick-pop .opt.act { background: var(--surface-2); }
.projpick-pop .opt.on { color: var(--primary); font-weight: 600; }
.projpick-pop .opt.on::after { content: " ✓"; }
.projpick-pop .none { padding: 12px; color: var(--muted); font-size: 13px; }
@media (max-width: 700px) { .projpick-btn { min-width: 0; max-width: 46vw; } }
