/* Ongole Urban GeoAI - Department Technical Review Web GIS.
   Map-first layout; visual language mirrors the Guntur dashboard reference
   (light theme, Inter, soft shadows, rounded cards, 4-colour change palette). */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f0f2f8;
  --border: #e2e5ee;
  --text: #2d3348;
  --text2: #7c829c;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #7c3aed;
  --cyan: #0891b2;
  --pink: #db2777;
  --ink: #1b2130;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --topbar-h: 60px;
  --foot-h: 34px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  overflow: hidden;
}
h1, h2, h3, h4 { font-weight: 700; }

/* ===================== TOP BAR ===================== */
.topbar {
  height: var(--topbar-h);
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; gap: 12px; z-index: 50; position: relative;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand-text h1 span { color: #9cc4ff; font-weight: 500; }
.brand-sub { font-size: 11px; color: #aab3c5; letter-spacing: .2px; }
.draft-pill {
  background: #b91c1c; color: #fff; font-size: 11px; font-weight: 800;
  letter-spacing: 1.5px; padding: 3px 9px; border-radius: 5px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.legend-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: #e7ebf3;
  background: rgba(255,255,255,.08); padding: 3px 9px; border-radius: 20px;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip-btn {
  background: #2a62d6; color: #fff; border: 0; cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 7px;
}
.chip-btn:hover { background: #2451b0; }

/* ===================== STAGE (map + panel) ===================== */
.stage {
  display: flex; height: calc(100vh - var(--topbar-h) - var(--foot-h));
  position: relative;
}
#map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Floating map controls */
.map-ui { position: absolute; z-index: 20; }
.map-ui-left { top: 12px; left: 12px; width: 268px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100% - 24px); overflow-y: auto; }
.ctl-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-lg); }
.ctl-card h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--text2); }
.ctl-head { display: flex; align-items: baseline; justify-content: space-between; }
.ctl-sub { font-size: 9px; color: var(--amber); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.ctl-note { font-size: 10px; color: var(--text2); margin: 2px 0 7px; }
.ctl-note-foot { margin: 7px 0 0; padding-top: 6px; border-top: 1px dashed var(--border); font-style: italic; }

/* Basemap radios */
.basemap-list { display: flex; flex-direction: column; gap: 3px; }
.bm-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.bm-item:hover { background: var(--surface2); }
.bm-item input { accent-color: var(--blue); }
.bm-item .bm-label { flex: 1; }
.bm-tag { font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 2px 6px; border-radius: 10px; }
.bm-tag.intenant { background: #d1fae5; color: #065f46; }
.bm-tag.external { background: #e5e7eb; color: #4b5563; }

/* Layer groups */
.layer-groups { display: flex; flex-direction: column; gap: 9px; margin-top: 7px; }
.lgroup-title { font-size: 10px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.lyr-item { display: flex; align-items: center; gap: 7px; padding: 3px 4px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
.lyr-item:hover { background: var(--surface2); }
.lyr-item input { accent-color: var(--blue); }
.lyr-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.15); }
.lyr-name { flex: 1; }
.opacity-row { display: flex; align-items: center; gap: 7px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.opacity-row label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: .4px; }
.opacity-row input { flex: 1; accent-color: var(--blue); }

/* Legend (bottom-right) */
.map-ui-legend { bottom: 44px; right: 12px; width: 212px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; box-shadow: var(--shadow-lg); max-height: 46%; overflow-y: auto; }
.map-ui-legend h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); margin-bottom: 6px; }
.legend-body { display: flex; flex-direction: column; gap: 8px; }
.legend-empty { font-size: 11px; color: var(--text2); }
.legend-layer-title { font-size: 11px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.legend-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text); }
.legend-row .sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; border: 1px solid rgba(0,0,0,.12); }
.legend-img { max-width: 100%; }

/* Honesty strip + loading */
.map-ui-honest { bottom: 8px; left: 12px; background: rgba(27,33,48,.86); color: #fde68a; font-size: 10.5px; font-weight: 600; padding: 4px 10px; border-radius: 6px; max-width: 64%; }
.loading { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; font-size: 12px; padding: 7px 15px; border-radius: 20px; box-shadow: var(--shadow-lg); }
.loading.err { background: #b91c1c; }

/* ===================== DASHBOARD PANEL ===================== */
.panel-dock {
  width: 396px; min-width: 396px; background: var(--surface);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  box-shadow: -4px 0 16px rgba(0,0,0,.05); transition: margin-right .25s ease;
}
body.panel-hidden .panel-dock { margin-right: -400px; }
.panel-head { padding: 13px 15px 11px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.draft-tag { background: #fee2e2; color: #991b1b; font-size: 9px; font-weight: 800; letter-spacing: 1px; padding: 2px 6px; border-radius: 4px; }
.panel-sub { font-size: 11px; color: var(--text2); margin-top: 3px; }
.panel-x { background: var(--surface2); border: 1px solid var(--border); color: var(--text2); width: 28px; height: 28px; border-radius: 7px; font-size: 18px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.panel-x:hover { background: #e5e7eb; }
.panel-body { padding: 13px; overflow-y: auto; scrollbar-width: thin; }
.dpanel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 11px; box-shadow: var(--shadow); }
.dpanel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text2); margin-bottom: 8px; }
.dpanel-note { font-size: 10px; color: var(--text2); margin-top: 6px; }
.dpanel-foot { font-size: 10.5px; color: var(--text2); text-align: center; padding: 3px 0 2px; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 11px; cursor: pointer; transition: transform .1s; }
.kpi:hover { transform: translateY(-1px); border-color: #c7cde0; }
.kpi.active { outline: 2px solid var(--blue); outline-offset: -2px; }
.kpi .val { font-size: 21px; font-weight: 800; }
.kpi .lbl { font-size: 9.5px; color: var(--text2); text-transform: uppercase; letter-spacing: .3px; margin-top: 1px; }
.kpi.wide { grid-column: 1 / -1; }

/* ===================== POPUPS ===================== */
.maplibregl-popup-content { font-family: 'Inter', system-ui, sans-serif; border-radius: 10px; box-shadow: var(--shadow-lg); padding: 11px 13px; }
.pop-title { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.popup-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.popup-table td { padding: 2px 4px; vertical-align: top; }
.popup-table td:first-child { color: var(--text2); white-space: nowrap; padding-right: 10px; }
.popup-table td:last-child { color: var(--text); font-weight: 500; }
.pop-candidate { margin-top: 8px; font-size: 9.5px; color: #9a3412; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 5px; padding: 4px 6px; }

/* ===================== ACCESS GATE ===================== */
.gate { position: fixed; inset: 0; z-index: 2000; background: linear-gradient(135deg,#0b1220,#1b2740); display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
body.gate-done .gate { display: none; }
.gate-card { background: var(--surface); width: 100%; max-width: 720px; border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; margin: auto; }
.gate-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 12px; }
.gate-logo { height: 40px; }
.gate-head h1 { font-size: 18px; }
.gate-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.gate-banner { background: #fff7ed; color: #9a3412; border-top: 1px solid #fed7aa; border-bottom: 1px solid #fed7aa; font-size: 11.5px; font-weight: 600; padding: 9px 22px; }
.gate-terms { max-height: 230px; overflow-y: auto; padding: 14px 22px; font-size: 12px; color: #434a5e; border-bottom: 1px solid var(--border); }
.gate-terms h4 { font-size: 12.5px; color: var(--ink); margin: 11px 0 3px; }
.gate-terms p { margin: 5px 0; }
.gate-terms strong { color: var(--ink); }
.gate-form { padding: 15px 22px 20px; }
.gate-row { display: flex; gap: 12px; margin-bottom: 11px; }
.gate-row label { flex: 1; font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .4px; display: flex; flex-direction: column; gap: 4px; }
.gate-row input { font: inherit; font-size: 13px; color: var(--text); padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; text-transform: none; letter-spacing: 0; }
.gate-check { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--text); margin-bottom: 13px; }
.gate-check input { margin-top: 2px; accent-color: var(--blue); }
.gate-btn { width: 100%; background: #2a62d6; color: #fff; border: 0; font: inherit; font-size: 14px; font-weight: 700; padding: 11px; border-radius: 8px; cursor: pointer; }
.gate-btn:hover { background: #2451b0; }
.gate-btn:disabled { background: #a9b4c9; cursor: not-allowed; }
.gate-note { font-size: 10.5px; color: var(--text2); margin-top: 9px; }

/* ===================== FOOTER ===================== */
.appfoot { height: var(--foot-h); background: var(--ink); color: #aab3c5; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; font-size: 10.5px; }
.foot-left, .foot-right, .foot-mid { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.foot-left strong, .foot-right strong { color: #e7ebf3; }
.foot-logo { height: 18px; opacity: .9; }
.emblem-ph { border: 1px dashed #4b5563; border-radius: 5px; padding: 2px 8px; color: #9ca3af; font-style: italic; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 920px) {
  .stage { flex-direction: column; }
  .panel-dock { width: 100%; min-width: 100%; max-height: 46vh; border-left: 0; border-top: 1px solid var(--border); }
  body.panel-hidden .panel-dock { margin-right: 0; display: none; }
  .map-ui-left { width: 230px; }
  .appfoot { font-size: 9px; }
  .foot-mid { display: none; }
}
