/* GASH v2 - Main Stylesheet */
/* CSS Custom Properties, Grid/Flexbox Layout, Dark/Light Mode */

/* ===== CSS Custom Properties ===== */
:root {
    /* Colors */
    --color-primary: #e94560;
    --color-primary-hover: #d63851;
    --color-primary-light: rgba(233, 69, 96, 0.15);

    /* Node colors */
    --node-1: #ff0000;
    --node-2: #00cc00;
    --node-3: #cc6600;
    --node-4: #0000ff;
    --node-5: #ff00ff;
    --node-6: #888888;
    --node-8: #ff8800;
    --node-9: #00cccc;
    --node-10: #990000;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Sidebar */
    --sidebar-width: 240px;

    /* Transitions */
    --transition: 150ms ease;

    /* Font */
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Light theme */
[data-theme="light"] {
    --bg-body: #f5f5f7;
    --bg-card: #ffffff;
    --bg-sidebar: #f0f0f4;
    --bg-input: #ffffff;
    --bg-hover: #f0f0f2;
    --bg-code: #f0f0f2;
    --bg-table-stripe: #f8f8fa;
    --bg-badge: #e8e8ec;

    --border-color: #d1d1d6;
    --border-light: #e5e5ea;

    --text-primary: #1a1a2e;
    --text-secondary: #636366;
    --text-muted: #8e8e93;
    --text-inverse: #ffffff;

    --sidebar-text: #3a3a4a;
    --sidebar-text-muted: #8e8e93;
    --sidebar-text-section: #a0a0a8;
    --sidebar-border: rgba(0,0,0,0.08);
    --sidebar-hover-bg: rgba(0,0,0,0.04);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    --status-ok: #34c759;
    --status-warn: #ff9500;
    --status-error: #ff3b30;
    --status-info: #007aff;

    --status-ok-bg: rgba(52, 199, 89, 0.12);
    --status-warn-bg: rgba(255, 149, 0, 0.12);
    --status-error-bg: rgba(255, 59, 48, 0.12);
    --status-info-bg: rgba(0, 122, 255, 0.12);
}

/* Dark theme */
[data-theme="dark"] {
    --bg-body: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-sidebar: #12121f;
    --bg-input: #16213e;
    --bg-hover: #1f2940;
    --bg-code: #16213e;
    --bg-table-stripe: #151528;
    --bg-badge: #2a2a42;

    --border-color: #2a2a42;
    --border-light: #222238;

    --text-primary: #e8e8ed;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;
    --text-inverse: #0f0f1a;

    --sidebar-text: #c0c0d0;
    --sidebar-text-muted: #a0a0b8;
    --sidebar-text-section: #666680;
    --sidebar-border: rgba(255,255,255,0.08);
    --sidebar-hover-bg: rgba(255,255,255,0.06);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

    --status-ok: #30d158;
    --status-warn: #ffd60a;
    --status-error: #ff453a;
    --status-info: #0a84ff;

    --status-ok-bg: rgba(48, 209, 88, 0.15);
    --status-warn-bg: rgba(255, 214, 10, 0.15);
    --status-error-bg: rgba(255, 69, 58, 0.15);
    --status-info-bg: rgba(10, 132, 255, 0.15);
}

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

html { font-size: 14px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ===== App Layout ===== */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

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

.sidebar-header {
    padding: var(--space-lg) var(--space-md);
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}
.sidebar-logo:hover { text-decoration: none; }
.sidebar-logo svg { stroke: var(--color-primary); }

.nav-list {
    list-style: none;
    padding: var(--space-sm) 0;
    flex: 1;
}

.nav-section {
    padding: var(--space-lg) var(--space-md) var(--space-xs);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text-section);
}

.nav-list li a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--sidebar-text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    font-size: 0.9rem;
}

.nav-list li a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-list li a.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 500;
}

.nav-list li a.active svg { stroke: var(--color-primary); }

.nav-toggle { display: none; }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.page-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.user-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Page Content ===== */
.page-content {
    flex: 1;
    padding: var(--space-lg);
}

/* ===== Login Layout ===== */
.login-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: var(--space-lg);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.login-header svg {
    stroke: var(--color-primary);
    margin-bottom: var(--space-sm);
}

.login-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: var(--space-xs);
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.login-form .form-group { margin-bottom: var(--space-md); }

.login-form .btn { margin-top: var(--space-sm); }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* ===== Grid Layouts ===== */
.grid { display: grid; gap: var(--space-lg); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ===== Dashboard Cards ===== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.stat-card-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===== Status indicators ===== */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: var(--space-xs);
}
.status-dot.ok { background: var(--status-ok); }
.status-dot.warn { background: var(--status-warn); }
.status-dot.error { background: var(--status-error); }
.status-dot.offline { background: var(--text-muted); }

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-badge.ok { background: var(--status-ok-bg); color: var(--status-ok); }
.status-badge.warn { background: var(--status-warn-bg); color: var(--status-warn); }
.status-badge.error { background: var(--status-error-bg); color: var(--status-error); }
.status-badge.info { background: var(--status-info-bg); color: var(--status-info); }

/* ===== Forms ===== */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

select {
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-danger {
    background: var(--status-error);
    border-color: var(--status-error);
    color: #fff;
}
.btn-danger:hover { background: #e0332b; }

.btn-warning {
    background: var(--status-warn);
    border-color: var(--status-warn);
    color: #fff;
}
.btn-warning:hover { background: #e88700; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-xs { padding: 2px 8px; font-size: 0.75rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; border: none; background: transparent; color: var(--text-secondary); }
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); border-radius: var(--radius-sm); }

.btn-group {
    display: flex;
    gap: 1px;
}
.btn-group .btn {
    border-radius: 0;
}
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

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

.data-table th {
    background: var(--bg-card);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.data-table tbody tr:nth-child(even) { background: var(--bg-table-stripe); }
.data-table tbody tr:hover { background: var(--bg-hover); }

.data-table.table-compact th { padding: 6px 8px; }
.data-table.table-compact td { padding: 4px 8px; }

.data-table.table-narrow th,
.data-table.table-narrow td { white-space: nowrap; width: 1%; }
.data-table.table-narrow td:last-child,
.data-table.table-narrow th:last-child { white-space: normal; width: auto; }

.boiler-filter {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px var(--space-lg);
}
.boiler-filter input[type="date"] {
    padding: 2px 6px;
    font-size: 0.78rem;
    width: 130px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.boiler-filter input[type="text"] {
    padding: 2px 6px;
    font-size: 0.78rem;
    width: 150px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Digital value styles */
.data-table td.digital-on {
    background: var(--status-ok-bg);
    color: var(--status-ok);
    font-weight: 600;
}
.data-table td.digital-off {
    color: var(--text-muted);
}
.data-table td.alarm {
    background: var(--status-error-bg);
    color: var(--status-error);
    font-weight: 600;
}

/* Trend arrows */
.trend-up { color: var(--status-error); }
.trend-up::after { content: ' \2197'; }
.trend-down { color: var(--status-info); }
.trend-down::after { content: ' \2198'; }
.trend-stable { color: var(--text-muted); }
.trend-stable::after { content: ' \2192'; }

/* ===== Alerts ===== */
.alert {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: 0.85rem;
}
.alert-success { background: var(--status-ok-bg); color: var(--status-ok); }
.alert-error { background: var(--status-error-bg); color: var(--status-error); }
.alert-warning { background: var(--status-warn-bg); color: var(--status-warn); }
.alert-info { background: var(--status-info-bg); color: var(--status-info); }

/* ===== Admin Notice ===== */
.admin-notice {
    background: var(--status-warn-bg);
    color: var(--status-warn);
    border-left: 4px solid var(--status-warn);
    padding: var(--space-sm) var(--space-lg);
    margin: 0 var(--space-lg);
    margin-top: var(--space-md);
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.admin-notice-date {
    opacity: 0.6;
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ===== Filters ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    align-items: flex-end;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}
.date-inputs input { width: auto; font-size: 0.82rem; }
.date-sep { color: var(--text-muted); padding: 0 2px; }

.date-presets {
    display: flex;
    gap: 4px;
    margin-top: var(--space-xs);
}
.date-presets .btn { font-family: var(--font-mono); }
.date-presets .btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.node-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.node-check {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
}
.node-check:hover { background: var(--bg-hover); }
.node-check input:checked + .node-check-label { color: var(--node-color); font-weight: 600; }
.node-check input { display: none; }
.node-check-label::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--node-color, #888);
    margin-right: 4px;
    opacity: 0.4;
    vertical-align: middle;
}
.node-check input:checked + .node-check-label::before { opacity: 1; }

/* ===== Chart ===== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    overflow: hidden;
}

.chart-svg {
    width: 100%;
    display: block;
}


.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    font-size: 0.8rem;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.chart-legend-item:hover { background: var(--bg-hover); }
.chart-legend-item.hidden { opacity: 0.4; }

.chart-legend-color {
    width: 12px;
    height: 3px;
    border-radius: 1px;
}

.chart-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    font-size: 0.8rem;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    z-index: 1000;
    font-family: var(--font-mono);
}

/* ===== Custom Chart Legend (right side) ===== */
.gash-chart-wrapper {
    display: flex;
    gap: var(--space-sm);
    width: 100%;
}

.gash-chart-area {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.gash-chart-legend {
    width: 160px;
    flex-shrink: 0;
    overflow-y: auto;
    max-height: 600px;
    padding: var(--space-xs) 0;
    font-size: 0.75rem;
    border-left: 1px solid var(--border-light);
    padding-left: var(--space-sm);
}

.gash-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition), opacity var(--transition);
    line-height: 1.3;
}

.gash-legend-item:hover {
    background: var(--bg-hover);
}

.gash-legend-item.inactive {
    opacity: 0.3;
}

.gash-legend-color {
    width: 12px;
    height: 3px;
    border-radius: 1px;
    flex-shrink: 0;
}

.gash-legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.gash-legend-item:hover .gash-legend-label {
    color: var(--text-primary);
}

/* Resolution info text */
#resolution-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: var(--space-xs) 0;
}

/* ===== Parameter Grid (v1-style table) ===== */
.param-grid-wrapper {
    overflow-x: auto;
    margin-bottom: var(--space-md);
}

.param-grid-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-sm);
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--space-xs);
}
.param-grid-toggle:hover {
    color: var(--text-primary);
}

.param-grid-wrapper.collapsed .param-grid {
    display: none;
}
.param-grid-wrapper.collapsed .param-grid-toggle {
    border-bottom: none;
    margin-bottom: 0;
}

.param-grid {
    border-collapse: collapse;
    font-size: 0.78rem;
    width: 100%;
    min-width: 600px;
}

.param-grid th,
.param-grid td {
    border: 1px solid var(--border-light);
    padding: 3px 5px;
    text-align: center;
    white-space: nowrap;
}

.param-grid thead th {
    background: var(--bg-card);
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 2;
}

.param-grid .param-label-cell {
    text-align: right;
    font-weight: 500;
    color: var(--text-secondary);
    padding-right: 8px;
    white-space: nowrap;
    background: var(--bg-card);
    position: sticky;
    left: 0;
    z-index: 1;
}

.param-grid .param-kwb-cell {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding-left: 8px;
    background: var(--bg-card);
}

.param-grid .param-section td {
    background: var(--bg-hover);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 4px 8px;
    text-align: left;
}

.param-grid .param-cell {
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
    min-width: 54px;
}

.param-grid .param-cell:hover {
    background: var(--bg-hover);
}

.param-grid .param-cell.active {
    font-weight: 600;
}

.param-grid .param-cell input[type="checkbox"] {
    display: none;
}

.param-grid .param-cell .cell-color {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    cursor: pointer;
    vertical-align: middle;
    opacity: 0.35;
    vertical-align: middle;
    opacity: 0.3;
    transition: opacity var(--transition);
}

.param-grid .param-cell.active .cell-color {
    opacity: 1;
    border-color: var(--text-primary);
}

.param-grid .param-cell .param-info {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: block;
    line-height: 1.1;
}

.param-grid .param-cell.active .param-info {
    color: var(--text-primary);
}

.param-grid .param-cell.unavailable {
    background: var(--bg-table-stripe);
    cursor: default;
}


/* ===== Preset Panel ===== */
.preset-panel {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.preset-panel select { width: auto; min-width: 150px; }

/* ===== Dashboard Specifics ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.node-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border-left: 3px solid var(--node-color, var(--border-color));
}

.node-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    cursor: pointer;
    user-select: none;
}
.node-card.collapsed .node-card-header {
    margin-bottom: 0;
}
.node-card.collapsed .node-card-values {
    display: none;
}

.node-card-chevron {
    display: inline-block;
    font-size: 0.7em;
    margin-right: 4px;
    color: var(--text-muted);
}

.node-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}

.node-card-drag {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0 6px 0 0;
    user-select: none;
    line-height: 1;
}
.node-card-drag:active { cursor: grabbing; }

.node-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.node-card.dragging {
    opacity: 0.4;
}
.node-card.drag-over-top {
    box-shadow: 0 -3px 0 0 var(--color-primary);
}
.node-card.drag-over-bottom {
    box-shadow: 0 3px 0 0 var(--color-primary);
}

.node-card-values {
    display: grid;
    gap: 2px;
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

.node-card-row {
    display: flex;
    justify-content: space-between;
}

.node-card-label {
    color: var(--text-secondary);
}

/* ===== Sparkline ===== */
.sparkline {
    display: inline-block;
    vertical-align: middle;
}
.sparkline polyline {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 1.5;
}

/* ===== Profile / Admin Forms ===== */
.form-card {
    max-width: 600px;
}

.form-card .form-group:last-of-type { margin-bottom: var(--space-lg); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-actions {
    display: flex;
    gap: var(--space-sm);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

/* Admin table actions */
.table-actions {
    display: flex;
    gap: 4px;
}
.table-actions .btn { padding: 2px 6px; font-size: 0.75rem; }

/* ===== User Dropdown ===== */
.user-dropdown { position: relative; }
.user-dropdown-toggle { display: flex; align-items: center; gap: 4px; background: none; border: none;
    color: var(--text-secondary); cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 0.85rem; }
.user-dropdown-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }
.user-dropdown-menu { display: none; position: absolute; top: 100%; right: 0; margin-top: 4px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); min-width: 160px; z-index: 200; overflow: hidden; }
.user-dropdown.open .user-dropdown-menu { display: block; }
.user-dropdown-item { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
    color: var(--text-primary); text-decoration: none; font-size: 0.85rem; }
.user-dropdown-item:hover { background: var(--bg-hover); color: var(--color-primary); text-decoration: none; }

/* ===== Help Page ===== */
.help-section-title { font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin: var(--space-lg) 0 var(--space-sm) 0; }
.help-section-title:first-child { margin-top: 0; }
.help-text { padding: var(--space-md) var(--space-lg); color: var(--text-secondary); line-height: 1.7; font-size: 0.9rem; }
.help-text h4 { color: var(--text-primary); margin: var(--space-md) 0 var(--space-xs) 0; }
.help-text p { margin: 0 0 var(--space-sm) 0; }
.help-text ul, .help-text ol { margin: 0 0 var(--space-sm) 0; padding-left: var(--space-lg); }

/* ===== Help Modal ===== */
.help-modal-body { padding: var(--space-md) var(--space-lg); color: var(--text-secondary);
    line-height: 1.7; font-size: 0.9rem; max-height: 60vh; overflow-y: auto; }
.help-modal-body h4 { color: var(--text-primary); margin: var(--space-md) 0 var(--space-xs) 0; }
.help-modal-body p { margin: 0 0 var(--space-sm) 0; }
.help-modal-body ul, .help-modal-body ol { margin: 0 0 var(--space-sm) 0; padding-left: var(--space-lg); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }

    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 300ms ease;
        width: 240px;
        height: auto;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    body.nav-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 99;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 4px;
    }

    .page-content { padding: var(--space-md); }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

    .filter-bar { flex-direction: column; }
    .date-inputs { flex-direction: column; }
    .date-inputs input { width: 100%; }

    .form-row { grid-template-columns: 1fr; }

    .user-dropdown-toggle .user-info { display: none; }

    .gash-chart-wrapper { flex-direction: column; }
    .gash-chart-legend {
        width: 100%;
        max-height: 120px;
        border-left: none;
        border-top: 1px solid var(--border-light);
        padding-left: 0;
        padding-top: var(--space-xs);
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-xs);
    }
}

@media (max-width: 480px) {
    html { font-size: 13px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--status-error); }
.text-ok { color: var(--status-ok); }
.text-mono { font-family: var(--font-mono); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* ===== Loading spinner ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}
.loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: var(--space-sm);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Color input for chart params ===== */
input[type="color"] {
    width: 28px;
    height: 28px;
    padding: 1px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}
.modal-overlay.hidden {
    display: none;
}
.modal-content {
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-content .card {
    margin: 0;
}

/* ===== Cell sublabel (realtime table per-node labels) ===== */
.cell-sublabel {
    font-size: 0.75em;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 2px;
}

/* ===== Alert info ===== */
.alert-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--text-color);
    border-left: 3px solid #3b82f6;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}

/* ===== Clickable table cells ===== */
.clickable-cell {
    cursor: pointer;
    transition: background var(--transition);
}
.clickable-cell:hover {
    background: var(--bg-hover);
}
