/* ============================================================
   Style 1 — Map Dashboard  |  NQ57
   Government Official Design System
   ============================================================ */

:root {
  --s1-bg:           #F8FAFC;
  --s1-header:       #B91C1C;
  --s1-header-dark:  #991B1B;
  --s1-primary:      #0F172A;
  --s1-accent:       #0369A1;
  --s1-success:      #16A34A;
  --s1-warning:      #D97706;
  --s1-danger:       #DC2626;
  --s1-card:         #FFFFFF;
  --s1-border:       #E2E8F0;
  --s1-hover:        #EFF6FF;
  --s1-text:         #1E293B;
  --s1-text-muted:   #64748B;
  --s1-font-heading: 'Fira Code', 'Courier New', monospace;
  --s1-font-body:    'Fira Sans', 'Segoe UI', system-ui, sans-serif;
  --panel-w:         300px;
  --header-h:        64px;
  --kpi-h:           80px;
  --nav-h:           44px;
}

/* ---- Base ---- */
body {
  font-family: var(--s1-font-body);
  background: var(--s1-bg);
  color: var(--s1-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   HEADER
   ============================================================ */
.s1-header {
  background: linear-gradient(135deg, var(--s1-header) 0%, var(--s1-header-dark) 100%);
  color: #fff;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.s1-header-inner {
  max-width: 1800px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
}

.s1-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.s1-logo-emblem {
  opacity: 0.92;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.3));
}

.s1-logo-text {
  display: flex;
  flex-direction: column;
}

.s1-logo-top {
  font-family: var(--s1-font-heading);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.8;
  line-height: 1.2;
}

.s1-logo-sub {
  font-family: var(--s1-font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.s1-header-title {
  flex: 1;
  text-align: center;
}

.s1-header-title h1 {
  font-family: var(--s1-font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

#header-subtitle {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
  font-weight: 300;
}

.s1-header-meta {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.s1-meta-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.s1-meta-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.65;
  font-weight: 500;
}

.s1-meta-value {
  font-family: var(--s1-font-heading);
  font-size: 12px;
  font-weight: 600;
}

/* ============================================================
   KPI ROW
   ============================================================ */
.s1-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--s1-primary);
  border-bottom: 3px solid var(--s1-header);
}

.s1-kpi-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-right: 1px solid rgba(255,255,255,0.08);
  transition: background var(--transition-fast, 150ms ease);
}

.s1-kpi-card:last-child { border-right: none; }
.s1-kpi-card:hover { background: rgba(255,255,255,0.05); }

.s1-kpi-card--highlight {
  background: rgba(220,38,38,0.15);
}
.s1-kpi-card--highlight:hover {
  background: rgba(220,38,38,0.22);
}

.s1-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.s1-kpi-icon--blue    { background: rgba(3,105,161,0.35); color: #60A5FA; }
.s1-kpi-icon--indigo  { background: rgba(79,70,229,0.35); color: #A5B4FC; }
.s1-kpi-icon--green   { background: rgba(22,163,74,0.35); color: #86EFAC; }
.s1-kpi-icon--red     { background: rgba(220,38,38,0.35); color: #FCA5A5; }

.s1-kpi-body { display: flex; flex-direction: column; }

.s1-kpi-label {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  line-height: 1;
  margin-bottom: 4px;
}

.s1-kpi-value {
  font-family: var(--s1-font-heading);
  font-size: 16px;
  font-weight: 700;
  color: #F1F5F9;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.s1-kpi-pct {
  font-size: 20px;
  color: #FCA5A5;
}

/* ============================================================
   NAV BAR
   ============================================================ */
.s1-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--nav-h);
  background: #fff;
  border-bottom: 1px solid var(--s1-border);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

.s1-btn-back {
  color: var(--s1-primary);
  font-family: var(--s1-font-body);
  font-size: 13px;
}

.s1-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.s1-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--s1-text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.s1-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================
   MAIN 3-COLUMN LAYOUT
   ============================================================ */
.s1-main {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr var(--panel-w);
  height: calc(100vh - var(--header-h) - var(--kpi-h) - var(--nav-h) - 3px);
  overflow: hidden;
}

/* ============================================================
   PANELS (shared)
   ============================================================ */
.s1-panel {
  background: var(--s1-card);
  border-right: 1px solid var(--s1-border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.s1-panel-right {
  border-right: none;
  border-left: 1px solid var(--s1-border);
}

.s1-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 2px solid var(--s1-border);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}

.s1-panel-title {
  font-family: var(--s1-font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--s1-primary);
  display: flex;
  align-items: center;
  gap: 7px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.s1-panel-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.s1-panel-icon--blue   { background: #DBEAFE; color: #1D4ED8; }
.s1-panel-icon--amber  { background: #FEF3C7; color: #B45309; }

.s1-panel-badge {
  background: var(--s1-accent);
  color: #fff;
  font-family: var(--s1-font-heading);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.5;
  min-width: 28px;
  text-align: center;
}

/* ---- Donut chart ---- */
.s1-chart-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border-bottom: 1px solid var(--s1-border);
}

.s1-chart-wrap canvas {
  max-width: 200px;
  max-height: 200px;
}

.s1-chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.s1-chart-center-val {
  font-family: var(--s1-font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--s1-primary);
  line-height: 1.2;
}

.s1-chart-center-lbl {
  font-size: 10px;
  color: var(--s1-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ---- Section label ---- */
.s1-section-label {
  padding: 10px 16px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--s1-text-muted);
  border-bottom: 1px solid #F1F5F9;
}

/* ---- Top list ---- */
.s1-top-list {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.s1-loading {
  padding: 16px;
  text-align: center;
  color: var(--s1-text-muted);
  font-size: 13px;
}

/* ---- Top item ---- */
.s1-top-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast, 150ms ease);
  border: 1px solid transparent;
}

.s1-top-item:hover {
  background: var(--s1-hover);
  border-color: rgba(3,105,161,0.15);
}

.s1-top-item.highlighted {
  background: #DBEAFE;
  border-color: var(--s1-accent);
}

.s1-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--s1-bg);
  border: 1.5px solid var(--s1-border);
  font-family: var(--s1-font-heading);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--s1-text-muted);
}

.s1-top-info {
  flex: 1;
  min-width: 0;
}

.s1-top-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--s1-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-bottom: 4px;
}

.s1-progress-bar {
  height: 5px;
  background: #E2E8F0;
  border-radius: 3px;
  overflow: hidden;
}

.s1-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
  min-width: 2px;
}

.s1-top-pct {
  font-family: var(--s1-font-heading);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 38px;
  text-align: right;
}

/* ---- Detail button ---- */
.s1-detail-btn {
  margin: 8px 16px 16px;
  padding: 9px 14px;
  background: none;
  border: 1.5px solid var(--s1-accent);
  color: var(--s1-accent);
  border-radius: 6px;
  font-family: var(--s1-font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 150ms ease;
  width: calc(100% - 32px);
}

.s1-detail-btn:hover {
  background: var(--s1-accent);
  color: #fff;
}

/* ============================================================
   MAP
   ============================================================ */
.s1-map-wrap {
  position: relative;
  overflow: hidden;
}

.s1-map {
  width: 100%;
  height: 100%;
  background: #E8EDF2;
}

.s1-map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(248,250,252,0.85);
  font-size: 13px;
  color: var(--s1-text-muted);
  font-weight: 500;
  z-index: 500;
  transition: opacity 0.3s ease;
}

.s1-map-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Leaflet tooltip overrides */
.s1-map-tooltip {
  background: #0F172A;
  color: #F1F5F9;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--s1-font-body);
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 160px;
  pointer-events: none;
}

.s1-map-tooltip::before { display: none; }

.s1-tt-name {
  font-family: var(--s1-font-heading);
  font-size: 12px;
  font-weight: 700;
  color: #F8FAFC;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: 5px;
}

.s1-tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 3px 0;
  font-size: 11px;
}

.s1-tt-label { color: rgba(255,255,255,0.6); }
.s1-tt-val   { font-weight: 600; font-family: var(--s1-font-heading); color: #F1F5F9; }

/* ============================================================
   MODAL
   ============================================================ */
.s1-modal-box {
  max-width: 960px;
  position: relative;
}

.s1-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--s1-border);
}

.s1-modal-header h3 {
  font-family: var(--s1-font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--s1-primary);
}

.s1-modal-sub {
  font-size: 12px;
  color: var(--s1-text-muted);
  margin-top: 3px;
}

.s1-modal-close {
  position: static;
  background: #F1F5F9;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--s1-text-muted);
  flex-shrink: 0;
  transition: all 150ms ease;
}

.s1-modal-close:hover {
  background: var(--s1-danger);
  color: #fff;
  opacity: 1;
}

/* ---- List modal table ---- */
.s1-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.s1-list-table th {
  text-align: left;
  padding: 9px 12px;
  font-weight: 700;
  font-family: var(--s1-font-heading);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #F8FAFC;
  border-bottom: 2px solid var(--s1-border);
  color: var(--s1-primary);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.s1-list-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.s1-list-table tr:hover td { background: var(--s1-hover); }

.s1-list-table .s1-rate-cell {
  font-family: var(--s1-font-heading);
  font-weight: 700;
  font-size: 12px;
}

.s1-list-table .s1-name-cell {
  font-weight: 600;
  max-width: 200px;
}

.s1-list-table .s1-name-cell button {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--s1-accent);
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: var(--s1-font-body);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.s1-list-table .s1-name-cell button:hover { color: var(--s1-primary); }

.s1-mini-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.s1-mini-bar-track {
  flex: 1;
  height: 6px;
  background: #E2E8F0;
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.s1-mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
  min-width: 2px;
}

/* ---- NV modal table ---- */
.s1-nv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.s1-nv-table th {
  text-align: left;
  padding: 9px 10px;
  font-weight: 700;
  font-family: var(--s1-font-heading);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--s1-primary);
  color: #F1F5F9;
  border-bottom: 2px solid var(--s1-header);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.s1-nv-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: top;
}

.s1-nv-table tr:hover td { background: var(--s1-hover); }

.s1-nv-table .s1-stt-cell {
  font-family: var(--s1-font-heading);
  font-size: 11px;
  color: var(--s1-text-muted);
  text-align: center;
  width: 36px;
}

.s1-nv-table .s1-ten-cell {
  font-weight: 500;
  line-height: 1.4;
  max-width: 260px;
}

.s1-nv-table .s1-loai-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: #EFF6FF;
  color: var(--s1-accent);
  white-space: nowrap;
}

.s1-nv-table .s1-money-cell {
  font-family: var(--s1-font-heading);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  color: var(--s1-text-muted);
}

.s1-nv-table .s1-pct-cell {
  font-family: var(--s1-font-heading);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.s1-nv-table .s1-tinh-cell {
  font-size: 11px;
  color: var(--s1-text-muted);
  line-height: 1.4;
  max-width: 200px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet: ≤1100px */
@media (max-width: 1100px) {
  :root { --panel-w: 260px; }

  .s1-header-title h1 { font-size: 14px; }
  .s1-header-meta { display: none; }

  .s1-kpi-value { font-size: 13px; }
  .s1-kpi-pct   { font-size: 16px; }
  .s1-kpi-card  { padding: 10px 14px; }
}

/* Tablet vertical: ≤900px — map on top, panels below */
@media (max-width: 900px) {
  .s1-main {
    grid-template-columns: 1fr;
    grid-template-rows: 420px auto auto;
    height: auto;
    overflow: visible;
  }

  .s1-panel-left  { order: 2; border-right: none; border-bottom: 1px solid var(--s1-border); }
  .s1-panel-right { order: 3; border-left: none;  border-top:  1px solid var(--s1-border); }
  .s1-map-wrap    { order: 1; }

  .s1-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile: ≤600px */
@media (max-width: 600px) {
  .s1-header-inner { padding: 0 12px; gap: 10px; }
  .s1-header-logo  { display: none; }
  .s1-header-title h1 { font-size: 12px; letter-spacing: 0; }
  #header-subtitle { display: none; }

  .s1-kpi-row   { grid-template-columns: repeat(2, 1fr); }
  .s1-kpi-label { font-size: 9px; }
  .s1-kpi-value { font-size: 12px; }
  .s1-kpi-pct   { font-size: 14px; }
  .s1-kpi-icon  { width: 32px; height: 32px; }

  .s1-nav { flex-direction: column; height: auto; padding: 8px 12px; gap: 6px; align-items: flex-start; }
  .s1-legend { gap: 8px; }

  .s1-main { grid-template-rows: 360px auto auto; }
}
