/* ============================================================
   AgriSentinel — global "agronomy paper" theme (light).
   Shared across every page. Page-specific extras live in
   dashboard.css. Class names are stable; JS depends on them.
   ============================================================ */
:root {
  --ink:#12241A;
  --paper:#F3F5EF;
  --panel:#FFFFFF;
  --panel-2:#EEF1E9;
  --line:#E3E8DD;
  --line-strong:#CBD4C2;
  --muted:#5F6B5E;
  --brand:#1F7A44;
  --brand-bright:#46B25B;
  --brand-dim:#186235;
  --amber:#D99A2B;
  --up:#12633a;
  --down:#9c3423;
  --red:#C24A38;
  --radius:14px;
  --shadow:0 1px 2px rgba(18,36,26,.04), 0 10px 28px -14px rgba(18,36,26,.18);
  --sidebar-w:56px;
}

* { box-sizing: border-box; }

body {
  margin:0;
  font-family:'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size:14px;
  line-height:1.45;
  color:var(--ink);
  -webkit-font-smoothing:antialiased;
  background:
    radial-gradient(1200px 520px at 100% -12%, rgba(70,178,91,.08), transparent 60%),
    radial-gradient(900px 480px at -10% 110%, rgba(31,122,68,.05), transparent 55%),
    var(--paper);
  background-attachment:fixed;
  min-height:100vh;
}

.mono { font-family:'IBM Plex Mono', monospace; font-variant-numeric:tabular-nums; }
.display { font-family:'Bricolage Grotesque','IBM Plex Sans',sans-serif; letter-spacing:-.01em; }

a { color:var(--brand); text-decoration:none; }
a:hover { color:var(--brand-dim); text-decoration:underline; }

/* ---------- left sidebar nav ---------- */
.nav {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:12px;
  width:var(--sidebar-w);
  padding:14px 0 16px;
  background:rgba(255,255,255,.82);
  backdrop-filter:saturate(1.1) blur(8px);
  border-right:1px solid var(--line);
  position:fixed;
  top:0;
  left:0;
  bottom:0;
  z-index:1000;
}
.nav .brand {
  display:flex;
  align-items:center;
  justify-content:center;
}
.nav .brand img {
  height:24px;
  width:auto;
  display:block;
}
.nav a {
  display:flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  border-radius:9px;
  color:var(--muted);
}
.nav a svg { width:17px; height:17px; }
.nav a.active, .nav a:hover { color:var(--ink); background:var(--panel-2); text-decoration:none; }
.nav .spacer { flex:1; }

.nav .account { position:relative; display:flex; }
.nav .account-btn {
  display:flex;
  align-items:center;
  justify-content:center;
  width:32px;
  height:32px;
  border-radius:50%;
  background:none;
  border:1px solid var(--line-strong);
  color:var(--muted);
  cursor:pointer;
  padding:0;
  margin:0;
}
.nav .account-btn svg { width:17px; height:17px; }
.nav .account-btn:hover, .nav .account-btn[aria-expanded="true"] { color:var(--ink); background:var(--panel-2); }

.nav .account-menu {
  position:absolute;
  left:44px;
  bottom:0;
  min-width:190px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:6px;
  display:none;
  flex-direction:column;
  gap:2px;
}
.nav .account-menu.open { display:flex; }
.nav .account-menu a {
  width:auto;
  height:auto;
  justify-content:flex-start;
  gap:10px;
  padding:9px 10px;
  border-radius:8px;
  color:var(--ink);
  font-size:13.5px;
  font-weight:500;
}
.nav .account-menu a svg { width:16px; height:16px; flex:none; }
.nav .account-menu a:hover { background:var(--panel-2); text-decoration:none; }

/* ---------- layout ---------- */
body.has-sidebar { padding-left:var(--sidebar-w); }
.container { max-width:1320px; margin:0 auto; padding:22px 24px 48px; }

h1 { font-family:'Bricolage Grotesque',sans-serif; font-weight:700; font-size:30px; letter-spacing:-.025em; margin:0 0 4px; }
h2 { font-family:'Bricolage Grotesque',sans-serif; font-weight:600; font-size:17px; letter-spacing:-.01em; margin:0 0 12px; }
.subtitle { color:var(--muted); margin:6px 0 20px; font-size:13.5px; }

/* ---------- cards ---------- */
.cards { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; margin-bottom:24px; }
.card {
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px 20px;
  box-shadow:var(--shadow);
}
.card h2 { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.1em; font-family:'Bricolage Grotesque',sans-serif; }
.card .row { display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid var(--line); }
.card .row:last-child { border-bottom:none; }
.card .row .name { font-weight:500; }
.card .row .val { font-family:'IBM Plex Mono',monospace; }

/* ---------- deltas ---------- */
.up { color:var(--up); }
.down { color:var(--down); }

/* ---------- table ---------- */
table {
  width:100%;
  border-collapse:collapse;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
th, td { text-align:left; padding:11px 15px; border-bottom:1px solid var(--line); }
th {
  color:var(--muted); font-weight:600; font-size:11px; letter-spacing:.08em;
  text-transform:uppercase; cursor:pointer; user-select:none;
  font-family:'Bricolage Grotesque',sans-serif;
}
th:hover { color:var(--ink); }
td { font-family:'IBM Plex Mono',monospace; }
td:first-child { font-family:'IBM Plex Sans',sans-serif; }
tr:last-child td { border-bottom:none; }
tbody tr { transition:background .12s; }
tbody tr:hover { background:#F7F9F4; }
.swatch { display:inline-block; width:12px; height:12px; border-radius:3px; margin-right:8px; vertical-align:middle; border:1px solid rgba(0,0,0,.06); }

/* ---------- forms ---------- */
.form {
  max-width:400px;
  margin:8vh auto;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:18px;
  padding:34px 32px 32px;
  box-shadow:var(--shadow);
  position:relative;
  overflow:hidden;
}
.form::before {
  content:"";
  position:absolute; left:0; right:0; top:0; height:4px;
  background:linear-gradient(90deg,var(--brand),var(--brand-bright),var(--amber));
}
.form h1 { text-align:center; margin-bottom:20px; }
.form h1 img { height:64px; width:auto; }

label { display:block; margin:14px 0 5px; color:var(--muted); font-size:11px; letter-spacing:.06em; text-transform:uppercase; font-weight:500; }
input, select {
  width:100%;
  padding:10px 12px;
  background:var(--panel);
  border:1px solid var(--line-strong);
  border-radius:9px;
  color:var(--ink);
  font-size:14px;
  font-family:'IBM Plex Sans',sans-serif;
}
input::placeholder { color:#9aa79a; }
input:focus, select:focus { outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(31,122,68,.12); }

button {
  background:var(--brand);
  color:#fff;
  border:none;
  border-radius:999px;
  padding:11px 20px;
  font-size:14px;
  font-weight:600;
  font-family:'IBM Plex Sans',sans-serif;
  cursor:pointer;
  margin-top:16px;
  transition:background .15s, transform .05s;
}
button:hover { background:var(--brand-dim); }
button:active { transform:translateY(1px); }
button.secondary { background:var(--panel); color:var(--ink); border:1px solid var(--line-strong); }
button.secondary:hover { background:var(--panel-2); }
button.danger-btn { background:var(--red); }
button.danger-btn:hover { background:#a13a2a; }
button:disabled { opacity:.5; cursor:not-allowed; }

/* ---------- toolbar ---------- */
.toolbar { display:flex; gap:14px; align-items:flex-end; flex-wrap:wrap; margin-bottom:20px; }
.toolbar > div { display:flex; flex-direction:column; }
.toolbar label { margin:0 0 5px; }
.toolbar select, .toolbar input {
  width:auto; min-width:170px;
  background:var(--panel);
  border-radius:999px;
  padding:9px 15px;
  box-shadow:var(--shadow);
  border:1px solid var(--line);
}
.toolbar input[type="file"] { padding:8px 12px; border-radius:10px; box-shadow:none; }

/* ---------- tabs ---------- */
.tabs { display:flex; gap:8px; margin-bottom:14px; }
.tab {
  padding:8px 14px; border:1px solid var(--line); border-radius:999px;
  cursor:pointer; color:var(--muted); background:var(--panel); font-size:13px;
  transition:border-color .15s, background .15s, color .15s;
}
.tab:hover { border-color:var(--line-strong); }
.tab.active { color:#fff; background:var(--ink); border-color:var(--ink); }

/* ---------- messages ---------- */
.msg { padding:11px 15px; border-radius:10px; margin:12px 0; font-size:13px; }
.msg.error { background:#F8E7E3; color:var(--down); border:1px solid #E3BDB4; }
.msg.ok { background:#E7F2E9; color:var(--up); border:1px solid #C2DDC7; }
.msg.info { background:#EAF1E5; color:#2f5d3a; border:1px solid #CBDDBF; }

/* ---------- maps ---------- */
.map {
  height:520px;
  border-radius:var(--radius);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  overflow:hidden;
  background:#e8ece6;
}
.map-sm { height:320px; }
.leaflet-container { font-family:'IBM Plex Sans',sans-serif; }

.legend { display:flex; align-items:center; gap:8px; margin-top:12px; font-size:12px; color:var(--muted); }
.legend .bar { display:flex; border-radius:4px; overflow:hidden; }
.legend .bar span { width:22px; height:12px; }

/* ---------- settings ---------- */
.settings-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.settings-card {
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:18px 20px;
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
}
.settings-card .top { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:22px; }
.settings-card .icon {
  width:36px; height:36px;
  display:flex; align-items:center; justify-content:center;
  color:var(--ink);
}
.settings-card .icon svg { width:22px; height:22px; }
.settings-card .name { font-weight:600; font-size:14.5px; margin-bottom:2px; }
.settings-card .val { color:var(--muted); font-size:13px; font-family:'IBM Plex Sans',sans-serif; }
.settings-card button.pill-outline {
  background:var(--panel);
  color:var(--ink);
  border:1px solid var(--line-strong);
  border-radius:999px;
  padding:7px 16px;
  font-size:13px;
  font-weight:600;
  margin-top:0;
}
.settings-card button.pill-outline:hover { background:var(--panel-2); }
.settings-card.danger .icon { color:var(--red); }
.settings-card.danger button.pill-outline { color:var(--red); border-color:#E3BDB4; }
.settings-card.danger button.pill-outline:hover { background:#F8E7E3; }

/* ---------- modal ---------- */
.modal-overlay {
  position:fixed; inset:0; z-index:2000;
  background:rgba(18,36,26,.35);
  display:flex; align-items:center; justify-content:center;
  padding:20px;
}
.modal-overlay.hidden { display:none; }
.modal {
  background:var(--panel);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:26px 26px 22px;
  width:100%;
  max-width:380px;
  position:relative;
}
.modal h2 { margin-bottom:16px; }
.modal .actions { display:flex; gap:10px; margin-top:18px; }
.modal .actions button { margin-top:0; flex:1; }
.modal label:first-of-type { margin-top:0; }

/* ---------- utils ---------- */
.muted { color:var(--muted); }
.hidden { display:none; }
.switch-auth { text-align:center; margin-top:18px; color:var(--muted); font-size:13px; }
