/* =====================================================
   AGRISENSE — FULL RESPONSIVE DESIGN SYSTEM v8
   One file. No duplicates. No override wars.
   Dark default. Light via html[data-theme="light"].
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* =====================================================
   1. DESIGN TOKENS
   ===================================================== */
:root {
    /* Surfaces */
    --bg:        #080f0a;
    --bg2:       #050c07;
    --surface:   #0d1810;
    --surface2:  #131f16;
    --surface3:  #1a2a1d;
    --border:    rgba(61,220,104,0.13);
    --border2:   rgba(255,255,255,0.07);

    /* Text */
    --text:   #eaf5ec;
    --text2:  #9bbfa0;
    --muted:  #5a7a5e;

    /* Brand */
    --green:  #3ddc68;
    --green2: #28c255;
    --green3: #1a9940;
    --gdim:   rgba(61,220,104,0.12);
    --gglow:  rgba(61,220,104,0.22);

    --amber:  #f0a43a;
    --adim:   rgba(240,164,58,0.13);
    --red:    #f05050;
    --rdim:   rgba(240,80,80,0.12);

    /* Radii */
    --r-xl:   22px;
    --r-lg:   16px;
    --r-md:   12px;
    --r-sm:    8px;
    --r-xs:    5px;
    --r-pill: 999px;

    /* Motion */
    --ease:   cubic-bezier(.2,.9,.2,1);
    --spring: cubic-bezier(.34,1.56,.64,1);

    /* Shadow */
    --shadow-sm: 0 2px 8px  rgba(0,0,0,.40);
    --shadow:    0 8px 32px rgba(0,0,0,.50);
    --shadow-lg: 0 24px 80px rgba(0,0,0,.65);

    /* Layout */
    --sidebar-w:     72px;
    --sidebar-open: 268px;
    --topbar-h:      86px;

    /* Fonts */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Code", "Consolas", "Fira Code", monospace;
}

html[data-theme="light"] {
    --bg:       #f0f5f1;
    --bg2:      #e4ede6;
    --surface:  #ffffff;
    --surface2: #f0f5f1;
    --surface3: #e4ede6;
    --border:   rgba(22,120,46,0.15);
    --border2:  rgba(0,0,0,0.08);
    --text:     #0c1f10;
    --text2:    #2d5035;
    --muted:    #5a7a5e;
    --green:    #157a30;
    --green2:   #1a9940;
    --green3:   #15873a;
    --gdim:     rgba(22,120,46,0.10);
    --gglow:    rgba(22,120,46,0.20);
    --amber:    #b06d00;
    --adim:     rgba(176,109,0,0.10);
    --red:      #c0392b;
    --rdim:     rgba(192,57,43,0.10);
    --shadow-sm: 0 2px 8px  rgba(0,0,0,.07);
    --shadow:    0 8px 32px rgba(0,0,0,.10);
    --shadow-lg: 0 24px 80px rgba(0,0,0,.14);
}

/* =====================================================
   2. RESET
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background .22s ease, color .22s ease;
}
body::before {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 55% 40% at 10% 0%,   rgba(61,220,104,.06) 0%, transparent 60%),
        radial-gradient(ellipse 45% 35% at 90% 100%, rgba(240,164,58,.04) 0%, transparent 55%);
}
html[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 55% 40% at 10% 0%,   rgba(22,120,46,.05) 0%, transparent 60%),
        radial-gradient(ellipse 45% 35% at 90% 100%, rgba(176,109,0,.03) 0%, transparent 55%);
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { border: none; background: none; cursor: pointer; }
h1,h2,h3,h4,h5,h6 {
    font-family: var(--font);
    line-height: 1.1; letter-spacing: -.03em; color: var(--text);
}
h1 { font-size: clamp(28px,5vw,60px); font-weight: 800; }
h2 { font-size: clamp(20px,3vw,30px); font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
p  { color: var(--text2); }
.eyebrow {
    font-family: var(--mono); font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .14em; color: var(--muted);
    display: inline-block;
}

/* =====================================================
   3. LOADING BAR + SPINNER
   ===================================================== */
.spa-loading-bar {
    position: fixed; top: 0; left: 0; z-index: 99999;
    width: 0%; height: 3px; opacity: 0; pointer-events: none;
    border-radius: 0 2px 2px 0;
    background: linear-gradient(90deg, var(--green3), var(--green), var(--green2));
    box-shadow: 0 0 10px var(--gglow);
    transition: width .3s var(--ease), opacity .3s ease;
}
.spa-loading-bar.active { opacity: 1; }

#spa-loading-spinner {
    position: fixed; inset: 0; z-index: 99998;
    display: flex; align-items: center; justify-content: center;
    background: rgba(8,15,10,.50);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
}
html[data-theme="light"] #spa-loading-spinner { background: rgba(240,245,241,.55); }
#spa-loading-spinner.active { opacity: 1; pointer-events: auto; }
.spinner-ring {
    width: 40px; height: 40px; border-radius: 50%;
    border: 3px solid var(--border2); border-top-color: var(--green);
    animation: spin .7s linear infinite;
}

/* =====================================================
   4. BUTTONS — one clear layer, no stacking
   ===================================================== */

/* Primary — green gradient */
button[type="submit"],
.btn-primary,
.primary-action,
.nav-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 12px 24px;
    border-radius: var(--r-pill);
    font-family: var(--font); font-weight: 700; font-size: 14px;
    background: linear-gradient(135deg, var(--green2), var(--green3));
    color: #fff; border: none; cursor: pointer;
    box-shadow: 0 4px 16px var(--gglow);
    transition: transform .16s var(--spring), box-shadow .16s ease;
    white-space: nowrap; text-decoration: none; text-align: center;
}
button[type="submit"]:hover,
.btn-primary:hover,
.primary-action:hover,
.nav-button:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--gglow); }
button[type="submit"]:active,
.btn-primary:active { transform: translateY(0) scale(.98); }

/* Ghost */
.btn-ghost,
.secondary-action {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 12px 24px;
    border-radius: var(--r-pill);
    font-family: var(--font); font-weight: 700; font-size: 14px;
    background: transparent; color: var(--text2);
    border: 1.5px solid var(--border2); cursor: pointer;
    transition: transform .16s var(--spring), border-color .14s ease, color .14s ease;
    white-space: nowrap; text-decoration: none;
}
.btn-ghost:hover,
.secondary-action:hover { transform: translateY(-2px); border-color: var(--border); color: var(--text); }

/* Icon buttons — hard reset from green gradient */
.theme-toggle,
.mobile-menu-button,
.sidebar-pin,
.profile-button,
.password-toggle {
    background: var(--surface2);
    background-image: none;
    box-shadow: none;
    transform: none;
}
.theme-toggle,
.mobile-menu-button {
    display: grid; place-items: center;
    width: 42px; height: 42px; padding: 0;
    border-radius: var(--r-lg);
    color: var(--text2);
    border: 1px solid var(--border2); cursor: pointer; flex-shrink: 0;
    transition: color .14s ease, border-color .14s ease;
}
.theme-toggle:hover,
.mobile-menu-button:hover { color: var(--text); border-color: var(--border); }
.theme-toggle svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; }
.mobile-menu-button svg { width: 20px; height: 20px; fill: currentColor; }

.theme-icon-dark  { display: block; }
.theme-icon-light { display: none;  }
html[data-theme="light"] .theme-icon-dark  { display: none;  }
html[data-theme="light"] .theme-icon-light { display: block; }

.password-toggle {
    padding: 0 16px;
    border-radius: var(--r-md);
    background: var(--surface3);
    color: var(--text2);
    border: 1.5px solid var(--border2);
    font-size: 13px; font-weight: 600;
    white-space: nowrap; flex-shrink: 0; cursor: pointer;
    transition: border-color .14s ease, color .14s ease;
}
.password-toggle:hover { border-color: var(--border); color: var(--green); }

/* =====================================================
   5. FORMS
   ===================================================== */
label {
    display: block; margin: 16px 0 7px;
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
label:first-of-type { margin-top: 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
select, textarea {
    width: 100%; min-height: 46px;
    background: var(--surface2); color: var(--text);
    border: 1.5px solid var(--border2); border-radius: var(--r-md);
    padding: 12px 15px; font-size: 15px; font-family: var(--font);
    outline: none; -webkit-appearance: none; appearance: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--green2);
    box-shadow: 0 0 0 4px var(--gdim);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }

.password-field { display: flex; align-items: stretch; gap: 10px; }
.password-field input { flex: 1; min-width: 0; }
.password-field button,
.password-row button {
    flex: 0 0 auto;
}

/* =====================================================
   6. FLASH + BADGES
   ===================================================== */
.flash, .login-alert {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 12px 16px; border-radius: var(--r-md);
    margin-bottom: 16px; font-size: 14px; font-weight: 500; border: 1px solid;
}
.flash::before, .login-alert::before {
    content: ""; flex-shrink: 0; margin-top: 7px; font-size: 8px;
    width: 7px; height: 7px; border-radius: 999px; background: currentColor;
}
.flash, .flash.success  { background: var(--gdim); color: var(--green); border-color: var(--gglow); }
.flash.warning, .login-alert { background: var(--adim); color: var(--amber); border-color: rgba(240,164,58,.22); }
.flash.danger, .flash.error  { background: var(--rdim); color: var(--red);   border-color: rgba(240,80,80,.22); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: var(--r-pill);
    font-family: var(--mono); font-size: 11px; font-weight: 600; border: 1px solid;
}
.badge-green { background: var(--gdim); color: var(--green); border-color: var(--gglow); }
.badge-amber { background: var(--adim); color: var(--amber); border-color: rgba(240,164,58,.2); }
.badge-red   { background: var(--rdim); color: var(--red);   border-color: rgba(240,80,80,.2); }
.badge-dot, .status-pill-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: currentColor; display: block; flex-shrink: 0;
    animation: pulse-dot 2.4s ease infinite;
}

/* =====================================================
   7. APP SHELL — Desktop
   ===================================================== */
.app-body { overflow: hidden; height: 100vh; }
.app-root {
    display: flex; align-items: stretch;
    width: 100%; height: 100vh; overflow: hidden;
    position: relative; z-index: 1;
}

/* ── SIDEBAR ── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 300;
    display: flex; flex-direction: column;
    padding: 18px 10px;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 0%, var(--gdim), transparent 34%),
        linear-gradient(180deg, var(--surface), var(--surface2));
    border-right: 1px solid var(--border);
    transition: width .28s var(--ease), box-shadow .28s var(--ease);
    will-change: width;
}
html[data-theme="light"] .sidebar {
    background:
        radial-gradient(circle at 20% 0%, rgba(22,120,46,.07), transparent 34%),
        linear-gradient(180deg, #fff, #edf6ef);
}
.sidebar:hover,
body.sidebar-pinned .sidebar {
    width: var(--sidebar-open);
    box-shadow: 18px 0 60px rgba(0,0,0,.22);
}
html[data-theme="light"] .sidebar:hover,
html[data-theme="light"] body.sidebar-pinned .sidebar {
    box-shadow: 18px 0 40px rgba(0,0,0,.08);
}

/* Sidebar top / brand */
.sidebar-top {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 8px;
    padding: 0 0 16px; margin-bottom: 14px;
    border-bottom: 1px solid var(--border); overflow: hidden;
}
.sidebar-top > a.brand { flex: 1; min-width: 0; padding: 0; border: none; margin: 0; }

.sidebar-brand,
.sidebar > a.brand,
.sidebar .brand {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; overflow: hidden;
}
.sidebar-brand img,
.sidebar > a.brand img,
.sidebar .brand img {
    width: 44px; height: 44px; border-radius: var(--r-lg);
    flex-shrink: 0; object-fit: contain;
}
.sidebar-brand-text,
.sidebar .brand-text {
    opacity: 0; transform: translateX(-8px); overflow: hidden;
    transition: opacity .2s var(--ease), transform .2s var(--ease), max-width .2s var(--ease);
    max-width: 0; white-space: nowrap;
}
.sidebar:hover .sidebar-brand-text,
.sidebar:hover .brand-text,
body.sidebar-pinned .sidebar-brand-text,
body.sidebar-pinned .brand-text {
    opacity: 1; transform: translateX(0); max-width: 190px;
}
.sidebar-brand-text strong,
.sidebar .brand-text strong,
.sidebar .brand strong {
    display: block; font-size: 17px; font-weight: 800;
    letter-spacing: -.04em; color: var(--text); line-height: 1.1;
}
.sidebar-brand-text span,
.sidebar .brand-text span,
.sidebar .brand span {
    display: block; margin-top: 3px;
    font-family: var(--mono); font-size: 9px; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase; color: var(--green);
}

/* Sidebar pin button */
.sidebar-pin {
    display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 14px;
    background: var(--gdim); border: 1px solid var(--gglow);
    color: var(--green); cursor: pointer; flex-shrink: 0;
    transition: color .14s ease, border-color .14s ease;
}
.sidebar-pin svg { width: 18px; height: 18px; fill: currentColor; }
.sidebar-pin:hover { color: var(--text); }

/* Side nav */
.side-nav {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; gap: 8px;
    overflow-y: auto; overflow-x: hidden;
    padding: 2px 0 6px;
    scrollbar-width: thin; scrollbar-color: var(--green) transparent;
}
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--green); border-radius: 999px; }

.side-nav a,
a.logout-link {
    display: flex; align-items: center; gap: 12px;
    flex: 0 0 50px; height: 50px; min-height: 50px;
    padding: 0 10px; border-radius: var(--r-pill);
    color: var(--text2); font-weight: 700; font-size: 13.5px;
    text-decoration: none; border: 1px solid transparent;
    white-space: nowrap; overflow: hidden;
    transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s var(--spring);
}
.side-nav a:hover { color: var(--text); background: var(--surface2); border-color: var(--border2); transform: translateX(3px); }
.side-nav a.active { color: var(--green); background: var(--gdim); border-color: var(--gglow); }

a.logout-link { margin-top: auto; color: var(--red); }
a.logout-link:hover { background: var(--rdim); color: var(--red); border-color: rgba(240,80,80,.22); transform: translateX(3px); }

.nav-icon {
    display: grid; place-items: center;
    flex: 0 0 38px; width: 38px; height: 38px;
    border-radius: 14px; background: var(--surface3);
    transition: background .16s ease;
}
.nav-icon svg { width: 18px; height: 18px; fill: currentColor; }
.side-nav a.active .nav-icon,
.side-nav a:hover .nav-icon { background: var(--gdim); color: var(--green); }
a.logout-link .nav-icon { color: var(--red); }

.nav-label {
    opacity: 0; transform: translateX(-8px);
    overflow: hidden; max-width: 0; white-space: nowrap;
    transition: opacity .2s var(--ease), transform .2s var(--ease), max-width .2s var(--ease);
}
.sidebar:hover .nav-label,
body.sidebar-pinned .nav-label { opacity: 1; transform: translateX(0); max-width: 180px; }

/* ── MAIN SHELL ── */
.main-shell {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    height: 100vh; min-height: 100vh;
    display: flex; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    background:
        radial-gradient(circle at 8% 0%, var(--gdim), transparent 32%),
        radial-gradient(circle at 100% 100%, var(--adim), transparent 30%),
        var(--bg);
    transition: margin-left .28s var(--ease), width .28s var(--ease);
    scrollbar-width: thin; scrollbar-color: var(--green) transparent;
    position: relative; z-index: 1;
}
.main-shell::-webkit-scrollbar { width: 7px; }
.main-shell::-webkit-scrollbar-thumb { background: var(--green); border-radius: 999px; }

.sidebar:hover ~ .main-shell,
.sidebar:hover + .main-shell,
body.sidebar-pinned .main-shell {
    margin-left: var(--sidebar-open);
    width: calc(100% - var(--sidebar-open));
}

/* ── TOPBAR ── */
.topbar {
    position: sticky; top: 0; z-index: 200;
    flex: 0 0 var(--topbar-h);
    width: 100%; height: var(--topbar-h);
    padding: 0 36px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: rgba(8,15,10,.90);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border-bottom: 1px solid var(--border);
    transition: background .22s ease;
}
html[data-theme="light"] .topbar { background: rgba(245,250,246,.93); }

.topbar-title { min-width: 0; flex: 1; }
.topbar-title .eyebrow { margin-bottom: 1px; }
.topbar-title h1 {
    font-size: 22px; font-weight: 800; letter-spacing: -.04em; line-height: 1.1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }

.status-pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: var(--r-pill);
    background: var(--gdim); color: var(--green); border: 1px solid var(--gglow);
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    letter-spacing: .05em; white-space: nowrap;
}
.status-pill > span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green); display: block; flex-shrink: 0;
    box-shadow: 0 0 6px var(--green); animation: pulse-dot 2.5s ease infinite;
}

/* ── PROFILE MENU ── */
.profile-menu { position: relative; }
.profile-button {
    display: inline-flex; align-items: center; gap: 8px;
    height: 40px; padding: 4px 12px 4px 4px;
    border-radius: var(--r-pill);
    background: var(--surface2); border: 1px solid var(--border2);
    color: var(--text); cursor: pointer;
    transition: border-color .14s ease;
}
.profile-button:hover { border-color: var(--border); }
.profile-avatar {
    display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--gdim); color: var(--green);
    font-size: 13px; font-weight: 800; flex-shrink: 0;
    border: 1.5px solid var(--gglow);
}
.profile-name  { font-weight: 700; font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-caret { color: var(--muted); font-size: 11px; }

.profile-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 9999;
    width: 240px; padding: 8px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
    visibility: hidden; opacity: 0;
    transform: translateY(-6px) scale(.97); pointer-events: none;
    transition: opacity .15s var(--ease), transform .15s var(--ease), visibility .15s;
}
.profile-dropdown.open {
    visibility: visible; opacity: 1;
    transform: translateY(0) scale(1); pointer-events: auto;
}
.profile-dropdown-head {
    padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.profile-dropdown-head strong { display: block; font-size: 14px; font-weight: 700; }
.profile-dropdown-head span   { display: block; margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.profile-dropdown a {
    display: block; padding: 9px 12px; border-radius: var(--r-md);
    color: var(--text2); font-size: 14px; font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.profile-dropdown a:hover { background: var(--surface2); color: var(--text); }
.profile-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 5px 0; }

.mobile-menu-button { display: none; }

/* ── PAGE CONTENT ── */
.spa-root {
    flex: 0 0 auto;
    width: 100%; max-width: 1320px; margin: 0 auto;
    padding: 44px 36px 52px;
    position: relative; z-index: 1;
}
.spa-root > * { animation: page-in .2s var(--ease) both; }

/* Stat cards */
.cards {
    display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 18px; margin-bottom: 24px;
}
.card, .form-card {
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: var(--r-xl); padding: 22px;
    transition: border-color .18s ease, transform .18s var(--spring);
}
.card:hover { border-color: var(--border); transform: translateY(-2px); }
.card span {
    display: block; font-family: var(--mono); font-size: 10px; font-weight: 600;
    letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.card strong {
    display: block; margin-top: 10px;
    font-size: clamp(32px, 4vw, 48px); font-weight: 800; letter-spacing: -.04em;
    color: var(--text); line-height: 1;
}

h2.section-title,
.spa-root h2 {
    font-size: clamp(18px,2.5vw,26px); font-weight: 800; letter-spacing: -.04em;
    margin: 28px 0 14px;
}
.spa-root h2:first-child { margin-top: 0; }

.dashboard-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 22px;
}
.dashboard-actions form { display: inline-flex; }

/* Tables */
.responsive-table, .table-wrap {
    width: 100%; overflow-x: auto; border-radius: var(--r-xl);
    -webkit-overflow-scrolling: touch;
}
table {
    width: 100%; min-width: 600px; border-collapse: collapse;
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: var(--r-xl); overflow: hidden; font-size: 14px;
}
th {
    padding: 12px 17px; text-align: left;
    font-family: var(--mono); font-size: 10px; font-weight: 600;
    letter-spacing: .10em; text-transform: uppercase;
    color: var(--muted); background: var(--surface2);
    border-bottom: 1px solid var(--border2); white-space: nowrap;
}
td {
    padding: 13px 17px; text-align: left;
    border-bottom: 1px solid var(--border2); color: var(--text2); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface2); }

/* ── FOOTER (inside main shell) ── */
.app-mega-footer {
    flex: 0 0 auto;
    width: calc(100% - 72px); margin: 50px auto 38px;
    border-radius: 26px; border: 1px solid var(--border);
    background:
        radial-gradient(ellipse 60% 50% at 0% 0%,   rgba(61,220,104,.11) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 100% 100%,rgba(240,164,58,.06) 0%, transparent 50%),
        #09160b;
    overflow: hidden;
}
html[data-theme="light"] .app-mega-footer {
    background: radial-gradient(ellipse 60% 50% at 0% 0%, rgba(22,120,46,.07) 0%, transparent 55%), #d6ebd8;
    border-color: rgba(22,120,46,.14);
}

/* =====================================================
   8. LANDING PAGE
   ===================================================== */
.landing-body { overflow-x: hidden; }

.landing-nav, .auth-header {
    position: sticky; top: 10px; z-index: 200;
    width: min(1280px, calc(100% - 40px)); margin: 10px auto 0;
    padding: 9px 13px 9px 9px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    background: rgba(13,24,16,.86);
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    border: 1px solid var(--border); border-radius: 100px;
    transition: background .22s ease;
}
html[data-theme="light"] .landing-nav,
html[data-theme="light"] .auth-header {
    background: rgba(255,255,255,.92); box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.landing-brand,
.auth-brand,
.auth-header .brand {
    display: flex; align-items: center; gap: 9px; text-decoration: none;
}
.landing-brand img,
.auth-brand img,
.auth-header .brand img {
    width: 34px; height: 34px; border-radius: 9px; object-fit: contain;
}
.landing-brand > span,
.auth-brand strong,
.auth-header .brand strong {
    font-size: 16px; font-weight: 800; letter-spacing: -.04em; color: var(--text);
}
.auth-brand > div,
.auth-header .brand > div { display: flex; flex-direction: column; }
.auth-brand span, .auth-header .brand span {
    font-family: var(--mono); font-size: 9px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .14em; color: var(--green);
}

.landing-nav-actions, .auth-header-actions { display: flex; align-items: center; gap: 7px; }
.nav-link, .auth-header-actions a {
    padding: 7px 13px; border-radius: var(--r-pill);
    font-weight: 600; font-size: 14px; color: var(--text2);
    transition: color .12s ease, background .12s ease;
}
.nav-link:hover, .auth-header-actions a:hover { color: var(--text); background: var(--surface2); }

/* Landing hero */
.landing-hero {
    display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center;
    width: min(1280px, calc(100% - 40px)); margin: 72px auto 64px;
    min-height: calc(100vh - 200px);
}
.hero-badge {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 13px 5px 7px; border-radius: var(--r-pill);
    background: var(--gdim); border: 1px solid var(--gglow);
    font-family: var(--mono); font-size: 11px; font-weight: 600;
    color: var(--green); letter-spacing: .04em; margin-bottom: 20px;
}
.hero-badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%;
    background: var(--green); flex-shrink: 0; animation: pulse-dot 2s ease infinite;
}
.hero-copy h1 { font-size: clamp(32px, 5vw, 60px); font-weight: 800; letter-spacing: -.05em; margin-bottom: 18px; }
.hero-copy > p { font-size: 15px; line-height: 1.7; color: var(--text2); margin-bottom: 28px; max-width: 46ch; }
.hero-actions  { display: flex; align-items: center; gap: 11px; margin-bottom: 38px; flex-wrap: wrap; }
.hero-stats {
    display: flex; align-items: center; gap: 28px;
    padding-top: 22px; border-top: 1px solid var(--border2);
}
.hero-stats > div strong { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.04em; }
.hero-stats > div span  { display: block; margin-top: 1px; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .04em; }

.hero-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 24px; padding: 24px; box-shadow: var(--shadow-lg);
}
.panel-top { display: flex; gap: 7px; margin-bottom: 20px; }
.panel-top span { width: 11px; height: 11px; border-radius: 50%; }
.panel-top span:nth-child(1) { background: #f05050; }
.panel-top span:nth-child(2) { background: var(--amber); }
.panel-top span:nth-child(3) { background: var(--green); }

.sensor-card { padding: 14px 17px; border-radius: var(--r-lg); margin-bottom: 9px; border: 1px solid; }
.sensor-card:last-child { margin-bottom: 0; }
.sensor-card small { display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; opacity: .7; }
.sensor-card strong { display: block; margin-bottom: 3px; font-size: 14px; font-weight: 700; }
.sensor-card p { font-size: 12px; opacity: .72; }
.sensor-card.healthy { background: var(--gdim); border-color: var(--gglow); color: var(--green); }
.sensor-card.warning  { background: var(--adim); border-color: rgba(240,164,58,.22); color: var(--amber); }
.sensor-card.danger   { background: var(--rdim); border-color: rgba(240,80,80,.22);  color: var(--red); }

.landing-section {
    width: min(1280px, calc(100% - 40px)); margin: 0 auto 70px;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.feature-card {
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: var(--r-xl); padding: 24px;
    transition: border-color .18s ease, transform .18s var(--spring);
}
.feature-card:hover { border-color: var(--border); transform: translateY(-2px); }
.feature-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.feature-card p  { font-size: 14px; line-height: 1.65; color: var(--text2); }

/* Landing footer */
.mega-footer {
    width: min(1280px, calc(100% - 40px)); margin: 56px auto 30px;
    border-radius: 26px; border: 1px solid var(--border);
    background:
        radial-gradient(ellipse 60% 50% at 0% 0%,   rgba(61,220,104,.11) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 100% 100%,rgba(240,164,58,.06) 0%, transparent 50%),
        #09160b;
    overflow: hidden;
}
html[data-theme="light"] .mega-footer {
    background: radial-gradient(ellipse 60% 50% at 0% 0%, rgba(22,120,46,.07) 0%, transparent 55%), #d6ebd8;
    border-color: rgba(22,120,46,.14);
}

.mega-footer-inner { padding: 46px 46px 28px; }
.footer-main, .footer-main.compact {
    display: grid; grid-template-columns: 1.5fr .8fr .8fr .8fr; gap: 40px;
}
.footer-logo-row { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.footer-logo-row img {
    width: 42px; height: 42px; border-radius: 12px; object-fit: contain;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); padding: 4px;
}
.footer-logo-row strong { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.04em; color: #eaf5ec; }
.footer-logo-row span   { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: rgba(180,240,200,.55); }
html[data-theme="light"] .footer-logo-row strong { color: #0c1f10; }
html[data-theme="light"] .footer-logo-row span   { color: var(--muted); }

.footer-brand-block > p { font-size: 13px; line-height: 1.7; color: rgba(180,240,200,.62); margin-bottom: 10px; }
html[data-theme="light"] .footer-brand-block > p { color: var(--text2); }
.footer-credit { font-size: 12px; color: rgba(180,240,200,.78); font-weight: 600; }
html[data-theme="light"] .footer-credit { color: var(--text2); }

.footer-column { display: grid; gap: 8px; align-content: start; }
.footer-column h4 {
    margin-bottom: 4px; font-family: var(--mono); font-size: 10px; font-weight: 600;
    letter-spacing: .14em; text-transform: uppercase; color: var(--amber);
}
.footer-column a,
.footer-column span { font-size: 13px; font-weight: 500; color: rgba(180,240,200,.58); line-height: 1.5; transition: color .12s ease; }
html[data-theme="light"] .footer-column a,
html[data-theme="light"] .footer-column span { color: var(--text2); }
.footer-column a:hover { color: rgba(180,240,200,.95); }
html[data-theme="light"] .footer-column a:hover { color: var(--text); }

.footer-bottom {
    margin-top: 36px; padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; justify-content: space-between; gap: 12px;
    font-family: var(--mono); font-size: 11px; color: rgba(180,240,200,.40);
}
html[data-theme="light"] .footer-bottom { border-top-color: rgba(0,0,0,.08); color: var(--muted); }

/* =====================================================
   9. AUTH PAGES
   ===================================================== */
.auth-body { overflow-x: hidden; }
.auth-root { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main  { flex: 1; display: grid; place-items: center; padding: 44px 18px; }

.auth-panel {
    width: min(860px,100%);
    display: grid; grid-template-columns: 1.1fr .9fr;
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: 28px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.auth-panel.single-auth { max-width: 440px; grid-template-columns: 1fr; }

.auth-copy {
    padding: 52px 46px;
    background:
        radial-gradient(ellipse 110% 60% at 0% 0%, var(--gdim) 0%, transparent 55%),
        var(--surface2);
    border-right: 1px solid var(--border2);
    display: flex; flex-direction: column; justify-content: center;
}
.auth-copy h1 { font-size: clamp(24px,3.5vw,44px); font-weight: 800; letter-spacing: -.05em; margin-bottom: 14px; }
.auth-copy > p { font-size: 14px; line-height: 1.65; color: var(--text2); margin-bottom: 24px; }

.auth-feature-grid { display: grid; gap: 10px; margin-top: 4px; }
.auth-feature-grid > div { display: flex; align-items: baseline; gap: 9px; }
.auth-feature-grid strong { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--green); letter-spacing: .06em; flex-shrink: 0; }
.auth-feature-grid span   { font-size: 13px; color: var(--text2); }

.auth-card {
    padding: 48px 40px;
    display: flex; flex-direction: column; justify-content: center;
}
.auth-card-logo { width: 46px; height: 46px; border-radius: var(--r-lg); margin-bottom: 16px; object-fit: contain; }
.auth-card h2   { font-size: 26px; font-weight: 800; letter-spacing: -.04em; margin-bottom: 5px; }
.auth-card > p  { font-size: 13px; color: var(--muted); }
.auth-card form button[type="submit"] { width: 100%; margin-top: 22px; }

.auth-links { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 18px; }
.auth-links a { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 8px; border-radius: var(--r-xs); transition: color .12s ease; }
.auth-links a:hover { color: var(--green); }

/* =====================================================
   10. MOBILE DRAWER CLOSE BUTTON (global — beats submit gradient)
   ===================================================== */
.mobile-drawer-close {
    display: grid; place-items: center;
    width: 38px; height: 38px; padding: 0;
    border-radius: 14px;
    background: var(--surface3);
    background-image: none;
    color: var(--text2);
    border: 1px solid var(--border2); cursor: pointer; flex-shrink: 0;
    font-size: 0; box-shadow: none; transform: none;
    transition: color .14s ease, border-color .14s ease;
}
.mobile-drawer-close::after {
    content: ""; display: block; width: 14px; height: 14px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 6L6 18M6 6l12 12' stroke='currentColor' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 6L6 18M6 6l12 12' stroke='currentColor' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
.mobile-drawer-close:hover { color: var(--red); border-color: rgba(240,80,80,.25); }

.mobile-drawer-backdrop { display: none; }
.mobile-drawer          { display: none; }

/* =====================================================
   11. EVALUATION + ABOUT PAGE EXTRAS
   ===================================================== */
.evaluation-summary-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 18px; margin: 28px 0;
}
.evaluation-card {
    min-width: 0; padding: 26px;
    background: var(--surface); border: 1px solid var(--border2);
    border-radius: 26px;
}
.evaluation-card.best {
    border-color: var(--gglow);
    background: radial-gradient(circle at top left, var(--gdim), transparent 45%), var(--surface);
}
.evaluation-card > span  { display: block; margin-bottom: 12px; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.evaluation-card > strong { display: block; margin-bottom: 16px; font-size: clamp(26px,3.5vw,52px); font-weight: 800; letter-spacing: -.06em; line-height: 1.05; color: var(--text); overflow-wrap: anywhere; word-break: break-word; }

.metric-card strong,
.metric-card span,
.stat-card strong,
.stat-card span,
.card-value {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.explanation-panel, .feature-panel, .table-card {
    padding: 26px; margin: 24px 0; border-radius: 26px;
    background: var(--surface); border: 1px solid var(--border2);
    overflow: hidden;
}
.explanation-panel h3, .feature-panel h3, .table-card h3 { font-size: 20px; margin-bottom: 10px; }

.feature-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.feature-list span {
    display: inline-flex; align-items: center;
    padding: 9px 14px; border-radius: var(--r-pill);
    background: var(--gdim); border: 1px solid var(--gglow);
    color: var(--green); font-weight: 700; font-size: 13px;
}

/* About */
.page-hero { padding: 56px 0 32px; }
.page-hero h1 { font-size: clamp(36px,7vw,80px); letter-spacing: -.06em; margin-bottom: 16px; }
.page-hero > p { font-size: clamp(16px,2vw,22px); line-height: 1.65; color: var(--muted); max-width: 900px; }

.content-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 30px; padding: clamp(22px,4vw,42px); margin-bottom: 24px;
}
.content-card h2 { font-size: clamp(20px,3vw,34px); margin-bottom: 14px; }
.content-card p  { font-size: clamp(15px,1.5vw,18px); line-height: 1.75; color: var(--muted); margin-bottom: 16px; }
.content-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.clean-list { padding-left: 20px; margin-top: 12px; display: grid; gap: 10px; color: var(--muted); font-size: 16px; line-height: 1.65; }

/* =====================================================
   12. ANIMATIONS
   ===================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.82); }
}
@keyframes page-in {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   13. RESPONSIVE — 1200px
   ===================================================== */
@media (max-width: 1200px) {
    .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .evaluation-summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .landing-hero { grid-template-columns: 1fr; min-height: auto; gap: 40px; margin-top: 52px; }
    .hero-panel { max-width: 480px; }
    .landing-section { grid-template-columns: 1fr 1fr; }
    .footer-main, .footer-main.compact { grid-template-columns: 1fr 1fr; }
    .content-grid { grid-template-columns: 1fr; }
}

/* =====================================================
   14. RESPONSIVE — 820px (MOBILE)
   ===================================================== */
@media (max-width: 820px) {

    /* App body — normal scroll on mobile */
    .app-body { overflow-x: hidden; height: auto; }
    .app-root { height: auto; min-height: 100vh; overflow: visible; align-items: flex-start; }

    /* Hide sidebar, reset main shell */
    .sidebar { display: none !important; }
    .main-shell {
        margin-left: 0 !important; width: 100% !important;
        height: auto !important; min-height: 100vh !important; max-height: none !important;
        overflow: visible !important; overflow-x: hidden !important;
    }

    /* Mobile topbar — floating pill */
    .topbar {
        position: sticky; top: 10px; z-index: 300;
        width: calc(100% - 24px) !important;
        height: auto !important; min-height: 60px !important;
        flex: none !important;
        margin: 10px auto 0 !important;
        padding: 8px 10px !important;
        border-radius: var(--r-pill) !important;
        display: grid !important;
        grid-template-columns: 44px 1fr auto !important;
        gap: 8px !important; align-items: center !important;
        background: var(--surface) !important;
        border: 1px solid var(--border) !important;
        box-shadow: var(--shadow) !important;
        backdrop-filter: none !important;
    }
    html[data-theme="light"] .topbar { background: #fff !important; box-shadow: 0 10px 28px rgba(0,0,0,.08) !important; }

    .mobile-menu-button {
        display: grid !important; place-items: center;
        width: 44px !important; height: 44px !important;
        border-radius: 50% !important;
        background: var(--green) !important;
        color: var(--bg) !important; border: none !important;
        box-shadow: 0 6px 18px var(--gglow) !important;
    }
    .mobile-menu-button svg { width: 20px !important; height: 20px !important; fill: currentColor !important; }

    .topbar-title { text-align: left; }
    .topbar-title h1 { font-size: 16px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-title .eyebrow { display: none; }

    .topbar-actions { gap: 6px; }
    .status-pill { display: none; }
    .profile-name, .profile-caret { display: none; }
    .profile-button {
        width: 40px !important; height: 40px !important;
        padding: 0 !important; border-radius: 50% !important;
        justify-content: center !important;
    }
    .theme-toggle { width: 40px !important; height: 40px !important; border-radius: 50% !important; }

    .profile-dropdown {
        position: fixed !important; right: 12px !important;
        top: 80px !important; width: calc(100% - 24px) !important;
        max-width: 300px !important;
    }

    /* Spa root */
    .spa-root { padding: 18px 13px 36px !important; max-width: 100% !important; }

    /* Cards */
    .cards { grid-template-columns: 1fr 1fr !important; gap: 10px !important; margin-bottom: 16px !important; }
    .card { padding: 16px !important; }
    .card strong { font-size: 30px !important; }

    /* Actions */
    .dashboard-actions { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; }
    .dashboard-actions form,
    .dashboard-actions button,
    .dashboard-actions a { width: 100% !important; }

    /* Table */
    table { min-width: 560px !important; }

    /* Evaluation */
    .evaluation-summary-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
    .evaluation-card { padding: 20px !important; border-radius: 20px !important; }

    /* About */
    .page-hero { padding: 28px 0 20px !important; }
    .content-card { border-radius: 22px !important; padding: 20px !important; }
    .content-grid { grid-template-columns: 1fr !important; }
    .clean-list { font-size: 14px !important; }

    /* Backdrop */
    .mobile-drawer-backdrop {
        display: block !important;
        position: fixed !important; inset: 0 !important; z-index: 9998 !important;
        background: rgba(0,0,0,.62) !important;
        backdrop-filter: blur(6px) !important; -webkit-backdrop-filter: blur(6px) !important;
        opacity: 0 !important; pointer-events: none !important;
        transition: opacity .26s var(--ease) !important;
    }
    body.mobile-drawer-open .mobile-drawer-backdrop { opacity: 1 !important; pointer-events: auto !important; }

    /* Drawer panel */
    .mobile-drawer {
        display: flex !important; flex-direction: column !important;
        position: fixed !important; top: 0 !important; bottom: 0 !important; left: 0 !important;
        width: min(85vw, 300px) !important; z-index: 9999 !important;
        padding: 22px 16px !important; overflow-y: auto !important;
        background:
            radial-gradient(circle at 20% 0%, var(--gdim), transparent 34%),
            linear-gradient(180deg, var(--surface), var(--surface2)) !important;
        border-right: 1px solid var(--border) !important;
        border-radius: 0 28px 28px 0 !important;
        box-shadow: 22px 0 60px rgba(0,0,0,.62) !important;
        transform: translateX(-108%) !important;
        transition: transform .3s var(--ease) !important;
    }
    html[data-theme="light"] .mobile-drawer { box-shadow: 22px 0 44px rgba(0,0,0,.12) !important; }
    body.mobile-drawer-open .mobile-drawer { transform: translateX(0) !important; }
    .mobile-drawer[hidden], .mobile-drawer-backdrop[hidden] { display: none !important; }

    .mobile-drawer-head {
        display: flex !important; align-items: center !important;
        justify-content: space-between !important; gap: 10px !important;
        padding-bottom: 18px !important;
        border-bottom: 1px solid var(--border) !important; margin-bottom: 18px !important;
        flex-shrink: 0 !important;
    }
    .mobile-drawer-brand { display: flex !important; align-items: center !important; gap: 10px !important; text-decoration: none !important; }
    .mobile-drawer-brand img { width: 42px !important; height: 42px !important; border-radius: 12px !important; object-fit: contain !important; }
    .mobile-drawer-brand strong { display: block !important; font-size: 18px !important; font-weight: 800 !important; letter-spacing: -.04em !important; color: var(--text) !important; line-height: 1.1 !important; }
    .mobile-drawer-brand span   { display: block !important; margin-top: 3px !important; font-family: var(--mono) !important; font-size: 9px !important; font-weight: 600 !important; text-transform: uppercase !important; letter-spacing: .12em !important; color: var(--green) !important; }

    .mobile-drawer-nav { display: flex !important; flex-direction: column !important; gap: 6px !important; flex: 1 !important; }
    .mobile-drawer-nav a {
        display: flex !important; align-items: center !important; gap: 13px !important;
        min-height: 50px !important; padding: 12px 16px !important;
        border-radius: var(--r-pill) !important;
        background: transparent !important; border: 1px solid transparent !important;
        color: var(--muted) !important; text-decoration: none !important;
        transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s var(--spring) !important;
    }
    .mobile-drawer-nav a:hover,
    .mobile-drawer-nav a.active {
        background: var(--gdim) !important; color: var(--green) !important;
        border-color: var(--gglow) !important; transform: translateX(3px) !important;
    }
    .mobile-drawer-nav a svg {
        width: 20px !important; height: 20px !important; fill: currentColor !important;
        flex-shrink: 0 !important; opacity: .75 !important;
    }
    .mobile-drawer-nav a:hover svg, .mobile-drawer-nav a.active svg { opacity: 1 !important; }
    .mobile-drawer-nav a span  { display: block !important; font-size: 14px !important; font-weight: 700 !important; color: inherit !important; line-height: 1.2 !important; }
    .mobile-drawer-nav a small { display: none !important; }

    /* Landing on mobile */
    .landing-hero { grid-template-columns: 1fr !important; margin-top: 28px !important; min-height: auto !important; gap: 28px !important; }
    .hero-panel { display: none !important; }
    .landing-section { grid-template-columns: 1fr !important; }

    /* Auth on mobile */
    .auth-main { padding: 20px 13px 40px !important; align-items: flex-start !important; }
    .auth-panel { grid-template-columns: 1fr !important; border-radius: 20px !important; }
    .auth-copy  { display: none !important; }
    .auth-card  { padding: 26px 20px !important; }
    .auth-header { width: calc(100% - 18px) !important; border-radius: 16px !important; }
    .landing-nav { width: calc(100% - 18px) !important; border-radius: 16px !important; }

    /* Footer on mobile */
    .mega-footer, .app-mega-footer {
        width: calc(100% - 18px) !important; margin: 32px auto 20px !important;
        border-radius: 20px !important; max-width: none !important;
    }
    .mega-footer-inner { padding: 24px 20px 18px !important; }
    .footer-main, .footer-main.compact { grid-template-columns: 1fr !important; gap: 20px !important; }
    .footer-bottom { flex-direction: column !important; gap: 4px !important; text-align: center !important; }
}

/* =====================================================
   15. RESPONSIVE — 480px
   ===================================================== */
@media (max-width: 480px) {
    .cards { grid-template-columns: 1fr !important; }
    .topbar { width: calc(100% - 18px) !important; grid-template-columns: 42px 1fr auto !important; }
    .hero-stats { gap: 16px !important; flex-wrap: wrap !important; }
    .hero-copy h1 { font-size: 28px !important; }
    .hero-actions { flex-direction: column !important; align-items: stretch !important; }
    .hero-actions a, .hero-actions button { width: 100% !important; justify-content: center !important; }
    .auth-card { padding: 20px 16px !important; }
    table { min-width: 480px !important; }
    .evaluation-card > strong { font-size: 28px !important; }
}

/* =====================================================
   16. UTILS
   ===================================================== */
.text-green  { color: var(--green)  !important; }
.text-amber  { color: var(--amber)  !important; }
.text-red    { color: var(--red)    !important; }
.text-warning { color: var(--amber) !important; }
.text-danger  { color: var(--red)   !important; }
.text-muted  { color: var(--muted)  !important; }
.text-text2  { color: var(--text2)  !important; }
.font-mono   { font-family: var(--mono) !important; }
.desktop-only { }
.mobile-only  { display: none !important; }
@media (max-width: 820px) {
    .desktop-only { display: none !important; }
    .mobile-only  { display: flex  !important; }
}

/* =====================================================
   17. STABILITY PASS
   Final active design rules live here; final-overrides.css is disabled.
   ===================================================== */
:root {
    --green-soft: var(--gdim);
}

.spa-loading-content {
    opacity: .62;
    pointer-events: none;
}

.page-section,
.dashboard-page,
.dataset-page,
.result-page,
.profile-page {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    animation: page-in .22s ease both;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.section-head h2 {
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.muted {
    color: var(--muted);
}

.responsive-table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-lg);
    border: 1px solid var(--border2);
    background: var(--surface);
}

.responsive-table table {
    min-width: 680px;
    margin: 0;
}

.responsive-table td,
.responsive-table th {
    vertical-align: top;
}

.profile-menu {
    z-index: 600;
}

.profile-dropdown {
    z-index: 10000;
}

.dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 0 0 28px;
}

.dashboard-section-title {
    margin: 28px 0 12px;
}

.content-card {
    width: 100%;
    padding: 24px;
    border-radius: var(--r-lg);
    border: 1px solid var(--border2);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.result-page .content-card {
    margin: 18px 0 24px;
}

.form-card {
    max-width: 720px;
}

@media (min-width: 821px) {
    .mobile-menu-button,
    .mobile-drawer,
    .mobile-drawer-backdrop {
        display: none !important;
    }
}

@media (max-width: 820px) {
    .section-head {
        margin-bottom: 16px;
    }

    .page-section,
    .dashboard-page,
    .dataset-page,
    .result-page,
    .profile-page {
        max-width: 100%;
    }

    .responsive-table table {
        min-width: 680px !important;
    }

    .mobile-drawer-nav a {
        color: var(--text2) !important;
    }

    .mobile-drawer-nav a small {
        display: block !important;
        margin-top: 3px !important;
        font-size: 11px !important;
        line-height: 1.25 !important;
        color: var(--muted) !important;
    }

    .mobile-drawer-close {
        color: var(--text) !important;
    }

    .app-mega-footer .footer-main,
    .mega-footer .footer-main {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .footer-column a,
    .footer-column span {
        overflow-wrap: anywhere;
    }
}
/* =====================================================
   AGRISENSE MOBILE CUT-OFF FIX — FINAL OVERRIDE
   Paste at the very bottom of style.css
   ===================================================== */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
}

.app-root,
.main-shell,
.spa-root,
.topbar,
.mega-footer,
.app-mega-footer {
    max-width: 100%;
    box-sizing: border-box;
}

/* Desktop safety */
.main-shell {
    min-width: 0;
}

.spa-root {
    min-width: 0;
}

/* Stop long headings/cards/tables from pushing the layout */
.spa-root *,
.topbar *,
.card,
.form-card,
.content-card,
.table-card,
.evaluation-card,
.explanation-panel,
.feature-panel {
    min-width: 0;
    box-sizing: border-box;
}

/* Tables should scroll internally, not push the page */
.responsive-table,
.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

/* =====================================================
   MOBILE ONLY
   ===================================================== */
@media (max-width: 820px) {
    html,
    body {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    body.app-body {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .app-root {
        width: 100% !important;
        max-width: 100% !important;
        min-height: 100vh !important;
        height: auto !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        display: block !important;
    }

    .sidebar {
        display: none !important;
    }

    .main-shell {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
    }

    .topbar {
        width: calc(100% - 18px) !important;
        max-width: calc(100% - 18px) !important;
        margin: 10px auto 0 !important;
        padding: 8px 9px !important;
        display: grid !important;
        grid-template-columns: 42px minmax(0, 1fr) auto !important;
        align-items: center !important;
        gap: 7px !important;
        overflow: hidden !important;
    }

    .mobile-menu-button {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        flex: 0 0 42px !important;
    }

    .topbar-brand {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .topbar-brand img {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        flex: 0 0 32px !important;
    }

    .topbar-brand strong {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 15px !important;
    }

    .topbar-actions {
        min-width: 0 !important;
        max-width: max-content !important;
        display: flex !important;
        align-items: center !important;
        gap: 5px !important;
    }

    .theme-toggle,
    .profile-button {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        flex: 0 0 38px !important;
    }

    .spa-root {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 18px 12px 34px !important;
        margin: 0 auto !important;
        overflow-x: hidden !important;
    }

    .spa-root > * {
        max-width: 100% !important;
    }

    h1,
    h2,
    h3,
    .spa-root h1,
    .spa-root h2,
    .spa-root h3 {
        max-width: 100% !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
    }

    .cards {
        width: 100% !important;
        max-width: 100% !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .card,
    .form-card,
    .content-card,
    .table-card,
    .evaluation-card,
    .explanation-panel,
    .feature-panel {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .card strong {
        font-size: 28px !important;
        line-height: 1.05 !important;
        overflow-wrap: anywhere !important;
    }

    table {
        min-width: 620px !important;
    }

    .responsive-table,
    .table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .mega-footer,
    .app-mega-footer {
        width: calc(100% - 18px) !important;
        max-width: calc(100% - 18px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
        overflow: hidden !important;
    }
}

/* Tiny phones */
@media (max-width: 390px) {
    .topbar {
        grid-template-columns: 40px minmax(0, 1fr) auto !important;
        gap: 5px !important;
        padding: 7px 8px !important;
    }

    .mobile-menu-button {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }

    .topbar-brand strong {
        font-size: 14px !important;
    }

    .theme-toggle,
    .profile-button {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .profile-avatar {
        width: 28px !important;
        height: 28px !important;
    }

    .spa-root {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}
/* =====================================================
   AGRISENSE MOBILE GAP / SPACING FIX
   Paste at the bottom of style.css
   ===================================================== */

@media (max-width: 820px) {
    .topbar {
        margin: 10px auto 0 !important;
    }

    .spa-root {
        padding-top: 14px !important;
        padding-bottom: 18px !important;
    }

    .spa-root h1:first-child,
    .spa-root h2:first-child,
    .spa-root .page-title:first-child,
    .spa-root .section-title:first-child {
        margin-top: 0 !important;
    }

    .spa-root > h1:first-child,
    .spa-root > h2:first-child {
        margin-bottom: 12px !important;
    }

    .cards {
        margin-top: 0 !important;
        margin-bottom: 14px !important;
    }

    .card {
        margin: 0 !important;
    }

    .responsive-table,
    .table-wrap {
        margin-top: 10px !important;
        margin-bottom: 14px !important;
    }

    .mega-footer,
    .app-mega-footer {
        margin-top: 16px !important;
        margin-bottom: 16px !important;
    }

    .mega-footer-inner {
        padding-top: 22px !important;
        padding-bottom: 18px !important;
    }
}

@media (max-width: 480px) {
    .spa-root {
        padding-top: 12px !important;
        padding-bottom: 14px !important;
    }

    .mega-footer,
    .app-mega-footer {
        margin-top: 12px !important;
    }
}
