:root {
    --sidebar-width: 15.5rem;
    --content-padding: 2rem 2.5rem 2.5rem;
    --font-base: 1rem;
    --font-lg: 1.125rem;
}

html, body {
    font-size: 16px;
}

body {
    margin: 0;
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    border-right: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(0, 0, 0, 0.15);
    transition: width 0.2s ease;
}

.admin-sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.admin-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.admin-toolbar {
    min-height: 3.25rem;
    padding: 0 0.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.admin-toolbar-static {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
}

.admin-toolbar-static .toolbar-brand {
    flex: 1;
}

.admin-toolbar-static .toolbar-logout {
    color: inherit;
    text-decoration: none;
    font-weight: 600;
    opacity: 0.85;
}

.admin-toolbar-static .toolbar-logout:hover {
    opacity: 1;
    text-decoration: underline;
}

.toolbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
}

.toolbar-domain {
    opacity: 0.75;
    font-size: var(--font-base);
}

.toolbar-icon {
    font-size: 1.35rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.admin-content {
    flex: 1;
    width: 100%;
    max-width: none;
    padding: var(--content-padding);
    box-sizing: border-box;
}

.admin-login-shell {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #0f172a 100%);
}

/* Sidebar */
.sidebar {
    height: 100%;
    min-height: 100vh;
    padding: 1.25rem 0.85rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-sizing: border-box;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.25rem 0.65rem 0.5rem;
}

.sidebar-brand strong {
    display: block;
    font-size: 1.05rem;
}

.sidebar-brand small {
    opacity: 0.65;
    font-size: 0.85rem;
}

.sidebar-logo {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    color: white;
    flex-shrink: 0;
}

.sidebar-logo.large {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.15rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 0.9rem;
    border-radius: 0.75rem;
    text-decoration: none;
    color: inherit;
    font-size: var(--font-lg);
    font-weight: 500;
    opacity: 0.82;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.nav-item svg {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
    opacity: 0.9;
}

.nav-item:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    opacity: 1;
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
}

.sidebar-footer {
    padding: 0.75rem 0.9rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer-label {
    font-size: 0.8rem;
    opacity: 0.55;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-footer code {
    font-size: 0.85rem;
    opacity: 0.8;
    word-break: break-all;
}

/* Page hero headers — each page different color */
.page-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.page-hero-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.page-hero-icon svg {
    width: 1.85rem;
    height: 1.85rem;
}

.page-hero-text h1 {
    margin: 0 0 0.35rem;
    font-size: 1.85rem;
    font-weight: 700;
}

.page-hero-text p {
    margin: 0;
    font-size: var(--font-lg);
    opacity: 0.78;
    max-width: 42rem;
}

.page-hero-badge {
    margin-left: auto;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: var(--font-base);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.hero-dashboard { background: linear-gradient(135deg, rgba(56,189,248,0.12), rgba(99,102,241,0.08)); }
.hero-dashboard .page-hero-icon { background: rgba(56,189,248,0.2); color: #7dd3fc; }

.hero-devices { background: linear-gradient(135deg, rgba(167,139,250,0.12), rgba(129,140,248,0.08)); }
.hero-devices .page-hero-icon { background: rgba(167,139,250,0.2); color: #c4b5fd; }

.hero-backups { background: linear-gradient(135deg, rgba(45,212,191,0.12), rgba(56,189,248,0.06)); }
.hero-backups .page-hero-icon { background: rgba(45,212,191,0.2); color: #5eead4; }

.hero-ai { background: linear-gradient(135deg, rgba(244,114,182,0.12), rgba(167,139,250,0.08)); }
.hero-ai .page-hero-icon { background: rgba(244,114,182,0.2); color: #f9a8d4; }

.hero-settings { background: linear-gradient(135deg, rgba(148,163,184,0.12), rgba(100,116,139,0.08)); }
.hero-settings .page-hero-icon { background: rgba(148,163,184,0.2); color: #cbd5e1; }

/* KPI cards */
.kpi-grid {
    display: grid;
    gap: 1.15rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1.5rem;
}

.kpi-card {
    border-radius: 1rem;
    padding: 1.35rem 1.4rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.18);
    min-height: 8.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.35rem;
}

.kpi-title {
    opacity: 0.75;
    font-size: var(--font-base);
    font-weight: 500;
}

.kpi-value {
    font-size: 2.75rem;
    line-height: 1.05;
    font-weight: 700;
}

.kpi-subtitle {
    opacity: 0.65;
    font-size: 0.95rem;
}

.kpi-card.accent-blue { border-left: 5px solid #38bdf8; }
.kpi-card.accent-teal { border-left: 5px solid #2dd4bf; }
.kpi-card.accent-violet { border-left: 5px solid #a78bfa; }
.kpi-card.accent-indigo { border-left: 5px solid #818cf8; }
.kpi-card.accent-green { border-left: 5px solid #4ade80; }
.kpi-card.accent-amber { border-left: 5px solid #fbbf24; }

/* Panels & cards */
.dashboard-panels {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: 1.15fr 1fr;
}

.panel-card,
.content-card {
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem 1.35rem 1rem;
    background: rgba(0, 0, 0, 0.18);
}

.panel-card-header h2,
.content-card h2 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.panel-card-header p {
    margin: 0 0 1rem;
    opacity: 0.7;
    font-size: var(--font-base);
}

.content-card {
    padding: 1.35rem;
}

.settings-card {
    padding: 1.5rem 1.75rem 1.75rem;
}

.settings-tabs {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-tab {
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(226, 232, 240, 0.72);
    cursor: pointer;
    font-size: var(--font-lg);
    margin-bottom: -1px;
    padding: 0.65rem 1rem 0.85rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.settings-tab:hover {
    color: #f8fafc;
}

.settings-tab.active {
    border-bottom-color: #818cf8;
    color: #f8fafc;
}

.settings-tab-panel {
    padding-top: 0.25rem;
}

.settings-value {
    font-size: var(--font-lg);
}

.settings-db-status {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-db-ok {
    color: #4ade80;
}

.settings-db-warn {
    color: #fbbf24;
}

.settings-db-error {
    color: #f87171;
}

.settings-db-pending {
    opacity: 0.75;
}

.settings-db-button {
    margin-top: 0.25rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(99, 102, 241, 0.25);
    color: inherit;
    font-size: var(--font-base);
    cursor: pointer;
}

.settings-db-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-db-button:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.4);
}

.devices-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 1rem;
}

.devices-message {
    margin: 0 0 1rem;
}

.dashboard-chart {
    min-height: 360px;
}

.chart-empty {
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    border-radius: 0.75rem;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    color: rgba(226, 232, 240, 0.75);
    font-size: var(--font-lg);
}

.simple-bar-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.65rem;
    min-height: 280px;
    padding: 1rem 0.5rem 0.25rem;
}

.simple-bar-day {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.simple-bar-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.25rem;
    width: 100%;
    height: 220px;
}

.simple-bar {
    width: 42%;
    min-height: 0;
    border-radius: 0.35rem 0.35rem 0 0;
    transition: height 0.25s ease;
}

.simple-bar.total {
    background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
}

.simple-bar.success {
    background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}

.simple-bar-label {
    font-size: 0.8rem;
    opacity: 0.75;
    text-align: center;
}

.simple-bar-legend {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 0.75rem;
    font-size: var(--font-base);
    opacity: 0.85;
}

.legend-dot {
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.legend-dot.total {
    background: #6366f1;
}

.legend-dot.success {
    background: #34d399;
}

.data-grid {
    font-size: var(--font-base);
}

.data-grid-full {
    min-height: 520px;
}

.data-grid-tall {
    min-height: 420px;
}

.empty-hint,
.hint {
    opacity: 0.75;
    font-size: var(--font-base);
    margin-top: 0.5rem;
}

.loading-block {
    padding: 3rem 0;
    font-size: var(--font-lg);
    opacity: 0.8;
}

/* Login */
.login-panel {
    width: min(420px, 100%);
    margin: 0 auto;
}

.login-panel-inner {
    border-radius: 1rem;
    padding: 2rem 2.25rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.login-brand {
    display: flex;
    gap: 1.15rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.65rem;
}

.login-brand p {
    margin: 0.25rem 0 0;
    opacity: 0.75;
    font-size: var(--font-base);
}

.login-error {
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.5rem;
    background: rgba(239, 68, 68, 0.18);
    color: #fecaca;
    font-size: var(--font-base);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.login-label {
    font-weight: 600;
    font-size: var(--font-base);
    color: #e2e8f0;
}

.login-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.85rem 1rem;
    min-height: 2.85rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #0f172a;
    color: #f8fafc;
    font-size: var(--font-lg);
    line-height: 1.4;
}

.login-input::placeholder {
    color: rgba(148, 163, 184, 0.65);
}

.login-input:focus {
    outline: 2px solid #38bdf8;
    outline-offset: 1px;
    border-color: #38bdf8;
}

.login-button-native {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.85rem 1rem;
    border: none;
    border-radius: 0.55rem;
    font-weight: 600;
    font-size: var(--font-lg);
    cursor: pointer;
    background: #38bdf8;
    color: white;
}

@media (max-width: 1200px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-hero-badge {
        display: none;
    }
}

@media (max-width: 768px) {
    :root {
        --content-padding: 1rem 1rem 1.5rem;
        --sidebar-width: 100%;
    }

    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar:not(.collapsed) {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    }

    .sidebar {
        min-height: auto;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav-item span {
        display: none;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .kpi-value {
        font-size: 2.2rem;
    }

    .page-hero {
        flex-wrap: wrap;
    }

    .page-hero-text h1 {
        font-size: 1.45rem;
    }
}
