:root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #202020;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);
    --gridline: #2c2c2a;

    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.12);

    --status-good: #0ca30c;
    --status-good-wash: rgba(12, 163, 12, 0.14);
    --status-warning: #fab219;
    --status-warning-wash: rgba(250, 178, 25, 0.14);
    --status-critical: #d03b3b;
    --status-critical-wash: rgba(208, 59, 59, 0.14);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--page-plane);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; }

a { color: var(--accent); }

/* ---------- Layout: sidebar + content ---------- */

.sidebar-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 0.25rem 0.75rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar nav.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }

.sidebar a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar a:hover { background: var(--surface-2); color: var(--text-primary); }
.sidebar a.active { background: var(--accent-wash); color: var(--accent); }

.sidebar .divider { border-top: 1px solid var(--border); margin: 0.75rem 0.25rem; }

.sidebar form { margin-top: auto; padding-top: 0.75rem; }
.sidebar form button {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.sidebar form button:hover { border-color: var(--border-strong); color: var(--text-primary); }

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1200px;
}

/* ---------- Top bar (auxiliary pages that still use it) ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.user-badge { margin-right: 0.5rem; color: var(--text-muted); font-size: 0.85rem; }

.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem; }

/* ---------- Typography rhythm ---------- */

h2 {
    font-size: 0.78rem;
    margin: 2rem 0 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
h2:first-child { margin-top: 0; }

/* ---------- Breadcrumbs / share tabs ---------- */

.breadcrumbs { margin-bottom: 1.25rem; color: var(--text-muted); font-size: 0.88rem; }
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); }

.shares { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.shares a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
}
.shares a.active { color: var(--accent); border-color: var(--accent); background: var(--accent-wash); }
.shares a:hover:not(.active) { border-color: var(--border-strong); color: var(--text-primary); }

/* ---------- Actions row / forms ---------- */

.actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.inline-form, .inline { display: flex; gap: 0.5rem; align-items: center; }

button, input[type="submit"] {
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.95rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: var(--font-sans);
    transition: opacity 0.12s ease;
}
button:hover { opacity: 0.88; }
button:active { opacity: 0.75; }

.btn-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
}
.btn-link:hover { border-color: var(--border-strong); color: var(--text-primary); }

input[type="text"], input[type="password"], input[type="file"], select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.rename-input { width: 130px; }

/* ---------- Tables ---------- */

.file-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

.file-table th, .file-table td {
    text-align: left;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.86rem;
}
.file-table thead th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--surface-2);
}
.file-table tbody tr:last-child td { border-bottom: none; }
.file-table tbody tr:hover { background: var(--surface-2); }

.file-table a { color: var(--text-secondary); text-decoration: none; }
.file-table a:hover { color: var(--accent); }

.row-actions { display: flex; gap: 0.6rem; align-items: center; }
.row-actions form button, .row-actions > a {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 0.3rem 0.4rem;
    font-weight: 400;
}
.row-actions form button:hover { color: var(--text-primary); background: var(--surface-2); }

.empty { text-align: center; color: var(--text-muted); padding: 1.5rem !important; }

/* ---------- Status badges ---------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}
.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-ok { background: var(--status-good-wash); color: var(--status-good); }
.status-down { background: var(--status-critical-wash); color: var(--status-critical); }
.status-warn { background: var(--status-warning-wash); color: var(--status-warning); }

/* ---------- Dashboard: stat tiles + meters ---------- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.dashboard-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
}
.dashboard-card h3 {
    margin: 0 0 0.6rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.dashboard-card .big-stat {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.dashboard-card .stat-sub {
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.meter-track {
    margin-top: 0.7rem;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}
.meter-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.3s ease;
}
.meter-fill.status-good { background: var(--status-good); }
.meter-fill.status-warning { background: var(--status-warning); }
.meter-fill.status-critical { background: var(--status-critical); }

/* ---------- Apps grid ---------- */

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.app-card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.2rem;
    text-align: center;
}
.app-icon {
    font-size: 1.9rem;
    margin-bottom: 0.5rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    margin-left: auto;
    margin-right: auto;
}
.app-card h3 { margin: 0.2rem 0 0.3rem; font-size: 0.95rem; }
.app-desc { color: var(--text-muted); font-size: 0.8rem; min-height: 2.6rem; line-height: 1.4; }
.app-actions { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.9rem; }

/* ---------- Auth pages ---------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 20%, rgba(57, 135, 229, 0.08), transparent 40%),
        var(--page-plane);
}

.auth-box {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    width: 320px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.auth-box h1 { font-size: 1.2rem; margin: 0 0 0.3rem; }
.auth-box p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0; }

.auth-box label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}
.auth-box input { display: block; width: 100%; margin-top: 0.35rem; }
.auth-box button { width: 100%; margin-top: 0.5rem; padding: 0.6rem; }

/* ---------- Alerts ---------- */

.alert {
    background: var(--status-critical-wash);
    border: 1px solid rgba(208, 59, 59, 0.35);
    color: #f0908f;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.alert-ok {
    background: var(--accent-wash);
    border-color: rgba(57, 135, 229, 0.35);
    color: #7fb3ef;
}
