/* BMA 2568 Dashboard — Thai Government Clean White */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;600&display=swap');

:root {
  --c-primary: #1a4fa8;
  --c-primary-light: #2563eb;
  --c-primary-dark: #0f2d6b;
  --c-accent:  #f59e0b;
  --c-pass:    #16a34a;
  --c-fail:    #dc2626;
  --c-skip:    #9ca3af;
  --c-bg:      #f8faff;
  --c-surface: #ffffff;
  --c-border:  #e5eaf5;
  --c-text:    #1e293b;
  --c-muted:   #64748b;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(26,79,168,.07), 0 1px 2px rgba(26,79,168,.04);
  --shadow-md: 0 4px 12px rgba(26,79,168,.1), 0 2px 6px rgba(26,79,168,.06);
  --shadow-lg: 0 12px 32px rgba(26,79,168,.12), 0 4px 12px rgba(26,79,168,.08);
  --font: 'Sarabun', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); font-size: 15px; line-height: 1.6; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app-header {
  background: var(--c-surface);
  border-bottom: 2px solid var(--c-primary);
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-emblem { width: 36px; height: 36px; }
.logo-text { font-size: 15px; font-weight: 700; color: var(--c-primary-dark); line-height: 1.2; }
.logo-sub { font-size: 11px; font-weight: 400; color: var(--c-muted); }
.header-year {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 600;
  color: var(--c-primary);
  background: #eff6ff; border-radius: 4px; padding: 3px 8px;
}
.nav-tabs {
  display: flex; gap: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.nav-tab {
  padding: 12px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--c-muted); cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.nav-tab:hover { color: var(--c-primary); }
.nav-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

.main-content { max-width: 1440px; margin: 0 auto; padding: 24px 24px 80px; }

/* ── Cards ── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 10px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--c-text); }
.card-body { padding: 20px; }

/* ── Stat strip ── */
.stat-strip {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 24px;
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin-bottom: 6px; }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; line-height: 1; }
.stat-sub { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.stat-pass { color: var(--c-pass); }
.stat-fail { color: var(--c-fail); }
.stat-skip { color: var(--c-skip); }
.stat-total { color: var(--c-primary); }

/* ── Dimension grid ── */
.dim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.dim-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.dim-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dim-card-top {
  padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 12px;
}
.dim-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.dim-name { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.dim-desc { font-size: 12px; color: var(--c-muted); line-height: 1.4; }
.dim-progress { padding: 0 20px 16px; }
.progress-bar { height: 6px; background: #e5eaf5; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--c-pass); border-radius: 3px; transition: width .4s; }
.dim-stats { display: flex; gap: 12px; margin-top: 8px; }
.dim-stat { font-size: 12px; font-family: var(--font-mono); }

/* ── Issue list ── */
.issue-list { display: flex; flex-direction: column; gap: 8px; }
.issue-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer; transition: all .15s;
}
.issue-row:hover { border-color: var(--c-primary-light); background: #eff6ff; }
.issue-code { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--c-muted); flex-shrink: 0; min-width: 28px; }
.issue-name { font-size: 14px; font-weight: 500; flex: 1; }
.issue-progress { width: 80px; }
.issue-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--c-pass); min-width: 36px; text-align: right; }

/* ── KR Table ── */
.kr-table-wrap { overflow-x: auto; }
.kr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kr-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); border-bottom: 2px solid var(--c-border); white-space: nowrap; }
.kr-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.kr-table tr:hover td { background: #f8faff; }
.kr-code { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--c-primary); }
.kr-name { color: var(--c-text); line-height: 1.4; }
.kr-result { font-size: 12px; color: var(--c-muted); }

/* ── Badge / Status ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-pass { background: #dcfce7; color: var(--c-pass); }
.badge-fail { background: #fee2e2; color: var(--c-fail); }
.badge-skip { background: #f1f5f9; color: var(--c-skip); }
.badge-pct { background: #eff6ff; color: var(--c-primary); font-family: var(--font-mono); }

/* ── SDG chips ── */
.sdg-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sdg-chip {
  width: 22px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  color: #fff; flex-shrink: 0; cursor: pointer;
  transition: transform .1s;
}
.sdg-chip:hover { transform: scale(1.2); }

/* ── Panel / Drill-down ── */
.panel {
  position: fixed; top: 0; right: 0;
  width: min(580px, 100vw);
  height: 100vh;
  background: var(--c-surface);
  box-shadow: -4px 0 32px rgba(0,0,0,.15);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 200;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.panel.open { transform: translateX(0); }
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.panel-overlay.open { opacity: 1; pointer-events: auto; }
.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.panel-close {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: var(--c-muted);
  background: #f1f5f9; border: none; transition: background .15s;
}
.panel-close:hover { background: #e2e8f0; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.panel-section { margin-bottom: 24px; }
.panel-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--c-muted);
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--c-border);
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--c-muted); margin-bottom: 16px;
  flex-wrap: wrap;
}
.breadcrumb-item { cursor: pointer; color: var(--c-primary); }
.breadcrumb-item:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--c-border); }

/* ── Search ── */
.search-wrap { position: relative; max-width: 400px; }
.search-input {
  width: 100%; padding: 10px 16px 10px 40px;
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  font-family: var(--font); font-size: 14px; background: var(--c-surface);
  outline: none; transition: border-color .15s;
}
.search-input:focus { border-color: var(--c-primary-light); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--c-muted); }

/* ── Loading ── */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; gap: 10px; color: var(--c-muted); }
.spinner { width: 20px; height: 20px; border: 2px solid var(--c-border); border-top-color: var(--c-primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Agency chips ── */
.agency-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.agency-chip {
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--c-border);
  cursor: pointer; transition: all .12s;
}
.agency-chip.H { background: #eff6ff; color: var(--c-primary); border-color: #bfdbfe; }
.agency-chip.R { background: #f8faff; color: var(--c-muted); }
.agency-chip:hover { border-color: var(--c-primary); }

/* ── Tabs inside panel ── */
.inner-tabs { display: flex; border-bottom: 1px solid var(--c-border); margin-bottom: 16px; }
.inner-tab { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--c-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.inner-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }

/* ── Highlight text ── */
.highlight-list { font-size: 13px; color: var(--c-muted); line-height: 1.8; }
.highlight-list li { list-style: none; padding-left: 16px; position: relative; }
.highlight-list li::before { content: '·'; position: absolute; left: 0; color: var(--c-primary); font-weight: 700; }

/* ── Top banner ── */
.top-banner {
  background: linear-gradient(135deg, var(--c-primary-dark) 0%, var(--c-primary) 60%, var(--c-primary-light) 100%);
  color: #fff; padding: 24px 28px; border-radius: var(--r-lg); margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.banner-title { font-size: 22px; font-weight: 700; }
.banner-sub { font-size: 13px; opacity: .8; margin-top: 4px; }
.banner-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.banner-stat { text-align: center; }
.banner-stat-val { font-family: var(--font-mono); font-size: 26px; font-weight: 700; line-height: 1; }
.banner-stat-lbl { font-size: 11px; opacity: .75; margin-top: 2px; }

/* ── Section header ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 18px; font-weight: 700; color: var(--c-text); }

/* Responsive */
@media (max-width: 768px) {
  .main-content { padding: 16px; }
  .dim-grid { grid-template-columns: 1fr; }
  .panel { width: 100vw; }
  .banner-title { font-size: 17px; }
  .stat-strip { grid-template-columns: repeat(2,1fr); }
}
