/* ================================
   BASE RESET & DEFAULTS
   ================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    padding: 0;
    transition: background 0.35s ease, color 0.35s ease;
}

a, .btn-link { color: var(--text-bright); }
.content { padding-top: 0; }
h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

#blazor-error-ui {
    color-scheme: dark only;
    background: #1a1a2e;
    color: #e0e0e0;
    bottom: 0;
    box-shadow: 0 -1px 8px rgba(0,0,0,0.5);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ================================
   CSS VARIABLES — DARK (default)
   Clean white-on-black, no blue tint
   ================================ */
:root,
[data-theme="dark"] {
    --bg: #000000;
    --bg2: #080808;
    --card: #0a0a0a;
    --card-hover: #141414;
    --card-alt: #0e0e0e;
    --border: #1c1c1c;
    --border-light: #2a2a2a;
    --text: #d4d4d4;
    --text-dim: #858585;
    --text-bright: #f5f5f5;
    --topbar-bg: rgba(0,0,0,0.92);
    --topbar-blur: blur(24px);
    --chip-bg: rgba(255,255,255,0.04);
    --hover-overlay: rgba(255,255,255,0.04);
    --shadow-card: 0 16px 48px rgba(0,0,0,0.6);
    --scrollbar-thumb: #222222;
    --scrollbar-hover: #333333;
    --health-bg: rgba(255,255,255,0.05);
    --green: #34d399;
    --green-dim: rgba(52,211,153,0.1);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251,191,36,0.1);
    --orange: #fb923c;
    --orange-dim: rgba(251,146,60,0.12);
    --red: #f87171;
    --red-dim: rgba(248,113,113,0.08);
    --gray: #9ca3af;
    --gray-dim: rgba(156,163,175,0.08);
    --blue: #60a5fa;
    --blue-dim: rgba(96,165,250,0.1);
    --accent: #ffffff;
    --accent-dim: rgba(255,255,255,0.08);
    --mono: 'JetBrains Mono', 'Courier New', monospace;
    --radius: 12px;
    --radius-sm: 6px;
}

/* ================================
   CSS VARIABLES — LIGHT
   ================================ */
[data-theme="light"] {
    --bg: #f3f4f6;
    --bg2: #e5e7eb;
    --card: #ffffff;
    --card-hover: #f9fafb;
    --card-alt: #f9fafb;
    --border: #e5e7eb;
    --border-light: #d1d5db;
    --text: #374151;
    --text-dim: #6b7280;
    --text-bright: #111827;
    --topbar-bg: rgba(255,255,255,0.92);
    --topbar-blur: blur(24px);
    --chip-bg: rgba(0,0,0,0.03);
    --hover-overlay: rgba(0,0,0,0.02);
    --shadow-card: 0 8px 32px rgba(0,0,0,0.08);
    --scrollbar-thumb: #d1d5db;
    --scrollbar-hover: #9ca3af;
    --health-bg: rgba(0,0,0,0.04);
    --green: #059669;
    --green-dim: rgba(5,150,105,0.1);
    --yellow: #d97706;
    --yellow-dim: rgba(217,119,6,0.1);
    --orange: #ea580c;
    --orange-dim: rgba(234,88,12,0.1);
    --red: #dc2626;
    --red-dim: rgba(220,38,38,0.07);
    --gray: #6b7280;
    --gray-dim: rgba(107,114,128,0.08);
    --blue: #2563eb;
    --blue-dim: rgba(37,99,235,0.08);
    --accent: #111827;
    --accent-dim: rgba(0,0,0,0.05);
}

/* ================================
   TOPBAR
   ================================ */
.d-topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 2rem;
    height: 56px;
    background: var(--topbar-bg);
    backdrop-filter: var(--topbar-blur);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.35s ease, border-color 0.35s ease;
}

.d-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.d-brand-icon {
    color: var(--text-bright);
    font-size: 1.1rem;
    opacity: 0.6;
}

.d-brand-text {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.d-brand-thin {
    font-weight: 400;
    opacity: 0.5;
}

.d-brand-divider {
    color: var(--text-dim);
    opacity: 0.3;
    font-weight: 300;
    margin: 0 0.15rem;
}

.d-brand-module {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.d-brand-sub {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-left: 0.3rem;
}

.d-btn-back {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.d-btn-back:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
}

.d-stats-strip {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    margin-right: auto;
}

.d-stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.2rem 0.9rem;
    border-radius: 6px;
    background: var(--chip-bg);
}

.d-stat-num {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.2;
}

.d-stat-lbl {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text-dim);
}

.d-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.d-clock {
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
}

.d-btn-refresh {
    background: var(--accent-dim);
    border: 1px solid var(--border-light);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.d-btn-refresh:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--text-dim);
    color: var(--text-bright);
}

.d-refresh-ico { display: inline-block; }
.d-refresh-ico.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================
   BODY AREA
   ================================ */
.d-body {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ================================
   CENTER MESSAGES (Loading / Error)
   ================================ */
.d-center-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text-dim);
    text-align: center;
}

.d-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.2rem;
}

.d-err-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: var(--red);
}

.d-err-text {
    max-width: 500px;
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* ================================
   SILO CARDS GRID
   ================================ */
.d-silo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
}

/* ================================
   SILO CARD
   ================================ */
.d-silo-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.d-silo-card:hover {
    transform: translateY(-3px);
    background: var(--card-hover);
    border-color: var(--border-light);
    box-shadow: var(--shadow-card);
}

/* Accent glow line at top */
.d-card-accent {
    height: 2px;
    width: 100%;
}

.s-accent-normal { background: linear-gradient(90deg, transparent, var(--green), transparent); }
.s-accent-warninga, .s-accent-warningb { background: linear-gradient(90deg, transparent, var(--orange), transparent); }
.s-accent-alarm { background: linear-gradient(90deg, transparent, var(--red), transparent); animation: accent-pulse 2s ease-in-out infinite; }
.s-accent-error { background: linear-gradient(90deg, transparent, var(--gray), transparent); }

@keyframes accent-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Card glow effects */
.d-silo-card.s-normal { box-shadow: 0 0 30px rgba(52,211,153,0.06); }
.d-silo-card.s-warninga, .d-silo-card.s-warningb { box-shadow: 0 0 30px rgba(251,146,60,0.08); }
.d-silo-card.s-alarm { box-shadow: 0 0 40px rgba(248,113,113,0.1); animation: card-alarm 3s ease-in-out infinite; }
.d-silo-card.s-error { box-shadow: 0 0 30px rgba(156,163,175,0.06); }

@keyframes card-alarm {
    0%, 100% { box-shadow: 0 0 40px rgba(248,113,113,0.1); }
    50% { box-shadow: 0 0 60px rgba(248,113,113,0.18); }
}

.d-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.2rem 1.5rem 0.5rem;
}

.d-silo-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: 0.06em;
    margin: 0;
}

.d-silo-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

/* Status pill */
.d-status-pill {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    flex-shrink: 0;
}

.s-pill-normal { background: var(--green-dim); color: var(--green); border: 1px solid rgba(52,211,153,0.2); }
.s-pill-warninga, .s-pill-warningb { background: var(--orange-dim); color: var(--orange); border: 1px solid rgba(251,146,60,0.2); }
.s-pill-alarm { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.s-pill-error { background: var(--gray-dim); color: var(--gray); border: 1px solid rgba(156,163,175,0.15); }

/* Hero temperature */
.d-temp-hero {
    text-align: center;
    padding: 0.8rem 0 0.5rem;
    position: relative;
}

.d-temp-big {
    font-family: var(--mono);
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1;
}

.d-temp-deg {
    font-size: 1.2rem;
    color: var(--text-dim);
    vertical-align: super;
    margin-left: -0.2rem;
}

.d-temp-sub {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--text-dim);
    margin-top: 0.3rem;
}

.d-temp-none { color: var(--text-dim); }

.s-temp-ok { color: var(--green); text-shadow: 0 0 30px rgba(52,211,153,0.35); }
.s-temp-warn { color: var(--orange); text-shadow: 0 0 30px rgba(251,146,60,0.35); }
.s-temp-alarm { color: var(--red); text-shadow: 0 0 30px rgba(248,113,113,0.45); }

/* Card stats */
.d-card-stats {
    display: flex;
    justify-content: space-around;
    padding: 0.7rem 1.5rem;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.d-cs { text-align: center; }

.d-cs-val {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-bright);
    display: block;
}

.d-cs-of {
    font-weight: 400;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.d-cs-lbl {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--text-dim);
}

/* Health bar */
.d-health-bar {
    display: flex;
    height: 4px;
    margin: 0 1.5rem;
    margin-top: 0.75rem;
    border-radius: 2px;
    overflow: hidden;
    background: var(--health-bg);
}

.d-hb-seg { transition: width 0.6s ease; }
.hb-ok { background: var(--green); }
.hb-warn { background: var(--orange); }
.hb-alarm { background: var(--red); }
.hb-err { background: var(--gray); }

/* Cable mini bars */
.d-cable-bars {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    height: 50px;
    padding: 0.6rem 1.5rem 0.3rem;
}

.d-cb {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.d-cb-fill {
    width: 100%;
    border-radius: 2px 2px 0 0;
    margin-top: auto;
    min-height: 2px;
    transition: height 0.6s ease;
}

.d-cb-normal { background: var(--green); }
.d-cb-warninga { background: var(--yellow); }
.d-cb-warningb { background: var(--orange); }
.d-cb-alarm { background: var(--red); }
.d-cb-error { background: var(--gray); opacity: 0.5; }

.d-cb-lbl {
    font-size: 0.5rem;
    color: var(--text-dim);
    margin-top: 2px;
    font-family: var(--mono);
}

/* Card footer */
.d-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.d-card-time {
    font-family: var(--mono);
    font-size: 0.7rem;
}

.d-card-arrow {
    color: var(--text-dim);
    font-size: 1rem;
    transition: transform 0.2s, color 0.2s;
}

.d-silo-card:hover .d-card-arrow { color: var(--text-bright); }

.d-silo-card:hover .d-card-arrow { transform: translateX(4px); }

/* Glow effects */
.glow-red {
    color: var(--red) !important;
    text-shadow: 0 0 14px rgba(248,113,113,0.6);
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ================================
   DETAIL PAGE
   ================================ */

/* Alerts */
.d-alerts {
    background: rgba(239,68,68,0.04);
    border: 1px solid rgba(239,68,68,0.12);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.d-alerts-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--red);
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(239,68,68,0.08);
}

.d-alerts-ico { font-size: 1rem; }

.d-alerts-body {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem;
}

.d-alert-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: background 0.15s;
}

.d-alert-row:hover { background: var(--hover-overlay); }

.d-alert-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.a-alarm .d-alert-dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.a-error .d-alert-dot { background: var(--gray); box-shadow: 0 0 8px rgba(156,163,175,0.5); }
.a-warningb .d-alert-dot { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

.d-alert-loc {
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.75rem;
}

.d-alert-val {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.d-alert-tag {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.a-alarm .d-alert-tag { background: var(--red-dim); color: var(--red); }
.a-error .d-alert-tag { background: var(--gray-dim); color: var(--gray); }
.a-warningb .d-alert-tag { background: var(--orange-dim); color: var(--orange); }

/* Cables */
.d-cables {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.d-cable {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color 0.2s;
}

.d-cable.c-normal { border-left: 3px solid var(--green); }
.d-cable.c-warninga { border-left: 3px solid var(--yellow); }
.d-cable.c-warningb { border-left: 3px solid var(--orange); }
.d-cable.c-alarm { border-left: 3px solid var(--red); }
.d-cable.c-error { border-left: 3px solid var(--gray); }

.d-cable-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.7rem;
}

.d-cable-head h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-bright);
    margin: 0;
}

.d-cable-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: var(--mono);
}

.d-cable-meta strong { color: var(--text); }

/* Sensor tiles */
.d-sensors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.d-sensor {
    width: 68px;
    height: 68px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: default;
}

.ds-normal {
    background: var(--green-dim);
    border: 1px solid rgba(52,211,153,0.2);
}

.ds-warninga {
    background: var(--yellow-dim);
    border: 1px solid rgba(251,191,36,0.2);
}

.ds-warningb {
    background: var(--orange-dim);
    border: 1px solid rgba(251,146,60,0.22);
}

.ds-alarm {
    background: var(--red-dim);
    border: 1px solid rgba(248,113,113,0.22);
    animation: sensor-alarm 2.5s ease-in-out infinite;
}

@keyframes sensor-alarm {
    0%, 100% { box-shadow: 0 0 8px rgba(248,113,113,0.08); }
    50% { box-shadow: 0 0 18px rgba(248,113,113,0.22); }
}

.ds-error {
    background: var(--gray-dim);
    border: 1px solid rgba(156,163,175,0.15);
    animation: sensor-err 3s ease-in-out infinite;
}

@keyframes sensor-err {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.ds-id {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.ds-val {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 700;
}

.ds-normal .ds-val { color: var(--green); }
.ds-warninga .ds-val { color: var(--yellow); }
.ds-warningb .ds-val { color: var(--orange); }
.ds-alarm .ds-val { color: var(--red); }

.ds-err-txt { color: var(--gray) !important; font-size: 0.75rem; }

.ds-unit {
    font-size: 0.5rem;
    color: var(--text-dim);
}

/* Legend */
.d-legend {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    margin-top: 1.5rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: var(--text-dim);
}

.d-leg-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.d-leg-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lg-ok { background: var(--green); }
.lg-warn { background: var(--orange); }
.lg-alarm { background: var(--red); }
.lg-err { background: var(--gray); }

/* ================================
   HOURLY TEMPERATURE GRID (flipped)
   Rows = hours (latest first), Columns = silos
   ================================ */
.d-hourly-section {
    margin-top: 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(0,0,0,0.2);
}

.d-hourly-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-alt);
}

.d-hourly-header-left {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.d-hourly-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-bright);
    margin: 0;
    letter-spacing: 0.03em;
}

.d-hourly-sub {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.04em;
}

.d-hourly-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar for the grid */
.d-hourly-scroll::-webkit-scrollbar { height: 6px; }
.d-hourly-scroll::-webkit-scrollbar-track { background: transparent; }
.d-hourly-scroll::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
.d-hourly-scroll::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

.d-hourly-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-family: var(--mono);
}

.d-hourly-table thead th {
    padding: 0.7rem 0.6rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-align: center;
    border-bottom: 2px solid var(--border-light);
    white-space: nowrap;
    position: relative;
    background: var(--card-alt);
}

/* Sticky time column (first column) */
.d-ht-time-col {
    text-align: left !important;
    padding-left: 1.25rem !important;
    min-width: 110px;
    width: 120px;
    position: sticky;
    left: 0;
    background: var(--card-alt);
    z-index: 3;
    font-size: 0.65rem !important;
    color: var(--text-dim) !important;
    text-transform: uppercase;
    letter-spacing: 0.12em !important;
}

/* Silo column headers */
.d-ht-silo-hdr {
    min-width: 150px;
    padding: 0.7rem 0.6rem !important;
}

.d-ht-silo-num {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.d-ht-silo-desc {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: 0.02em;
    margin-top: 2px;
}

/* Table body rows */
.d-hourly-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.d-hourly-table tbody tr:last-child {
    border-bottom: none;
}

/* Zebra striping for alternate rows */
.d-ht-row-alt {
    background: var(--card-alt);
}

.d-ht-row-alt .d-ht-time-cell {
    background: var(--card-alt);
}

.d-hourly-table tbody tr:hover {
    background: var(--hover-overlay);
}

/* Highlight latest row (first row since reversed) */
.d-ht-row-now {
    background: rgba(255,255,255,0.04) !important;
    position: relative;
}

.d-ht-row-now td:first-child {
    border-left: 3px solid var(--text-bright);
}

.d-ht-row-now:hover {
    background: rgba(255,255,255,0.07) !important;
}

/* Sticky time cell (first column in body) */
.d-ht-time-cell {
    padding: 0.55rem 0.8rem 0.55rem 1.25rem;
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 2;
    white-space: nowrap;
}

.d-hourly-table tbody tr:hover .d-ht-time-cell {
    background: var(--card-hover);
}

.d-ht-row-now .d-ht-time-cell {
    background: rgba(255,255,255,0.04);
}

.d-ht-row-now:hover .d-ht-time-cell {
    background: rgba(255,255,255,0.07);
}

.d-ht-time {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: 0.04em;
}

.d-ht-date {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-top: 1px;
}

.d-ht-now-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 10px var(--green), 0 0 4px var(--green);
    animation: glow-pulse 2s ease-in-out infinite;
}

/* Data cells */
.d-ht-cell {
    padding: 0.5rem 0.6rem;
    text-align: center;
    min-width: 110px;
    transition: background 0.15s;
}

.d-ht-avg {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.3;
}

.d-ht-peak {
    display: block;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-dim);
    line-height: 1.2;
    margin-top: 1px;
}

.d-ht-err .d-ht-avg {
    color: var(--gray);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.d-ht-empty .d-ht-avg {
    color: var(--text-dim);
    opacity: 0.35;
    font-size: 0.7rem;
}

/* ================================
   TEMPERATURE TREND CHART
   ================================ */
.d-chart-section {
    margin-top: 2rem;
    margin-bottom: 2rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(0,0,0,0.2);
}

.d-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--card-alt);
}

.d-chart-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-bright);
    margin: 0;
    letter-spacing: 0.03em;
}

.d-chart-controls {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.d-chart-toggles {
    display: flex;
    gap: 2px;
    background: rgba(0,0,0,0.2);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.d-chart-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-dim);
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.d-chart-toggle:hover {
    color: var(--text-bright);
    background: rgba(255,255,255,0.06);
}

.d-chart-toggle.active {
    background: var(--text-bright);
    color: #000;
    box-shadow: 0 2px 10px rgba(255,255,255,0.15);
}

.d-chart-refresh {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--chip-bg);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.d-chart-refresh:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
    color: var(--text-bright);
}

.d-ct-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blue);
    flex-shrink: 0;
}

.d-ct-peak .d-ct-dot,
.d-ct-dot.d-ct-peak {
    background: var(--orange);
}

.d-ct-both .d-ct-dot,
.d-ct-dot.d-ct-both {
    background: linear-gradient(135deg, var(--blue), var(--orange));
}

.d-chart-toggle.active .d-ct-dot {
    background: #000;
}

.d-chart-toggle.active .d-ct-dot.d-ct-peak {
    background: #000;
}

.d-chart-toggle.active .d-ct-dot.d-ct-both {
    background: linear-gradient(135deg, #000, #333);
}

#siloTempChart {
    padding: 0.75rem 0.75rem 0.25rem;
    min-height: 380px;
}

/* Light mode hourly & chart overrides */
[data-theme="light"] .d-ht-time-col,
[data-theme="light"] .d-ht-time-cell {
    background: var(--card);
}

[data-theme="light"] .d-ht-row-alt .d-ht-time-cell,
[data-theme="light"] .d-ht-row-alt {
    background: var(--card-alt);
}

[data-theme="light"] .d-hourly-table tbody tr:hover .d-ht-time-cell {
    background: var(--card-hover);
}

[data-theme="light"] .d-hourly-section,
[data-theme="light"] .d-chart-section {
    box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

[data-theme="light"] .d-chart-toggles {
    background: rgba(0,0,0,0.04);
    border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .d-chart-toggle:hover {
    background: rgba(0,0,0,0.04);
    color: var(--text-bright);
}

[data-theme="light"] .d-ht-row-now {
    background: rgba(0,0,0,0.03) !important;
}

[data-theme="light"] .d-ht-row-now td:first-child {
    border-left-color: var(--text-bright);
}

[data-theme="light"] .d-ht-row-now:hover {
    background: rgba(0,0,0,0.05) !important;
}

[data-theme="light"] .d-ht-row-now .d-ht-time-cell {
    background: rgba(0,0,0,0.03);
}

[data-theme="light"] .d-ht-row-now:hover .d-ht-time-cell {
    background: rgba(0,0,0,0.05);
}

[data-theme="light"] .d-hourly-header,
[data-theme="light"] .d-chart-header {
    background: var(--card-alt);
}

[data-theme="light"] .d-hourly-table thead th {
    background: var(--card-alt);
}

[data-theme="light"] .d-chart-refresh {
    background: rgba(0,0,0,0.03);
}

[data-theme="light"] .d-chart-refresh:hover {
    background: rgba(0,0,0,0.06);
}

[data-theme="light"] .d-chart-toggle.active {
    background: var(--text-bright);
    color: #fff;
}

[data-theme="light"] .d-chart-toggle.active .d-ct-dot {
    background: #fff;
}

[data-theme="light"] .d-chart-toggle.active .d-ct-dot.d-ct-peak {
    background: #fff;
}

[data-theme="light"] .d-chart-toggle.active .d-ct-dot.d-ct-both {
    background: linear-gradient(135deg, #fff, #ddd);
}

[data-theme="light"] .d-brand-icon {
    color: var(--text-bright);
    opacity: 0.4;
}

/* ================================
   RESPONSIVE — COMPREHENSIVE MOBILE-FIRST
   ================================ */

/* --- Extra small phones (max-width: 420px) --- */
@media (max-width: 420px) {
    .d-topbar {
        padding: 0 0.6rem;
        gap: 0.35rem;
        height: 44px;
    }

    .d-brand-text { font-size: 0.78rem; }
    .d-brand-thin { display: none; }
    .d-brand-divider, .d-brand-module { display: none; }
    .d-brand-icon { font-size: 0.9rem; }

    .d-stats-strip {
        display: flex;
        gap: 0.15rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 1;
        min-width: 0;
    }
    .d-stats-strip::-webkit-scrollbar { display: none; }

    .d-stat-chip {
        padding: 0.15rem 0.45rem;
        min-width: 40px;
    }
    .d-stat-num { font-size: 0.75rem; }
    .d-stat-lbl { font-size: 0.45rem; letter-spacing: 0.06em; }

    .d-topbar-right { gap: 0.35rem; }
    .d-clock { font-size: 0.7rem; display: none; }
    .d-btn-theme, .d-btn-refresh { width: 30px; height: 30px; }
    .d-theme-ico { font-size: 0.9rem; }

    .d-body { padding: 0.6rem; }

    .d-silo-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .d-card-top { padding: 0.8rem 1rem 0.35rem; }
    .d-silo-name { font-size: 0.9rem; }
    .d-silo-sub { font-size: 0.6rem; }
    .d-status-pill { font-size: 0.5rem; padding: 0.15rem 0.5rem; }

    .d-temp-hero { padding: 0.4rem 0 0.3rem; }
    .d-temp-big { font-size: 2.2rem; }
    .d-temp-deg { font-size: 0.9rem; }
    .d-temp-sub { font-size: 0.5rem; }

    .d-card-stats { padding: 0.5rem 0.8rem; }
    .d-cs-val { font-size: 0.8rem; }
    .d-cs-lbl { font-size: 0.45rem; }

    .d-health-bar { margin: 0.4rem 0.8rem 0; }
    .d-cable-bars { height: 36px; padding: 0.4rem 0.8rem 0.2rem; gap: 2px; }
    .d-cb-lbl { font-size: 0.4rem; }
    .d-card-foot { padding: 0.4rem 0.8rem; font-size: 0.65rem; }

    /* Viz section */
    .d-viz-section { border-radius: 8px; margin-bottom: 12px; }
    .d-viz-header { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .d-viz-title { font-size: 13px; }
    .d-viz-sub { font-size: 10px; }
    .d-viz-btns { width: 100%; display: flex; gap: 4px; }
    .d-viz-btn { padding: 5px 10px; font-size: 10px; flex: 1; text-align: center; }
    .d-viz-canvas-wrap { padding: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .d-viz-legend { padding: 8px 12px; gap: 8px; }
    .d-viz-legend-label { font-size: 9px; }
    .d-viz-legend-item { font-size: 9px; gap: 3px; }
    .d-viz-dot { width: 10px; height: 10px; }

    /* Session grid */
    .d-hourly-section { margin-top: 0.75rem; border-radius: 8px; }
    .d-hourly-header { padding: 0.65rem 0.8rem; }
    .d-hourly-header-left { flex-direction: column; gap: 0.15rem; }
    .d-hourly-title { font-size: 0.78rem; }
    .d-hourly-sub { font-size: 0.55rem; }
    .d-hourly-table { min-width: 360px; }
    .d-ht-time-col { min-width: 80px; width: 85px; padding-left: 0.6rem !important; }
    .d-ht-time-cell { padding: 0.4rem 0.5rem 0.4rem 0.6rem; }
    .d-ht-time { font-size: 0.7rem; }
    .d-ht-silo-hdr { min-width: 100px; }
    .d-ht-silo-num { font-size: 0.65rem; }
    .d-ht-silo-desc { font-size: 0.5rem; }
    .d-ht-cell { min-width: 90px; padding: 0.35rem 0.4rem; }
    .d-ht-avg { font-size: 0.78rem; }
    .d-ht-peak { font-size: 0.52rem; }

    /* Chart */
    .d-chart-section { margin-top: 0.75rem; border-radius: 8px; margin-bottom: 1rem; }
    .d-chart-header { padding: 0.65rem 0.8rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .d-chart-title { font-size: 0.78rem; }
    .d-chart-controls { width: 100%; }
    .d-chart-toggles { width: 100%; }
    .d-chart-toggle { flex: 1; justify-content: center; padding: 0.3rem 0.5rem; font-size: 0.6rem; }
    .d-ct-dot { width: 5px; height: 5px; }
    #siloTempChart { min-height: 250px; padding: 0.4rem 0.25rem 0.2rem; }

    /* Detail page */
    .d-sensor { width: 48px; height: 48px; border-radius: 8px; }
    .ds-id { font-size: 0.45rem; }
    .ds-val { font-size: 0.85rem; }
    .ds-unit { font-size: 0.4rem; }
    .d-cable { padding: 0.7rem 0.8rem; }
    .d-cable-head h3 { font-size: 0.8rem; }
    .d-cable-meta { gap: 0.5rem; font-size: 0.65rem; }
    .d-sensors { gap: 4px; }
    .d-legend { padding: 0.7rem 0.8rem; gap: 0.8rem; font-size: 0.65rem; }
    .d-alerts { border-radius: 8px; }
    .d-alerts-head { padding: 0.6rem 0.8rem; font-size: 0.7rem; }
    .d-alert-row { padding: 0.35rem 0.5rem; font-size: 0.7rem; gap: 0.4rem; }
    .d-alert-loc { font-size: 0.65rem; }
    .d-alert-val { font-size: 0.65rem; }
    .d-alert-tag { font-size: 0.48rem; }

    /* Settings button on mobile */
    .d-btn-settings { width: 30px; height: 30px; }
    .d-settings-ico { font-size: 1rem; }
}

/* --- Small phones & narrow screens (421px - 640px) --- */
@media (min-width: 421px) and (max-width: 640px) {
    .d-topbar {
        padding: 0 0.75rem;
        gap: 0.4rem;
        height: 46px;
    }

    .d-brand-text { font-size: 0.82rem; }
    .d-brand-thin { display: none; }
    .d-brand-module { font-size: 0.7rem; }

    .d-stats-strip {
        display: flex;
        gap: 0.15rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 1;
        min-width: 0;
    }
    .d-stats-strip::-webkit-scrollbar { display: none; }

    .d-stat-chip { padding: 0.15rem 0.55rem; }
    .d-stat-num { font-size: 0.8rem; }
    .d-stat-lbl { font-size: 0.48rem; }

    .d-clock { font-size: 0.72rem; }
    .d-btn-theme, .d-btn-refresh { width: 32px; height: 32px; }

    .d-body { padding: 0.75rem; }

    .d-silo-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .d-card-top { padding: 0.9rem 1.1rem 0.4rem; }
    .d-silo-name { font-size: 0.95rem; }
    .d-temp-big { font-size: 2.5rem; }
    .d-card-stats { padding: 0.55rem 1rem; }

    /* Viz section */
    .d-viz-header { padding: 12px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .d-viz-btns { width: 100%; }
    .d-viz-btn { flex: 1; text-align: center; padding: 6px 12px; font-size: 11px; }
    .d-viz-canvas-wrap { padding: 10px; }

    /* Session grid */
    .d-hourly-section { margin-top: 0.85rem; }
    .d-hourly-header { padding: 0.7rem 1rem; }
    .d-hourly-title { font-size: 0.82rem; }
    .d-ht-time-col { min-width: 90px; width: 95px; }

    /* Chart */
    .d-chart-section { margin-top: 0.85rem; }
    .d-chart-header { padding: 0.7rem 1rem; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .d-chart-controls { width: 100%; }
    .d-chart-toggles { width: 100%; }
    .d-chart-toggle { flex: 1; justify-content: center; font-size: 0.65rem; }
    #siloTempChart { min-height: 280px; }

    /* Detail page */
    .d-sensor { width: 54px; height: 54px; }
    .d-cable { padding: 0.8rem 1rem; }
}

/* --- Tablets / Medium screens (641px - 768px) --- */
@media (min-width: 641px) and (max-width: 768px) {
    .d-topbar {
        padding: 0 1rem;
        gap: 0.75rem;
        height: 50px;
    }

    .d-brand-text { font-size: 0.88rem; }
    .d-stat-chip { padding: 0.18rem 0.7rem; }

    .d-body { padding: 1rem; }

    .d-silo-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .d-temp-big { font-size: 2.8rem; }

    /* Viz: let header be row on tablet */
    .d-viz-header { padding: 14px 16px; }
    .d-viz-btn { padding: 6px 14px; font-size: 11px; }

    .d-chart-header { gap: 0.75rem; }
    .d-chart-toggle { font-size: 0.68rem; }

    .d-sensor { width: 60px; height: 60px; }
}

/* --- Small desktop / wide tablets (769px - 1024px) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    .d-silo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .d-body { padding: 1.5rem; }
    .d-temp-big { font-size: 2.8rem; }
}

/* --- Standard desktop (1025px - 1200px) --- */
@media (min-width: 1025px) and (max-width: 1200px) {
    .d-silo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Large desktop (1201px+) --- */
@media (min-width: 1201px) {
    .d-silo-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

/* === MOBILE TOUCH OPTIMIZATIONS === */
@media (hover: none) and (pointer: coarse) {
    /* Bigger touch targets */
    .d-silo-card { cursor: default; }
    .d-silo-card:hover { transform: none; }
    .d-silo-card:active { transform: scale(0.98); background: var(--card-hover); }

    .d-viz-btn { min-height: 36px; }
    .d-chart-toggle { min-height: 34px; }
    .d-btn-theme, .d-btn-refresh { min-width: 36px; min-height: 36px; }

    /* Disable hover effects that look weird on touch */
    .d-card-arrow { transform: none !important; }
    .d-silo-card:hover .d-card-arrow { transform: none !important; }
}

/* ================================
   THEME TOGGLE BUTTON
   ================================ */
.d-btn-theme {
    background: var(--chip-bg);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.d-btn-theme:hover {
    background: var(--card-hover);
    border-color: var(--border-light);
    transform: scale(1.05);
}

.d-theme-ico {
    font-size: 1.1rem;
    display: inline-block;
    transition: transform 0.4s ease;
}

.d-btn-theme:hover .d-theme-ico {
    transform: rotate(25deg);
}

/* ================================
   GLOBAL TRANSITION HELPERS
   ================================ */
.d-silo-card,
.d-cable,
.d-sensor,
.d-legend,
.d-alerts,
.d-stat-chip,
.d-status-pill,
.d-btn-back,
.d-btn-refresh,
.d-hourly-section,
.d-chart-section {
    transition: all 0.3s ease;
}

/* ================================
   LIGHT MODE — CARD GLOW OVERRIDES
   ================================ */
[data-theme="light"] .d-silo-card.s-normal { box-shadow: 0 2px 16px rgba(5,150,105,0.08); }
[data-theme="light"] .d-silo-card.s-warninga,
[data-theme="light"] .d-silo-card.s-warningb { box-shadow: 0 2px 16px rgba(234,88,12,0.08); }
[data-theme="light"] .d-silo-card.s-alarm { box-shadow: 0 2px 20px rgba(220,38,38,0.1); }
[data-theme="light"] .d-silo-card.s-error { box-shadow: 0 2px 16px rgba(107,114,128,0.08); }

[data-theme="light"] .d-silo-card:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

[data-theme="light"] .s-temp-ok { color: var(--green); text-shadow: none; }
[data-theme="light"] .s-temp-warn { color: var(--orange); text-shadow: none; }
[data-theme="light"] .s-temp-alarm { color: var(--red); text-shadow: none; }

/* Custom scrollbar globally */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

[data-theme="light"] .d-alerts {
    background: rgba(220,38,38,0.04);
    border-color: rgba(220,38,38,0.12);
}

[data-theme="light"] .d-alerts-head {
    border-bottom-color: rgba(220,38,38,0.08);
}

[data-theme="light"] .d-cable.c-normal { border-left-color: var(--green); }
[data-theme="light"] .d-cable.c-warninga { border-left-color: var(--yellow); }
[data-theme="light"] .d-cable.c-warningb { border-left-color: var(--orange); }
[data-theme="light"] .d-cable.c-alarm { border-left-color: var(--red); }
[data-theme="light"] .d-cable.c-error { border-left-color: var(--gray); }

/* Light sensor tiles — slightly stronger bg for contrast */
[data-theme="light"] .ds-normal {
    background: rgba(22,163,74,0.08);
    border-color: rgba(22,163,74,0.2);
}
[data-theme="light"] .ds-warninga {
    background: rgba(202,138,4,0.08);
    border-color: rgba(202,138,4,0.2);
}
[data-theme="light"] .ds-warningb {
    background: rgba(234,88,12,0.08);
    border-color: rgba(234,88,12,0.2);
}
[data-theme="light"] .ds-alarm {
    background: rgba(220,38,38,0.08);
    border-color: rgba(220,38,38,0.2);
}
[data-theme="light"] .ds-error {
    background: rgba(107,114,128,0.06);
    border-color: rgba(107,114,128,0.15);
}

/* Light status pills */
[data-theme="light"] .s-pill-normal { background: rgba(22,163,74,0.08); border-color: rgba(22,163,74,0.2); }
[data-theme="light"] .s-pill-warninga,
[data-theme="light"] .s-pill-warningb { background: rgba(234,88,12,0.08); border-color: rgba(234,88,12,0.2); }
[data-theme="light"] .s-pill-alarm { background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.2); }
[data-theme="light"] .s-pill-error { background: rgba(220,38,38,0.06); border-color: rgba(220,38,38,0.15); }

/* Light accent lines */
[data-theme="light"] .s-accent-normal { background: linear-gradient(90deg, transparent, var(--green), transparent); }
[data-theme="light"] .s-accent-alarm { background: linear-gradient(90deg, transparent, var(--red), transparent); }
[data-theme="light"] .s-accent-error { background: linear-gradient(90deg, transparent, var(--gray), transparent); }

/* Light blazor error */
[data-theme="light"] #blazor-error-ui {
    background: #fff;
    color: #333;
    box-shadow: 0 -1px 8px rgba(0,0,0,0.1);
}

/* Light DashboardLayout shell */
[data-theme="light"] .dash-shell {
    background: var(--bg);
}

/* ================================
   SCROLLBAR STYLING
   ================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ================================
   SILO 3D VISUALIZATION
   ================================ */
.d-viz-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 1.5rem;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 4px 32px rgba(0,0,0,0.2);
}

.d-viz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--card-alt);
}

.d-viz-header-left { display: flex; flex-direction: column; gap: 2px; }

.d-viz-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
    margin: 0;
    letter-spacing: 0.03em;
}

.d-viz-sub {
    font-size: 12px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
}

.d-viz-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.d-viz-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.d-viz-btn:hover {
    background: var(--hover-overlay);
    border-color: var(--text-dim);
}

.d-viz-btn.active {
    background: var(--text-bright);
    color: var(--bg);
    border-color: var(--text-bright);
    box-shadow: 0 2px 12px rgba(255,255,255,0.12);
}

.d-viz-canvas-wrap {
    text-align: center;
    padding: 20px;
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.d-viz-tooltip {
    display: none;
    position: fixed;
    background: rgba(10,10,20,0.95);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
    line-height: 1.6;
    border: 1px solid rgba(255,255,255,0.08);
    max-width: calc(100vw - 32px);
}

.d-viz-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 20px 14px;
    border-top: 1px solid var(--border);
    background: var(--card-alt);
}

.d-viz-legend-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    font-family: 'JetBrains Mono', monospace;
}

.d-viz-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text);
}

.d-viz-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 1.5px solid rgba(255,255,255,0.15);
    box-shadow: 0 0 6px rgba(0,0,0,0.2);
}

.d-viz-dot-err {
    background: #6b7280;
    border: 2px dashed #ff3333;
}

[data-theme="light"] .d-viz-section { box-shadow: 0 2px 20px rgba(0,0,0,0.06); }
[data-theme="light"] .d-viz-dot { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .d-viz-tooltip { background: rgba(10,10,20,0.92); }
[data-theme="light"] .d-viz-btn.active { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
