/* ระบบส่งงานวิจัย — Satit VRU
   แนวคิด: "เส้นทางงานวิจัย" ทุกขั้นตอนคือสถานีบนเส้นเดียว สีเส้นบอกระดับการศึกษา */

:root {
  --ink: #172036;
  --ink-2: #4B5570;
  --ink-3: #8790A6;
  --paper: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8F9FC;
  --line: #E2E6EE;
  --line-2: #EDF0F5;

  --primary: #2641CF;
  --primary-ink: #1B2FA0;
  --primary-soft: #E9EDFF;

  --ok: #15985F;   --ok-soft: #E2F5EB;
  --wait: #B97F00; --wait-soft: #FFF3D1;
  --rev: #6B4EE6;  --rev-soft: #EEE9FF;
  --fix: #D93E45;  --fix-soft: #FDE8E8;
  --prog: #2F7BEA; --prog-soft: #E6F0FF;
  --none: #C2C8D4; --none-soft: #F0F2F6;

  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 7px;
  --lift: 0 1px 2px rgba(23, 32, 54, .06), 0 12px 32px -16px rgba(23, 32, 54, .28);

  --font-ui: 'Anuphan', 'Noto Sans Thai', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Thai Looped', 'Anuphan', 'Noto Sans Thai', system-ui, sans-serif;
  --sidebar: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-ui); line-height: 1.3; margin: 0; letter-spacing: -.005em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16.5px; font-weight: 600; }
p { margin: 0 0 12px; }
small { font-size: 13px; }
.ic { width: 18px; height: 18px; flex: none; }
.num { font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 200; }
.skip:focus { left: 12px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; border-radius: 6px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-family: var(--font-ui); font-size: 16px; font-weight: 700; line-height: 1.25; }
.brand small { color: var(--ink-3); font-size: 12.5px; line-height: 1.3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-family: var(--font-ui); font-weight: 500; font-size: 15px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.nav a .lvl-ic { color: var(--lc); }
.nav a.active .lvl-ic { color: var(--lc); }
.nav .badge {
  margin-left: auto; min-width: 22px; text-align: center;
  background: var(--fix); color: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 1px 7px; line-height: 1.6;
}
.nav-group { font-size: 12.5px; color: var(--ink-3); padding: 18px 12px 6px; font-family: var(--font-ui); }
.side-foot { margin-top: auto; padding: 14px 8px 0; }
.year-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px; font-family: var(--font-ui); }
.year-pill .ic { width: 15px; height: 15px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-family: var(--font-ui); font-size: 14.5px; color: var(--ink-3); flex: 1; }
.crumbs a { color: var(--ink-2); white-space: nowrap; }
.crumbs span { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .ic { width: 14px; height: 14px; }
.me { display: flex; align-items: center; gap: 10px; }
.me-t { display: flex; flex-direction: column; line-height: 1.3; }
.me-t strong { font-family: var(--font-ui); font-size: 14px; font-weight: 600; }
.me-t small { color: var(--ink-3); font-size: 12.5px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.menu-btn { display: none; }
.content { padding: 28px; width: 100%; max-width: 1360px; }
.foot { margin-top: auto; padding: 18px 28px 26px; color: var(--ink-3); font-size: 13px; }
.scrim { display: none; }

.avatar {
  --av: var(--primary);
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: color-mix(in srgb, var(--av) 14%, white); color: var(--av);
  font-family: var(--font-ui); font-weight: 700; font-size: 15px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.sm { width: 30px; height: 30px; font-size: 13px; }

/* ---------- page head ---------- */
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; flex-wrap: wrap; }
.page-h h1 { font-size: 28px; font-weight: 700; }
.page-h p { color: var(--ink-2); margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: var(--r-md);
  font-family: var(--font-ui); font-weight: 600; font-size: 15px; line-height: 1;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-ink); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #0E1526; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: #D3D9E4; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--surface); color: var(--fix); border-color: #F3C5C7; }
.btn-danger:hover { background: var(--fix-soft); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-lg { height: 50px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }

.field { margin-bottom: 18px; }
.field > label, .label { display: block; font-family: var(--font-ui); font-weight: 600; font-size: 14.5px; margin-bottom: 6px; color: var(--ink); }
.req::after { content: ' *'; color: var(--fix); }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  font: inherit; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 104px; padding: 11px 14px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--primary); }
.search { position: relative; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 40px; min-width: 240px; }

/* choice cards (decision / storage driver) */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice .c-body {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1.5px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.choice .c-body .ic { width: 22px; height: 22px; margin-top: 2px; color: var(--ink-3); }
.choice strong { display: block; font-family: var(--font-ui); font-size: 15.5px; }
.choice small { color: var(--ink-3); line-height: 1.45; display: block; }
.choice input:checked + .c-body { border-color: var(--primary); background: var(--primary-soft); }
.choice input:checked + .c-body .ic { color: var(--primary); }
.choice input:focus-visible + .c-body { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); }
.choice.ok input:checked + .c-body { border-color: var(--ok); background: var(--ok-soft); }
.choice.ok input:checked + .c-body .ic { color: var(--ok); }
.choice.fix input:checked + .c-body { border-color: var(--fix); background: var(--fix-soft); }
.choice.fix input:checked + .c-body .ic { color: var(--fix); }

/* dropzone */
.drop {
  position: relative; border: 2px dashed #CDD3DF; border-radius: var(--r-lg);
  background: var(--surface-2); padding: 30px 20px; text-align: center; transition: border-color .15s, background .15s;
}
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop .ic { width: 34px; height: 34px; color: var(--primary); }
.drop strong { display: block; font-family: var(--font-ui); font-size: 16px; margin-top: 8px; }
.drop small { color: var(--ink-3); }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop.has { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.drop .picked { display: none; margin-top: 8px; font-family: var(--font-ui); font-weight: 600; color: var(--ok); word-break: break-all; }
.drop.has .picked { display: block; }
.drop.has .ic { color: var(--ok); }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel + .panel { margin-top: 20px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-h h2 { font-size: 17.5px; display: flex; align-items: center; gap: 10px; }
.panel-h h2 .ic { color: var(--ink-3); }
.panel-b { padding: 22px; }
.panel-b.tight { padding: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 20px; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 8px 14px; font-size: 15px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- chips & dots ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px 3px 9px; border-radius: 999px;
  font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--none-soft); color: var(--ink-2);
}
.chip .ic { width: 15px; height: 15px; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.wait { background: var(--wait-soft); color: var(--wait); }
.chip.rev { background: var(--rev-soft); color: var(--rev); }
.chip.fix { background: var(--fix-soft); color: var(--fix); }
.chip.prog { background: var(--prog-soft); color: var(--prog); }
.chip.none, .chip.mute { background: var(--none-soft); color: var(--ink-3); }
.chip.plain { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

.lvl { --lc: var(--primary); display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; color: var(--lc); background: color-mix(in srgb, var(--lc) 11%, white); padding: 3px 11px 3px 9px; border-radius: 999px; white-space: nowrap; }
.lvl .ic { width: 15px; height: 15px; }

.dot { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; position: relative; z-index: 1; background: var(--surface); border: 2px solid var(--none); color: var(--none); }
.dot .ic { width: 14px; height: 14px; stroke-width: 2.6; }
.dot.s-approved { background: var(--lc, var(--ok)); border-color: var(--lc, var(--ok)); color: #fff; }
.dot.s-pending { background: var(--wait-soft); border-color: var(--wait); color: var(--wait); }
.dot.s-reviewing { background: var(--rev-soft); border-color: var(--rev); color: var(--rev); }
.dot.s-revise { background: var(--fix-soft); border-color: var(--fix); color: var(--fix); }
.dot.s-none .ic { opacity: 0; }

/* ---------- THE RAIL ---------- */
.rail { --lc: var(--primary); list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-start; }
.rail .stn { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 4px; }
.rail .stn::before {
  content: ''; position: absolute; top: 20px; left: calc(-50% + 22px); right: calc(50% + 22px); height: 4px;
  border-radius: 4px; background: var(--line);
}
.rail .stn:first-child::before { display: none; }
.rail .stn.reached::before { background: var(--lc); }
.rail .node {
  position: relative; z-index: 1; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--none); color: var(--ink-3);
  font-family: var(--font-ui); font-size: 16px;
}
.rail .node .ic { width: 20px; height: 20px; stroke-width: 2.4; }
.rail .s-approved .node { background: var(--lc); border-color: var(--lc); color: #fff; }
.rail .s-pending .node { background: var(--wait-soft); border-color: var(--wait); color: var(--wait); }
.rail .s-reviewing .node { background: var(--rev-soft); border-color: var(--rev); color: var(--rev); }
.rail .s-revise .node { background: var(--fix-soft); border-color: var(--fix); color: var(--fix); }
.rail .current .node { box-shadow: 0 0 0 7px color-mix(in srgb, var(--lc) 16%, transparent); }
.rail .current.s-none .node { border-color: var(--lc); color: var(--lc); }
.rail .lbl { margin-top: 12px; font-family: var(--font-ui); font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.rail .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; }
.rail .current .lbl { color: var(--ink); }
.rail.big .node { width: 52px; height: 52px; font-size: 18px; }
.rail.big .stn::before { top: 24px; left: calc(-50% + 26px); right: calc(50% + 26px); height: 5px; }
.rail.big .lbl { font-size: 15.5px; }

@media (prefers-reduced-motion: no-preference) {
  .rail .current .node { animation: arrive 1.1s cubic-bezier(.2, .8, .2, 1) .25s both; }
  @keyframes arrive {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lc) 45%, transparent); }
    100% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--lc) 16%, transparent); }
  }
}

/* ---------- teacher hero ---------- */
.hero {
  --lc: var(--primary);
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--lift);
  overflow: hidden;
}
.hero-top { padding: 26px 28px 8px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.hero-top h1 { font-size: 26px; font-weight: 700; max-width: 62ch; }
.hero-top .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.progress-num { text-align: right; font-family: var(--font-ui); }
.progress-num b { font-size: 40px; line-height: 1; font-weight: 700; color: var(--lc); font-variant-numeric: tabular-nums; }
.progress-num span { display: block; color: var(--ink-3); font-size: 13.5px; margin-top: 4px; }
.hero-rail { padding: 26px 22px 30px; overflow-x: auto; }
.hero-rail .rail { min-width: 560px; }
.next {
  display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 20px 28px; border-top: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--lc) 5%, var(--surface-2));
}
.next .n-t { display: flex; gap: 14px; align-items: flex-start; min-width: 0; flex: 1 1 380px; }
.next .n-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--lc); flex: none; }
.next .n-ic .ic { width: 22px; height: 22px; }
.next strong { font-family: var(--font-ui); font-size: 16.5px; display: block; }
.next p { margin: 2px 0 0; color: var(--ink-2); font-size: 14.5px; }
.next.fix { background: var(--fix-soft); }
.next.fix .n-ic { color: var(--fix); }
.next.wait { background: var(--wait-soft); }
.next.wait .n-ic { color: var(--wait); }
.next.done { background: var(--ok-soft); }
.next.done .n-ic { color: var(--ok); }

/* ---------- status strip (admin) ---------- */
.overview { padding: 26px 28px; }
.overview h2 { font-size: 22px; font-weight: 600; max-width: 60ch; }
.overview h2 b { font-weight: 700; }
.strip { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--none-soft); margin-top: 20px; gap: 3px; }
.strip i { display: block; height: 100%; min-width: 4px; }
.legend { display: flex; gap: 12px 34px; flex-wrap: wrap; margin-top: 18px; }
.legend > * { display: flex; flex-direction: column; color: var(--ink); }
.legend a:hover { text-decoration: none; }
.legend a:hover span { text-decoration: underline; }
.legend b { font-family: var(--font-ui); font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.legend span { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-2); }
.legend span::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--sw); }
.c-ok { --sw: var(--ok); background: var(--ok); }
.c-wait { --sw: #E0A300; background: #E0A300; }
.c-fix { --sw: var(--fix); background: var(--fix); }
.c-prog { --sw: var(--prog); background: var(--prog); }
.c-none { --sw: var(--none); background: var(--none); }

/* ---------- line map per level ---------- */
.lmap-card { --lc: var(--primary); }
.lmap-card .panel-h h2 .lv-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--lc) 12%, white); color: var(--lc); }
.lmap-card .panel-h h2 .lv-ic .ic { width: 19px; height: 19px; }
.lmap-wrap { overflow-x: auto; padding: 22px 16px 18px; }
.lmap { list-style: none; margin: 0; padding: 0; display: flex; min-width: 560px; }
.lmap li { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 4px; }
.lmap li::before { content: ''; position: absolute; top: 49px; left: -50%; right: 50%; height: 4px; background: var(--lc); opacity: .9; }
.lmap li:first-child::before { display: none; }
.lmap .cnt { height: 38px; font-family: var(--font-ui); font-size: 26px; font-weight: 700; line-height: 38px; font-variant-numeric: tabular-nums; }
.lmap .cnt.zero { color: var(--none); font-weight: 600; }
.lmap .pin { position: relative; z-index: 1; width: 22px; height: 22px; margin-top: 0; border-radius: 50%; background: var(--surface); border: 4px solid var(--lc); }
.lmap li.end .pin { width: 26px; height: 26px; margin-top: -2px; background: var(--lc); display: grid; place-items: center; color: #fff; border-width: 0; }
.lmap li.end .pin .ic { width: 15px; height: 15px; stroke-width: 3; }
.lmap .nm { margin-top: 10px; font-family: var(--font-ui); font-size: 13.5px; font-weight: 600; line-height: 1.35; color: var(--ink-2); }
.lmap .br { display: flex; gap: 4px; justify-content: center; margin-top: 6px; min-height: 22px; flex-wrap: wrap; }
.lmap .br i { font-style: normal; font-size: 12px; font-weight: 700; font-family: var(--font-ui); padding: 0 7px; border-radius: 999px; line-height: 20px; }
.lmap .br .f { background: var(--fix-soft); color: var(--fix); }
.lmap .br .w { background: var(--wait-soft); color: var(--wait); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
.tbl th {
  text-align: left; font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; color: var(--ink-3);
  padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr[data-href] { cursor: pointer; }
.tbl tr[data-href]:hover td { background: #FAFBFE; }
.tbl .c { text-align: center; }
.tbl .r { text-align: right; }
.tbl .person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.tbl .person strong { font-family: var(--font-ui); font-weight: 600; display: block; line-height: 1.35; }
.tbl .person small { color: var(--ink-3); display: block; }
.tbl .title-cell { max-width: 320px; color: var(--ink-2); font-size: 14.5px; }
.tbl .title-cell span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tbl th.stepcol { text-align: center; font-size: 12.5px; line-height: 1.3; white-space: normal; min-width: 76px; }
.tbl td.stepcell { position: relative; text-align: center; padding-left: 0; padding-right: 0; }
.tbl td.stepcell::before, .tbl td.stepcell::after { content: ''; position: absolute; top: 50%; height: 3px; margin-top: -1.5px; background: var(--line); }
.tbl td.stepcell::before { left: 50%; right: 0; }
.tbl td.stepcell::after { left: 0; right: 50%; }
.tbl td.stepcell.first::after, .tbl td.stepcell.last::before { display: none; }
.tbl td.stepcell.s-approved::before, .tbl td.stepcell.reached::after { background: var(--lc); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
tr.is-hidden { display: none; }

/* filter bar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.fchips { display: flex; gap: 8px; flex-wrap: wrap; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 14px; font-family: var(--font-ui); font-size: 14px; font-weight: 500; cursor: pointer;
}
.fchip:hover { border-color: #CBD2DE; color: var(--ink); text-decoration: none; }
.fchip b { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-3); }
.fchip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.fchip.active b { color: rgba(255, 255, 255, .7); }

.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 9px; font-family: var(--font-ui); font-weight: 600; font-size: 14.5px; color: var(--ink-2); }
.tabs a:hover { background: var(--surface-2); text-decoration: none; }
.tabs a.active { background: var(--ink); color: #fff; }
.tabs a .ic { width: 16px; height: 16px; }
.tabs a[style] .ic { color: var(--lc); }

/* ---------- files ---------- */
.file {
  display: inline-flex; align-items: center; gap: 10px; max-width: 100%;
  padding: 7px 12px 7px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 14.5px;
}
.file:hover { border-color: #C9D0DC; text-decoration: none; background: var(--surface-2); }
.file .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file .fsize { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.file .dl { color: var(--ink-3); width: 16px; height: 16px; }
.ext {
  display: inline-grid; place-items: center; min-width: 38px; height: 26px; padding: 0 6px; border-radius: 6px;
  font-family: var(--font-ui); font-size: 11px; font-weight: 700; color: #fff; text-transform: lowercase; background: #6B7385;
}
.ext .ic { width: 15px; height: 15px; }
.x-doc { background: #2B579A; } .x-pdf { background: #C9302C; } .x-xls { background: #1E7145; }
.x-ppt { background: #C43E1C; } .x-img { background: #7C4DCC; } .x-zip { background: #5A6275; } .x-link { background: var(--primary); }
.files { display: flex; flex-wrap: wrap; gap: 8px; }

.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.res-list li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); }
.res-list li:hover { border-color: var(--line); background: var(--surface-2); }
.res-list .r-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); flex: none; }
.res-list .r-t { flex: 1; min-width: 0; }
.res-list .r-t strong { display: block; font-family: var(--font-ui); font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.res-list .r-t small { color: var(--ink-3); }

/* ---------- timeline ---------- */
.tl { list-style: none; margin: 0; padding: 0; --lc: var(--primary); }
.tl > li { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 16px; padding-bottom: 26px; }
.tl > li::before { content: ''; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--line); }
.tl > li:last-child { padding-bottom: 0; }
.tl > li:last-child::before { display: none; }
.tl > li.s-approved::before { background: var(--lc); }
.tl .dot { width: 40px; height: 40px; border-width: 3px; }
.tl .dot .ic { width: 18px; height: 18px; }
.tl .dot b { font-family: var(--font-ui); color: var(--ink-3); font-size: 15px; position: absolute; }
.tl .dot.s-none .ic { display: none; }
.tl-h { display: flex; justify-content: space-between; align-items: center; gap: 8px 14px; flex-wrap: wrap; min-height: 40px; }
.tl-h h3 { font-size: 16.5px; }
.tl-h .when { color: var(--ink-3); font-size: 13.5px; }
.ver { margin-top: 10px; border: 1px solid var(--line-2); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.ver.old { opacity: .72; }
.ver-h { display: flex; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.ver-h .vno { font-family: var(--font-ui); font-weight: 700; font-size: 14px; }
.ver-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 16px; margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }
.ver-meta span b { color: var(--ink-3); font-weight: 500; margin-right: 4px; }
.note { margin-top: 10px; font-size: 14.5px; color: var(--ink-2); }
.comment { margin-top: 10px; padding: 12px 14px; border-radius: 0 10px 10px 0; border-left: 3px solid var(--ink-3); background: var(--surface); font-size: 14.5px; }
.comment.fix { border-left-color: var(--fix); background: var(--fix-soft); }
.comment.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.comment .c-by { display: block; font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; margin-bottom: 4px; color: var(--ink); }
.comment p { margin: 0; white-space: pre-line; }
.more-ver summary { cursor: pointer; font-family: var(--font-ui); font-size: 14px; color: var(--primary); margin-top: 10px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.more-ver summary::-webkit-details-marker { display: none; }
.more-ver summary .ic { width: 16px; height: 16px; transition: transform .15s; }
.more-ver[open] summary .ic { transform: rotate(180deg); }

/* list rows (queue, activity) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 14px; padding: 13px 22px; border-bottom: 1px solid var(--line-2); }
.rows li:last-child { border-bottom: 0; }
.rows .r-main { flex: 1; min-width: 0; }
.rows .r-main strong { font-family: var(--font-ui); font-weight: 600; display: block; line-height: 1.35; }
.rows .r-main small { color: var(--ink-3); }
.rows .r-side { text-align: right; font-size: 13px; color: var(--ink-3); white-space: nowrap; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 42px 22px; color: var(--ink-2); }
.empty > .ic { width: 44px; height: 44px; padding: 10px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); box-sizing: content-box; }
.empty h2, .empty h3 { margin: 14px 0 6px; color: var(--ink); }
.empty p { max-width: 46ch; margin: 0 auto 16px; }
.empty.big { padding: 80px 22px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--prog-soft); color: #1C4F9C; font-size: 14.5px; margin-bottom: 18px; }
.notice .ic { margin-top: 3px; }
.notice.warn { background: var(--wait-soft); color: #7A5600; }
.notice.err { background: var(--fix-soft); color: #9D2127; }
.notice.ok { background: var(--ok-soft); color: #0E6A42; }
.notice p { margin: 0; }
.divider { height: 1px; background: var(--line-2); margin: 20px 0; border: 0; }
.section-t { font-family: var(--font-ui); font-weight: 600; font-size: 15px; color: var(--ink-2); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.pct-bar { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; min-width: 80px; }
.pct-bar i { display: block; height: 100%; background: var(--lc, var(--primary)); border-radius: 999px; }
.sel-year { height: 38px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 10px; font: inherit; font-family: var(--font-ui); background: var(--surface); }
.code { font-family: var(--font-ui); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.overdue { color: var(--fix); font-weight: 600; }
.due-soon { color: var(--wait); font-weight: 600; }

/* toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 100; max-width: calc(100vw - 40px); }
.toast {
  display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 460px;
  background: var(--ink); color: #fff; padding: 13px 14px 13px 16px; border-radius: 12px; box-shadow: var(--lift);
  font-size: 15px;
}
.toast > .ic { color: #9FB2FF; }
.toast.t-ok > .ic { color: #7DDBAE; }
.toast.t-err > .ic { color: #FF9A9E; }
.toast.t-warn > .ic { color: #FFD166; }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: rgba(255, 255, 255, .6); cursor: pointer; padding: 2px; display: grid; }
.toast button .ic { width: 16px; height: 16px; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .35s cubic-bezier(.2, .8, .2, 1); }
  @keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
}

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); background: var(--surface); }
.auth-art { position: relative; overflow: hidden; background: var(--ink); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-art .brand { color: #fff; padding: 0; }
.auth-art .brand small { color: rgba(255, 255, 255, .6); }
.auth-art h1 { font-size: clamp(30px, 3.4vw, 46px); font-weight: 700; line-height: 1.25; max-width: 16ch; }
.auth-art .lead { color: rgba(255, 255, 255, .72); font-size: 16.5px; max-width: 44ch; margin-top: 16px; }
.metro { width: 100%; height: auto; display: block; }
.metro .ln { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.metro .st { fill: var(--ink); stroke-width: 5; }
.metro .hub { fill: #fff; }
.metro text { font-family: var(--font-ui); font-size: 15px; font-weight: 600; fill: rgba(255, 255, 255, .85); }
.metro text.t-kg { fill: #6FD3A4; } .metro text.t-pr { fill: #8DB9F6; } .metro text.t-se { fill: #F6B479; }
@media (prefers-reduced-motion: no-preference) {
  .metro .ln { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 1.8s cubic-bezier(.6, .1, .2, 1) forwards; }
  .metro .ln:nth-of-type(2) { animation-delay: .18s; }
  .metro .ln:nth-of-type(3) { animation-delay: .36s; }
  .metro .st, .metro .hub, .metro text { opacity: 0; animation: pop .4s ease-out forwards; animation-delay: 1.5s; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes pop { to { opacity: 1; } }
}
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card > p { color: var(--ink-2); margin-bottom: 26px; }
.pw { position: relative; }
.pw .input { padding-right: 46px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--ink-3); cursor: pointer; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; }
.pw button:hover { color: var(--ink); background: var(--surface-2); }
.auth-foot { margin-top: 28px; color: var(--ink-3); font-size: 13.5px; }

/* install */
.install { max-width: 720px; margin: 48px auto; padding: 0 20px; }
.install .panel-b h1 { font-size: 24px; margin: 10px 0 4px; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.checks li { display: flex; gap: 10px; align-items: center; font-size: 14.5px; }
.checks .ok { color: var(--ok); } .checks .bad { color: var(--fix); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 284px; z-index: 60; transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--lift); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(23, 32, 54, .38); z-index: 55; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
  .me-t { display: none; }
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 32px 24px; }
  .auth-art .metro-box { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .page-h h1 { font-size: 23px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .hero-top { padding: 20px 18px 4px; }
  .hero-top h1 { font-size: 21px; }
  .progress-num { text-align: left; }
  .next { padding: 18px; }
  .panel-b { padding: 18px; }
  .panel-h { padding: 16px 18px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 10px; }
  .search .input { min-width: 0; }
  .rows li { padding: 12px 16px; }
  /* เส้นทางแนวตั้งบนมือถือ */
  .hero-rail .rail { min-width: 0; }
  .rail.big { flex-direction: column; }
  .rail.big .stn { flex-direction: row; align-items: center; text-align: left; gap: 14px; padding: 8px 0; flex: none; }
  .rail.big .stn::before { top: -50%; bottom: 50%; left: 24px; right: auto; width: 4px; height: auto; }
  .rail.big .lbl { margin-top: 0; }
  .rail.big .stn > .lbl, .rail.big .stn > .sub { display: block; }
  .rail.big .stn { display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 0; }
  .rail.big .node { grid-row: 1 / 3; }
  .rail.big .lbl { align-self: end; }
  .rail.big .sub { align-self: start; }
  .toast { min-width: 0; }
}
@media print {
  .sidebar, .topbar, .page-actions, .toolbar, .foot, .toasts { display: none !important; }
  .app { display: block; }
  .panel { break-inside: avoid; }
}
.auth-art .brand svg rect { fill: rgba(255, 255, 255, .08); }

/* ---------- public pages (สมัคร / ยืนยัน / ลืมรหัสผ่าน) ---------- */
.pub-body { background: var(--paper); min-height: 100vh; display: flex; flex-direction: column; }
.pub-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.pub-top .brand { padding: 0; }
.pub { width: 100%; max-width: 560px; margin: 0 auto; padding: 36px 20px 20px; flex: 1; }
.pub.wide { max-width: 860px; }
.pub h1 { font-size: 27px; font-weight: 700; margin-bottom: 6px; }
.pub .lead { color: var(--ink-2); margin-bottom: 22px; }
.reg-rail { margin: 6px 0 28px; }
.reg-rail .node { width: 40px; height: 40px; }
.reg-rail .node .ic { width: 18px; height: 18px; }
.reg-rail .stn::before { top: 18px; left: calc(-50% + 20px); right: calc(50% + 20px); }
.reg-rail .lbl { font-size: 13.5px; margin-top: 8px; }
.reg-rail .s-none .node .ic { opacity: .75; }
.lvl-choices .choice .c-body .ic { color: var(--lc); }
.lvl-choices .choice input:checked + .c-body { border-color: var(--lc); background: color-mix(in srgb, var(--lc) 9%, white); }
.lvl-choices .choice input:checked + .c-body .ic { color: var(--lc); }
.result { text-align: center; padding: 34px 26px; }
.result .r-ic { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; margin-bottom: 14px; background: var(--primary-soft); color: var(--primary); }
.result .r-ic .ic { width: 30px; height: 30px; }
.result.ok .r-ic { background: var(--ok-soft); color: var(--ok); }
.result.wait .r-ic { background: var(--wait-soft); color: var(--wait); }
.result.fix .r-ic { background: var(--fix-soft); color: var(--fix); }
.result h2 { font-size: 22px; margin-bottom: 8px; }
.result p { color: var(--ink-2); max-width: 46ch; margin: 0 auto 16px; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.copybox { display: flex; gap: 8px; }
.copybox .input { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 14.5px; }
.bulkbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.q-status { font-size: 12.5px; }
@media (max-width: 640px) {
  .pub-top { padding: 12px 16px; }
  .pub-top .brand small { display: none; }
  .reg-rail .lbl { font-size: 12px; }
  .pub h1 { font-size: 23px; }
}

/* ปุ่มดาวน์โหลดตามรูปแบบไฟล์ */
.fmts { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fmt {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 8px;
  font-family: var(--font-ui); font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.fmt .ic { width: 15px; height: 15px; }
.fmt:hover { text-decoration: none; background: var(--surface-2); }
.fmt-doc { color: #2B579A; border-color: #C9D6EC; }
.fmt-doc:hover { background: #EEF3FB; }
.fmt-pdf { color: #B72B27; border-color: #F0C9C7; }
.fmt-pdf:hover { background: #FDF0EF; }
.fmt-xls { color: #1E7145; border-color: #C3E0CF; }
.fmt-link { color: var(--primary); border-color: #CBD4FA; }
.res-list li { flex-wrap: wrap; }
.res-mini { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding: 6px 0; border-top: 1px dashed var(--line-2); }
.res-mini:first-child { border-top: 0; }
.res-mini span.t { font-size: 14px; color: var(--ink-2); min-width: 0; }
.res-mini .fmt { height: 28px; padding: 0 9px; font-size: 12.5px; }
.sample-added { color: var(--ok); font-family: var(--font-ui); font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.sample-added .ic { width: 15px; height: 15px; }
.res-list .r-t { flex: 1 1 200px; }
.res-list .fmts { margin-left: auto; }
@media (max-width: 640px) {
  .res-list .fmts { width: 100%; margin-left: 50px; }
}

/* ---------- รูปถ่ายผู้ใช้ ---------- */
img.avatar { object-fit: cover; background: var(--surface-2); border: 1px solid var(--line-2); padding: 0; }
.avatar.xl { width: 64px; height: 64px; font-size: 24px; }
.avatar.xxl { width: 96px; height: 96px; font-size: 34px; }
.avatar.nophoto { background: var(--surface-2); color: var(--ink-3); border: 1px dashed #CBD2DE; }
.avatar.nophoto .ic { width: 45%; height: 45%; }
.me a { display: inline-flex; border-radius: 50%; }
.profile-top { display: flex; gap: 18px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.photo-pick { display: flex; gap: 16px; align-items: center; padding: 14px; border: 1.5px dashed #CDD3DF; border-radius: var(--r-lg); background: var(--surface-2); }
.photo-pick.over { border-color: var(--primary); background: var(--primary-soft); }
.photo-prev { flex: none; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--surface); border: 1px solid var(--line); color: var(--ink-3); }
.photo-prev .ic { width: 40px; height: 40px; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-prev.has { border: 3px solid var(--ok); }
.photo-meta { min-width: 0; }
.photo-meta .hint { margin: 8px 0 0; }
.photo-name { display: block; font-size: 13px; color: var(--ok); font-family: var(--font-ui); font-weight: 600; margin-top: 4px; word-break: break-all; }
.photo-btn { position: relative; cursor: pointer; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 640px) { .photo-pick { flex-direction: column; text-align: center; } }
