/* ============================================================
   SondaFlow OS — Theme v2.1 "Stratigraphic Control"
   Additive layer loaded AFTER app.css. Re-skins the whole app by
   overriding design tokens, then refines core components.
   Personality: Space Grotesk (display) + Inter (UI) + IBM Plex Mono (data).
   Domain motif: stratigraphic log — petrol/aqua (water/aquifer) + ochre (earth).
   ============================================================ */

:root {
  /* Canvas & surfaces — cool, a touch warmer than clinical */
  --bg: #E9EDF1;
  --paper: #E9EDF1;
  --surface: #FFFFFF;
  --surface-2: #F0F3F6;

  /* Text */
  --ink: #0E2229;
  --graphite: #0E2229;
  --muted: #596B74;
  --line: #DCE3E9;
  --line-strong: #C7D2DA;

  /* Brand — petrol / aqua (water, aquifer) */
  --petrol: #0B6570;
  --petrol-700: #08464E;
  --petrol-900: #05343A;
  --petrol-050: #E1EFF0;
  --aqua: #14AEBB;
  --aqua-soft: #E1EFF0;

  /* Earth accent — ochre (strata) */
  --earth: #B5772A;
  --earth-050: #F6EDDC;

  /* Status */
  --success: #1B8F62;
  --success-bg: #E1F3EA;
  --warning: #B5772A;
  --warning-bg: #F6EDDC;
  --danger: #C9403F;
  --danger-bg: #F9E6E6;
  --info: #2C74B0;
  --info-bg: #E3EEF7;
  --neutral: #64757F;
  --neutral-bg: #EAEFF2;

  /* Sidebar — deep petrol */
  --sidebar-bg: #0C242C;
  --sidebar-ink: #B7C6CD;
  --sidebar-active-bg: rgba(20, 174, 187, .15);
  --sidebar-active-ink: #EAFBFD;

  /* Radius — slightly crisper */
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* Shadows — softer, layered, cool-tinted */
  --sh-1: 0 1px 2px rgba(14,34,41,.05), 0 1px 3px rgba(14,34,41,.06);
  --sh-2: 0 10px 30px -12px rgba(14,34,41,.22), 0 2px 6px rgba(14,34,41,.06);
  --sh-3: 0 24px 60px -20px rgba(5,52,58,.38);
  --focus-ring: 0 0 0 3px rgba(20,174,187,.30);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

body {
  background:
    radial-gradient(900px 480px at 100% -10%, rgba(20,174,187,.05), transparent 60%),
    var(--bg);
  letter-spacing: .002em;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, .kpi-value, .metric strong, .display {
  font-family: var(--font-display);
  letter-spacing: -.015em;
}
h1 { font-size: 27px; font-weight: 600; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15.5px; font-weight: 600; }

/* Monospace for the numeric / identifier surfaces of a drilling ERP */
.kpi-value, .metric strong,
td.num, th.num, .num,
.mono, code, kbd, samp, .depth, .ref-id {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ---------- App shell ---------- */
.app-shell { grid-template-columns: 256px 1fr; }

.sidebar {
  background:
    linear-gradient(180deg, #0E2E37 0%, var(--sidebar-bg) 46%, var(--petrol-900) 100%);
  padding: 22px 14px 16px;
  border-right: 1px solid rgba(255,255,255,.05);
  display: flex;
  flex-direction: column;
}
.sidebar > a:first-child { display: block; padding: 0 6px; margin-bottom: 20px; }
.sidebar img { width: 150px; margin-bottom: 0; }
.sidebar nav { gap: 1px; }
.sidebar a {
  color: var(--sidebar-ink);
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .003em;
  border-radius: var(--r-sm);
}
.sidebar a:hover { background: rgba(255,255,255,.06); color: #F3FBFC; }
.sidebar a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-ink); }
.sidebar a.active::before { top: 7px; bottom: 7px; width: 3px; background: var(--aqua); box-shadow: 0 0 10px rgba(20,174,187,.6); }
.sidebar .nav-section { color: rgba(183,198,205,.5); font-size: 10.5px; letter-spacing: .1em; }
/* Strata hairline foot: earth-tone depth ticks anchoring the rail */
.sidebar::after {
  content: "";
  margin: 16px 6px 0;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg,
    var(--earth) 0 18%, #8f6f43 18% 34%, var(--petrol) 34% 52%,
    var(--aqua) 52% 60%, #7d939c 60% 78%, #56626a 78% 100%);
  opacity: .5;
}

.topbar {
  padding: 12px 26px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  box-shadow: 0 1px 0 var(--line);
  border-bottom: 0;
}
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--petrol), var(--aqua) 60%, transparent);
}
.topbar-title strong { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }
.topbar-title .muted { font-size: 12.5px; }

.content { padding: 26px 26px 56px; }

/* ---------- Cards ---------- */
.card {
  border-radius: var(--r-lg);
  border-color: var(--line);
  box-shadow: var(--sh-1);
}
.card.is-interactive:hover, a.card:hover, .card[href]:hover {
  border-color: color-mix(in srgb, var(--aqua) 45%, var(--line));
  box-shadow: var(--sh-2);
}

/* ---------- KPI / metric cards ---------- */
.grid.cols-4 { gap: 14px; }
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 16px 16px;
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--aqua), var(--petrol));
  opacity: .85;
}
.kpi .kpi-label {
  color: var(--muted); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.kpi .kpi-value { font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.kpi .kpi-value small { font-family: var(--font-sans); font-size: 12px; font-weight: 500; }
.metric strong { font-size: 28px; font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { border-radius: var(--r-lg); box-shadow: var(--sh-1); }
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
}
th, td { padding: 10px 15px; }
td { font-size: 13.5px; }
tbody tr:nth-child(odd) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
tbody tr:hover td { background: color-mix(in srgb, var(--aqua) 8%, var(--surface)); }
tbody tr { transition: background var(--t-fast) ease; }

/* ---------- Buttons ---------- */
.button, .btn, button, input[type="submit"] {
  border-radius: var(--r-sm);
  font-weight: 600;
  letter-spacing: .005em;
  box-shadow: 0 1px 1px rgba(5,52,58,.12);
}
.button:not(.secondary):not(.warning):not(.danger),
.btn:not(.btn-secondary):not(.btn-ghost):not(.btn-warning):not(.btn-danger),
button[type="submit"], input[type="submit"] {
  background: linear-gradient(180deg, #0C6E79, var(--petrol));
  border-color: var(--petrol-700);
}
.button:not(.secondary):not(.warning):not(.danger):hover,
button[type="submit"]:hover, input[type="submit"]:hover {
  background: linear-gradient(180deg, var(--petrol), var(--petrol-700));
}
.button.secondary, .btn-secondary {
  background: var(--surface); color: var(--petrol-700);
  border-color: var(--line); box-shadow: var(--sh-1);
}
.button.secondary:hover, .btn-secondary:hover {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--petrol) 30%, var(--line));
}

/* ---------- Forms ---------- */
input, select, textarea { border-radius: var(--r-sm); background: var(--surface); }
input:focus, select:focus, textarea:focus { border-color: var(--aqua); }
label { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }

/* ---------- Status pills / badges ---------- */
.status, .badge {
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid transparent;
}
.status { background: var(--petrol-050); color: var(--petrol-700); border-color: color-mix(in srgb, var(--petrol) 18%, transparent); }
.badge-brand { background: var(--petrol-050); color: var(--petrol-700); }
.badge-success, .status.success { background: var(--success-bg); color: var(--success); }
.badge-warning, .status.warning { background: var(--warning-bg); color: var(--earth); }
.badge-danger,  .status.danger  { background: var(--danger-bg); color: var(--danger); }

/* ---------- Breadcrumbs / alerts ---------- */
.breadcrumbs { font-size: 12.5px; }
.breadcrumbs .sep { color: var(--line-strong); }
.alert { border-radius: var(--r); }

/* ============================================================
   Auth page — the signature: a stratigraphic log
   ============================================================ */
.auth-aside {
  background:
    linear-gradient(157deg, #0B2A32 0%, #0D5560 58%, #0A4148 100%);
  overflow: hidden;
}
.auth-aside::after {
  /* faint depth grid */
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(180deg, rgba(255,255,255,.045) 0 1px, transparent 1px 64px);
  pointer-events: none;
}
.auth-aside-inner { position: relative; z-index: 2; max-width: 440px; }
.auth-eyebrow {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--aqua); margin-bottom: 14px;
}
.auth-aside h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 3vw, 36px); line-height: 1.08; }
.auth-aside p { color: #C6E4E7; }
.auth-aside-list li { color: #DDEFF1; font-size: 13.5px; }
.auth-aside-list .badge { background: rgba(20,174,187,.16); color: #BFF3F7; border-color: rgba(20,174,187,.3); }

/* The strata column — pinned to the right edge, behind content */
.strata-log {
  position: absolute; top: 0; bottom: 0; right: 0; width: 118px;
  display: flex; flex-direction: column; z-index: 1;
  border-left: 1px solid rgba(255,255,255,.10);
  box-shadow: -30px 0 60px -20px rgba(0,0,0,.35);
}
.strata-band {
  position: relative; flex: var(--h, 1) 0 0;
  display: flex; align-items: flex-start; justify-content: flex-start;
  padding: 5px 0 0 10px;
  background: var(--c, #6b5a3e);
}
.strata-band::after {
  /* subtle grain between strata */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: rgba(0,0,0,.28);
}
.strata-band .depth {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em;
  color: rgba(255,255,255,.82); text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.strata-band.aquifer {
  background: linear-gradient(180deg, #12919d, var(--aqua));
  box-shadow: inset 0 0 24px rgba(255,255,255,.18);
}
.strata-band.aquifer .depth { color: #04353b; text-shadow: none; font-weight: 600; }
/* casing / borehole line */
.strata-log::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px;
  margin-left: -1px; z-index: 3;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.85) 0 8px, transparent 8px 14px);
  opacity: .5;
}
@media (max-width: 1100px) { .strata-log { display: none; } }

/* Auth card refinement */
.auth-card { border-radius: 16px; box-shadow: var(--sh-3); border-color: color-mix(in srgb, var(--line) 70%, transparent); padding: 32px 30px; }
.auth-logo { width: 158px; }
.auth-card h1 { font-family: var(--font-display); font-weight: 600; font-size: 23px; }
.auth-foot { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; }

/* ---------- A11y niceties ---------- */
a:focus-visible, button:focus-visible, .button:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus-ring);
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Responsive guards (mirror app.css so our later rules don't undo mobile) ---------- */
@media (max-width: 840px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
  .sidebar > a:first-child { margin-bottom: 0; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1 1 100%; }
  .sidebar::after { display: none; }
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 40px; }
}
@media (max-width: 560px) {
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 23px; }
}
