/* ============================================
   Kernel Pro — Dashboard v2
   Professional · Clean · Refined
   ============================================ */

:root {
    /* — Surface — */
    --bg-base:      #0c0d12;
    --bg-elevated:  #13141c;
    --bg-card:      #181924;
    --bg-card-hover:#1e2030;
    --bg-input:     #1a1b26;

    /* — Text — */
    --text-primary:   #e4e6ed;
    --text-secondary: #8b8fa4;
    --text-muted:     #555871;

    /* — Border — */
    --border:       #222436;
    --border-hover: #2e3148;

    /* — Accent — */
    --accent:       #4f7cff;
    --accent-dim:   rgba(79,124,255,0.12);
    --accent-hover: #3d6af0;

    /* — Semantic — */
    --green:  #34d399;
    --red:    #f87171;
    --amber:  #fbbf24;

    /* — Misc — */
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
    --radius-pill: 100px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03);
    --shadow-float: 0 8px 32px rgba(0,0,0,0.5);
    --sidebar-w: 240px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Noto Sans SC', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 14px;
    letter-spacing: -0.011em;
}

/* ───── Sidebar ───── */

.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
}
.sidebar.open { transform: translateX(0); }

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-head img {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: cover;
}
.sidebar-head span {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.sidebar-nav a.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 600;
}
.sidebar-nav-icon {
    width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.6;
}
.sidebar-nav a.active .sidebar-nav-icon { opacity: 1; }

.sidebar-foot {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-logout {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.15s;
}
.sidebar-logout:hover { color: var(--red); }

.sidebar-copy {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 8px;
    opacity: 0.6;
}

/* ───── Mobile overlay + hamburger ───── */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s var(--ease);
}
.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.hamburger {
    position: fixed;
    top: 14px; left: 14px;
    z-index: 101;
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.hamburger:active { background: var(--bg-card); }
.hamburger span {
    display: block;
    width: 16px; height: 1.5px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.2s var(--ease);
    transform-origin: center;
}
.hamburger.active span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* ───── Main layout ───── */

.main {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 64px 16px 40px;
}

.content {
    max-width: 540px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ───── User bar ───── */

.user-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}
.user-bar-avatar {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-input);
    flex-shrink: 0;
}
.user-bar-info { flex: 1; min-width: 0; }
.user-bar-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-bar-email {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-bar-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--accent-dim);
    color: var(--accent);
}

/* ───── Stats grid ───── */

.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s, transform 0.15s;
    position: relative;
    overflow: hidden;
}
.stat:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.stat-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 15px;
}
.stat-icon.blue  { background: rgba(79,124,255,0.1);  color: var(--accent); }
.stat-icon.green { background: rgba(52,211,153,0.1);  color: var(--green); }
.stat-icon.amber { background: rgba(251,191,36,0.1);  color: var(--amber); }
.stat-icon.red   { background: rgba(248,113,113,0.1); color: var(--red); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 0.02em;
}

.stat.accent {
    border-color: rgba(79,124,255,0.25);
    background: linear-gradient(135deg, rgba(79,124,255,0.06) 0%, var(--bg-card) 100%);
}

/* ───── Chart card ───── */

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
}
.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.chart-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.chart-body {
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-base);
    padding: 4px;
}
.chart-body canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
}

/* ───── Quick actions ───── */

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
    box-shadow: var(--shadow-card);
}
.btn-action:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}
.btn-action:active { transform: scale(0.98); }

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

/* ───── Toast ───── */

.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-120%);
    z-index: 5000;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-float);
    transition: transform 0.25s var(--ease);
    pointer-events: none;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success {
    background: rgba(52,211,153,0.12);
    color: var(--green);
    border-color: rgba(52,211,153,0.25);
}
.toast.error {
    background: rgba(248,113,113,0.12);
    color: var(--red);
    border-color: rgba(248,113,113,0.25);
}

/* ───── Skeleton ───── */

.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.8s ease infinite;
    border-radius: 4px;
    color: transparent !important;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ───── Scrollbar ───── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================
   Desktop — ≥ 1024px
   ============================================ */

@media (min-width: 1024px) {

    .hamburger,
    .sidebar-overlay { display: none; }

    .sidebar {
        position: fixed;
        transform: translateX(0);
        box-shadow: none;
    }

    .main {
        margin-left: var(--sidebar-w);
        padding: 32px 32px 48px;
    }

    .content {
        max-width: 1080px;
        display: grid;
        grid-template-columns: 280px 1fr;
        grid-template-rows: auto auto auto;
        gap: 16px;
        align-items: start;
    }

    /* User bar spans full width */
    .user-bar {
        grid-column: 1 / -1;
        padding: 20px 24px;
    }

    /* Stats in left column, stacked */
    .stats {
        grid-column: 1;
        grid-row: 2 / 4;
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .stat {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 18px 20px;
    }
    .stat-icon { margin-bottom: 0; }
    .stat-body { flex: 1; }
    .stat-value { font-size: 26px; }

    /* Chart in right area */
    .chart-card {
        grid-column: 2;
        grid-row: 2;
    }

    /* Actions in right area */
    .actions {
        grid-column: 2;
        grid-row: 3;
    }
}

@media (min-width: 1280px) {
    .main { padding: 36px 40px 56px; }
    .content { gap: 20px; }
    .stat-value { font-size: 30px; }
}

@media (min-width: 1600px) {
    :root { --sidebar-w: 260px; }
    .main { padding: 40px 48px 64px; }
    .content { max-width: 1200px; }
}
