/* PaddyNet Admin: "Warm Sawah" by day, "Night Tech" in dark mode (same as the app) */
:root {
  --bg: #FBF6E9;
  --surface: #FFFDF7;
  --surface-2: #F3ECDA;
  --border: #E4DAC2;
  --text: #2A2118;
  --muted: #5E5244;
  --primary: #2F6B2F;
  --primary-text: #FFFFFF;
  --accent: #D9A520;
  --logo-mark: #2F6B2F;
  --danger: #B3261E;
  --warn-bg: #FFF3D6;
  --warn-text: #6B4A00;
  --grid: rgba(42, 33, 24, 0.10);
  /* Disease colours for charts (checked for colour-blind safety) */
  --c-blb: #2F5DA8;
  --c-blast: #C2412D;
  --c-brown: #C98A0E;
  --c-normal: #2F7D4F;
  --seq: #2F6B2F;       /* confusion matrix shading */
  --seq-ink: #FFFFFF;   /* text on dark cells */
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0A2624;
  --surface: #11403C;
  --surface-2: #0E3532;
  --border: #1E5650;
  --text: #EAF6F2;
  --muted: #A9C7C0;
  --primary: #9BE15D;
  --primary-text: #0A2624;
  --accent: #E5B84B;
  --logo-mark: #9BE15D;
  --danger: #FF8A80;
  --warn-bg: #3A3315;
  --warn-text: #F3DB9A;
  --grid: rgba(234, 246, 242, 0.10);
  --c-blb: #4697E4;
  --c-blast: #C74B47;
  --c-brown: #BB881A;
  --c-normal: #35AA76;
  --seq: #9BE15D;
  --seq-ink: #0A2624;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 800; }
h1 { font-size: 24px; }
h2 { font-size: 17px; margin-bottom: 12px; }
p { margin: 0 0 12px; }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-weight: 700; }
.warning { background: var(--warn-bg); color: var(--warn-text); padding: 10px 12px; border-radius: 8px; }
.banner { background: var(--surface); border: 1px solid var(--danger); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; }
.logo { width: 34px; height: 34px; }
.brand-lg .logo { width: 52px; height: 52px; }
.logo-mark { stroke: var(--logo-mark); }
.logo-grain { fill: var(--accent); }
.wordmark { font-weight: 800; font-size: 20px; letter-spacing: 0.2px; }
.wordmark b { color: var(--accent); font-weight: 800; }
.brand-lg .wordmark { font-size: 28px; }
.tag { font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }

/* Buttons and inputs */
.btn {
  font: inherit; font-weight: 700; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-ghost { background: transparent; text-align: left; }
.btn-small { padding: 3px 10px; font-size: 13px; }
.btn-danger { color: var(--danger); }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 14px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 20px; }
.login-card p { margin: 0; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: var(--text); text-decoration: none; font-weight: 700;
  padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; justify-content: space-between;
}
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a.active { background: var(--primary); color: var(--primary-text); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.badge { background: var(--c-blast); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 8px; }
.content { padding: 22px 28px 40px; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page { display: flex; flex-direction: column; gap: 16px; }

/* Cards and tiles */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.pad { padding: 14px 20px; margin: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; }
.tiles-3 .tile { background: var(--surface-2); border: none; }
.tile-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.tile-value { font-size: 30px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.tile-sub { font-size: 13px; color: var(--muted); }
.tile-alert .tile-value.has-alerts { color: var(--danger); }

/* Horizontal bars (results by disease) */
.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
.hbar-top .num { color: var(--muted); font-weight: 600; }
.hbar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* Lists and tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.list .sub { color: var(--muted); font-size: 13px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.card { overflow-x: auto; }
.empty { color: var(--muted); text-align: center; padding: 20px; margin: 0; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.inline-form input[type="number"] { width: 90px; }
.card-head .inline-form { margin: 0; }

/* Legend and charts */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; font-weight: 700; }
.legend-toggle label { flex-direction: row; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.chart-box { position: relative; height: 320px; }
#map { height: 520px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); font-weight: 700; font-size: 14px; }
.facts dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 0 10px; font-size: 13px; font-weight: 700; }
/* Confusion matrix */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg-btn { font: inherit; font-weight: 700; font-size: 13px; border: 0; background: var(--surface); color: var(--muted); padding: 6px 12px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--primary); color: var(--primary-text); }
.cm-grid { border-collapse: separate; border-spacing: 2px; font-size: 14px; margin: 4px 0 16px; }
.cm-grid th { font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 6px; }
.cm-grid th.row-head { text-align: right; white-space: nowrap; }
.cm-grid td { width: 64px; height: 44px; text-align: center; font-weight: 700; border-radius: 4px; font-variant-numeric: tabular-nums; }
.cm-grid td.diag { outline: 2px solid var(--accent); outline-offset: -2px; }
.cm-axis { font-size: 12px; color: var(--muted); font-weight: 700; }
.table tfoot td { font-weight: 800; border-top: 1px solid var(--border); border-bottom: none; }
.cm { width: 100%; max-width: 520px; border-radius: 8px; background: #fff; display: block; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 700;
}
.leaflet-popup-content { font-family: "Nunito", system-ui, sans-serif; font-size: 14px; }

/* Smaller screens */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 14px 16px; gap: 12px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 0; }
  .content { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #map { height: 400px; }
}
