/* ==========================================================================
   Token system
   Palette drawn from the BMA seal's own colors: forest green (การปกครอง),
   gold and dark-goldenrod (ตราสัญลักษณ์ประดับทอง). Paper-cream background
   reads as an official document rather than a generic dashboard.
   ========================================================================== */
:root {
  --paper: #faf7ec;
  --panel: #ffffff;
  --ink: #1c2620;
  --muted: #5d6b60;
  --line: #e6dfc4;

  --green-950: #0a2e20;
  --green-800: #0f4a34;
  --green-700: #146447;
  --green-600: #1c7d55;
  --green-100: #e4f0e6;

  --gold-700: #9c6b0b;
  --gold-600: #b8860b;
  --gold-500: #d4af37;
  --gold-100: #fbf1cf;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,30,20,.05), 0 6px 20px rgba(20,30,20,.06);

  --font-display: "Sarabun", "Noto Sans Thai", "IBM Plex Sans Thai", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Sarabun", "Noto Sans Thai", "IBM Plex Sans Thai", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
}

/* ==========================================================================
   Signature element: a three-tone "sash" band under the top nav — the one
   deliberate flourish, echoing the ribbon on an official seal/document.
   Used once; everything else stays quiet.
   ========================================================================== */
.sash {
  height: 5px;
  background: linear-gradient(90deg, var(--green-700) 0%, var(--green-700) 40%, var(--gold-500) 40%, var(--gold-500) 70%, var(--gold-700) 70%, var(--gold-700) 100%);
}

/* ==========================================================================
   Top navigation
   ========================================================================== */
.topnav {
  background: var(--green-950);
  color: #eef3ee;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  padding: 13px 0;
  margin-right: 8px;
  cursor: pointer;
  user-select: none;
}
.brand .title { font-weight: 700; font-size: 15.5px; color: #fff; letter-spacing: .01em; }
.brand .subtitle { font-size: 11px; color: var(--gold-500); font-weight: 600; letter-spacing: .04em; }

.nav-menu { display: flex; gap: 2px; flex-wrap: wrap; }
.nav-item {
  display: flex; align-items: center; gap: 7px;
  padding: 14px 14px;
  font-size: 13.8px; color: #cfe0d2; cursor: pointer;
  border-bottom: 3px solid transparent;
  user-select: none;
  white-space: nowrap;
}
.nav-item .ico { font-size: 13px; color: var(--gold-500); }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; border-bottom-color: var(--gold-500); font-weight: 600; }

/* ==========================================================================
   Layout
   ========================================================================== */
.main { max-width: 1320px; margin: 0 auto; padding: 24px 22px 60px; }
.topbar {
  display:flex; align-items:center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap:10px;
}
.topbar h1 { font-family: var(--font-display); font-size: 21px; margin: 0; font-weight: 700; color: var(--green-950); }
.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--green-700); cursor: pointer; text-decoration: none; font-weight: 600; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ==========================================================================
   Cards / KPI — gold top-rule evokes a letterhead / official seal card
   ========================================================================== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border: 1px solid var(--line);
  border-top: 3px solid var(--gold-500);
}
.kpi-card .label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.kpi-card .value { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--green-950); }
.kpi-card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 18px; margin-bottom: 18px;
}
.panel h2 {
  font-family: var(--font-display); font-size: 15px; margin: 0 0 12px; font-weight: 700;
  color: var(--green-950); display:flex; align-items:center; justify-content:space-between;
}
.panel h2 .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.chart-wrap { position: relative; height: 300px; }
.chart-wrap.short { height: 220px; }

/* ==========================================================================
   Notice banner (data-quality callout)
   ========================================================================== */
.notice {
  background: var(--gold-100); border: 1px solid var(--gold-500); border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: 16px; font-size: 13.5px; color: #5a4308;
  display: flex; gap: 10px; align-items: flex-start;
}
.notice .ico { color: var(--gold-700); font-size: 16px; line-height:1.3; }
.notice a { color: var(--green-700); font-weight: 600; cursor: pointer; }

/* ==========================================================================
   Table
   ========================================================================== */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left; padding: 9px 10px; background: var(--green-100); color: var(--green-800);
  font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing:.03em;
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--gold-100); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { max-height: 520px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.bar-cell { display:flex; align-items:center; gap:8px; }
.bar-track { flex:1; height:6px; background:#eef1e5; border-radius:4px; overflow:hidden; }
.bar-fill { height:100%; background: linear-gradient(90deg, var(--green-600), var(--gold-500)); border-radius:4px; }

/* ==========================================================================
   Filters
   ========================================================================== */
.filter-row { display:flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items:center; }
.filter-row input, .filter-row select {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; font-size: 13.5px;
  background: #fff; color: var(--ink); font-family: inherit;
}
.filter-row input[type=text] { min-width: 220px; flex: 1; }
.filter-row .amt { width: 130px; }
.check-label { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); cursor:pointer; user-select:none; }
.btn {
  border: 1px solid var(--line); background:#fff; border-radius:9px; padding:8px 14px;
  font-size:13.5px; cursor:pointer; color: var(--ink);
}
.btn.primary { background: var(--green-700); border-color: var(--green-700); color:#fff; }
.btn:hover { filter: brightness(0.97); }

.pagination { display:flex; align-items:center; gap:8px; justify-content:flex-end; margin-top:12px; font-size:13px; color: var(--muted); }
.pagination button { border:1px solid var(--line); background:#fff; border-radius:8px; padding:5px 10px; cursor:pointer; }
.pagination button:disabled { opacity:.4; cursor:default; }

.badge { display:inline-block; padding:2px 9px; border-radius:20px; font-size:11.5px; background: var(--green-100); color: var(--green-800); font-weight:700;}
.badge.gold { background: var(--gold-100); color: var(--gold-700); }
.loading { text-align:center; padding: 40px; color: var(--muted); font-size:13.5px;}
.empty { text-align:center; padding: 30px; color: var(--muted); font-size:13.5px;}

.mono { font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .nav-item span.label { display: none; }
  .nav-item { padding: 12px 10px; }
}
