/* =====================================================================
   ธนาคารขวด — Bottle Bank · Shared design system
   Direction: "Tactile & Friendly" — soft mint surfaces, rounded shapes,
   chunky friendly type, warm motivating personality, credible for staff.
   Identity preserved: the brand green leads. Thai-first legibility.
   ===================================================================== */

:root {
  /* Surfaces — the body IS soft mint, not white-with-accent */
  --bg:            #e7f3ea;   /* soft mint body */
  --bg-deep:       #dcecdf;   /* mint shade for wells */
  --surface:       #ffffff;   /* cards */
  --surface-soft:  #f1f8f3;   /* input / sub-panel fill */

  /* Greens — committed brand family */
  --green:         #2f7d4f;
  --green-2:       #245f3c;   /* deep */
  --green-3:       #173e26;   /* darkest, headings on mint */
  --leaf:          #3fa463;   /* brighter, friendly accent + progress */
  --leaf-soft:     #d7efde;   /* soft chip / tint bg */
  --green-soft:    #e1f1e6;
  --green-line:    #cbe4d2;   /* hairline */

  /* Ink — all AA-verified on white & mint */
  --ink:           #15281c;   /* near-black green */
  --ink-2:         #41564a;   /* body-muted  ~7:1 */
  --ink-3:         #5f7164;   /* secondary   ~5:1 */
  --on-green:      #ffffff;
  --on-green-soft: rgba(255,255,255,0.92);

  /* Warm + status pops, used sparingly */
  --amber:         #c98a06;   /* achievement / reward */
  --amber-soft:    #fbf0d3;
  --danger:        #c0392b;
  --danger-soft:   #fbe7e3;

  /* Shape — tactile, rounded */
  --r-xl:   26px;   /* hero, modal */
  --r-lg:   20px;   /* cards, panels */
  --r-md:   14px;   /* buttons, inputs */
  --r-sm:   10px;
  --r-pill: 999px;

  /* Depth — soft green-tinted shadows */
  --shadow-sm: 0 2px 8px rgba(23,62,38,0.06);
  --shadow:    0 8px 24px rgba(23,62,38,0.10);
  --shadow-lg: 0 22px 54px rgba(23,62,38,0.20);
  --ring:      0 0 0 4px rgba(63,164,99,0.20);

  /* Motion — lively ease-out, never bounce */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t:    0.22s var(--ease);

  /* Semantic z-index scale */
  --z-sticky: 50;
  --z-modal:  200;
  --z-toast:  300;
  --z-gate:   400;

  /* Legacy token aliases — keep older inline styles / JS-injected markup working */
  --black: var(--ink);
  --cream: var(--surface-soft);
  --green-soft: var(--leaf-soft);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Sarabun', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Brand glow on its own composited fixed layer — stays put on scroll
   without forcing a full-page repaint the way background-attachment:fixed does. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 8% -10%, rgba(63,164,99,0.10), transparent 60%),
    radial-gradient(1000px 520px at 100% 0%, rgba(47,125,79,0.08), transparent 55%);
}

.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* Display type */
.kanit, .hero-title, .brand-name, .stat-value, .section-title, .panel-title,
.chart-title, .badge, .count-val, .lb-count, .rc-count, .s-count,
.modal-hd span, .ss-total, .pt-amount { font-family: 'Kanit', sans-serif; }

::selection { background: var(--leaf); color: #fff; }

/* Inline SVG icons (see icons.js). Inherit color via currentColor, size via 1em. */
.ic { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex-shrink: 0; }
[data-ic] svg, .ic svg { display: block; }

/* Keyboard focus */
:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }

/* Touch devices: ensure ≥44px hit areas without bloating dense desktop tables */
@media (pointer: coarse) {
  .count-btn { width: 44px; height: 44px; font-size: 18px; }
  .count-input { height: 44px; }
  .modal-x { width: 44px; height: 44px; }
  .act-btn, .tab, .logoff-btn, .logout-btn, .refresh-btn,
  .btn-cancel, .btn-save, .btn-sell-ok, .btn-danger, .add-btn,
  .room-sell-btn, .gate-btn, .pg-btn { min-height: 44px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Entrance — applied selectively, not as a blanket reflex */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { transform: scale(0.965); } to { transform: scale(1); } }
.rise { animation: rise 0.55s var(--ease) both; }
.rise-1 { animation-delay: 0.04s; } .rise-2 { animation-delay: 0.10s; }
.rise-3 { animation-delay: 0.16s; } .rise-4 { animation-delay: 0.22s; }

/* =====================  HEADER  ===================== */
header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: rgba(255,255,255,0.82);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--green-line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--leaf), var(--green-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 19px; box-shadow: var(--shadow-sm);
}
.brand-name { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 1px; }
.role-tag {
  display: inline-block; font-family: 'Kanit', sans-serif; font-size: 10px; font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-pill); background: var(--leaf-soft); color: var(--green-2);
  margin-left: 8px; letter-spacing: 0.08em; vertical-align: middle;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-name { font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 600; color: var(--ink); }
.room-tag {
  font-size: 12px; padding: 5px 13px; border-radius: var(--r-pill); font-weight: 600;
  background: var(--leaf-soft); color: var(--green-2);
}
.status-dot {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2);
  padding: 6px 13px; border: 1px solid var(--green-line); border-radius: var(--r-pill); background: #fff;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 3px rgba(63,164,99,0.18); animation: blink 2.4s var(--ease) infinite; }
.dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(192,57,43,0.18); animation: none; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

.logoff-btn, .logout-btn {
  background: #fff; border: 1px solid var(--green-line); color: var(--ink-2);
  padding: 8px 15px; border-radius: var(--r-pill); font-size: 13px; cursor: pointer;
  font-family: 'Sarabun', sans-serif; transition: var(--t);
}
.logoff-btn:hover, .logout-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.logoff-btn:active, .logout-btn:active { transform: scale(0.97); }

/* =====================  HERO  ===================== */
.hero {
  position: relative; overflow: hidden; margin-top: 22px;
  border-radius: var(--r-xl); padding: 30px 34px;
  background: linear-gradient(150deg, var(--green) 0%, var(--green-2) 100%);
  color: #fff; box-shadow: var(--shadow);
}
.hero.dark { background: linear-gradient(150deg, #1d3a28 0%, var(--green-3) 100%); }
.hero::after, .hero::before { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::after  { right: -70px; top: -90px; width: 280px; height: 280px; background: rgba(255,255,255,0.08); }
.hero::before { right: 120px; bottom: -120px; width: 200px; height: 200px; background: rgba(255,255,255,0.05); }
.hero > * { position: relative; z-index: 1; }
.hero-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.hero-sub { font-size: 14.5px; color: var(--on-green-soft); margin-top: 10px; max-width: 52ch; line-height: 1.6; }

/* Focal metric inside the hero — one dominant number, not a row of metric cards */
.hero-figure { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-figure .hf-num { font-family: 'Kanit', sans-serif; font-size: clamp(3.2rem, 11vw, 5.2rem); font-weight: 700; line-height: 0.85; letter-spacing: -0.03em; color: #fff; }
.hero-figure .hf-unit { font-family: 'Kanit', sans-serif; font-size: 18px; font-weight: 600; color: var(--on-green-soft); }
.hero-impact { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-impact .hi-num, .hero-impact .hi-lbl { display: inline-flex; align-items: center; }
.hero-impact .hi-num {
  font-family: 'Kanit', sans-serif; font-size: 15px; font-weight: 700; color: #fff;
  background: rgba(255,255,255,0.16); padding: 7px 14px 7px 12px; border-radius: var(--r-pill);
  gap: 6px;
}
.hero-impact .hi-lbl { font-size: 12.5px; color: var(--on-green-soft); margin: 0 18px 0 8px; }

/* =====================  STAT CARDS  ===================== */
.stats-bar { display: grid; gap: 14px; padding: 22px 0; }
.stat-card {
  position: relative; background: var(--surface); border: 1px solid var(--green-line);
  border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm); transition: var(--t);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--leaf); }
.stat-card .accent, .stat-card .accent-icon {
  position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: var(--leaf-soft); color: var(--green);
}
.stat-card .accent-icon.amber-bg { background: var(--amber-soft); color: var(--amber); }
.stat-card .accent-icon.dark-bg  { background: rgba(255,255,255,0.12); color: #fff; }
.stat-card.dark { background: linear-gradient(160deg, var(--green-3), #0f2417); border-color: transparent; color: #fff; }
.stat-card.dark .stat-value { color: #fff; }
.stat-card.dark .stat-label { color: rgba(255,255,255,0.66); }
.stat-card.dark .stat-sub   { color: rgba(255,255,255,0.7); }
.stat-card.dark .accent, .stat-card.dark .accent-icon { background: rgba(255,255,255,0.12); color: #fff; }
/* Feature stat — the one operationally-primary number per console; breaks the
   identical-card grid and gives the dashboard a deliberate focal point. */
.stat-card.feature { background: linear-gradient(155deg, var(--green), var(--green-2)); border-color: transparent; color: #fff; }
.stat-card.feature .stat-value { color: #fff; font-size: 52px; }
.stat-card.feature .stat-label { color: var(--on-green-soft); }
.stat-card.feature .stat-sub { color: var(--on-green-soft); }
.stat-card.feature .accent, .stat-card.feature .accent-icon { background: rgba(255,255,255,0.18); color: #fff; }
.stat-card.feature:hover { border-color: transparent; box-shadow: var(--shadow); }
.stat-label { font-family: 'Kanit', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-size: 40px; font-weight: 700; line-height: 1; color: var(--ink); margin-top: 12px; letter-spacing: -0.02em; }
.stat-value.green { color: var(--green); }
.stat-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 9px; }

/* Secondary mini-stats (student) — horizontal, quiet, deliberately NOT the
   big-number metric-card template. Supporting info under the hero figure. */
.substat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 22px 0; }
.substat { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); transition: var(--t); }
.substat:hover { border-color: var(--leaf); transform: translateY(-2px); }
.substat .ss-ico { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; background: var(--leaf-soft); color: var(--green); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.substat .ss-body { min-width: 0; }
.substat .ss-k { font-family: 'Kanit', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.substat .ss-v { font-family: 'Kanit', sans-serif; font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.1; margin-top: 2px; }
.substat .ss-meta { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
@media (max-width: 560px) { .substat-row { grid-template-columns: 1fr; } }

/* =====================  PANEL  ===================== */
.section-title { font-family: 'Kanit', sans-serif; font-size: 17px; font-weight: 700; color: var(--ink); padding: 26px 0 14px; display: flex; align-items: center; gap: 9px; letter-spacing: -0.01em; }
.dot-leaf { width: 9px; height: 9px; border-radius: 50% 50% 50% 0; background: var(--leaf); transform: rotate(45deg); flex-shrink: 0; }
.panel { background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.panel-header { padding: 16px 20px; border-bottom: 1px solid var(--green-line); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-soft); }
.panel-title { font-family: 'Kanit', sans-serif; font-size: 15px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 9px; }
.badge { font-size: 11px; font-weight: 600; padding: 5px 12px; border-radius: var(--r-pill); background: var(--leaf-soft); color: var(--green-2); }

/* =====================  TABS — segmented pill  ===================== */
.tabs { display: flex; gap: 6px; padding: 12px 16px; background: var(--surface-soft); border-bottom: 1px solid var(--green-line); flex-wrap: wrap; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; font-size: 13px; cursor: pointer; color: var(--ink-2);
  background: transparent; border: 1px solid transparent; border-radius: var(--r-pill);
  font-family: 'Kanit', sans-serif; font-weight: 600; transition: var(--t);
}
.tab:hover { color: var(--ink); background: #fff; }
.tab.active { color: #fff; background: var(--green); box-shadow: var(--shadow-sm); }
.tab-content { display: none; } .tab-content.active { display: block; }

/* =====================  SEARCH + ACTION BUTTONS  ===================== */
.search-row { padding: 14px 16px; border-bottom: 1px solid var(--green-line); display: flex; gap: 10px; align-items: center; background: var(--surface); }
.search-input {
  flex: 1; background: var(--surface-soft); border: 1px solid var(--green-line); border-radius: var(--r-md);
  padding: 11px 15px; color: var(--ink); font-size: 14px; font-family: 'Sarabun', sans-serif; outline: none; transition: var(--t);
}
.search-input:focus { border-color: var(--leaf); background: #fff; box-shadow: var(--ring); }
.search-input::placeholder { color: var(--ink-3); }
.add-btn {
  padding: 11px 18px; background: var(--green); color: #fff; border: none; border-radius: var(--r-md);
  font-family: 'Kanit', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--t); white-space: nowrap;
}
.add-btn:hover { background: var(--green-2); transform: translateY(-1px); }
.add-btn:active { transform: scale(0.97); }
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--green-line); color: var(--ink-2); padding: 7px 14px;
  border-radius: var(--r-pill); font-size: 12px; cursor: pointer; font-family: 'Sarabun', sans-serif; transition: var(--t); white-space: nowrap;
}
.refresh-btn:hover { border-color: var(--leaf); color: var(--green); background: var(--leaf-soft); }

/* =====================  TABLE  ===================== */
.table-wrap { overflow-x: auto; }
/* Long tables get a scroll cap so one list can't run the whole page long.
   The header sticks so you never lose the column meanings mid-scroll. */
.table-wrap.cap { max-height: 460px; overflow-y: auto; }
.table-wrap.cap thead th { position: sticky; top: 0; z-index: 2; }
.table-wrap.cap::-webkit-scrollbar { width: 6px; }
.table-wrap.cap::-webkit-scrollbar-thumb { background: var(--green-line); border-radius: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { padding: 12px 14px; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; background: var(--surface-soft); border-bottom: 1px solid var(--green-line); font-family: 'Kanit', sans-serif; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--green-line); transition: background 0.15s var(--ease); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-soft); }
tbody td { padding: 11px 14px; }
.td-no { color: var(--ink-3); font-weight: 600; font-size: 13px; font-family: 'Kanit', sans-serif; }
.td-sno { font-family: 'Kanit', monospace; font-size: 13px; color: var(--green-2); letter-spacing: 0.06em; background: var(--leaf-soft); padding: 3px 9px; border-radius: var(--r-sm); }
.room-badge { display: inline-block; font-size: 12px; padding: 4px 11px; border-radius: var(--r-pill); background: var(--leaf-soft); color: var(--green-2); font-weight: 600; }
.rfid-code { font-family: ui-monospace, monospace; font-size: 12px; color: var(--ink-3); }
.count-val { font-family: 'Kanit', sans-serif; font-size: 16px; font-weight: 700; color: var(--green); }

/* Stepper */
.count-edit { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; }
.count-btn {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--green-line); background: #fff;
  color: var(--green); font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; transition: var(--t); line-height: 1;
}
.count-btn:hover { background: var(--green); color: #fff; border-color: var(--green); transform: translateY(-1px); }
.count-btn:active { transform: scale(0.9); }
.count-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.count-input {
  width: 46px; text-align: center; background: var(--surface-soft); border: 1px solid var(--green-line);
  border-radius: 9px; padding: 5px; color: var(--ink); font-size: 14px; font-family: 'Kanit', sans-serif; font-weight: 700; outline: none; transition: var(--t);
}
.count-input:focus { border-color: var(--leaf); box-shadow: var(--ring); }

/* Row action buttons */
.act-wrap { display: flex; gap: 6px; }
.act-btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 13px; border-radius: var(--r-pill); font-size: 12px; cursor: pointer; font-family: 'Kanit', sans-serif; transition: var(--t); font-weight: 600; border: 1px solid var(--green-line); background: #fff; }
.act-edit { color: var(--green); } .act-edit:hover { background: var(--leaf-soft); border-color: var(--leaf); }
.act-del { color: var(--danger); border-color: #efc9c4; } .act-del:hover { background: var(--danger-soft); border-color: var(--danger); }

/* =====================  PAGER  ===================== */
/* 2,900+ students is not a scroll. Long lists page instead, and the search
   box is the real way in — the pager only walks whatever is left after it. */
.pager {
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface-soft); border-top: 1px solid var(--green-line);
}
.pager.hidden { display: none; }
.pg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--green-line); color: var(--ink-2); padding: 8px 15px;
  border-radius: var(--r-pill); font-size: 12.5px; cursor: pointer;
  font-family: 'Kanit', sans-serif; font-weight: 600; transition: var(--t); white-space: nowrap;
}
.pg-btn:hover:not(:disabled) { border-color: var(--leaf); color: var(--green); background: var(--leaf-soft); }
.pg-btn:active:not(:disabled) { transform: scale(0.96); }
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.pg-info {
  font-family: 'Kanit', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--ink-3);
  min-width: 108px; text-align: center;
}

/* =====================  FEED (student scans)  ===================== */
.feed { padding: 12px; max-height: 480px; overflow-y: auto; }
.feed::-webkit-scrollbar, .recent-list::-webkit-scrollbar, .student-list::-webkit-scrollbar { width: 6px; }
.feed::-webkit-scrollbar-thumb, .recent-list::-webkit-scrollbar-thumb, .student-list::-webkit-scrollbar-thumb { background: var(--green-line); border-radius: 4px; }
.feed-item { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: var(--r-md); margin-bottom: 7px; background: var(--surface-soft); border: 1px solid var(--green-line); transition: var(--t); }
.feed-item:hover { border-color: var(--leaf); transform: translateX(2px); }
.feed-icon { width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0; background: var(--leaf-soft); color: var(--green); display: flex; align-items: center; justify-content: center; font-size: 19px; }
.feed-main { flex: 1; min-width: 0; }
.feed-num { font-family: 'Kanit', sans-serif; font-size: 15px; font-weight: 700; color: var(--green); }
.feed-date { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.feed-time { font-size: 12px; color: var(--ink-2); white-space: nowrap; background: #fff; padding: 5px 11px; border-radius: var(--r-pill); border: 1px solid var(--green-line); }

/* =====================  LEADERBOARD  ===================== */
.leaderboard { padding: 12px; }
.lb-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); margin-bottom: 8px; background: var(--surface); border: 1px solid var(--green-line); transition: var(--t); }
.lb-item:hover { border-color: var(--leaf); transform: translateX(2px); }
.lb-item.me { background: var(--leaf-soft); border-color: var(--leaf); }
.lb-rank { font-family: 'Kanit', sans-serif; font-size: 17px; font-weight: 700; width: 38px; height: 38px; border-radius: 12px; background: var(--surface-soft); color: var(--ink-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lb-item:nth-child(1) .lb-rank { background: linear-gradient(145deg, var(--amber), #a86f04); color: #fff; }
.lb-item:nth-child(2) .lb-rank { background: var(--green); color: #fff; }
.lb-item:nth-child(3) .lb-rank { background: var(--leaf); color: #fff; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-no { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.lb-bar-wrap { margin-top: 7px; background: var(--bg-deep); border-radius: var(--r-pill); height: 6px; overflow: hidden; }
.lb-bar { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--green)); border-radius: var(--r-pill); transition: width 0.9s var(--ease); }
.lb-count { font-family: 'Kanit', sans-serif; font-size: 21px; font-weight: 700; color: var(--green); }
.lb-item.me .lb-count { color: var(--green-2); }
.me-tag { font-size: 10px; color: #fff; background: var(--leaf); padding: 2px 9px; border-radius: var(--r-pill); vertical-align: middle; margin-left: 6px; font-family: 'Kanit', sans-serif; font-weight: 600; }

/* eco tip */
.eco-tip { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: var(--amber-soft); border: 1px solid #f0dca6; border-radius: var(--r-lg); margin-top: 14px; }
.eco-tip .icon { width: 40px; height: 40px; border-radius: 13px; background: var(--amber); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.eco-tip .text { font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.eco-tip .text strong { color: var(--ink); }

/* =====================  ROOM SALE CARDS (officer)  ===================== */
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 16px; }
.room-card { background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-lg); padding: 20px; text-align: center; transition: var(--t); }
.room-card:hover { border-color: var(--leaf); transform: translateY(-3px); box-shadow: var(--shadow); }
.rc-room { font-family: 'Kanit', sans-serif; font-size: 15px; font-weight: 700; color: var(--ink); }
.rc-people { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.rc-count { font-family: 'Kanit', sans-serif; font-size: 44px; font-weight: 700; color: var(--green); line-height: 1.05; margin: 12px 0 4px; letter-spacing: -0.02em; }
.rc-unit { font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }
.rc-bar-wrap { background: var(--bg-deep); border-radius: var(--r-pill); height: 7px; overflow: hidden; margin-bottom: 16px; }
.rc-bar { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--green)); border-radius: var(--r-pill); transition: width 0.9s var(--ease); }
.room-sell-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px; background: var(--green); color: #fff; border: none; border-radius: var(--r-md); font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--t); }
.room-sell-btn:hover:not(:disabled) { background: var(--green-2); transform: translateY(-1px); }
.room-sell-btn:active:not(:disabled) { transform: scale(0.98); }
.room-sell-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* =====================  STUDENT LIST (officer sidebar)  ===================== */
.student-list { max-height: 500px; overflow-y: auto; }
.st-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--green-line); transition: background 0.15s var(--ease); }
.st-row:last-child { border-bottom: none; }
.st-row:hover { background: var(--surface-soft); }
.st-info { flex: 1; min-width: 0; }
.st-name { font-family: 'Kanit', sans-serif; font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }

/* =====================  RECENT SALES  ===================== */
.recent-list { padding: 12px; max-height: 320px; overflow-y: auto; }
.sale-item { padding: 13px 14px; border-radius: var(--r-md); margin-bottom: 7px; background: var(--surface-soft); border: 1px solid var(--green-line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.s-room-badge { font-size: 12px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--green); color: #fff; display: inline-block; font-weight: 600; }
.s-date { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.s-count { font-family: 'Kanit', sans-serif; font-size: 16px; font-weight: 700; color: var(--green-2); white-space: nowrap; }

/* =====================  CHARTS (manager)  ===================== */
.chart-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding-bottom: 4px; }
.chart-card { background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.chart-card.full { grid-column: 1 / -1; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.chart-title { font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.chart-badge { font-size: 10.5px; font-weight: 600; padding: 4px 10px; border-radius: var(--r-pill); background: var(--leaf-soft); color: var(--green-2); font-family: 'Kanit', sans-serif; }
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { width: 100% !important; max-height: 260px; }

/* =====================  MODALS  ===================== */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(15,36,23,0.5); display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(5px); }
.modal.open { display: flex; animation: rise 0.28s var(--ease); }
.modal-box { background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-xl); padding: 28px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); animation: pop 0.32s var(--ease); }
.modal-sm { max-width: 400px; }
.modal-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--green-line); }
.modal-hd span { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--ink); }
.modal-x { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-soft); border: none; color: var(--ink-3); font-size: 22px; cursor: pointer; line-height: 1; transition: var(--t); display: flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--danger-soft); color: var(--danger); }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-family: 'Kanit', sans-serif; font-size: 11px; color: var(--ink-2); margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.form-row input, .form-row textarea {
  width: 100%; background: var(--surface-soft); border: 1px solid var(--green-line); border-radius: var(--r-md);
  padding: 12px 14px; color: var(--ink); font-size: 14px; font-family: 'Sarabun', sans-serif; outline: none; transition: var(--t);
}
.form-row input:focus, .form-row textarea:focus { border-color: var(--leaf); background: #fff; box-shadow: var(--ring); }
.form-row textarea { resize: vertical; min-height: 56px; }
.form-row small { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; display: block; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.btn-cancel { padding: 11px 20px; border: 1px solid var(--green-line); background: #fff; color: var(--ink-2); border-radius: var(--r-md); font-family: 'Sarabun', sans-serif; font-size: 14px; cursor: pointer; transition: var(--t); }
.btn-cancel:hover { border-color: var(--ink); color: var(--ink); }
.btn-save, .btn-sell-ok { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 24px; background: var(--green); color: #fff; border: none; border-radius: var(--r-md); font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--t); }
.btn-save:hover, .btn-sell-ok:hover { background: var(--green-2); transform: translateY(-1px); }
.btn-save:active, .btn-sell-ok:active { transform: scale(0.98); }
.btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 22px; background: var(--danger); color: #fff; border: none; border-radius: var(--r-md); font-family: 'Kanit', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; transition: var(--t); }
.btn-danger:hover { filter: brightness(0.94); transform: translateY(-1px); }

.sell-summary { background: var(--leaf-soft); border: 1px solid var(--green-line); border-radius: var(--r-lg); padding: 22px; text-align: center; margin-bottom: 18px; }
.sell-summary .ss-room { font-family: 'Kanit', sans-serif; font-size: 16px; font-weight: 600; color: var(--green-2); }
.sell-summary .ss-total { font-family: 'Kanit', sans-serif; font-size: 50px; font-weight: 700; color: var(--green); line-height: 1.1; letter-spacing: -0.02em; }
.sell-summary .ss-unit { font-size: 14px; color: var(--ink-2); }
.sell-summary .ss-warn { font-size: 12.5px; color: var(--ink-3); margin-top: 10px; }
.price-row { display: flex; gap: 12px; align-items: flex-end; }
.price-row .form-row { flex: 1; }
.price-total { background: var(--leaf-soft); border: 1px solid var(--green-line); border-radius: var(--r-md); padding: 14px 18px; text-align: center; }
.price-total .pt-label { font-family: 'Kanit', sans-serif; font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.price-total .pt-amount { font-family: 'Kanit', sans-serif; font-size: 24px; font-weight: 700; color: var(--green); line-height: 1.2; }

/* =====================  TOAST  ===================== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: var(--z-toast);
  padding: 14px 22px; border-radius: var(--r-md); font-size: 14px; font-weight: 500;
  background: var(--ink); color: #fff; transform: translateY(90px); opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.35s var(--ease); pointer-events: none; box-shadow: var(--shadow-lg);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--danger); }

/* =====================  EMPTY  ===================== */
.empty { text-align: center; color: var(--ink-3); padding: 44px 20px; font-size: 14px; }
.empty.pad { padding: 24px; }

/* Shared modal body copy (confirmation dialogs) */
.modal-text { color: var(--ink-2); font-size: 14px; line-height: 1.8; padding-bottom: 8px; }
.modal-text strong { color: var(--ink); }
.modal-text small { color: var(--ink-3); }

/* =====================  ADMIN GATE  ===================== */
.admin-gate {
  position: fixed; inset: 0; z-index: var(--z-gate); display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(900px 480px at 10% 0%, rgba(63,164,99,0.14), transparent 60%),
    var(--bg);
}
.admin-gate.hidden { display: none; }
.admin-gate-box { text-align: center; max-width: 380px; width: 100%; background: var(--surface); border: 1px solid var(--green-line); border-radius: var(--r-xl); padding: 36px 32px; box-shadow: var(--shadow); }
.admin-gate-icon { width: 60px; height: 60px; border-radius: 18px; background: linear-gradient(145deg, var(--leaf), var(--green-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 20px; box-shadow: var(--shadow); }
.admin-gate-title { font-family: 'Kanit', sans-serif; font-size: 23px; font-weight: 700; color: var(--ink); }
.admin-gate-sub { font-size: 14px; color: var(--ink-2); margin-top: 8px; margin-bottom: 24px; line-height: 1.6; }
.admin-gate input { width: 100%; background: var(--surface-soft); border: 1px solid var(--green-line); border-radius: var(--r-md); padding: 14px 16px; color: var(--ink); font-size: 17px; font-family: 'Kanit', sans-serif; outline: none; text-align: center; letter-spacing: 0.2em; transition: var(--t); }
.admin-gate input:focus { border-color: var(--leaf); background: #fff; box-shadow: var(--ring); }
.admin-gate .gate-btn { width: 100%; padding: 14px; background: var(--green); color: #fff; border: none; border-radius: var(--r-md); font-size: 15px; font-weight: 700; font-family: 'Kanit', sans-serif; cursor: pointer; margin-top: 12px; transition: var(--t); }
.admin-gate .gate-btn:hover { background: var(--green-2); transform: translateY(-1px); }
.admin-gate .gate-btn:active { transform: scale(0.98); }
.admin-gate .gate-err { margin-top: 12px; padding: 11px; background: var(--danger-soft); border: 1px solid #efc9c4; border-radius: var(--r-sm); color: var(--danger); font-size: 13px; display: none; }
.admin-gate .gate-back { display: inline-block; margin-top: 18px; font-size: 13px; color: var(--ink-3); text-decoration: none; transition: var(--t); }
.admin-gate .gate-back:hover { color: var(--green); }
