/* ============================================================
   Control Climatico — Design System v3
   "Botanical Almanac" — editorial serif display + technical sans
   + warm cream on ink-forest, with a vivid lime accent.
   Same class surface as v2; visuals fully redesigned.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght,SOFT,WONK@0,9..144,300..900,0..100,0..1;1,9..144,300..900,0..100,0..1&family=Geist:wght@300..800&family=Geist+Mono:wght@400..600&display=swap');

/* --- Tokens --- */
:root {
    /* Surfaces — ink-forest dark */
    --bg-base: #0C100E;
    --bg-sidebar: #0A0D0B;
    --bg-surface: #131815;
    --bg-surface-2: #1A201D;
    --bg-surface-hover: #212823;
    --bg-input: #0E1311;
    --bg-overlay: rgba(10, 13, 11, 0.72);

    /* Borders — warm-cream tinted, organic */
    --border: rgba(232, 230, 215, 0.07);
    --border-strong: rgba(232, 230, 215, 0.14);
    --border-dotted: rgba(232, 230, 215, 0.18);
    --border-focus: rgba(200, 255, 107, 0.42);

    /* Text — warm cream, never sterile white */
    --text-primary: #ECEAD9;
    --text-secondary: #9DA398;
    --text-muted: #5C625B;
    --text-dim: #393E39;

    /* Density */
    --pad-card: 20px;
    --pad-sensor: 18px 20px;
    --pad-section: 32px;
    --gap-grid: 14px;
    --font-value: 3.6rem;

    /* Accent — vivid lime, "alive" */
    --accent: #C8FF6B;
    --accent-strong: #DAFF8C;
    --accent-dim: rgba(200, 255, 107, 0.14);
    --accent-soft: rgba(200, 255, 107, 0.06);
    --accent-ink: #1B2A0A;

    /* Semantic — all warmer, more organic */
    --red: #FF6B5B;
    --red-dim: rgba(255, 107, 91, 0.13);
    --amber: #FFB347;
    --amber-dim: rgba(255, 179, 71, 0.13);
    --blue: #7FB3D5;
    --blue-dim: rgba(127, 179, 213, 0.13);
    --purple: #C9A6E5;
    --purple-dim: rgba(201, 166, 229, 0.13);
    --cyan: #6FCFC0;
    --cyan-dim: rgba(111, 207, 192, 0.13);

    /* Radii — gentle, never sharp */
    --r-xs: 3px;
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 18px 42px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 32px rgba(200, 255, 107, 0.18);

    /* Fonts — editorial display + technical sans + matched mono */
    --font-display: 'Fraunces', 'Times New Roman', serif;
    --font-sans: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Geist Mono', 'JetBrains Mono', 'SF Mono', Menlo, monospace;

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --sidebar-w: 232px;
    --header-h: 56px;

    /* Paper grain — subtle SVG noise overlay */
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.92 0 0 0 0 0.92 0 0 0 0 0.85 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Light theme — warm cream paper */
[data-theme="light"] {
    --bg-base: #F5F1E4;
    --bg-sidebar: #EFEBDC;
    --bg-surface: #FBF8EC;
    --bg-surface-2: #EAE5D2;
    --bg-surface-hover: #E0DABF;
    --bg-input: #FFFEF5;
    --bg-overlay: rgba(245, 241, 228, 0.78);

    --border: rgba(28, 35, 25, 0.10);
    --border-strong: rgba(28, 35, 25, 0.20);
    --border-dotted: rgba(28, 35, 25, 0.28);
    --border-focus: rgba(74, 124, 44, 0.42);

    --text-primary: #1A1F18;
    --text-secondary: #4A5249;
    --text-muted: #7A816F;
    --text-dim: #B5BAA8;

    --accent: #4A7C2C;
    --accent-strong: #3A6322;
    --accent-dim: rgba(74, 124, 44, 0.13);
    --accent-soft: rgba(74, 124, 44, 0.05);
    --accent-ink: #FBF8EC;

    --red: #C84A3C;
    --red-dim: rgba(200, 74, 60, 0.10);
    --amber: #B57A12;
    --amber-dim: rgba(181, 122, 18, 0.10);
    --blue: #3D6E94;
    --blue-dim: rgba(61, 110, 148, 0.10);
    --purple: #7A4FA8;
    --purple-dim: rgba(122, 79, 168, 0.10);
    --cyan: #2F8A7A;
    --cyan-dim: rgba(47, 138, 122, 0.10);

    --shadow-sm: 0 1px 2px rgba(28, 35, 25, 0.06);
    --shadow-md: 0 4px 14px rgba(28, 35, 25, 0.08);
    --shadow-lg: 0 18px 40px rgba(28, 35, 25, 0.14);
    --shadow-glow: 0 0 32px rgba(74, 124, 44, 0.18);

    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.10 0 0 0 0 0.12 0 0 0 0 0.09 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Compact density */
[data-density="compact"] {
    --pad-card: 14px;
    --pad-sensor: 14px 16px;
    --pad-section: 22px;
    --gap-grid: 10px;
    --font-value: 2.6rem;
}
[data-density="compact"] .section { margin-bottom: 22px; }
[data-density="compact"] .sensor { gap: 12px; }
[data-density="compact"] .spark { height: 36px; }
[data-density="compact"] .actuator { padding: 12px 14px 10px; }
[data-density="compact"] .chart-body { height: 200px; }
[data-density="compact"] .page-title { font-size: 1.6rem; }

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 14px;
    color-scheme: dark;
}
[data-theme="light"] html { color-scheme: light; }

body {
    font-family: var(--font-sans);
    font-weight: 400;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    font-feature-settings: "ss01", "cv11";
    position: relative;
}

/* Paper grain overlay — subtle, persistent atmosphere */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: var(--grain);
    background-size: 240px 240px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* Background atmospheric wash — almost imperceptible */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 15% 0%, rgba(200, 255, 107, 0.045), transparent 60%),
        radial-gradient(ellipse 60% 50% at 90% 100%, rgba(127, 179, 213, 0.03), transparent 60%);
    pointer-events: none;
    z-index: -1;
}
[data-theme="light"] body::after {
    background:
        radial-gradient(ellipse 80% 60% at 15% 0%, rgba(74, 124, 44, 0.05), transparent 60%),
        radial-gradient(ellipse 60% 50% at 90% 100%, rgba(61, 110, 148, 0.04), transparent 60%);
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px dashed var(--border);
    height: var(--header-h);
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--r-md);
    background:
        radial-gradient(circle at 30% 30%, var(--accent-strong), var(--accent) 60%, #8FB838 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.15),
        0 0 18px rgba(200, 255, 107, 0.22);
    color: var(--accent-ink);
}
.sidebar-logo svg { stroke: var(--accent-ink); }

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-brand-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
    font-style: italic;
    font-variation-settings: "opsz" 36, "SOFT" 50, "WONK" 1;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    line-height: 1;
}

.sidebar-brand-subtitle {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    margin-top: 4px;
}

/* Nav */
.sidebar-nav {
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.sidebar-nav-section {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    padding: 18px 12px 8px;
    position: relative;
}
.sidebar-nav-section::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 1px;
    background: var(--border-dotted);
    margin-left: 8px;
    vertical-align: middle;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    font-weight: 450;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.2s var(--ease);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 10px var(--accent-dim);
}

.nav-item.active .nav-item-icon { color: var(--accent); }

.nav-item-icon {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.18s var(--ease);
}

.nav-item:hover .nav-item-icon { color: var(--text-secondary); }

/* Sidebar footer (conn status + actions) */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.74rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.25s, box-shadow 0.25s;
    position: relative;
}

.status-dot.online {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 12px var(--accent-dim);
    animation: breathe 2.4s ease-in-out infinite;
}

.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-dim);
}

@keyframes breathe {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.65; transform: scale(0.92); }
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
    min-width: 0;
    padding: 36px 44px 56px;
    max-width: 1480px;
    width: 100%;
    position: relative;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 20px;
    padding-bottom: 22px;
    border-bottom: 1px dashed var(--border);
}

.page-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 400;
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    line-height: 1;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 8px;
    letter-spacing: 0;
}

.page-meta {
    display: flex;
    align-items: center;
    gap: 18px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
}

/* Section header */
.section { margin-bottom: 36px; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 12px;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::before {
    content: '§';
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.1rem;
    color: var(--accent);
    letter-spacing: 0;
    line-height: 0.6;
}

.section-action {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-decoration: none;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.section-action:hover { color: var(--accent); }

/* ============================================================
   CARD (base)
   ============================================================ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
    position: relative;
}

.card-pad { padding: var(--pad-card); }

/* ============================================================
   STATUS BAR (sticky live summary)
   ============================================================ */
.status-bar {
    display: flex;
    align-items: stretch;
    margin-bottom: 28px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.status-bar-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-right: 1px dashed var(--border);
    min-width: 0;
}
.status-bar-item:last-child { border-right: none; }

.status-bar-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

.status-bar-value {
    color: var(--text-primary);
    font-weight: 500;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

.status-bar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.25s, box-shadow 0.25s;
}
.status-bar-dot.good { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-bar-dot.warn { background: var(--amber);  box-shadow: 0 0 0 3px var(--amber-dim); }
.status-bar-dot.hot  { background: var(--red);    box-shadow: 0 0 0 3px var(--red-dim); }
.status-bar-dot.cold { background: var(--blue);   box-shadow: 0 0 0 3px var(--blue-dim); }

[data-density="compact"] .status-bar-item { padding: 8px 13px; }

/* ============================================================
   SENSOR CARDS — editorial, with serif hero numbers
   ============================================================ */
.sensors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-grid);
}

.sensor {
    padding: var(--pad-sensor);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
    position: relative;
    overflow: hidden;
}

/* Subtle status-tinted top stripe */
.sensor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--text-dim);
    transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
    opacity: 0.6;
}
.sensor[data-status="good"]::before { background: var(--accent); box-shadow: 0 0 12px var(--accent-dim); opacity: 1; }
.sensor[data-status="warn"]::before { background: var(--amber); box-shadow: 0 0 12px var(--amber-dim); opacity: 1; }
.sensor[data-status="cold"]::before { background: var(--blue);  box-shadow: 0 0 12px var(--blue-dim); opacity: 1; }
.sensor[data-status="hot"]::before  { background: var(--red);   box-shadow: 0 0 12px var(--red-dim); opacity: 1; }

.sensor:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.sensor-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sensor-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sensor-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.sensor-name {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    border-radius: 99px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: var(--bg-surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.badge.good { background: var(--accent-dim); color: var(--accent); border-color: rgba(200,255,107,0.22); }
.badge.warn { background: var(--amber-dim); color: var(--amber); border-color: rgba(255,179,71,0.22); }
.badge.cold { background: var(--blue-dim);  color: var(--blue);  border-color: rgba(127,179,213,0.22); }
.badge.hot  { background: var(--red-dim);   color: var(--red);   border-color: rgba(255,107,91,0.22); }
.badge.none { background: var(--bg-surface-2); color: var(--text-muted); }

/* readout — Fraunces serif hero numbers */
.sensor-readout {
    display: flex;
    align-items: baseline;
    gap: 8px;
    line-height: 0.85;
    margin-top: 4px;
}

.sensor-value {
    font-family: var(--font-display);
    font-size: var(--font-value);
    font-weight: 400;
    font-variation-settings: "opsz" 144, "SOFT" 30;
    font-variant-numeric: tabular-nums lining-nums;
    letter-spacing: -0.045em;
    color: var(--text-primary);
    line-height: 0.85;
}

.sensor-updated {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: -8px;
}

.sensor-updated::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: breathe 2.4s ease-in-out infinite;
    box-shadow: 0 0 6px var(--accent);
}

.sensor-updated.stale::before { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.sensor-updated.stale         { color: var(--amber); }
.sensor-updated.dead::before  { background: var(--red); animation: none; box-shadow: none; }
.sensor-updated.dead          { color: var(--red); }

.sensor-unit {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0;
}

/* gauge — minimal hairline with optimal range */
.gauge {
    position: relative;
    width: 100%;
    height: 4px;
    background: var(--bg-surface-2);
    border-radius: 99px;
    overflow: visible;
}

.gauge-optimal {
    position: absolute;
    top: -1px;
    height: 6px;
    background: var(--accent-soft);
    border-left: 1px solid rgba(200, 255, 107, 0.35);
    border-right: 1px solid rgba(200, 255, 107, 0.35);
    border-radius: 2px;
    pointer-events: none;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    transition: width 0.7s var(--ease), background 0.3s var(--ease);
    box-shadow: 0 0 10px currentColor;
}

.gauge-fill.good { background: var(--accent); color: var(--accent-dim); }
.gauge-fill.warn { background: var(--amber);  color: var(--amber-dim); }
.gauge-fill.cold { background: var(--blue);   color: var(--blue-dim); }
.gauge-fill.hot  { background: var(--red);    color: var(--red-dim); }

.gauge-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* sparkline */
.spark {
    position: relative;
    height: 44px;
}
.spark canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.spark-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}
.spark-meta .label { text-transform: uppercase; color: var(--text-dim); }

/* Sensor card as anchor link */
a.sensor.sensor-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
a.sensor.sensor-link::after {
    content: '↗';
    position: absolute;
    top: 16px;
    right: 18px;
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--text-dim);
    opacity: 0;
    transform: translate(-4px, 4px);
    transition: all 0.25s var(--ease);
}
a.sensor.sensor-link:hover::after {
    opacity: 1;
    transform: translate(0, 0);
    color: var(--accent);
}

/* ============================================================
   ACTUATORS
   ============================================================ */
.actuators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 10px;
}

.actuator {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    transition: border-color 0.2s var(--ease), background 0.3s var(--ease);
    position: relative;
    overflow: hidden;
}

.actuator:hover { border-color: var(--border-strong); }

.actuator.active {
    border-color: rgba(200, 255, 107, 0.32);
    background:
        radial-gradient(circle at 100% 0%, var(--accent-dim) 0%, transparent 60%),
        var(--bg-surface);
}

.actuator-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.actuator-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color 0.25s;
}

.actuator.active .actuator-icon {
    color: var(--accent);
    filter: drop-shadow(0 0 6px var(--accent-dim));
}

.actuator.active .actuator-icon.fan-icon svg {
    animation: spin 2.6s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.actuator-state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.25s, box-shadow 0.25s;
}

.actuator.active .actuator-state-dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), 0 0 10px var(--accent);
    animation: breathe 2.4s ease-in-out infinite;
}

.actuator-name {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.005em;
    line-height: 1.2;
}

.actuator-sub {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    margin-top: 2px;
}

.actuator.active .actuator-sub { color: var(--accent); }

.actuator-toggle {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.btn-seg {
    flex: 1;
    padding: 6px 0;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: all 0.15s var(--ease);
}

.btn-seg:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--bg-surface-2);
}

.btn-seg.btn-on:hover {
    color: var(--accent);
    border-color: rgba(200, 255, 107, 0.35);
    background: var(--accent-soft);
}

.btn-seg.btn-off:hover {
    color: var(--red);
    border-color: rgba(255, 107, 91, 0.32);
    background: var(--red-dim);
}

/* ============================================================
   CLIMATE PANEL
   ============================================================ */
.climate { padding: 22px; }

.climate-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    padding-bottom: 18px;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 18px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    font-variation-settings: "opsz" 72, "SOFT" 30;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    line-height: 1;
}

.stat-value.accent { color: var(--accent); }

.stat-value.mono {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 99px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    cursor: pointer;
    transition: all 0.18s var(--ease);
    border: 1px solid var(--border);
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    width: max-content;
}

.mode-chip:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.mode-chip.auto {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(200, 255, 107, 0.4);
}

.mode-chip.auto::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: breathe 2.2s ease-in-out infinite;
}

/* Stage pills */
.stages-row {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 14px;
    scrollbar-width: thin;
}

.stage-pill {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 99px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    text-transform: lowercase;
    letter-spacing: 0.04em;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.18s var(--ease);
    white-space: nowrap;
}

.stage-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.stage-pill.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: rgba(200, 255, 107, 0.4);
}

/* Decisions */
.decisions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.decision {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: border-color 0.2s;
    border-left: 2px solid var(--text-dim);
}

.decision.ok    { border-left-color: var(--accent); }
.decision.act   { border-left-color: var(--amber); background: var(--amber-dim); color: var(--text-primary); }

.decision-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--r-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    font-style: italic;
    flex-shrink: 0;
}

.decision-icon.t { background: var(--red-dim);    color: var(--red); }
.decision-icon.h { background: var(--blue-dim);   color: var(--blue); }
.decision-icon.c { background: var(--purple-dim); color: var(--purple); }

.decision-text {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
}

/* Thresholds grid */
.thresholds {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px;
}

.threshold {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 13px;
    border-radius: var(--r-sm);
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
}

.threshold-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.threshold-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   CHART
   ============================================================ */
.chart { padding: 20px 22px; }

.chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-legend { display: flex; gap: 18px; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: lowercase;
}

.legend-dot {
    width: 10px;
    height: 2px;
    border-radius: 2px;
}

.chart-range {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-surface-2);
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
}

.chart-range button {
    padding: 4px 11px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--r-xs);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    text-transform: lowercase;
}

.chart-range button:hover { color: var(--text-primary); }
.chart-range button.active {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.chart-body {
    position: relative;
    height: 240px;
    cursor: crosshair;
}

.chart-body canvas { width: 100%; height: 100%; }

/* Chart tooltip */
.chart-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    padding: 10px 14px;
    box-shadow: var(--shadow-lg);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    min-width: 150px;
    opacity: 0;
    transition: opacity 0.12s;
    z-index: 10;
    backdrop-filter: blur(6px);
}

.chart-tooltip.visible { opacity: 1; }

.chart-tooltip-time {
    color: var(--text-muted);
    font-size: 0.66rem;
    margin-bottom: 7px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.chart-tooltip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
}

.chart-tooltip-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-secondary);
    text-transform: lowercase;
}

.chart-tooltip-label::before {
    content: '';
    width: 10px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.chart-tooltip-value {
    color: var(--text-primary);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   BUTTONS (generic)
   ============================================================ */
.btn-primary {
    padding: 9px 18px;
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s;
    letter-spacing: -0.005em;
    box-shadow: 0 0 0 0 var(--accent-dim);
}

.btn-primary:hover {
    background: var(--accent-strong);
    box-shadow: 0 0 22px var(--accent-dim);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    padding: 9px 18px;
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.form-hint {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
    margin-top: 6px;
    letter-spacing: 0.04em;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.form-input:focus,
.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239DA398' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

table.data th {
    text-align: left;
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    border-bottom: 1px dashed var(--border);
    background: var(--bg-surface-2);
}

table.data td {
    padding: 11px 16px;
    color: var(--text-secondary);
    border-bottom: 1px dashed var(--border);
    font-variant-numeric: tabular-nums;
}

table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-surface-2); }

table.data code {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-muted);
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 500;
    border-radius: 99px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tag::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.tag.on     { background: var(--accent-dim); color: var(--accent); }
.tag.off    { background: var(--red-dim);    color: var(--red); }
.tag.auto   { background: var(--blue-dim);   color: var(--blue); }
.tag.manual { background: var(--amber-dim);  color: var(--amber); }

/* ============================================================
   HEALTH CARDS
   ============================================================ */
.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.health {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    transition: border-color 0.2s;
}
.health:hover { border-color: var(--border-strong); }

.health-dot {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.health-dot.healthy { background: var(--accent-dim); color: var(--accent); }
.health-dot.warning { background: var(--amber-dim);  color: var(--amber); }
.health-dot.error   { background: var(--red-dim);    color: var(--red); }

.health-info h3 {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 500;
    font-variation-settings: "opsz" 36;
    color: var(--text-primary);
    margin-bottom: 3px;
    letter-spacing: -0.012em;
}

.health-info p {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

/* ============================================================
   SETTINGS LAYOUT
   ============================================================ */
.settings-layout {
    display: grid;
    grid-template-columns: 232px 1fr;
    gap: 28px;
    align-items: flex-start;
}

.settings-nav {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    position: sticky;
    top: 28px;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    border: none;
    background: transparent;
    text-align: left;
    font-family: var(--font-sans);
    width: 100%;
    font-weight: 450;
}

.settings-nav-item:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.settings-nav-item.active svg { color: var(--accent); }

.settings-nav-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: color 0.15s;
}

.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap,
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-base);
    position: relative;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    text-align: left;
    position: relative;
    box-shadow: var(--shadow-lg);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    right: 24px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

.login-head { margin-bottom: 26px; }

.login-logo {
    width: 52px;
    height: 52px;
    border-radius: var(--r-md);
    background:
        radial-gradient(circle at 30% 30%, var(--accent-strong), var(--accent) 60%, #8FB838 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 0 1px rgba(0, 0, 0, 0.1),
        0 0 28px rgba(200, 255, 107, 0.28);
    color: var(--accent-ink);
}
.login-logo svg { stroke: var(--accent-ink); }

.login-title {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 400;
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
    text-align: center;
}

.login-subtitle {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    margin-top: 8px;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-form .form-input {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.9rem;
}

.login-btn {
    margin-top: 6px;
    width: 100%;
    padding: 12px;
    font-size: 0.88rem;
}

.login-error {
    background: var(--red-dim);
    border: 1px solid rgba(255, 107, 91, 0.3);
    color: var(--red);
    padding: 12px 14px;
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    margin-bottom: 14px;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 11px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s var(--ease-spring);
    max-width: 360px;
    color: var(--text-primary);
    backdrop-filter: blur(8px);
}

.toast.success { border-left: 2px solid var(--accent); }
.toast.error   { border-left: 2px solid var(--red); }
.toast.warning { border-left: 2px solid var(--amber); }

.toast svg { flex-shrink: 0; }
.toast.success svg { color: var(--accent); }
.toast.error svg   { color: var(--red); }
.toast.warning svg { color: var(--amber); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(8px); }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(232, 230, 215, 0.08);
    border-radius: 99px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 230, 215, 0.16);
    background-clip: padding-box;
    border: 2px solid transparent;
}
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(28, 35, 25, 0.10); background-clip: padding-box; }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(28, 35, 25, 0.22); background-clip: padding-box; }

/* ============================================================
   UTIL
   ============================================================ */
.mono       { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-3       { margin-top: 12px; }
.mt-4       { margin-top: 16px; }
.mb-3       { margin-bottom: 12px; }
.mb-4       { margin-bottom: 16px; }
.gap-row    { display: flex; gap: 12px; align-items: center; }
.text-muted { color: var(--text-muted); }
.text-mono  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-accent{ color: var(--accent); }

.empty-state {
    text-align: center;
    padding: 40px 18px;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-style: italic;
    font-family: var(--font-display);
    font-variation-settings: "opsz" 36;
}

/* Subtle staggered fade-in for cards on load */
.fade { animation: fade-up 0.5s var(--ease) both; }
.fade-in { animation: fade-up 0.45s var(--ease) both; }
.fade:nth-child(1) { animation-delay: 0.04s; }
.fade:nth-child(2) { animation-delay: 0.10s; }
.fade:nth-child(3) { animation-delay: 0.16s; }
.fade:nth-child(4) { animation-delay: 0.22s; }
.fade:nth-child(5) { animation-delay: 0.28s; }
.fade:nth-child(6) { animation-delay: 0.34s; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SIDEBAR FOOTER ICONS (alerts, theme, density)
   ============================================================ */
.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: auto;
}

.icon-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    position: relative;
}

.icon-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border);
}

.icon-btn svg { width: 16px; height: 16px; }

.icon-btn-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--red);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-sidebar);
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.18s var(--ease-spring);
}

.icon-btn-badge.visible { opacity: 1; transform: scale(1); }

@media (max-width: 900px) { .sidebar-actions { display: none; } }

/* ============================================================
   ROLE CHIP
   ============================================================ */
.role-chip {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    padding: 3px 9px;
    border-radius: 99px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.role-chip.role-admin    { background: var(--accent-dim); color: var(--accent); border-color: rgba(200,255,107,0.32); }
.role-chip.role-operator { background: var(--blue-dim);   color: var(--blue);   border-color: rgba(127,179,213,0.32); }
.role-chip.role-viewer   { background: var(--bg-surface-2); color: var(--text-muted); }

[data-role="viewer"] .mode-chip,
[data-role="viewer"] .stage-pill,
[data-role="viewer"] .btn-seg {
    cursor: not-allowed;
    opacity: 0.45;
    pointer-events: none;
}

/* ============================================================
   ALERTS PANEL (popover)
   ============================================================ */
.alerts-panel {
    position: fixed;
    bottom: 78px;
    left: calc(var(--sidebar-w) + 12px);
    width: 360px;
    max-height: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 150;
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.alerts-panel.open { display: flex; }

.alerts-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px dashed var(--border);
}

.alerts-panel-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    font-style: italic;
    font-variation-settings: "opsz" 36, "SOFT" 50;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.alerts-panel-clear {
    background: transparent;
    border: none;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--text-muted);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.alerts-panel-clear:hover { color: var(--accent); }

.alerts-panel-list { overflow-y: auto; flex: 1; }

.alert-row {
    display: flex;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px dashed var(--border);
    font-size: 0.8rem;
}
.alert-row:last-child { border-bottom: none; }

.alert-row-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.alert-row.warning .alert-row-icon { background: var(--amber-dim); color: var(--amber); }
.alert-row.error   .alert-row-icon { background: var(--red-dim);   color: var(--red); }
.alert-row.info    .alert-row-icon { background: var(--blue-dim);  color: var(--blue); }

.alert-row-content { flex: 1; min-width: 0; }

.alert-row-msg {
    color: var(--text-primary);
    margin-bottom: 3px;
    line-height: 1.4;
}

.alert-row-time {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    color: var(--text-muted);
    letter-spacing: 0.06em;
}

.alerts-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    font-family: var(--font-display);
    font-variation-settings: "opsz" 36;
}

@media (max-width: 900px) {
    .alerts-panel { left: 10px; right: 10px; width: auto; }
}

/* ============================================================
   TIMELINE (recent events)
   ============================================================ */
.timeline {
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
}

.timeline-row {
    display: grid;
    grid-template-columns: 80px 24px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 10px 22px;
    border-bottom: 1px dashed var(--border);
    font-size: 0.82rem;
    transition: background 0.12s;
}

.timeline-row:last-child { border-bottom: none; }
.timeline-row:hover { background: var(--bg-surface-2); }

.timeline-time {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.timeline-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
    justify-self: center;
    box-shadow: 0 0 0 3px transparent;
}

.timeline-dot.on     { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline-dot.off    { background: var(--text-muted); }
.timeline-dot.auto   { background: var(--blue);   box-shadow: 0 0 0 3px var(--blue-dim); }
.timeline-dot.manual { background: var(--amber);  box-shadow: 0 0 0 3px var(--amber-dim); }

.timeline-desc {
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-desc strong { font-weight: 500; color: var(--text-primary); }

.timeline-trigger {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    padding: 3px 9px;
    background: var(--bg-surface-2);
    border-radius: 99px;
}

/* ============================================================
   CALENDARIO / CROP CYCLE
   ============================================================ */
.cycle-hero {
    padding: 28px 32px;
    background:
        radial-gradient(circle at 100% 0%, var(--accent-dim) 0%, transparent 55%),
        var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 28px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.cycle-hero-main { min-width: 0; }

.cycle-hero-day {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
}

.cycle-hero-stage {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 400;
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    margin: 6px 0 6px;
    line-height: 0.95;
}

.cycle-hero-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.cycle-hero-progress {
    margin-top: 18px;
    height: 6px;
    background: var(--bg-surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.cycle-hero-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%);
    border-radius: 99px;
    transition: width 0.6s var(--ease);
    box-shadow: 0 0 14px var(--accent-dim);
}

.cycle-hero-progress-fill.due {
    background: linear-gradient(90deg, var(--amber) 0%, #FFC974 100%);
    box-shadow: 0 0 14px var(--amber-dim);
}

.cycle-hero-progress-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.cycle-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.cycle-action-due {
    background: var(--amber-dim);
    border: 1px solid rgba(255, 179, 71, 0.4);
    color: var(--amber);
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.45;
    max-width: 240px;
    text-align: center;
    font-family: var(--font-sans);
}

.stage-timeline {
    display: flex;
    gap: 5px;
    padding: 6px 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.stage-block {
    flex-shrink: 0;
    flex: 1;
    min-width: 100px;
    padding: 14px;
    border-radius: var(--r-md);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.2s var(--ease);
}

.stage-block.past { opacity: 0.5; background: var(--bg-surface-2); }

.stage-block.current {
    background: var(--accent-dim);
    border-color: rgba(200, 255, 107, 0.45);
    box-shadow: 0 0 0 1px rgba(200, 255, 107, 0.25), 0 8px 24px var(--accent-dim);
}

.stage-block-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.012em;
    line-height: 1.1;
}

.stage-block.past .stage-block-name { color: var(--text-secondary); font-style: italic; }

.stage-block.current .stage-block-name {
    color: var(--accent);
    font-style: italic;
    font-variation-settings: "opsz" 36, "SOFT" 50;
}

.stage-block-meta {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stage-block-dates {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

.events-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

@media (max-width: 900px) {
    .events-grid { grid-template-columns: 1fr; }
    .cycle-hero { grid-template-columns: 1fr; padding: 22px; }
    .cycle-hero-actions { align-items: flex-start; }
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 380px;
    overflow-y: auto;
}

.event-row {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 11px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-dim);
    border-radius: var(--r-sm);
    transition: all 0.18s;
}

.event-row:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-2);
}

.event-row.completed { opacity: 0.55; }
.event-row.completed .event-row-notes { text-decoration: line-through; }

.event-row.today      { border-left-color: var(--accent); background: var(--accent-soft); }
.event-row.tomorrow   { border-left-color: var(--blue); }
.event-row.upcoming   { border-left-color: var(--text-muted); }
.event-row.past       { border-left-color: var(--text-dim); }

.event-row.type-abono       { border-left-color: var(--amber); }
.event-row.type-poda        { border-left-color: var(--accent); }
.event-row.type-defoliacion { border-left-color: var(--cyan); }
.event-row.type-transplante { border-left-color: var(--purple); }
.event-row.type-plaga       { border-left-color: var(--red); }
.event-row.type-fase_cambio { border-left-color: var(--blue); }

.event-row-date {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.event-row-content { min-width: 0; }

.event-row-type {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.event-row-type::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.event-row-notes {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.event-row-actions button {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.event-row-actions button:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.event-row-actions button.danger:hover {
    color: var(--red);
    border-color: rgba(255, 107, 91, 0.4);
}

.event-add {
    padding: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    display: grid;
    grid-template-columns: 140px 160px 1fr auto;
    gap: 12px;
    align-items: end;
}

@media (max-width: 900px) {
    .event-add { grid-template-columns: 1fr 1fr; }
    .event-add .event-add-notes,
    .event-add .event-add-submit { grid-column: 1 / -1; }
}

.event-add input,
.event-add select { height: 38px; }

.no-cycle {
    padding: 48px 28px;
    text-align: center;
    background: var(--bg-surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-lg);
    position: relative;
}

.no-cycle h3 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 400;
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 50, "WONK" 1;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

.no-cycle p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 22px;
    line-height: 1.5;
}

.no-cycle-form {
    display: inline-flex;
    gap: 10px;
    align-items: end;
}

/* Dashboard cycle widget (compact) */
.cycle-widget {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin-bottom: 28px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s var(--ease);
    position: relative;
    overflow: hidden;
}
.cycle-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    box-shadow: 0 0 14px var(--accent-dim);
}

.cycle-widget:hover {
    border-color: var(--border-strong);
    background: var(--bg-surface-2);
    transform: translateY(-1px);
}

.cycle-widget-day {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 400;
    font-variation-settings: "opsz" 144, "SOFT" 30;
    color: var(--accent);
    min-width: 64px;
    text-align: center;
    line-height: 0.85;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
}

.cycle-widget-day-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    display: block;
    margin-top: 4px;
}

.cycle-widget-info { flex: 1; min-width: 0; }

.cycle-widget-stage {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.015em;
    line-height: 1.1;
}

.cycle-widget-meta {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.cycle-widget-cta {
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 1.4rem;
    line-height: 1;
    transition: color 0.15s, transform 0.2s;
}
.cycle-widget:hover .cycle-widget-cta { color: var(--accent); transform: translateX(3px); }

.cycle-widget.due {
    border-color: rgba(255, 179, 71, 0.4);
    background:
        radial-gradient(circle at 100% 0%, var(--amber-dim), transparent 60%),
        var(--bg-surface);
}
.cycle-widget.due::before { background: var(--amber); box-shadow: 0 0 14px var(--amber-dim); }
.cycle-widget.due .cycle-widget-day { color: var(--amber); }

/* ============================================================
   FEED (riego/abono) form
   ============================================================ */
.feed-add { grid-template-columns: 140px repeat(5, 1fr); }
@media (max-width: 900px) { .feed-add { grid-template-columns: 1fr 1fr; } }

.feed-products {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}
@media (max-width: 900px) { .feed-products { grid-template-columns: 1fr; } }

.feed-product-row {
    display: grid;
    grid-template-columns: 1fr 78px;
    gap: 4px;
}

.feed-add-bottom {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    margin-top: 10px;
    align-items: stretch;
}
@media (max-width: 900px) { .feed-add-bottom { grid-template-columns: 1fr; } }

/* ============================================================
   PHOTOS / PLANTS / COSTS (inventory)
   ============================================================ */
.photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}
.photo-card {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    aspect-ratio: 4 / 3;
}
.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s var(--ease);
}
.photo-card:hover img { transform: scale(1.05); }
.photo-meta {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 9px 12px;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    display: flex;
    justify-content: space-between;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    letter-spacing: 0.02em;
}
.photo-meta span { text-transform: capitalize; }
.photo-del {
    position: absolute;
    top: 8px; right: 8px;
    width: 26px; height: 26px;
    background: rgba(0,0,0,0.65);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--r-sm);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.photo-card:hover .photo-del { opacity: 1; }
.photo-del:hover { background: var(--red); border-color: var(--red); }

.plant-row {
    display: grid;
    grid-template-columns: 1fr 1fr 130px auto;
    gap: 14px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-sm);
    margin-bottom: 5px;
    font-size: 0.86rem;
}

.cost-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
}
.cost-chip {
    padding: 8px 14px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.cost-chip.total {
    background: var(--accent-dim);
    border-color: rgba(200, 255, 107, 0.32);
    color: var(--accent);
    font-weight: 600;
}
.cost-chip .text-muted {
    margin-right: 6px;
    text-transform: uppercase;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
}

/* ============================================================
   SENSOR DETAIL PAGE (/sensor/X)
   ============================================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 8px;
    transition: color 0.15s;
    letter-spacing: 0.04em;
    text-transform: lowercase;
}
.back-link::before { content: '←'; font-family: var(--font-display); font-size: 1rem; }
.back-link:hover { color: var(--accent); }

.sensor-hero {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 36px;
    padding: 32px 36px;
    background:
        radial-gradient(circle at 100% 0%, var(--accent-dim) 0%, transparent 55%),
        var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    align-items: center;
    position: relative;
    overflow: hidden;
}

@media (max-width: 900px) {
    .sensor-hero { grid-template-columns: 1fr; padding: 24px; }
}

.sensor-hero-current { min-width: 0; }

.sensor-hero-label {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.sensor-hero-value {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.sensor-hero-value > span:first-child {
    font-family: var(--font-display);
    font-size: 6rem;
    font-weight: 400;
    font-variation-settings: "opsz" 144, "SOFT" 30;
    letter-spacing: -0.055em;
    line-height: 0.85;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.sensor-hero-unit {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--text-muted);
}

.sensor-hero-trend {
    margin-top: 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.sensor-hero-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(95px, 1fr));
    gap: 22px;
}

@media (max-width: 600px) {
    .sensor-hero-stats { grid-template-columns: repeat(2, 1fr); }
}

.hero-stat { text-align: right; }
@media (max-width: 900px) { .hero-stat { text-align: left; } }

.hero-stat-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.hero-stat-value {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 400;
    font-variation-settings: "opsz" 72, "SOFT" 30;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.025em;
    line-height: 1;
}

.sensor-chart-body { height: 400px !important; }
[data-density="compact"] .sensor-chart-body { height: 320px !important; }

/* ============================================================
   THRESHOLDS PAGE (settings extra)
   ============================================================ */
.threshold-card {
    padding: 16px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 8px;
}

.threshold-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
    margin-top: 10px;
}

.threshold-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.threshold-values {
    display: flex;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .sensors-grid { grid-template-columns: repeat(2, 1fr); }
    .decisions    { grid-template-columns: 1fr; }
    :root         { --font-value: 3rem; }
}

@media (max-width: 900px) {
    :root { --sidebar-w: 64px; }
    .sidebar-brand-text,
    .nav-item span,
    .sidebar-nav-section,
    .sidebar-footer .status-text,
    .sidebar-footer .role-chip { display: none; }
    .sidebar-brand { justify-content: center; padding: 14px 0; }
    .nav-item { justify-content: center; padding: 10px; }
    .nav-item.active::before { display: none; }
    .sidebar-footer { justify-content: center; padding: 14px 0; }
    .main { padding: 24px 22px 40px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 14px; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
    :root { --font-value: 2.6rem; }
}

@media (max-width: 600px) {
    .sensors-grid    { grid-template-columns: 1fr; }
    .actuators-grid  { grid-template-columns: repeat(2, 1fr); }
    .form-row        { grid-template-columns: 1fr; }
    .page-title      { font-size: 1.7rem; }
    :root            { --font-value: 2.4rem; }
    .status-bar      { flex-wrap: wrap; }
    .status-bar-item { flex: 1 1 50%; border-bottom: 1px dashed var(--border); }
    .sensor-hero-value > span:first-child { font-size: 4.5rem; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    body::before, body::after { display: none; }
    .sidebar, .toast-container, .alerts-panel { display: none; }
    .app-shell { grid-template-columns: 1fr; }
    .main { padding: 24px; max-width: 100%; }
    body { background: #fff; color: #000; }
}
