:root {
  --navy: #071a34;
  --navy-2: #0d2b52;
  --navy-3: #163b67;
  --gold: #d6a84c;
  --gold-light: #f1d28b;
  --cream: #f7f3eb;
  --paper: #fffdfa;
  --ink: #10213b;
  --muted: #6d788a;
  --line: #e5e1d9;
  --green: #1f8b69;
  --orange: #d97735;
  --red: #bc4b4b;
  --shadow: 0 18px 50px rgba(7, 26, 52, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Noto Sans Lao", "Phetsarath OT", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: 256px;
  display: flex;
  flex-direction: column;
  padding: 25px 18px;
  overflow: hidden;
  color: white;
  background:
    radial-gradient(circle at 0 0, rgba(214,168,76,.18), transparent 35%),
    linear-gradient(165deg, #0c2b53 0%, #071a34 55%, #041225 100%);
}
.sidebar::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  left: -110px;
  bottom: 80px;
  border: 1px solid rgba(214,168,76,.18);
  border-radius: 50%;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.logo-frame {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  overflow: hidden;
  border: 2px solid rgba(214,168,76,.75);
  border-radius: 16px;
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.logo-frame img { width: 100%; height: 100%; object-fit: cover; }
.brand-lockup strong { display: block; font-family: Georgia, serif; font-size: 25px; letter-spacing: 2px; color: var(--gold-light); }
.brand-lockup span { font-size: 9px; letter-spacing: 3px; opacity: .7; }
.nav-list { display: grid; gap: 7px; margin-top: 58px; position: relative; z-index: 1; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border: 0;
  border-radius: 10px;
  color: rgba(255,255,255,.68);
  background: transparent;
  text-align: left;
  transition: .2s ease;
}
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.active { box-shadow: inset 3px 0 var(--gold); }
.nav-icon { display: grid; place-items: center; width: 25px; height: 25px; color: var(--gold-light); font-size: 17px; }
.sidebar-footer { margin-top: auto; position: relative; z-index: 1; padding: 16px 12px 2px; border-top: 1px solid rgba(255,255,255,.1); }
.source-status { font-size: 10px; letter-spacing: .5px; color: rgba(255,255,255,.58); }
.source-status b { font-weight: 600; }
.source-status span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #54c99b; box-shadow: 0 0 0 4px rgba(84,201,155,.1); }
.source-status.sync-error span { background: #ef8b68; box-shadow: 0 0 0 4px rgba(239,139,104,.1); }
.sidebar-footer a { display: block; margin-top: 12px; color: var(--gold-light); font-size: 11px; text-decoration: none; }

.main-content { margin-left: 256px; min-width: 0; }
.topbar {
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 19px 42px;
  background: rgba(255,253,250,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.menu-toggle { display: none; border: 0; color: var(--navy); background: transparent; font-size: 24px; }
.eyebrow { margin: 0 0 3px; color: #9a7636; font-size: 9px; font-weight: 800; letter-spacing: 2.3px; }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 13px; }
.date-chip { padding-right: 15px; border-right: 1px solid var(--line); text-align: right; }
.date-chip span { display: block; color: var(--muted); font-size: 9px; }
.date-chip strong { font-size: 12px; }
.export-button { border: 1px solid var(--navy); border-radius: 8px; padding: 10px 15px; background: var(--navy); color: white; font-size: 11px; font-weight: 700; }
.export-button:hover { background: var(--navy-2); }

.hero {
  min-height: 282px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 52px 48px;
  color: white;
  background:
    linear-gradient(100deg, rgba(5,22,44,.98), rgba(10,43,82,.88)),
    radial-gradient(circle at 75% 40%, rgba(214,168,76,.35), transparent 32%);
}
.hero::before, .hero::after { content: ""; position: absolute; border: 1px solid rgba(214,168,76,.26); border-radius: 50%; }
.hero::before { width: 430px; height: 430px; right: -75px; top: -177px; }
.hero::after { width: 325px; height: 325px; right: -10px; bottom: -237px; }
.hero-copy { position: relative; z-index: 1; }
.project-tag { display: inline-flex; gap: 10px; align-items: center; padding: 7px 11px; border: 1px solid rgba(214,168,76,.42); color: var(--gold-light); font-size: 9px; letter-spacing: 1.5px; }
.project-tag span { color: white; }
.hero h2 { margin: 17px 0 12px; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.2; letter-spacing: -1px; }
.hero h2 em { color: var(--gold-light); font-family: Georgia, serif; font-weight: 500; font-style: normal; }
.hero p { max-width: 590px; margin: 0; color: rgba(255,255,255,.63); line-height: 1.8; font-size: 12px; }
.hero-mark { position: relative; z-index: 1; min-width: 180px; text-align: center; }
.hero-mark span { display: block; color: transparent; -webkit-text-stroke: 1px rgba(214,168,76,.75); font: 100px/1 Georgia, serif; }
.hero-mark small { color: var(--gold-light); letter-spacing: 8px; }

.notice { display: flex; align-items: center; gap: 13px; margin: 24px 36px 0; padding: 15px 17px; border: 1px solid #ead8b6; border-radius: 12px; background: #fff8e9; box-shadow: 0 10px 30px rgba(120,83,20,.04); }
.notice-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; border-radius: 50%; background: var(--gold); color: white; font-weight: 900; }
.notice strong { font-size: 12px; }
.notice p { margin: 2px 0 0; color: #7f6842; font-size: 10px; line-height: 1.6; }
.notice button { margin-left: auto; flex: 0 0 auto; border: 0; background: transparent; color: #8c671f; font-size: 10px; font-weight: 800; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; padding: 24px 36px; }
.kpi-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.kpi-card.featured { color: white; border-color: var(--navy); background: linear-gradient(135deg, var(--navy-2), var(--navy)); }
.kpi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 19px; }
.kpi-head span { color: var(--muted); font-size: 10px; }
.featured .kpi-head span { color: rgba(255,255,255,.65); }
.kpi-head i { font: 11px Georgia, serif; color: var(--gold); }
.kpi-card > strong { display: block; overflow: hidden; font-family: Georgia, "Noto Sans Lao", serif; font-size: clamp(25px, 2.6vw, 36px); line-height: 1; white-space: nowrap; text-overflow: ellipsis; }
.kpi-card > p { margin: 7px 0 18px; color: var(--muted); font-size: 9px; }
.featured > p { color: rgba(255,255,255,.57); }
.kpi-foot { padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.featured .kpi-foot { border-color: rgba(255,255,255,.14); color: rgba(255,255,255,.6); }
.positive { color: var(--green); font-weight: 800; }
.featured .positive { color: #8ee0be; }
.neutral { color: var(--gold); font-weight: 800; }

.dashboard-grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; padding: 0 36px 32px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 25px; }
.panel-heading > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.panel-heading h3 { margin: 0; font-size: 13px; }
.section-no { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border: 1px solid #ead8b6; border-radius: 50%; color: #9c772f; font: 10px Georgia, serif; }
.panel-meta { color: var(--muted); font-size: 8px; letter-spacing: 1.3px; }

.village-bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 35px; align-items: center; gap: 12px; }
.bar-row label { overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.bar-track { height: 7px; overflow: hidden; border-radius: 999px; background: #eeeae3; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--navy-3), var(--gold)); transform-origin: left; animation: grow .8s ease both; }
.bar-row strong { color: var(--navy); font: 12px Georgia, serif; text-align: right; }
@keyframes grow { from { transform: scaleX(0); } }

.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 27px; }
.donut { width: 145px; height: 145px; display: grid; place-items: center; flex: 0 0 145px; border-radius: 50%; background: conic-gradient(var(--navy-2) 0 57.1%, var(--gold) 57.1% 89.8%, #d8d9da 89.8%); position: relative; }
.donut::after { content: ""; position: absolute; width: 98px; height: 98px; border-radius: 50%; background: var(--paper); }
.donut > div { z-index: 1; text-align: center; }
.donut strong { display: block; font: 20px Georgia, serif; }
.donut span { color: var(--muted); font-size: 8px; }
.legend { display: grid; gap: 10px; }
.legend-item { display: grid; grid-template-columns: 8px 1fr; gap: 0 8px; align-items: center; }
.legend-item i { width: 8px; height: 8px; border-radius: 50%; }
.legend-item strong { font-size: 10px; }
.legend-item span { grid-column: 2; color: var(--muted); font-size: 8px; }
.pricing-note { margin-top: 24px; padding: 13px; border-left: 3px solid var(--gold); background: #faf6ed; }
.pricing-note span { display: block; color: var(--muted); font-size: 8px; }
.pricing-note strong { font-size: 10px; }

.area-chart { min-height: 190px; display: flex; align-items: flex-end; justify-content: space-around; gap: 12px; padding-top: 15px; border-bottom: 1px solid var(--line); background: repeating-linear-gradient(to top, transparent 0 42px, #efede8 43px); }
.area-col { height: 185px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; }
.area-col strong { margin-bottom: 6px; font: 11px Georgia, serif; }
.area-col i { width: min(38px, 65%); min-height: 3px; border-radius: 5px 5px 0 0; background: linear-gradient(var(--gold-light), var(--gold)); animation: rise .8s ease both; }
.area-col.featured i { background: linear-gradient(var(--navy-3), var(--navy)); }
.area-col span { position: absolute; bottom: -24px; color: var(--muted); font-size: 8px; white-space: nowrap; }
@keyframes rise { from { height: 0 !important; } }
.inventory-panel { padding-bottom: 42px; }

.insight-panel { background: linear-gradient(150deg, #0d2b52, #071a34); color: white; border-color: var(--navy); }
.insight-panel .panel-heading h3 { color: white; }
.insight-list { display: grid; }
.insight-list > div { display: grid; grid-template-columns: 31px 1fr; gap: 11px; padding: 14px 0; border-top: 1px solid rgba(255,255,255,.11); }
.insight-list > div:first-child { border-top: 0; }
.insight-list span { color: var(--gold-light); font: 11px Georgia, serif; }
.insight-list p { margin: 0; color: rgba(255,255,255,.7); font-size: 10px; line-height: 1.7; }
.insight-list strong { color: white; font-size: 14px; }

.quality-section, .table-section { padding: 42px 36px; background: #f0ece4; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-title h2 { margin: 0; font-size: 24px; }
.quality-score { display: flex; align-items: center; gap: 7px; }
.quality-score strong { font: 40px Georgia, serif; color: var(--navy); }
.quality-score span { color: var(--muted); font-size: 8px; line-height: 1.3; }
.quality-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.quality-grid article { min-height: 158px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.quality-grid article > strong { display: block; margin: 15px 0 7px; font-size: 12px; }
.quality-grid article p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.7; }
.severity { display: inline-block; padding: 3px 7px; border-radius: 999px; font-size: 7px; font-weight: 800; }
.severity.high { color: var(--red); background: #fbe9e9; }
.severity.medium { color: var(--orange); background: #fff0e3; }
.severity.low { color: var(--green); background: #e8f6f0; }

.table-section { background: var(--cream); }
.table-title { align-items: center; }
.table-tools { display: flex; gap: 9px; }
.search-box { width: 260px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 10px; }
.table-tools select { border: 1px solid var(--line); border-radius: 8px; padding: 0 11px; color: var(--ink); background: white; font-size: 10px; }
.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { padding: 13px 14px; color: #758094; background: #f4f1eb; font-size: 8px; letter-spacing: .3px; text-align: left; white-space: nowrap; }
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: inherit;
  font-weight: 800;
  letter-spacing: inherit;
  white-space: nowrap;
}
.sort-button:hover, .sort-button.active { color: var(--navy); }
.sort-arrow { min-width: 10px; color: #aeb4bd; font-size: 9px; line-height: 1; }
.sort-button.active .sort-arrow { color: var(--gold); }
td { padding: 13px 14px; border-top: 1px solid #eeebe5; white-space: nowrap; }
tbody tr:hover { background: #fcfaf5; }
.row-id { color: #9b7a3d; font: 11px Georgia, serif; }
.money { font-weight: 800; }
.status-pill { display: inline-block; padding: 4px 7px; border-radius: 999px; color: var(--green); background: #e9f6f1; font-size: 8px; }
.status-pill.warn { color: var(--orange); background: #fff0e3; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.pagination > div { display: flex; align-items: center; gap: 8px; }
.pagination button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: white; }
.pagination button:disabled { opacity: .35; cursor: default; }

footer { display: flex; justify-content: space-between; padding: 24px 36px; color: var(--muted); background: var(--paper); font-size: 8px; letter-spacing: .4px; }

@media (max-width: 1100px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quality-grid { grid-template-columns: repeat(2, 1fr); }
  .donut-wrap { gap: 16px; }
}

@media (max-width: 780px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar { padding: 15px 18px; }
  .topbar h1 { font-size: 16px; }
  .date-chip { display: none; }
  .export-button { padding: 8px 10px; font-size: 9px; }
  .hero { min-height: 300px; padding: 42px 24px; }
  .hero-mark { display: none; }
  .notice { align-items: flex-start; margin: 18px 16px 0; }
  .notice button { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; padding: 18px 16px; gap: 10px; }
  .kpi-card { padding: 15px; }
  .kpi-card > strong { font-size: 23px; }
  .dashboard-grid { grid-template-columns: 1fr; padding: 0 16px 26px; }
  .quality-section, .table-section { padding: 32px 16px; }
  .quality-grid { grid-template-columns: 1fr; }
  .table-title { align-items: flex-start; flex-direction: column; }
  .table-tools { width: 100%; }
  .search-box { flex: 1; width: auto; }
}

@media (max-width: 480px) {
  .eyebrow { letter-spacing: 1.3px; }
  .hero h2 { font-size: 32px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 95px 1fr 28px; }
  .donut-wrap { align-items: flex-start; }
  .donut { width: 120px; height: 120px; flex-basis: 120px; }
  .donut::after { width: 80px; height: 80px; }
  .table-tools { flex-direction: column; }
  .table-tools select { min-height: 38px; }
  footer { flex-direction: column; gap: 7px; }
}

@media print {
  .sidebar, .export-button, .menu-toggle, .table-tools, .pagination { display: none !important; }
  .main-content { margin-left: 0; }
  .topbar { padding: 15px 0; }
  .notice, .kpi-grid, .dashboard-grid, .quality-section, .table-section { break-inside: avoid; }
  body { background: white; }
}
