*{box-sizing:border-box}
:root{
  --bg:#0e1116; --panel:#171b22; --panel-2:#1f2530; --ink:#e8edf8; --muted:#93a1b3;
  --brand:#4ea9ff; --accent:#00d0a9; --warn:#ffb02e; --danger:#ff5f52; --good:#3ad29f;
  --border:#2d3544;
}
html,body{height:100%}
body{
  margin:0; font-family:Inter,system-ui,Arial,Helvetica,sans-serif; color:var(--ink);
  background: radial-gradient(1200px 800px at 70% -10%, #1d2430 0%, var(--bg) 60%);
}
a{color:inherit; text-decoration:none}
.hidden{display:none}

.app-header{
  height:60px; border-bottom:1px solid var(--border); display:flex; align-items:center;
  padding:0 16px; background:#0e1219; backdrop-filter: blur(6px);
  justify-content:space-between; gap:12px;
}
.brand{display:flex; align-items:center; gap:10px}
.logo-circle{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
  background:linear-gradient(135deg,var(--brand),var(--accent)); color:#00121b; font-weight:700}
.brand-text{display:flex; flex-direction:column; line-height:1.05}
.brand-text span{color:var(--muted); font-size:12px}
.header-nav{display:flex; gap:10px}
.nav-link{padding:8px 10px; border-radius:8px}
.nav-link:hover{background:rgba(255,255,255,.06)}
.header-actions{display:flex; gap:8px}

#view-home{padding:36px 16px}
.welcome{margin:48px auto 24px auto; text-align:center; max-width:900px}
.welcome-line{margin:0 0 8px 0; font-weight:800; letter-spacing:.4px; font-size:40px}
.welcome-sub{margin:10px 0 0 0; color:var(--muted); font-weight:500}
.fade-seq{opacity:0; animation:fadeInUp .9s ease forwards}
.fade-seq:nth-child(1){animation-delay:.2s}
.fade-seq:nth-child(2){animation-delay:.6s}
.fade-seq:nth-child(3){animation-delay:1.0s}
@keyframes fadeInUp {
  from {opacity:0; transform: translateY(12px)}
  to {opacity:1; transform: translateY(0)}
}

.center-tabs{display:flex; justify-content:center; gap:18px; margin:36px auto; flex-wrap:wrap}
.tab-card {
  position: relative;
  width: 280px;
  padding: 18px;
  border-radius: 16px;

  /* Dark anchor */
  background:
    linear-gradient(
      180deg,
      rgba(12, 18, 28, 0.70),
      rgba(12, 18, 28, 0.82)
    );

  backdrop-filter: blur(12px);

  border: 1px solid rgba(255,255,255,.08);

  box-shadow:
    0 20px 60px rgba(0,0,0,.45);

  transition:
    transform .18s ease,
    box-shadow .18s ease,
    border-color .18s ease;
}

/* Glass overlay — SAME as navbar */
.tab-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,255,255,.06);
  pointer-events: none;
}

.tab-card:hover{transform: translateY(-2px); border-color: var(--brand)}
.tab-title{font-size:18px; font-weight:700; margin-bottom:6px}
.tab-sub{color:var(--muted); font-size:13px}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: #0f141c;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between; /* 🔥 key */
  gap: 12px;
  padding: 12px;
  background: #0f141c;
  border-bottom: 1px solid var(--border);
}

/* LEFT SIDE */
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1; /* allows search to grow */
}

/* RIGHT SIDE */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search dominance */
.toolbar-left .search {
  flex: 1;
  min-width: 220px;
  max-width: 300px;
}

/* Button sizing (toolbar-safe) */
.toolbar-primary {
  width: auto;
  margin: 0;
  padding: 10px 18px;
  border-radius: 12px;
  white-space: nowrap;
}

.search {
  flex: 1 1 auto;          /* 🔥 grows as much as possible */
  min-width: 220px;        /* 🔥 prevents shrinking too much */
  max-width: 300px;        /* optional: keeps it elegant on ultra-wide */

  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
}
.toolbar .primary {
  width: auto;             /* 🔥 stop stretching */
  margin-top: 0;

  padding: 10px 18px;      /* compact & premium */
  min-width: 180px;        /* consistent button size */
  border-radius: 12px;
  white-space: nowrap;
}

.primary{
  padding:10px 14px; border:1px solid var(--border); border-radius:10px; background:var(--brand);
  color:#00121b; font-weight:700; cursor:pointer
}
.primary.small{padding:8px 12px; font-size:13px}
.primary:hover{filter:brightness(1.02)}
.icon-btn{padding:10px 12px; border:1px solid var(--border); border-radius:10px; background:#0e1219; color:var(--ink); cursor:pointer}
.icon-btn:hover{background:#121723}

.content-grid{display:grid; grid-template-columns: 280px 1fr; gap:12px; padding:12px; height: calc(100dvh - 120px)}
.sidebar{
  border:1px solid var(--border); border-radius:12px; background:var(--panel); overflow:auto;
}
.field-item{
  padding:12px; border-bottom:1px dashed var(--border); cursor:pointer; outline:none
}
.field-item:focus{background:var(--panel-2); outline:2px solid var(--brand)}
.field-item:hover{background:var(--panel-2)}
.field-title{font-weight:700}
.field-meta{color:var(--muted); font-size:12px; margin-top:4px}

.map-wrap, .twin-wrap{
  border:1px solid var(--border); border-radius:12px; background:var(--panel); position:relative;
  display:flex; flex-direction:column; overflow:hidden;
}
.map-header{
  padding:10px 12px; border-bottom:1px solid var(--border); font-weight:700; background:var(--panel-2)
}
.map-canvas{width:100%; height:100%; background: radial-gradient(600px 400px at 60% -20%, #1a2230 0%, #0d1219 60%)}
.map-info{position:absolute; bottom:10px; left:12px; font-size:12px; color:var(--muted); background:rgba(0,0,0,0.35); padding:6px 10px; border-radius:8px}
.muted{color:var(--muted)}
.small{font-size:12px}

.quickbar{display:flex; flex-wrap:wrap; gap:8px; padding:10px; border-bottom:1px solid var(--border); background:#0f141c}
.chip{display:inline-flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(--border); border-radius:999px; background:#0e1219 ; color: white;}
.chip.btn{cursor:pointer}
.chip.btn.warn{border-color:var(--warn)}

.twin-status{display:flex; gap:12px; padding:12px; border-bottom:1px solid var(--border); background:#0f141c; position:sticky; top:60px; z-index:2}
.twin-status .status-item{font-size:14px}
.diagram-wrap{padding:12px; background:var(--panel); position:relative}
.diagram-controls{position:absolute; right:16px; top:16px; display:flex; gap:6px}
.diagram-canvas{width:100%; height:420px; border:1px solid var(--border); border-radius:12px; background:linear-gradient(180deg,#0b1118,#0a0e14)}
.diagram-canvas .pipe{stroke:#6eaadf; stroke-width:8; fill:none}
.diagram-canvas .mix{stroke-dasharray:10 6; animation: dash 2s linear infinite}
@keyframes dash{to{stroke-dashoffset:-32}}
.diagram-canvas .flow{stroke-dasharray:18 10; animation: dash 1.2s linear infinite}
.diagram-canvas .device{cursor:pointer}
.diagram-canvas .device:hover{filter:brightness(1.1)}
.diagram-canvas .fault rect, .diagram-canvas .fault circle, .diagram-canvas .fault path{stroke: var(--danger) !important}
.diagram-canvas .label{fill:#c9d6e7; font-size:13px}
.diagram-canvas .mutel{fill:#8ea0b3; font-size:12px}
.valve{fill:url(#valveGrad); stroke:#4ea9ff; stroke-width:2}
.tank{fill:url(#tankGrad); stroke:#4ea9ff; stroke-width:2}
.small-tank{fill:url(#smallTankGrad); stroke:#4ea9ff; stroke-width:2}
.pump{fill:url(#pumpGrad); stroke:#4ea9ff; stroke-width:2}
.zone{stroke:#4ea9ff; stroke-width:6}
.zone-header{fill:#c9d6e7; font-size:12px}
.zone.inactive{opacity:.35}
.zone.active{stroke:#00d0a9}
.zone-dot{fill:#00d0a9}

.twin-panel{padding:16px; display:grid; gap:12px; grid-template-columns: repeat(auto-fit,minmax(260px,1fr));}
.metric{border:1px solid var(--border); border-radius:12px; padding:12px; background:var(--panel-2)}
.ai-card .ai-row{margin:4px 0}
.ai-actions{display:flex; gap:8px; margin-top:10px}
.metric-label{color:var(--muted); font-size:12px; margin-bottom:8px}
.metric-bar{width:100%; height:8px; background:#0b0e13; border:1px solid var(--border); border-radius:999px; overflow:hidden}
.metric-bar span{display:block; height:100%; background:linear-gradient(90deg,var(--good),var(--brand))}
.metric-value{margin-top:6px; font-weight:700}
.pill{display:inline-block; padding:6px 10px; border-radius:999px; background:#0b0e13; border:1px solid var(--border)}
.pill.neutral{background:#151924}
.pill.info{background:#102230; border-color:#21405a}

.tank-level{display:flex; align-items:center; gap:12px}
.tank-shell{width:80px; height:80px; border:1px solid var(--border); border-radius:10px; background:#0b0e13; overflow:hidden; position:relative}
.tank-liquid{position:absolute; bottom:0; left:0; width:100%; height:0%; background: repeating-linear-gradient(135deg, rgba(78,169,255,.55) 0 6px, rgba(0,208,169,.55) 6px 12px);
animation: wave 3s linear infinite; transition: height .6s ease}
@keyframes wave{from{background-position:0 0} to{background-position:120px 0}}

.spark{width:100%; height:40px}
.rules-wrap{padding:12px}
.rules-table{width:100%; border-collapse:collapse}
.rules-table th, .rules-table td{border:1px solid var(--border); padding:8px; text-align:left}

dialog::backdrop{background:rgba(0,0,0,0.5)}
.modal{min-width: min(820px, 92vw); background:var(--panel); border:1px solid var(--border); border-radius:14px; padding:16px}
.modal label{display:block; font-size:14px; margin:10px 0}
.modal input, .modal textarea, .modal select{width:100%; margin-top:6px; padding:10px; border-radius:10px; border:1px solid var(--border); background:#0e1219; color:var(--ink)}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:12px}
/* AUTH SCREENS */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    padding: 40px 20px;
}

.auth-card {
    background: #161b22;
    padding: 30px;
    width: 100%;
    max-width: 420px;
    border-radius: 12px;
    box-shadow: 0 0 25px rgba(0,0,0,0.4);
    animation: fadeIn 0.6s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 20px;
}

.auth-header .logo-circle {
    width: 60px;
    height: 60px;
    background: #1f6feb;
    color: #fff;
    border-radius: 50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size: 24px;
    margin: 0 auto 10px;
}

.auth-title {
    margin: 10px 0 20px;
    text-align: center;
    font-size: 20px;
    color: #e5e5e5;
}

.auth-field {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.auth-field label {
    color: #c9d1d9;
    font-size: 14px;
    margin-bottom: 5px;
}

.auth-field input,
.auth-field select,
.auth-field textarea {
    background: #0d1117;
    border: 1px solid #30363d;
    padding: 10px;
    border-radius: 6px;
    color: #fff;
}

.auth-btn {
  width: min(220px, 80%);
  margin: 14px auto 0;
  display: block;

  height: 44px;              /*⬆️ taller button */
  border-radius: 12px;       /* ⬆️ smoother corners */

  font-size: 15px;
  font-weight: 600;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: #8b949e;
}

.auth-footer a {
    color: #58a6ff;
    text-decoration: none;
    font-weight: 500;
}

.auth-alert {
    background: #ff4d4d;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    color: white;
}

.auth-error {
    color: #ff7b72;
    font-size: 13px;
}

@keyframes fadeIn {
    from {opacity: 0; transform: translateY(20px);}
    to {opacity: 1; transform: translateY(0);}
}
.aoi-container {
  max-width: 600px;
  margin: 40px auto;
  background: #161b22;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
}

.step-title {
  font-size: 24px;
  margin-bottom: 20px;
  color: #e5e5e5;
}

.aoi-form label {
  display: block;
  margin-bottom: 15px;
  color: #c9d1d9;
}

.aoi-form input {
  width: 100%;
  padding: 12px;
  background: #0d1117;
  border: 1px solid #30363d;
  color: white;
  border-radius: 6px;
  margin-top: 5px;
}

.primary {
  margin-top: 20px;
  width: 100%;
}
.aoi-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 24px;
  padding: 24px;
}

.aoi-sidebar {
  background: #0d1117;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #21262d;
}

.aoi-sidebar-title {
  font-size: 20px;
  margin-bottom: 10px;
}

.aoi-sidebar-card {
  margin-top: 16px;
  padding: 12px;
  border-radius: 10px;
  background: #161b22;
  border: 1px solid #21262d;
}

.aoi-sidebar-card ul {
  margin: 0;
  padding-left: 18px;
}

.aoi-main {
  background: #0d1117;
  border-radius: 16px;
  padding: 20px 24px 24px;
  border: 1px solid #21262d;
}

.aoi-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.aoi-title {
  font-size: 24px;
  margin: 0;
}

.aoi-subtitle {
  margin: 4px 0 0;
  color: #8b949e;
}

.aoi-step-counter {
  font-size: 14px;
  color: #8b949e;
}

.aoi-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
}

.aoi-step {
  border-radius: 999px;
  padding: 6px 8px;
  border: 1px solid #30363d;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #8b949e;
}

.aoi-step-index {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #161b22;
  border: 1px solid #30363d;
  font-size: 10px;
}

.aoi-step.active {
  border-color: #58a6ff;
  color: #e6edf3;
}

.aoi-step.active .aoi-step-index {
  background: #58a6ff;
  border-color: #58a6ff;
  color: #0d1117;
}

.aoi-step.done {
  border-color: #238636;
}

.aoi-step.done .aoi-step-index {
  background: #238636;
  border-color: #238636;
}

.aoi-body {
  margin-top: 8px;
}

.aoi-form-card,
.aoi-map-card {
  background: #0d1117;
  border-radius: 12px;
  padding: 18px 20px;
  border: 1px solid #21262d;
}

.aoi-section-title {
  font-size: 18px;
  margin: 0 0 12px;
}

.aoi-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.aoi-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.aoi-field label {
  font-size: 13px;
  color: #c9d1d9;
}

.aoi-field input,
.aoi-field select,
.aoi-field textarea {
  width: 100%;
  padding: 10px 12px;
  background: #010409;
  border-radius: 6px;
  border: 1px solid #30363d;
  color: #e6edf3;
  font-size: 14px;
}

.aoi-field textarea {
  resize: vertical;
}

.aoi-form-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #30363d;
  color: #e6edf3;
  text-decoration: none;
  font-size: 14px;
}

.aoi-or-separator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 12px;
  font-size: 12px;
  color: #8b949e;
}

.aoi-or-separator::before,
.aoi-or-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #30363d;
}

.aoi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr);
  gap: 18px;
}

.aoi-map-placeholder {
  background: #010409;
  border-radius: 8px;
  border: 1px dashed #30363d;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aoi-summary-list {
  display: grid;
  gap: 10px;
}

.aoi-summary-list dt {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b949e;
}

.aoi-summary-list dd {
  margin: 0;
  font-size: 14px;
  color: #e6edf3;
}

/* Responsive */
@media (max-width: 900px) {
  .aoi-layout {
    grid-template-columns: 1fr;
  }
}
#aoiMap {
    height: 460px !important;
    width: 100%;
    background: #0e1117;
}

/* must exist for Leaflet */
#leafletMap {
  width: 100%;
  height: 100%;
  min-height: 600px; /* IMPORTANT */
  border-radius: 12px;
  overflow: hidden;
}

/* if your layout uses flex/grid, ensure parent can give height */
.map-wrap {
  min-height: 650px;
}

.map-canvas {
  min-height: 600px;
}
.content-grid { display: grid; grid-template-columns: 280px 1fr 320px; gap: 14px; }
.indices-panel { display:flex; flex-direction:column; gap:12px; }

.panel-card { background:#0f172a; border:1px solid #1f2937; border-radius:12px; padding:12px; }
.panel-title { font-weight:700; margin-bottom:8px; }
.idx-list { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.panel-meta { margin-top:10px; display:flex; flex-direction:column; gap:10px; font-size:14px; color:#cbd5e1; }
/* 🔽 Compact panel meta (height reduction only) */
.panel-meta {
  display: grid;                 /* switch from column stack */
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;                 /* tighter rows + columns */

  font-size: 13px;               /* slightly smaller */
  line-height: 1.15;             /* 🔥 height reduction */
  margin-top: 8px;
}

.panel-meta > div {
  white-space: nowrap;           /* prevents wrapping */
}

.legend-wrap { display:flex; flex-direction:column; gap:6px; font-size:13px; }
.legend-row { display:flex; align-items:center; gap:8px; }
.legend-color { width:22px; height:12px; border-radius:3px; border:1px solid rgba(255,255,255,.2); }
.legend-label { flex:1; color:#e2e8f0; }

.loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:10px;
  z-index: 999;
}
.loading.hidden { display:none; }
.spinner {
  width:36px; height:36px;
  border-radius:50%;
  border:4px solid rgba(255,255,255,.2);
  border-top-color: white;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.map-wrap { position: relative; } /* important so overlay sits over map */
  .leaflet-bar button {
  width: 30px;
  height: 30px;
  background: #111827;
  color: #e5e7eb;
  border: none;
  cursor: pointer;
}

.leaflet-bar button:hover {
  background: #1f2937;
}
/* ========== WEATHER FLOAT PANEL ========== */
.weather-float {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 640px;           /* more breathing room */
  max-width: calc(100vw - 40px);
  background: linear-gradient(180deg, #0f1724, #0b0f15);
  border: 1px solid #1f2a38;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  z-index: 600;
}

/* Header */
.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.weather-title {
  font-weight: 600;
}

/* Forecast button */
.forecast-btn {
  height: 28px;                 /* 🔒 LOCK HEIGHT */
  line-height: 28px;            /* vertical centering */
  padding: 0 14px;              /* horizontal only */

  background: linear-gradient(135deg,#3b82f6,#06b6d4);
  color: #fff;

  border: 1px solid transparent; /* 🔒 reserve border space */
  border-radius: 999px;

  font-size: 12px;
  font-weight: 500;

  cursor: pointer;

  box-sizing: border-box;

  transition:
    box-shadow .25s ease,
    filter .25s ease;           /* ❌ no size transitions */
}


.forecast-btn:hover {
  box-shadow: 0 0 14px rgba(59,130,246,0.7);
  filter: brightness(1.05);     /* visual feedback only */
}


/* Current weather grid */
.weather-current {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 13px;
}

/* Forecast container */
.weather-forecast {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1f2a38;
}
#weatherForecast {
  margin-top: 12px;
    width: 100%;
  height: 260px;
}

#weatherForecast canvas {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 6px;
}


.snow-alert {
  margin-top: 10px;
  font-size: 13px;
  color: #cfe8ff;
}
.weather-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* ========== AI FLOAT PANEL ========== */
.ai-float {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 320px;
  background: linear-gradient(180deg, #0f1724, #0b0f15);
  border: 1px solid #1f2a38;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.55);
  z-index: 650;
}

.ai-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-title {
  font-weight: 600;
}

.ai-body {
  margin-top: 6px;
}

.ai-metric {
  text-align: center;
  margin: 10px 0;
}

.ai-value {
  font-size: 34px;
  font-weight: 700;
  color: #38bdf8;
}

.ai-row {
  margin-top: 8px;
  font-size: 13px;
}

.ai-actions {
  margin-top: 12px;
  text-align: right;
}

.ai-actions .primary {
  padding: 6px 12px;
}
.dlg { border: 1px solid #1f2a38; border-radius: 14px; padding: 0; background:#0b0f15; color:#e6e6e6; width: min(760px, 92vw); }
.dlg-header { display:flex; align-items:center; justify-content:space-between; padding: 12px 14px; border-bottom:1px solid #1f2a38; }
.dlg-title { font-weight:700; }
.dlg-body { padding: 12px 14px; max-height: 55vh; overflow:auto; }
.dlg-actions { display:flex; gap:10px; justify-content:flex-end; padding: 12px 14px; border-top:1px solid #1f2a38; }
.gate-list { display:flex; flex-direction:column; gap:10px; margin-top:10px; }
.gate-row { border:1px solid #1f2a38; border-radius:12px; padding:10px 12px; background:#0f1724; display:flex; justify-content:space-between; gap:12px; }
.gate-left { display:flex; flex-direction:column; gap:4px; }
.gate-right { display:flex; align-items:center; gap:8px; }
.badge-miss { border:1px solid #ffb02e; background: rgba(255,176,46,.12); padding:2px 8px; border-radius:999px; font-size:12px; }
.badge-ok { border:1px solid #3ad29f; background: rgba(58,210,159,.12); padding:2px 8px; border-radius:999px; font-size:12px; }
.twin-3d-card{
  border:1px solid #1f2a38;
  background: linear-gradient(180deg, #0f1724, #0b0f15);
  border-radius:14px;
  padding:10px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  margin-top: 12px;
}

.twin-3d-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}

.twin-3d-host{
  position:relative;
  height:420px;
  min-height:420px;
  border-radius:12px;
  overflow:hidden;
  border:1px solid #1f2a38;
}



.twin-3d-fallback{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#e5e7eb;
  background:#0b0f15;
  padding:16px;
  text-align:center;
}

.hidden{ display:none !important; }

.diagram-wrap {
  position: relative;
  height: 420px;
  min-height: 420px;
  background: #0b0f15;
  border-radius: 14px;
  overflow: hidden;
}

/* Dedicated Three.js layer */
.twin-3d-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Canvas host fills the layer */
#twin3dHost {
  width: 100%;
  height: 100%;
}

/* SVG overlay */
.diagram-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none; /* 🔥 CRITICAL */
}

/* Controls */
.diagram-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
}
#view-digital {
  height: 100vh;
  overflow: hidden;
}
.twin-wrap {
  height: calc(100vh - 64px); /* subtract top toolbar height */
  overflow-y: auto;
  padding-bottom: 24px;
}
.diagram-canvas .device {
  pointer-events: auto;
}
.diagram-controls.svg-controls {
  top: 60px;
  right: 12px;
}

.diagram-controls.twin-controls {
  top: 12px;
  right: 12px;
}

/* ================= FLOATING POWERED BY ================= */
.powered-float {
  position: fixed;
  right: 20px;
  bottom: 16px;
  z-index: 900;

  display: flex;
  align-items: center;
  gap: 6px;

  padding: 8px 14px;
  border-radius: 999px;

  font-size: 12px;
  font-weight: 500;
  color: var(--muted);

  background: rgba(15, 23, 36, 0.85);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);

  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  pointer-events: none; /* doesn't block clicks */
}

.powered-float b {
  color: var(--ink);
  font-weight: 700;
}

/* Mobile safety */
@media (max-width: 640px) {
  .powered-float {
    right: 12px;
    bottom: 12px;
    font-size: 11px;
    padding: 6px 12px;
  }
}
body {
  background:
linear-gradient(
  rgba(10, 14, 22, 0.55),
  rgba(10, 14, 22, 0.72)
)
,
    url("/static/img/background.jpg");
    
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;

  color: var(--ink);
}
.welcome-line {
  text-shadow:
    0 2px 8px rgba(0,0,0,.45),
    0 1px 2px rgba(0,0,0,.35);
}

.welcome-sub {
  text-shadow:
    0 1px 6px rgba(0,0,0,.40);
}
/* ================= AUTH PAGE BACKGROUND ================= */
body.auth-page {
  background:
linear-gradient(
  rgba(10, 14, 22, 0.55),
  rgba(10, 14, 22, 0.72)
),
    url("/static/img/background.jpg");

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
/* ================= USER MENU ================= */
.user-menu {
  position: relative;
}

/* ================= USER CHIP (HEADER) ================= */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.08);

 background:#0e1219;
  backdrop-filter: blur(10px);

  color: #ffffff; /* 🔥 name is WHITE */
  cursor: pointer;
}

.user-chip:hover {
  background: rgba(255,255,255,.08);
}


.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #00121b;
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff; /* 🔥 force white */
}

.caret {
  font-size: 11px;
  opacity: 0.6;
}


/* Dropdown */
/* .user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;


  backdrop-filter: blur(12px);

  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  z-index: 1000;
} */
.app-header {
  overflow: visible; /* 🔥 REQUIRED */
  position: relative;
  z-index: 500;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background:
    linear-gradient(
      180deg,
      rgba(12, 18, 28, 0.88),
      rgba(12, 18, 28, 0.96)
    );

  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  z-index: 9999; /* 🔥 HIGH, deliberate */

  isolation: isolate; /* 🔥 breaks parent stacking */
}

.user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.user-dropdown-name {
  font-weight: 700;
}

.user-dropdown-meta {
  font-size: 12px;
  color: var(--muted);
}

.user-dropdown-item {
  margin: 6px 10px;
  padding: 10px 14px;
width: 90%;
  display: flex;
  align-items: center;
  gap: 10px;

  font-size: 13px;
  font-weight: 500;

  color: #e5e7eb;
  background: rgba(255,255,255,.04);

  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.06);

  cursor: pointer;
  text-decoration: none;

  transition:
    background .15s ease,
    transform .12s ease,
    box-shadow .12s ease;
}

.user-dropdown-item:hover {
  background: rgba(255,255,255,.10);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

.user-dropdown-item:hover {
  background: rgba(255,255,255,.06);
}

.user-dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 6px 0;
}

.user-dropdown-item.danger {
  color: #ff7b72;
  border-color: rgba(255,123,114,.25);
}

.user-dropdown-item.danger:hover {
  background: rgba(255,95,82,.18);
}
.dlgs { border: 1px solid #1f2a38; border-radius: 14px; padding: 0; background:#0b0f15; color:#e6e6e6;  width: min(420px, 90vw); }

.dlg-body {
  display: flex;
  flex-direction: column;
  gap: 12px; /* clean vertical spacing */
}

/* Each label becomes a vertical block */
.dlg-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;

  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
}

/* Inputs full-width and compact */
.dlg-body input {
  width: 100%;
  padding: 10px 12px;

  border-radius: 10px;
  border: 1px solid #1f2a38;
  background: #0e1219;
  color: #e5e7eb;

  font-size: 14px;
}

/* Input focus polish */
.dlg-body input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(78,169,255,.15);
}
.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
/* Profile dialog action button (view mode) */
.dlg-actions .primary.small {
  width: auto;                 /* 🔥 stop full width */
  min-width: 140px;            /* consistent size */
  padding: 8px 18px;           /* slimmer */
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
/* Edit profile action buttons */
.dlg-actions button {
  width: auto;
  min-width: 110px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
}

/* Primary Save button emphasis */
.dlg-actions .primary.small {
  min-width: 120px;
}

/* Cancel button polish */
.dlg-actions .icon-btn {
  padding: 8px 14px;
  font-size: 13px;
}
.dlg-actions {
  justify-content: center;
}
/* ===== SIDEBAR ===== */
.sidebar {
  background: #0b1220;
  overflow-y: auto;
}

/* ===== AOI CARD ===== */
.aoi-item {
  border-bottom: 1px solid #1f2937;
}

.aoi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
}

.aoi-header:hover {
  background: #0f172a;
}

.aoi-title {
  font-size: 14px;
  font-weight: 600;
  color: #e5e7eb;
}

.aoi-sub {
  font-size: 12px;
  color: #9ca3af;
}

/* Toggle arrow */
.aoi-toggle {
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  position: relative;
}

.aoi-toggle::before {
  content: "";
  border: solid #9ca3af;
  border-width: 0 2px 2px 0;
  display: inline-block;
  padding: 3px;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.aoi-item.open .aoi-toggle::before {
  transform: rotate(135deg);
}

/* ===== FIELDS ===== */
.aoi-fields {
  background: #0b1220;
  padding-left: 16px;
}

.field-row {
  padding: 8px 14px;
  border-left: 2px solid transparent;
  cursor: pointer;
}

.field-row:hover {
  background: #0f172a;
  border-left-color: #4ea9ff;
}

.field-name {
  font-size: 13px;
  color: #e5e7eb;
}

.field-meta {
  font-size: 11px;
  color: #9ca3af;
}

/* Active states */
.aoi-item.active > .aoi-header {
  background: rgba(78,169,255,0.12);
}

.field-row.active {
  background: rgba(78,169,255,0.15);
  border-left-color: #4ea9ff;
}
.boundary-mode-switch {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.mode-btn {
  padding: 6px 14px;
  border-radius: 999px;
  background: #1f2937;
  color: #9ca3af;
  border: 1px solid #374151;
  cursor: pointer;
}

.mode-btn.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}
.tooltip-wrap {
  position: relative;
  display: inline-block;
}

.tooltip-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.tooltip-wrap:hover::after {
  opacity: 1;
}
.gate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 10px;
  background: linear-gradient(180deg,#0f1724,#0b0f15);
  border: 1px solid #1f2937;
  margin-bottom: 10px;
}

.gate-row.ok {
  border-left: 3px solid #22c55e;
}

.gate-row.missing {
  border-left: 3px solid #f59e0b;
}

.gate-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: #020617;
  border: 1px solid #1f2937;
  cursor: pointer;
}

.gate-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-placeholder {
  width: 100%;
  height: 100%;
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #94a3b8;
}


.history-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.weather-forecast {
  overflow: hidden;
}
.history-chart-wrap {
  height: 260px;
  overflow-x: auto;
  overflow-y: hidden;
}

/* Force wider canvas so data breathes */
#weatherHistoryChart {
  min-width: 520px;
}


/* ===== Satellite index history ===== */
.indices-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
/* ================================
   Satellite Index History Modal
   ================================ */

#idxHistoryDlg {
  position: fixed;
  inset: 0;
  margin: auto;
  max-width: 720px;
  max-height: 65vh;
  width: calc(100% - 24px);
  z-index: 1000;

  display: flex;
  flex-direction: column;
  background: #0b0f14;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}

/* Header + footer remain auto-sized */
#idxHistoryDlg .modal-header,
#idxHistoryDlg .modal-footer {
  flex-shrink: 0;
}

/* Body takes remaining space */
#idxHistoryDlg .modal-body {
  flex: 1;
  overflow: hidden;
  padding: 12px 14px 16px;
}

/* ================================
   Chart container
   ================================ */

.history-chart-wrap {
  position: relative;
  height: 380px;   /* was 300px → +50px */
  margin-top: 12px;
}

/* Canvas must fully fill wrapper */
.history-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}
#idxHistLoad {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  width: 100px;
}


/* Inline controls row */
.idx-history-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

/* Labels */
.idx-history-controls label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #cbd5e1;
}

/* Date inputs */
.idx-history-controls input[type="date"] {
  height: 34px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #1f2a38;
  background: #0f1724;
  color: #e5e7eb;
}

/* Blue Load button */
.idx-load-btn {
  height: 34px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  margin-top: 25px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: #ffffff;

  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.idx-load-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59,130,246,0.35);
}

.idx-load-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.idx-chart-loading {
  position: absolute;
  inset: 0;
  z-index: 5;

  display: flex;
  align-items: center;
  justify-content: center;

  text-align: center;
  font-size: 15px;
  font-weight: 500;
  color: #cbd5e1;

  background: rgba(11, 15, 20, 0.65);
  backdrop-filter: blur(2px);
}


.idx-chart-loading.hidden {
  display: none;
}
#idxHistoryChart {
  width: 100% !important;
}
.ai-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-history-btn {
  background: #f3f4f6;
  border: 1px solid #ddd;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.ai-history-btn:hover {
  background: #e5e7eb;
}
/* ===== AOI FORM ACTION BUTTONS ===== */
.aoi-form-actions .primary {
  width: auto;                 /* 🔥 stop full-width */
  min-width: 180px;            /* balanced CTA size */
  padding: 0 18px;         /* slimmer height */
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
}
/* ===== AOI ACTION BUTTONS — HEIGHT SYNC ===== */
.aoi-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;     /* 🔥 key line */
  gap: 10px;
}

.aoi-form-actions .primary,
.aoi-form-actions .btn-ghost {
  height: 40px;
  padding: 0 18px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
}
.aoi-form-actions .primary {
  margin-top: 0 !important; /* 🔥 KILL the global margin */
}
#saveBtn {
  width: auto;
  min-width: 180px;
  padding: 10px 20px;

  display: block;       /* 🔥 required */
  margin: 20px auto;    /* 🔥 centers horizontally */
}


/* ===============================
   DIGITAL TWIN — FORCE WHITE TEXT
   =============================== */

#view-digital,
#view-digital * {
  color: #e8edf8;
}

/* Fix primary button text */
#view-digital .primary {
  color: #ffffff; /* 🔥 override dark text */
}

/* Inputs & search */
#view-digital input,
#view-digital input::placeholder,
#view-digital select {
  color: #e8edf8;
}

/* Select dropdown background */
#view-digital select {
  background: #0e1219;
}

/* Options inside select (browser dependent) */
#view-digital select option {
  background: #0e1219;
  color: #e8edf8;
}

/* Chips & pills safety */
#view-digital .chip,
#view-digital .pill {
  color: #e8edf8;
}
.ai-tooltip-wrapper {
  position: relative;
}

.ai-tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: 260px;
  padding: 10px 12px;
  background: white;
  color: #000408;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.ai-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

/* ✅ THIS is the key fix */
.ai-tooltip-wrapper:hover .ai-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ai-action-btn {
  position: relative;
}

.ai-tooltip {
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 10px 12px;
  background: white;           /* slate-900 */
  color:black;                /* slate-50 */
  font-size: 13px;
  line-height: 1.4;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.ai-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}

/* Show on hover */
.ai-action-btn:hover + .ai-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}
/* IMPORTANT: don’t let toolbar clip the tooltip */
.toolbar,
.toolbar-right,
.header-actions {
  overflow: visible !important;
}

/* wrapper provides positioning context */
.ai-tooltip-wrapper{
  position: relative;
  display: inline-flex;
}

/* tooltip box (BELOW button) */
.ai-tooltip{
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);

  min-width: 240px;
  max-width: 320px;
  padding: 10px 12px;

  background: white;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;

  color: black;
  font-size: 12px;
  line-height: 1.35;

  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  z-index: 99999;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
}

/* show on hover + keyboard focus */
.ai-tooltip-wrapper:hover .ai-tooltip,
.ai-tooltip-wrapper:focus-within .ai-tooltip{
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* small arrow */
.ai-tooltip::before{
  content:"";
  position:absolute;
  top:-6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: rgba(17,17,17,0.96);
  border-left: 1px solid rgba(255,255,255,0.10);
  border-top: 1px solid rgba(255,255,255,0.10);
}
.field-row { position: relative; padding-right: 90px; }
.field-boundary-btn{
  position:absolute; right:10px; top:50%; transform:translateY(-50%);
  padding:6px 10px; border-radius:10px; border:1px solid #2d3544;
  background:#171b22; color:#e8edf8; cursor:pointer; font-size:12px;
}
.field-boundary-btn:hover{ border-color:#4ea9ff; }
.outer-aoi-row {
  margin-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 10px;
}
.outer-aoi-row .field-name {
  font-weight: 600;
}
/* Map HUD (bottom-left) */
.leaflet-control.map-index-hud{
  background: rgba(13, 18, 25, 0.88);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--ink);
  box-shadow: 0 12px 34px rgba(0,0,0,.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  line-height: 1.25;
  min-width: 280px;
}

.map-index-hud-row{
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: baseline;
}

.map-index-hud-item .k{
  color: var(--muted);
  margin-right: 6px;
}

.map-index-hud-item .v{
  font-weight: 800;
  color: var(--ink);
}

.map-index-hud-item .badge{
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(78,169,255,.16);
  border: 1px solid rgba(78,169,255,.35);
  font-weight: 900;
  letter-spacing: .2px;
}
/* ================= AI HEADER LAYOUT ================= */

.ai-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Top row: title + close */
.ai-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Bottom row: tabs + history */
.ai-header-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Tabs container */
.ai-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
}

/* Individual tab */
.ai-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s ease;
}

.ai-tab.active {
  background: linear-gradient(135deg,#3b82f6,#06b6d4);
  color: #fff;
  font-weight: 600;
}

/* History button — secondary action */
.ai-history-btn {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #e5e7eb;
  cursor: pointer;
}

.ai-history-btn:hover {
  background: rgba(255,255,255,.14);
}
.ai-biochem-btn {
  margin-top: 10px;
  width: 100%;
  background: linear-gradient(135deg, #1abc9c, #16a085);
  border: none;
  color: white;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.ai-biochem-btn:hover {
  opacity: 0.9;
}
body.crop-armed { cursor: crosshair; }
#detectCropBtn.armed { outline: 2px solid #22c55e; }
.hidden { display: none !important; }

/* Make the side-by-side slider visible on dark UI */
.leaflet-sbs-range {
  height: 28px;
}
.leaflet-sbs-divider {
  background: rgba(255,255,255,0.55);
}
.compare-slider {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  width: 320px;
  accent-color: #4ea9ff;
}

.compare-slider.hidden {
  display: none;
}
.compare-slider-wrap {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;

  display: flex;
  align-items: center;
  gap: 10px;

  padding: 6px 12px;
  border-radius: 14px;

  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}

.compare-label {
  font-size: 12px;
  color: #fff;
  opacity: 0.85;
  user-select: none;
}

.compare-label.left::before {
  content: "◀ ";
}

.compare-label.right::after {
  content: " ▶";
}

.compare-slider-wrap input[type="range"] {
  width: 260px;
  accent-color: #4ea9ff;
}
.problem-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}
/* ✅ FORCE problem points pane to be above EVERYTHING inside the map */
#leafletMap .leaflet-pane#problemPointsPane {
  z-index: 999999 !important;
}
.toggle-row { display:flex; align-items:center; gap:8px; }
.toggle-row.is-disabled { opacity:.55; }
.toggle { display:flex; align-items:center; gap:8px; cursor:pointer; user-select:none; }
.toggle input[disabled] + span { cursor:not-allowed; }
.loading-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: grid;
  place-items: center;
  z-index: 99999;
}

.loading-overlay.hidden{ display:none; }

.loading-card{
  width: min(420px, 92vw);
  background: #111827;
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.spinner{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,0.18);
  border-top-color: rgba(255,255,255,0.85);
  animation: spin 0.9s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin{ to { transform: rotate(360deg); } }

.loading-title{
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 4px;
}

.loading-sub{
  font-size: 13px;
  color: rgba(229,231,235,0.75);
  margin-bottom: 8px;
}

.loading-msg{
  font-size: 12px;
  color: rgba(229,231,235,0.85);
  min-height: 16px;
}
/* 1) Give every action-button in a dlg the same box model */
.dlg .dlg-actions button {
  /* sizing */
  padding: 8px 18px;
  min-width: 160px;
  height: 40px;

  /* shape & text */
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;

  /* border & cursor */
  border: 1px solid var(--border);
  cursor: pointer;

  /* force same box-sizing everywhere */
  box-sizing: border-box;
  background-clip: padding-box;
}

/* 2) Primary gets your brand fill */
.dlg .dlg-actions .primary {
  background: var(--brand);
  color: #00121b;
}

/* 3) Ghost is transparent (but still same size & weight) */
.dlg .dlg-actions .ghost {
  background: transparent;
  color: var(--ink);
}

/* 4) Hover states for both */
.dlg .dlg-actions .primary:hover {
  filter: brightness(1.05);
}
.dlg .dlg-actions .ghost:hover {
  background: rgba(255,255,255,0.06);
}
.btn-save  { background:#3b82f6; border-color:#3b82f6; }  /* Tailwind “blue-500” */
.btn-save:hover { background:#2563eb; border-color:#2563eb; }
/* AI dropdown wrapper */
.ai-menu { position: relative; display: inline-flex; align-items: center; }

/* make aiBtn look like a toggle */
.ai-menu-btn { display: inline-flex; gap: 8px; align-items: center; }
.ai-menu-btn.is-open { outline: 2px solid rgba(78,169,255,.45); }

/* dropdown */
.ai-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 260px;
  z-index: 2000;

  background: #0b0f15;
  border: 1px solid #1f2937;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
  padding: 10px;
}

.ai-menu-section { display: grid; gap: 8px; }
.ai-menu-title { font-size: 12px; opacity: .75; letter-spacing: .02em; }

.ai-menu-item {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: inherit;
  cursor: pointer;
}
.ai-menu-item:hover { background: rgba(78,169,255,.10); border-color: rgba(78,169,255,.25); }

.ai-menu-divider {
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 10px 0;
}

.ai-menu-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Disease row */
.ai-menu-switch { display: inline-flex; gap: 8px; align-items: center; }

/* Detect button inside dropdown */
.ai-menu-item-btn { width: 100%; justify-content: flex-start; }
/* keep your existing css, then add/merge these */

/* hide helper */
.hidden { display: none !important; }

/* unify dropdown buttons (includes compare + detect) */
.ai-menu-dropdown button,
.ai-menu-dropdown .chip.btn,
.ai-menu-dropdown .icon-btn {
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  color: inherit;
  cursor: pointer;
}

/* hover */
.ai-menu-dropdown button:hover,
.ai-menu-dropdown .chip.btn:hover,
.ai-menu-dropdown .icon-btn:hover {
  background: rgba(78,169,255,.10);
  border-color: rgba(78,169,255,.25);
}

/* compare row spacing */
.ai-menu-row { display: grid; gap: 8px; }
.ai-menu-row .chip.btn { width: 100%; }

/* switch row aligns nicely */
.ai-menu-switch { display: inline-flex; gap: 8px; align-items: center; }
.soil-avg-wrap      { position:relative; display:inline-block; margin-left:.5rem }
.dropdown-menu      { position:absolute; left:0; top:100%; background:#111; border:1px solid #555;
                      min-width:180px; z-index:3000; }
.dropdown-menu > div{ padding:.35rem .75rem; cursor:pointer; }
.dropdown-menu > div:hover{ background:#222 }
.hidden             { display:none }
.soil-avg-value     { margin-left:.55rem; font-weight:600 }
/* Optional: make both dropdown menus look consistent */
#soilCondMenu.dropdown-menu > div {
  cursor: pointer;
  padding: .45rem .75rem;
}
#soilCondMenu.dropdown-menu > div:hover {
  background: rgba(255,255,255,.08);
}

/* keep value display consistent */
.soil-avg-value {
  min-width: 90px;
  display: inline-block;
}
.hidden { display: none !important; }
.soil-era5-wrap { display:flex; flex-direction:column; gap:.4rem; }
.soil-era5-row { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; }
.soil-era5-select { width: 140px; }
.soil-era5-date { width: 155px; }
.soil-era5-badges { display:flex; gap:.5rem; align-items:center; }
#era5KindMenu.dropdown-menu > div { padding:.5rem .75rem; cursor:pointer; }
#era5KindMenu.dropdown-menu > div:hover { background: rgba(255,255,255,.08); }
.hidden { display:none !important; }

.soil-era5-busy { opacity: .75; }
/* Soil (Live) tool */
.soil-live-title{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.soil-live-actions{ display:flex; gap:8px; }

.soil-live-mode{
  display:flex;
  gap:8px;
  margin:10px 0 12px;
}

.soil-live-mode-btn{
  flex:1;
  border:1px solid #1f2937;
  background:#0b1220;
  color:#cbd5e1;
  padding:8px 10px;
  border-radius:10px;
  cursor:pointer;
  font-size:13px;
}

.soil-live-mode-btn.active{
  background:#111c33;
  border-color:#334155;
  color:#e8edf8;
}

.soil-live-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.soil-live-label{
  font-size:12px;
  color:#93a1b3;
  margin-bottom:6px;
}

.soil-live-field select{
  width:100%;
  padding:10px;
  border-radius:10px;
  border:1px solid #1f2937;
  background:#0e1219;
  color:#e8edf8;
}

.soil-live-output{
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid #1f2937;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.soil-live-value{
  display:flex;
  align-items:baseline;
  gap:8px;
  font-size:20px;
  color:#e8edf8;
}

.soil-live-unit{
  font-size:12px;
  color:#93a1b3;
}

.soil-live-meta{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
}

.soil-live-hint{
  margin-top:6px;
  font-size:12px;
}

.hidden{ display:none !important; }
.dot{ opacity:.6; }
/* Soil Live inline (compact) */
.soil-live-inline{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: nowrap;
  margin-left: .5rem;
}

.soil-live-btn{
  padding: .35rem .6rem;
  line-height: 1.1;
  font-size: .9rem;
  border-radius: .55rem;
}

.soil-live-icon{
  padding: .35rem .55rem;
  line-height: 1.1;
  border-radius: .55rem;
}

.soil-live-value{
  margin-left: .3rem;
  font-weight: 600;
  min-width: 78px;
  display: inline-block;
}

.soil-live-unit{
  margin-left: .15rem;
  opacity: .8;
  font-size: .85rem;
}

.soil-live-meta{
  margin-left: .35rem;
  opacity: .65;
  font-size: .8rem;
  white-space: nowrap;
}

/* make these dropdowns match your existing style */
#soilLiveVarMenu.dropdown-menu,
#soilLiveDepthMenu.dropdown-menu{
  min-width: 190px;
}
#soilLiveVarMenu.dropdown-menu > div,
#soilLiveDepthMenu.dropdown-menu > div{
  padding: .45rem .75rem;
  cursor: pointer;
}
#soilLiveVarMenu.dropdown-menu > div:hover,
#soilLiveDepthMenu.dropdown-menu > div:hover{
  background: rgba(255,255,255,.08);
}
/* Soil Live Combo (single dropdown) */
.soil-live-combo{
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.soil-live-combo-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  height: 34px;
  padding: 0 12px;

  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0e1219;
  color: var(--ink);

  cursor: pointer;

  /* stop “resize jump” */
  min-width: 210px;                 /* reserve space for label */
  box-sizing: border-box;
  white-space: nowrap;
}

.soil-live-combo-label{
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 176px;                 /* keeps caret aligned */
  font-size: 13px;
  line-height: 1;
}

.soil-live-combo-caret{
  opacity: .65;
  font-size: 12px;
  line-height: 1;
}

.soil-live-combo-toggle:hover{
  background: #121723;
}

.soil-live-combo-refresh{
  height: 34px;
  width: 34px;
  display: inline-grid;
  place-items: center;

  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0e1219;
  color: var(--ink);
  cursor: pointer;
}

.soil-live-combo-refresh:hover{
  background: #121723;
}

/* stable numeric output */
.soil-live-combo-value{
  min-width: 74px;                  /* prevents layout shift */
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.soil-live-combo-unit{
  min-width: 54px;
  opacity: .8;
  font-size: 12px;
  white-space: nowrap;
}

.soil-live-combo-meta{
  opacity: .65;
  font-size: 12px;
  white-space: nowrap;
}

/* dropdown */
.soil-live-combo-menu{
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 260px;

  background: linear-gradient(180deg, rgba(12,18,28,.92), rgba(12,18,28,.98));
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  backdrop-filter: blur(12px);
  padding: 10px;
  z-index: 9999;
}

.slc-section{ display:flex; flex-direction:column; gap:6px; }
.slc-title{
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 6px;
}

.slc-divider{
  height: 1px;
  background: rgba(255,255,255,.08);
  margin: 10px 0;
}

.slc-list{ display:flex; flex-direction:column; gap:6px; }

.slc-item{
  width: 100%;
  text-align: left;

  padding: 9px 10px;
  border-radius: 10px;

  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  color: #e5e7eb;

  cursor: pointer;
  font-size: 13px;
}

.slc-item:hover{
  background: rgba(255,255,255,.10);
}

.slc-item.active{
  border-color: rgba(78,169,255,.45);
  background: rgba(78,169,255,.14);
}

/* you already have .hidden, keep only ONE definition in your css */
.hidden{ display:none !important; }



html[dir="rtl"] .app-header,
html[dir="rtl"] .toolbar,
html[dir="rtl"] .header-actions,
html[dir="rtl"] .header-nav {
  direction: rtl;
}

html[dir="rtl"] .header-nav {
  flex-direction: row-reverse;
}

html[dir="rtl"] .header-actions {
  flex-direction: row-reverse;
}

html[dir="rtl"] .toolbar-left,
html[dir="rtl"] .toolbar-right {
  flex-direction: row-reverse;
}

html[dir="rtl"] .user-dropdown,
html[dir="rtl"] .ai-menu-dropdown,
html[dir="rtl"] .soil-live-combo-menu {
  text-align: right;
}
.ai-ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
html[dir="rtl"] .ai-results { text-align: right; }
/* =========================================================
   FIX GIS TOP TOOLBAR ON LAPTOP (NO HTML CHANGES)
   Paste THIS at the VERY END of styles.css
   ========================================================= */

:root{
  --tb-h: 40px;
  --tb-r: 12px;
  --tb-f: 13px;
}

/* ---------- toolbar layout ---------- */
#view-gis .toolbar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  background:#0f141c;
  border-bottom:1px solid var(--border);
  flex-wrap:nowrap;              /* desktop: single row */
  overflow:visible;
}

#view-gis .toolbar > *{ min-width:0; }

/* LEFT GROUP stays flexible */
#view-gis .toolbar-left{
  display:flex;
  align-items:center;
  gap:10px;
  flex: 1 1 auto;
  min-width: 0;
}

/* RIGHT GROUP sticks to the right */
#view-gis .toolbar-right{
  display:flex;
  align-items:center;
  gap:8px;
  margin-left:auto;
  flex: 0 0 auto;
  min-width: 0;
}

/* ---------- consistent heights for ALL controls in toolbar ---------- */
#view-gis .toolbar .search,
#view-gis .toolbar .primary,
#view-gis .toolbar .icon-btn,
#view-gis .toolbar .chip,
#view-gis .toolbar .soil-live-combo-toggle,
#view-gis .toolbar .soil-live-combo-refresh{
  height: var(--tb-h);
  box-sizing: border-box;
}

/* search input */
#view-gis .toolbar .search{
  flex: 1 1 260px;
  min-width: 180px;
  max-width: clamp(220px, 22vw, 340px);
  padding: 0 14px;
  border-radius: var(--tb-r);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font-size: var(--tb-f);
  line-height: calc(var(--tb-h) - 2px);
}
#view-gis .toolbar .search::placeholder{ color: var(--muted); }

/* primary buttons (Register / Segments) */
#view-gis .toolbar .primary{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  padding: 0 16px;
  border-radius: var(--tb-r);
  white-space: nowrap;
  font-size: var(--tb-f);
  line-height: 1;

  margin-top: 0 !important;      /* kill global .primary margin */
  width: auto !important;        /* stop any stretching */
  min-width: 170px;              /* equal length */
}

/* keep "Create Segments" same size as register */
#view-gis .toolbar #segmentFieldsBtn{ min-width: 170px; }

/* icon/text buttons (Weather / AI / Settings) */
#view-gis .toolbar .icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  padding: 0 14px;
  border-radius: var(--tb-r);
  font-size: var(--tb-f);
  line-height: 1;

  margin: 0;
  white-space: nowrap;
}

/* equal length for Weather + AI toggle */
#view-gis .toolbar #weatherBtn,
#view-gis .toolbar #aiMenuToggle{
  min-width: 165px;
}

/* settings is square icon-only */
#view-gis .toolbar #settingsBtnGIS{
  width: var(--tb-h);
  min-width: var(--tb-h);
  padding: 0;
}

/* ---------- Soil combo stays premium + aligned ---------- */
#view-gis .toolbar .soil-live-combo{
  display:inline-flex;
  align-items:center;
  gap:8px;
  flex: 0 0 auto;
  min-width: 0;
}

#view-gis .toolbar .soil-live-combo-toggle{
  display:inline-flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;

  padding: 0 12px;
  border-radius: var(--tb-r);
  min-width: 230px;
  font-size: var(--tb-f);
  line-height: 1;
  white-space: nowrap;
}

#view-gis .toolbar .soil-live-combo-label{
  max-width: 170px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

#view-gis .toolbar .soil-live-combo-refresh{
  width: var(--tb-h);
  min-width: var(--tb-h);
  padding: 0;
  border-radius: var(--tb-r);
}

/* ---------- Problem Points chips look like real buttons ---------- */
#view-gis .toolbar .chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  padding: 0 12px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: var(--tb-f);
  line-height: 1;
}

#view-gis .toolbar .chip input[type="checkbox"]{
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--brand);
}

#view-gis .toolbar .chip span{
  display:inline-flex;
  align-items:center;
  line-height: 1;
}

/* =========================================================
   LAPTOP FIX (1280–1440): WRAP CLEANLY INTO 2 ROWS
   ========================================================= */
@media (max-width: 1440px){
  #view-gis .toolbar{
    flex-wrap: wrap;              /* allow neat second row */
    row-gap: 10px;
    column-gap: 10px;
    align-items: center;
  }

  /* row 1: LEFT group takes full width */
  #view-gis .toolbar-left{
    flex: 1 1 100%;
  }

  /* row 2: Soil + Problem chips on left, Right group pushed to end */
  #view-gis .toolbar #soilLiveCombo{ order: 2; }
  #view-gis .toolbar > label.chip{ order: 3; }

  #view-gis .toolbar-right{
    order: 4;
    margin-left: auto;
  }

  /* on laptop, allow search to use full row */
  #view-gis .toolbar .search{
    max-width: none;
    flex: 1 1 520px;
  }
}

/* =========================================================
   SMALL LAPTOP (<= 1366): TIGHTER PADDING + SAFE WIDTHS
   ========================================================= */
@media (max-width: 1366px){
  :root{ --tb-h: 38px; --tb-f: 12.5px; }

  #view-gis .toolbar{ padding: 10px 10px; gap: 8px; }

  #view-gis .toolbar .primary{ min-width: 160px; padding: 0 12px; }
  #view-gis .toolbar #segmentFieldsBtn{ min-width: 160px; }

  #view-gis .toolbar #weatherBtn,
  #view-gis .toolbar #aiMenuToggle{ min-width: 150px; padding: 0 12px; }

  #view-gis .toolbar .soil-live-combo-toggle{ min-width: 210px; }
  #view-gis .toolbar .soil-live-combo-label{ max-width: 150px; }
}

/* keep dropdowns/tooltips visible */
#view-gis .toolbar,
#view-gis .toolbar-left,
#view-gis .toolbar-right{ overflow: visible !important; }
/* =========================================================
   REMOVE PAGE SCROLL ON LAPTOP (GIS)
   Put this at the VERY END of styles.css
   ========================================================= */

/* lock the app area under the header */
#app{
  height: calc(100vh - 60px);   /* app-header is 60px */
  overflow: hidden;            /* no body/page scroll */
}

/* views fill the app area */
.view{
  height: 100%;
  overflow: hidden;
}

/* GIS becomes a column layout: toolbar (auto) + grid (fills rest) */
#view-gis{
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;               /* CRITICAL for nested flex overflow */
  overflow: hidden;
}

/* toolbar takes only the space it needs */
#view-gis .toolbar{
  flex: 0 0 auto;
}

/* content grid fills remaining height (no fixed calc needed anymore) */
#view-gis .content-grid{
  flex: 1 1 auto;
  height: auto !important;     /* override any old calc heights */
  min-height: 0;               /* CRITICAL */
  overflow: hidden;            /* internal panes handle scrolling */
}

/* allow only panels to scroll (not the whole page) */
#view-gis .sidebar,
#view-gis .indices-panel{
  min-height: 0;
  overflow: auto;
}

/* map column must be allowed to shrink and let leaflet fill it */
#view-gis .map-wrap{
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* map header stays fixed inside map column */
#view-gis .map-header{
  flex: 0 0 auto;
}

/* leaflet container grows to fill remaining space */
#view-gis .map-canvas{
  flex: 1 1 auto;
  min-height: 0;
}

/* force leaflet to not create extra height that triggers page scroll */
#view-gis #leafletMap{
  height: 100% !important;
  min-height: 0 !important;
}

/* also keep the indices panel from expanding height unexpectedly */
#view-gis .indices-panel{
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* =========================================================
   OPTIONAL: if Digital Twin ever scrolls the whole page too
   (safe to keep)
   ========================================================= */
#view-digital{
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
#view-digital .toolbar{ flex: 0 0 auto; }
#view-digital .content-grid{
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#view-digital .sidebar{ min-height: 0; overflow: auto; }
#view-digital .twin-wrap{ min-height: 0; overflow: auto; }
/* ===============================
GIS TOOLBAR — HARD NORMALIZATION
=============================== */

#view-gis .toolbar {
align-items: center;
}

/* ONE height to rule them all */
#view-gis .toolbar * {
box-sizing: border-box;
}

/* All toolbar controls share the same height */
#view-gis .toolbar .search,
#view-gis .toolbar .primary,
#view-gis .toolbar .icon-btn,
#view-gis .toolbar .chip,
#view-gis .toolbar .soil-live-combo-toggle,
#view-gis .toolbar .soil-live-combo-refresh {
height: var(--tb-h);
line-height: var(--tb-h);
}

/* Normalize button internals */
#view-gis .toolbar .primary,
#view-gis .toolbar .icon-btn,
#view-gis .toolbar .chip {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0 14px;
font-size: var(--tb-f);
white-space: nowrap;
}

/* Fix CHIP (checkbox buttons) properly */
#view-gis .toolbar .chip {
gap: 8px;
cursor: pointer;
}

/* Kill checkbox intrinsic size */
#view-gis .toolbar .chip input[type="checkbox"] {
width: 16px;
height: 16px;
margin: 0;
flex: 0 0 auto;
}

/* Prevent checkbox pushing text */
#view-gis .toolbar .chip span {
line-height: 1;
display: inline-flex;
align-items: center;
}

/* Dropdown toggles must reserve width */
#view-gis .toolbar #weatherBtn,
#view-gis .toolbar #aiMenuToggle {
min-width: 165px;
}

/* Soil combo stays aligned */
#view-gis .toolbar .soil-live-combo {
align-items: center;
}

/* Settings button is square */
#view-gis .toolbar #settingsBtnGIS {
width: var(--tb-h);
min-width: var(--tb-h);
padding: 0;
}

/* Compact Weather button (text-sized, not action-sized) */
#view-gis #weatherBtn {
  min-width: auto !important;   /* 🔥 override toolbar equal-width rule */
  padding: 0 12px;              /* tighter horizontal padding */
  font-weight: 500;             /* lighter than primary */
}
/* Fallback label when soil combo text is not yet set */
#view-gis .soil-live-combo-label:empty::before {
  content: "Soil Moisture • 3–9 cm";
  opacity: 0.85;
}
/* Make Soil combo size itself to text */
#view-gis .soil-live-combo-toggle {
  min-width: unset !important;     /* 🔥 remove forced width */
  width: auto;
  padding: 0 12px;
  justify-content: center;
}

/* Label should size to content */
#view-gis .soil-live-combo-label {
  max-width: none;
  white-space: nowrap;
}

/* Caret stays tight */
#view-gis .soil-live-combo-caret {
  margin-left: 6px;
  opacity: .65;
}
/* Make Register AOI + Create Segments size to text */
#view-gis .toolbar a.toolbar-primary,
#view-gis .toolbar #segmentFieldsBtn {
  min-width: unset !important;   /* 🔥 remove forced equal width */
  width: auto;
  padding: 0 14px;               /* keep height, shrink width */
  white-space: nowrap;
}
/* Make legacy AI button size to text */
#view-gis #aiBtn {
  min-width: unset !important;
  width: auto;
  padding: 0 12px;
  white-space: nowrap;
}
/* Tighten Soil Live combo spacing (professional compact mode) */
#view-gis .soil-live-combo {
  gap: 6px;                 /* was ~8–10px */
}

/* Reduce inner padding of main selector */
#view-gis .soil-live-combo-toggle {
  padding: 0 10px;
}

/* Refresh button closer to selector */
#view-gis .soil-live-combo-refresh {
  margin-left: 2px;
}

/* Numeric output tighter */
#view-gis .soil-live-combo-value {
  min-width: 56px;          /* was ~74px */
  margin-left: 4px;
}

/* Unit + meta compact */
#view-gis .soil-live-combo-unit,
#view-gis .soil-live-combo-meta {
  margin-left: 2px;
}
/* Hide "Select AOI / Field" helper text in soil combo */
#view-gis .soil-live-combo-meta {
  display: none;
}
/* Fully collapse unused soil combo output slots */
#view-gis .soil-live-combo-value:empty,
#view-gis .soil-live-combo-unit:empty,
#view-gis .soil-live-combo-meta {
  display: none !important;
}
/* Remove Soil Live refresh button completely */
#view-gis #soilLiveComboRefresh {
  display: none !important;
}
.auth-links{
  margin-top: 10px;
  text-align: center;
}

.auth-link{
  color: #58a6ff;
  font-size: 13px;
  text-decoration: none;
}

.auth-link:hover{
  text-decoration: underline;
}
/* =========================================================
   PROFESSIONAL HEADER STYLES (Responsive)
   ========================================================= */

/* 1. Base Desktop Styles */
.app-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  
  /* Modern Glass Effect */
  background: rgba(14, 18, 25, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  
  /* Sticky Positioning */
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* Brand Section */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #00121b;
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 15px rgba(78, 169, 255, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  color: #e8edf8;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-text span {
  color: #93a1b3;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Navigation (Centered Pills) */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-link {
  padding: 8px 18px;
  color: #93a1b3;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* User Profile Chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px; /* Tighter padding on left for avatar */
  height: 40px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
}

.user-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.user-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

/* 2. TABLET RESPONSIVENESS (Max-width: 1024px) */
@media (max-width: 1024px) {
  .app-header {
    padding: 0 16px;
  }
  
  /* Reduce nav spacing */
  .nav-link {
    padding: 8px 12px;
  }
}

/* =========================================================
   3. MOBILE RESPONSIVENESS (Max-width: 768px)
   ========================================================= */
@media (max-width: 768px) {
  
  /* 1. Expand Header to allow 2 rows */
  .app-header {
    height: auto;       /* Let height grow */
    min-height: 56px;
    padding: 8px 12px;
    flex-wrap: wrap;    /* Allow items to wrap */
    gap: 12px;
  }

  /* 2. Top Row: Brand (Left) & User (Right) */
  .brand {
    flex: 1; /* Pushes User to the right */
  }
  
  .header-actions {
    flex: 0 0 auto;
  }

  /* 3. Bottom Row: Navigation Tabs */
  .header-nav {
    display: flex;      /* UN-HIDE IT */
    order: 3;           /* Force to bottom row */
    width: 100%;        /* Full width */
    
    /* Look & Feel */
    justify-content: space-evenly; /* Spread tabs evenly */
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 4px;
  }

  /* 4. Mobile Nav Links Polish */
  .nav-link {
    font-size: 12px;
    padding: 8px 0;
    flex: 1;            /* Make touch targets equal width */
    text-align: center;
    border-radius: 8px;
  }
  
  /* Active state visual (Optional polish) */
  .nav-link:active {
    background: rgba(255, 255, 255, 0.1);
  }

  /* Hide Slogan Text to save space */
  .brand-text span {
    display: none; 
  }
  
  /* Collapse User Profile to Avatar Only */
  .user-chip {
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.1);
    justify-content: center;
  }
  
  .user-name, 
  .user-chip .caret {
    display: none; 
  }
  
  .user-avatar {
    width: 32px;
    height: 32px;
  }
}


















:root{
  --header-h: 64px; /* your header is 64px in the new header CSS */
}

/* Default: Django pages must scroll normally */
#app{
  height: auto;
  overflow: visible;
}

/* Only lock the app shell for SPA routes served at "/" */
body.spa-root #app{
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

/* Only SPA "views" should be locked */
body.spa-root .view{
  height: 100%;
  overflow: hidden;
}

/* Hard safety: AOI pages must always scroll */
body.aoi-page #app{
  height: auto !important;
  overflow: visible !important;
}
