/* Prospect Engine.
   Light and airy after Thomas's references: a floating light sidebar that folds
   to icons, a search bar on top, hairline dividers instead of heavy boxes, one
   indigo accent, and last period in grey beside this one.
   Status always carries an icon and a word, never colour alone. */

/* ---------- type: IBM Plex Sans Thai, Latin + Thai, loaded per script ---------- */
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-thai-400-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-thai-400-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-thai-600-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-thai-600-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-thai-700-latin.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+20AC, U+2122, U+2191, U+2193, U+2212, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-thai-700-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }

/* ---------- tokens ---------- */
:root {
  --font: "Plex", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", sans-serif;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f2f3f7;
  --hover: #f5f6fa;
  --line: #eaecf1;
  --line-strong: #dcdfe7;
  --ink: #1c1e2b;
  --ink-2: #414558;
  --muted: #737791;
  --faint: #a4a8ba;

  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-soft: #eef0fd;
  --accent-ink: #ffffff;

  /* status: reserved, always with icon + label */
  --a: #0d9488;      --a-soft: #e7f6f4;     /* no website: the opportunity */
  --b: #b45309;      --b-soft: #fdf2e3;     /* old website */
  --check: #4f46e5;  --check-soft: #eef0fd; /* search to confirm */
  --no: #737791;     --no-soft: #f2f3f7;
  --good: #0e8f55;   --good-soft: #e6f5ec;
  --danger: #d0303c; --danger-soft: #fdecee;

  /* chart palette, validated with the dataviz skill (light, all pairs pass) */
  --c1: #4f46e5; --c2: #0d9488; --c3: #d97706; --c-prev: #dfe2ea;

  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --shadow: 0 1px 2px rgba(28, 30, 43, .04);
  --shadow-md: 0 4px 16px -6px rgba(28, 30, 43, .10);
  --shadow-lg: 0 16px 40px -12px rgba(28, 30, 43, .22);
  --sidebar: 256px;
  --gutter: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1118; --surface: #161a24; --surface-2: #1d2230; --hover: #1a1f2b; --line: #252b3a; --line-strong: #323a4d;
    --ink: #edf0f6; --ink-2: #c7ccd9; --muted: #969cb2; --faint: #6c7289;
    --accent: #7c79f2; --accent-strong: #9896f6; --accent-soft: #23244a; --accent-ink: #0e1118;
    --a: #2cc3b1; --a-soft: #0f2a28; --b: #f0a24b; --b-soft: #2f210f; --check: #9c9af7; --check-soft: #23244a;
    --no: #969cb2; --no-soft: #1d2230; --good: #3ccf8e; --good-soft: #10291d; --danger: #f76e78; --danger-soft: #2f1519;
    /* dark steps, validated against the dark surface */
    --c1: #6f6ef0; --c2: #0f9f8f; --c3: #c47d12; --c-prev: #323a4d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-md: 0 4px 16px -6px rgba(0, 0, 0, .5); --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
html:lang(th) body { line-height: 1.7; }
h1, h2, h3 { margin: 0; color: var(--ink); letter-spacing: -.01em; font-weight: 600; }
h1 { font-size: clamp(22px, 1.2vw + 14px, 27px); line-height: 1.25; }
h2 { font-size: 16.5px; line-height: 1.35; }
h3 { font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
html:lang(th) .eyebrow { letter-spacing: .02em; text-transform: none; font-size: 12.5px; }
svg.i { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- shell: floating light sidebar ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.shell.collapsed { --sidebar: 88px; }
.side {
  position: sticky; top: var(--gutter); height: calc(100vh - 2 * var(--gutter)); margin: var(--gutter) 0 var(--gutter) var(--gutter);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-md); padding: 16px 12px; overflow: hidden;
}
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 18px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(145deg, #6b63f5, #4f46e5 55%, #3730a3); box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.logo-mark svg.i { width: 18px; height: 18px; stroke: #fff; }
.logo b { font-size: 15px; font-weight: 700; letter-spacing: -.01em; display: block; line-height: 1.2; white-space: nowrap; }
.logo small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.fold {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.fold:hover { color: var(--ink); background: var(--hover); }
.nav-label { padding: 14px 12px 8px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; min-height: 44px;
  color: var(--ink-2); font-weight: 500;
}
.nav a svg.i { color: var(--muted); }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav a.on svg.i { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.nav a.on .count { background: var(--surface); }
.nav .count.hot { background: var(--danger); color: #fff; }
.side-foot { margin-top: auto; display: grid; gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding: 10px 8px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center;
  font-weight: 600; font-size: 13px; text-transform: uppercase; flex: none; border: 1px solid var(--line);
}
.user .who { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.25; white-space: nowrap; }
.user .role { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.user button { margin-left: auto; background: none; border: 0; color: var(--muted); min-height: 36px; padding: 6px; cursor: pointer; border-radius: 8px; }
.user button:hover { color: var(--ink); background: var(--hover); }

/* folded to icons: by the button, or automatically on a medium window */
.shell.collapsed .logo > span:not(.logo-mark), .shell.collapsed .nav a .lbl, .shell.collapsed .nav .count,
.shell.collapsed .nav-label, .shell.collapsed .user > span:not(.avatar), .shell.collapsed .user button { display: none; }
.shell.collapsed .side-top { flex-direction: column; gap: 12px; }
.shell.collapsed .nav a { justify-content: center; padding: 10px; }
.shell.collapsed .user { justify-content: center; padding-left: 0; padding-right: 0; }
@media (max-width: 1180px) and (min-width: 901px) {
  .shell:not(.expanded) { --sidebar: 88px; }
  .shell:not(.expanded) .logo > span:not(.logo-mark), .shell:not(.expanded) .nav a .lbl, .shell:not(.expanded) .nav .count,
  .shell:not(.expanded) .nav-label, .shell:not(.expanded) .user > span:not(.avatar), .shell:not(.expanded) .user button { display: none; }
  .shell:not(.expanded) .side-top { flex-direction: column; gap: 12px; }
  .shell:not(.expanded) .nav a { justify-content: center; padding: 10px; }
  .shell:not(.expanded) .user { justify-content: center; }
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 14px;
  padding: calc(var(--gutter) + 4px) clamp(16px, 3vw, 36px) 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px);
}
.topbar .search { flex: 1; max-width: 560px; }
.topbar .search input { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.topbar .spacer { flex: 1; }
.topbar .today-date { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 8px clamp(16px, 3vw, 36px) 96px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.head-actions select { width: auto; min-width: 210px; }

.lang { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.lang button { background: none; border: 0; color: var(--muted); font: 600 12.5px var(--font); padding: 6px 12px; border-radius: 7px; cursor: pointer; min-height: 32px; }
.lang button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* phone / small tablet: top bar + bottom tabs */
.tabbar { display: none; }
.mobile-top { display: none; }
@media (max-width: 900px) {
  .shell { display: block; }
  .side, .topbar .today-date { display: none; }
  .topbar { padding-top: 10px; }
  .mobile-top {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px 16px 4px; padding-top: max(12px, env(safe-area-inset-top));
  }
  .page { padding-bottom: 110px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30;
    background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 6px 4px;
  }
  .tabbar a { display: grid; justify-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 0; min-height: 50px; border-radius: 12px; }
  .tabbar a.on { color: var(--accent); background: var(--accent-soft); }
  .tabbar svg.i { width: 22px; height: 22px; }
}

/* ---------- controls ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737791' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.search { position: relative; }
.search svg.i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-right: 42px; }

.btn {
  font: 600 14px/1 var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(79,70,229,.25), inset 0 1px 0 rgba(255,255,255,.14); }
.btn-primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.btn-secondary, .btn-outline { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--hover); color: var(--ink); }
.btn-outline { color: var(--accent); border-color: var(--line); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--line-strong); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; box-shadow: 0 0 0 1px var(--accent); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: 600 13.5px var(--font); background: none; border: 0; color: var(--muted); padding: 7px 14px; border-radius: 7px; cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.card-body { padding: 18px 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 18px; align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
@media (max-width: 1080px) { .grid-2.wide-left { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > *, .grid-2 > *, .kpis > *, .main { min-width: 0; }

/* Dashboard board: one surface, cells divided by hairlines (the gap shows the line colour). */
.dash {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
.cell { background: var(--surface); padding: clamp(18px, 2vw, 28px); min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; }
@media (max-width: 1180px) { .span-4 { grid-column: span 6; } .span-4:last-child { grid-column: span 12; } .span-5, .span-7 { grid-column: span 12; } }
@media (max-width: 900px) { .span-8, .span-7, .span-6, .span-5, .span-4, .span-4:last-child { grid-column: span 12; } }
.cell-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.cell-head h2 { font-size: 16.5px; }
.cell-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.big { font-size: clamp(26px, 1.4vw + 16px, 32px); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; }
.delta { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); margin: 4px 0 10px; }
.delta b { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta.up b { color: var(--good); }
.delta.down b { color: var(--danger); }
.cell .chart { margin-top: 10px; }
.cell .legend { margin: 14px 0 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { padding: 20px 22px; display: grid; gap: 6px; text-align: left; color: inherit; }
a.kpi:hover { border-color: var(--line-strong); color: inherit; box-shadow: var(--shadow-md); }
.kpi .label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); }
.kpi .value { font-size: clamp(24px, 1.4vw + 14px, 30px); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; color: var(--ink); }
.kpi.hero { background: var(--accent); border-color: var(--accent); }
.kpi.hero .label, .kpi.hero .hint { color: rgba(255, 255, 255, .78); }
.kpi.hero .value { color: #fff; font-size: clamp(30px, 2vw + 16px, 40px); }
.kpi .hint { font-size: 12.5px; color: var(--faint); }
.kpi .hint.bad { color: var(--danger); font-weight: 600; }
.kpi.hero .hint.bad { color: #fff; }
@media (prefers-color-scheme: dark) { .kpi.hero .value { color: var(--accent-ink); } .kpi.hero .label, .kpi.hero .hint { color: rgba(14, 17, 24, .72); } }

/* status pill: icon + word */
.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; line-height: 1;
  padding: 5px 10px 5px 8px; border-radius: 999px; background: var(--no-soft); color: var(--no); white-space: nowrap;
}
.pill svg.i { width: 14px; height: 14px; stroke-width: 2; }
.pill.p-A { background: var(--a-soft); color: var(--a); }
.pill.p-B { background: var(--b-soft); color: var(--b); }
.pill.p-check { background: var(--check-soft); color: var(--check); }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-radius: 6px; padding: 2px 8px; white-space: nowrap; }
.due { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.late { color: var(--danger); }
.due.today { color: var(--accent); }

/* lists */
.list { display: grid; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; align-items: center;
  padding: 16px 24px; border-top: 1px solid var(--line); color: inherit;
}
.item:first-child { border-top: 0; }
.item:hover { background: var(--hover); color: inherit; }
.item .title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.item .say { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-2); display: flex; gap: 8px; }
.item .say svg.i { color: var(--accent); margin-top: 3px; }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty svg.i { width: 28px; height: 28px; color: var(--faint); }

.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters .search { grid-column: 1 / -1; } }

/* pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; min-height: 240px; scroll-snap-align: start; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 12px; font-weight: 600; font-size: 13.5px; }
.col-head .n { font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.col-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 8px; display: inline-block; }
.col[data-stage="interested"] .dot, .col[data-stage="offer_sent"] .dot { background: var(--b); }
.col[data-stage="won"] .dot { background: var(--good); }
.col .empty { padding: 24px 8px; font-size: 13px; }
.bcard { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 8px; color: inherit; box-shadow: var(--shadow); }
.bcard:hover { border-color: var(--line-strong); color: inherit; box-shadow: var(--shadow-md); }
.bcard .t { font-weight: 600; font-size: 14px; line-height: 1.35; }
.bcard .s { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); }
.bcard .s svg.i { color: var(--accent); margin-top: 2px; }
.bcard .f { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.agenda-group + .agenda-group { margin-top: 22px; }
.agenda-group h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.agenda-group h3 .n { font-size: 12px; color: var(--muted); font-weight: 600; }

/* business page */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 13.5px; margin-bottom: 12px; background: none; border: 0; cursor: pointer; padding: 6px 0; min-height: 36px; font-family: var(--font); }
.back:hover { color: var(--ink); }
.biz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.biz-head .sub { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); }
.next { border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 72%); }
.next .step { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin: 6px 0 4px; }
.outcomes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.outcome { display: grid; gap: 3px; justify-items: start; text-align: left; padding: 10px 14px; min-height: 54px; white-space: normal; }
.outcome small { font-weight: 500; font-size: 12px; opacity: .85; }
.say-box { display: flex; gap: 10px; padding: 14px 16px; background: var(--surface-2); border-radius: var(--r); color: var(--ink-2); }
.say-box svg.i { color: var(--accent); margin-top: 3px; }
.reasons { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.reasons li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.reasons li svg.i { color: var(--b); margin-top: 3px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { position: relative; padding: 0 0 18px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 19px; bottom: 2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--faint); }
.timeline .what { font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.photo { display: block; width: 100%; border-radius: var(--r); margin-top: 14px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
details ul { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.score { display: flex; align-items: center; gap: 12px; margin: 10px 0 14px; }
.meter { flex: 1; height: 6px; background: var(--b-soft); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--b); border-radius: 999px; }
.score b { font-size: 13px; color: var(--ink-2); white-space: nowrap; }

/* ---------- insights ---------- */
.trend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.trend b { font-weight: 600; color: var(--ink-2); }
.trend.up b { color: var(--good); }
.trend.down b { color: var(--danger); }
.chart { position: relative; height: clamp(210px, 26vw, 290px); }
.chart.low { height: clamp(190px, 22vw, 250px); }
.chart.donut { height: clamp(200px, 20vw, 240px); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 12px; }
.legend.stats span { display: grid; gap: 2px; }
.legend.stats span > span { display: inline-flex; align-items: center; gap: 8px; }
.legend.stats small { color: var(--muted); font-size: 13px; padding-left: 17px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13.5px; text-align: center; padding: 0 20px; pointer-events: none; }

.funnel { display: grid; gap: 12px; margin-top: 12px; }
.fstep { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr) 44px; gap: 14px; align-items: center; }
.fstep .name { font-weight: 600; font-size: 14px; }
.fstep .name small { display: block; font-weight: 500; }
.fbar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.fbar i { display: block; height: 100%; min-width: 4px; background: var(--c1); border-radius: 999px; transition: width .4s ease; }
.fstep .n { font-weight: 600; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.fstep .drop { font-size: 12.5px; color: var(--muted); }
.fstep .drop.bad { color: var(--danger); font-weight: 600; }

.toplist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; }
.toplist li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.toplist li:first-child { border-top: 0; }
.toplist .ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); box-shadow: var(--shadow-md); }
.toplist .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toplist .nm small { display: block; color: var(--muted); font-size: 12.5px; }
.toplist .v { font-weight: 600; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 12px 24px; border-bottom: 1px solid var(--line); white-space: nowrap; }
html:lang(th) .tbl th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.tbl td { padding: 13px 24px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--hover); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.inbar { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.inbar .track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.inbar .track i { display: block; height: 100%; background: var(--c1); border-radius: 999px; }
.inbar small { width: 38px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.recs { display: grid; gap: 10px; margin-top: 10px; }
.rec { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); color: inherit; background: var(--surface); }
.rec:hover { border-color: var(--line-strong); color: inherit; box-shadow: var(--shadow-md); }
.rec .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--good-soft); color: var(--good); }
.rec.warn .ic { background: var(--danger-soft); color: var(--danger); }
.rec.check .ic { background: var(--check-soft); color: var(--check); }
.rec h3 { font-size: 14.5px; margin-bottom: 2px; }
.rec p { font-size: 13px; color: var(--muted); }
.rec > svg.i { color: var(--faint); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.login-art { background: radial-gradient(900px 500px at 15% 0%, #6b63f5 0%, #4338ca 45%, #1e1b4b 100%); color: #e0e0ff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; margin: 14px; border-radius: 22px; }
.login-art .logo { color: #fff; }
.login-art .logo small { color: #c7c8ff; }
.login-art h2 { color: #fff; font-size: clamp(26px, 2.2vw + 12px, 36px); line-height: 1.2; font-weight: 700; letter-spacing: -.02em; max-width: 460px; }
.login-art p { color: #c7c8ff; max-width: 420px; margin-top: 14px; font-size: 16px; }
.login-form { display: grid; place-items: center; padding: 32px 20px; }
.login-form form { width: 100%; max-width: 360px; display: grid; gap: 16px; }
@media (max-width: 900px) { .login-wrap { grid-template-columns: 1fr; background: var(--bg); } .login-art { display: none; } }

/* ---------- toast, skeleton ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: var(--surface); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: calc(100% - 32px);
}
.toast.bad { background: var(--danger); color: #fff; }
@media (max-width: 900px) { .toast { bottom: calc(96px + env(safe-area-inset-bottom)); } }
.skel { height: 14px; border-radius: 6px; margin: 18px 22px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } * { transition: none !important; } }

@media (max-width: 640px) {
  .fstep { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .fstep .fbar { grid-column: 1 / -1; order: 3; }
  .rec { grid-template-columns: 38px minmax(0, 1fr); }
  .rec > svg.i { display: none; }
  .card-head, .card-body, .item { padding-left: 16px; padding-right: 16px; }
  .tbl th, .tbl td { padding-left: 14px; padding-right: 14px; }
  .head-actions { width: 100%; }
  .head-actions > * { flex: 1 1 auto; }
  .head-actions select { min-width: 0; }
}
@media (max-width: 900px) { .topbar .spacer { display: none; } .topbar .search { max-width: none; } }

/* live indicator: green and pulsing while the worker has finished a job in the last five minutes */
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live.on i { background: var(--good); box-shadow: 0 0 0 0 rgba(14, 143, 85, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(14, 143, 85, 0); } 100% { box-shadow: 0 0 0 0 rgba(14, 143, 85, 0); } }
@media (max-width: 1100px) { .live span { display: none; } .live { padding: 8px; } }
@media (prefers-reduced-motion: reduce) { .live.on i { animation: none; } }

/* the segment table needs the full width until the window is really wide */
@media (max-width: 1500px) { .span-5, .span-7 { grid-column: span 12; } }
