/* Bản đồ kinh tế — giao diện tái thiết kế */

:root {
  --bg-deep: #070a0f;
  --bg: #0c1017;
  --surface: #121822;
  --surface-2: #181f2c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f4fa;
  --muted: #8b98ab;
  --accent: #22d3ee;
  --accent-dim: rgba(34, 211, 238, 0.15);
  --accent-2: #a78bfa;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  height: 100%;
  min-height: 0;
}

/* —— Sidebar —— */
.sidebar {
  width: 400px;
  min-width: 300px;
  max-width: 100%;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.sidebar-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, #0891b2 50%, var(--accent-2) 100%);
  box-shadow: 0 8px 24px rgba(34, 211, 238, 0.25);
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.hint {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--accent-dim);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: var(--radius-sm);
}

.hint-icon {
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.9;
}

.hint strong {
  color: var(--accent);
  font-weight: 600;
}

.data-note {
  margin-bottom: 14px;
  padding: 0;
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: var(--radius);
  background: rgba(34, 211, 238, 0.06);
  overflow: hidden;
}

.data-note summary {
  padding: 12px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}

.data-note summary::-webkit-details-marker {
  display: none;
}

.data-note summary::before {
  content: "▸ ";
  color: var(--accent);
}

.data-note[open] summary::before {
  content: "▾ ";
}

.demo-data-body {
  padding: 0 14px 14px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--muted);
}

.demo-data-body .demo-h {
  margin: 10px 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.demo-data-body .demo-h:first-child {
  margin-top: 0;
}

.demo-data-body ul {
  margin: 0 0 0 1rem;
  padding: 0;
}

.demo-data-body li {
  margin: 4px 0;
}

.muted {
  color: var(--muted);
}

.legend-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.legend-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 8px 0 6px;
  line-height: 1.45;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -4px;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
}

.block {
  margin-bottom: 12px;
}

.card {
  padding: 14px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card--flat {
  background: transparent;
  border-style: dashed;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.input,
select.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
select.input:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.toggle-row {
  padding: 12px 14px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  margin: 0;
  color: var(--text);
}

.inline-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.kpi {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.kpi-card {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}

.kpi-card span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-card strong {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.02em;
}

.chart-block .chart-tabs {
  margin-bottom: 10px;
}

.chart-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chart-tabs .tab {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chart-tabs .tab:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chart-tabs .tab.active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(167, 139, 250, 0.15));
  border-color: rgba(34, 211, 238, 0.35);
  color: var(--text);
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
}

.actions .btn-block {
  display: block;
  text-align: center;
  text-decoration: none;
}

.btn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px rgba(8, 145, 178, 0.35);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.legend {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 12px;
}

.legend .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
}

.legend .sw {
  width: 20px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* —— Map —— */
.map-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

.map-frame {
  flex: 1;
  position: relative;
  min-height: 0;
  margin: 12px 12px 12px 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

#map {
  height: 100%;
  width: 100%;
  min-height: 280px;
  background: #05070a;
}

.map-attrib {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 500;
}

/* —— Panel chi tiết thửa —— */
.panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: min(420px, calc(100% - 40px));
  max-height: calc(100% - 40px);
  overflow: auto;
  padding: 18px 18px 20px;
  border-radius: 16px;
  background: rgba(15, 20, 30, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  z-index: 1000;
}

.panel.hidden {
  display: none;
}

.panel-title {
  margin: 0 40px 8px 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.panel-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.panel-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.panel-section-title {
  margin: 18px 0 8px !important;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text) !important;
  font-size: 0.82rem !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.45;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.45;
}

.form-hint strong {
  color: var(--accent);
}

.table-wrap {
  max-height: 200px;
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.attr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.attr-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.attr-table td:first-child {
  width: 42%;
  color: var(--muted);
  white-space: nowrap;
}

.attr-table tr:last-child td {
  border-bottom: none;
}

.attr-table td:last-child {
  word-break: break-word;
  color: var(--text);
}

.ent-card {
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.ent-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.ent-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.ent-actions .btn {
  font-size: 0.78rem;
  padding: 6px 12px;
}

.ent-form .field-label {
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.form-actions .btn {
  flex: 1;
}

/* —— Loading —— */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 15, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  gap: 20px;
}

.loading.hidden {
  display: none;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.leaflet-container {
  font-family: inherit;
}

/* —— Responsive —— */
@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 46vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }

  .map-frame {
    margin: 0 0 12px 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .panel {
    top: auto;
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: 55vh;
  }
}
