:root {
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-2: #161616;
    --border: #1f1f1f;
    --border-strong: #2a2a2a;
    --text: #fafafa;
    --muted: #71717a;
    --accent: #3b82f6;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
    --radius: 10px;
    --sidebar-w: 240px;
}

[data-theme="light"] {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #0a0a0a;
    --muted: #71717a;
    --shadow: 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; padding: 0; margin: 0; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- layout ---------- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    padding: 0 8px;
}
.logo { font-size: 22px; line-height: 1; color: var(--muted); }
.logo-text { letter-spacing: -.01em; }

.link-group-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 0 8px 6px;
}
.link-group ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--text);
    font-weight: 450;
}
.link-group ul li a:hover {
    background: var(--surface-2);
    text-decoration: none;
}
.dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
}

.sidebar-foot {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.theme-toggle, .logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    background: transparent;
    border: 0;
    color: var(--muted);
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    text-align: left;
}
.theme-toggle:hover, .logout:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

/* ---------- main ---------- */
.main {
    padding: 24px 32px 60px;
    max-width: 1400px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 12px;
}
.greeting .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.search-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    min-width: 220px;
    justify-content: space-between;
}
.search-hint:hover { border-color: var(--border-strong); }
.search-hint kbd {
    font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", monospace;
    font-size: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text);
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 24px 0 12px;
}

/* ---------- kpis ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    opacity: .9;
}
.kpi-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}
.kpi-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

/* ---------- project cards ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color .12s;
}
.card:hover { border-color: var(--border-strong); }
.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.card-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--accent);
}
.card h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.card h3 a:hover { text-decoration: underline; }
.card p { margin: 0 0 12px; font-size: 12px; }
.card-links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.card-links li a {
    font-size: 12px;
    padding: 3px 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
}
.card-links li a:hover {
    color: var(--text);
    text-decoration: none;
    border-color: var(--border-strong);
}

/* ---------- activity ---------- */
.activity {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.activity li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.activity li:last-child { border-bottom: 0; }
.activity-icon {
    width: 8px; height: 8px; border-radius: 50%;
}
.activity-text { flex: 1; }
.activity-time { font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- palette ---------- */
.palette {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 16px;
    z-index: 50;
}
.palette[hidden] { display: none; }
.palette-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    width: 100%;
    max-width: 520px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.palette-card input {
    width: 100%;
    background: transparent;
    border: 0;
    padding: 14px 16px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    border-bottom: 1px solid var(--border);
}
.palette-card ul li {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.palette-card ul li:hover,
.palette-card ul li[aria-selected="true"] {
    background: var(--surface-2);
}
.palette-card ul li .badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-left: auto;
}

/* ---------- login ---------- */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--bg);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    width: 100%;
    max-width: 320px;
    text-align: center;
}
.login-logo { font-size: 36px; color: var(--muted); line-height: 1; }
.login-card h1 { margin: 8px 0 4px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.input {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
    outline: none;
}
.input:focus { border-color: var(--border-strong); }
.input.error { border-color: #ef4444; }
.btn {
    background: var(--text);
    color: var(--bg);
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
}
.btn:hover { opacity: .9; }
.error-msg { color: #ef4444; font-size: 12px; margin: 4px 0 0; }

/* ---------- menu toggle (mobile) ---------- */
.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
}

/* ---------- responsive ---------- */
@media (max-width: 880px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .menu-toggle {
        display: inline-flex;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 84%;
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 45;
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
    }
    .sidebar[data-open="true"] {
        transform: translateX(0);
    }
    .main {
        padding: 60px 16px 60px;
    }
    .topbar {
        margin-bottom: 16px;
    }
    .search-hint {
        min-width: 0;
        flex: 1;
    }
}

@media (max-width: 480px) {
    .kpis {
        grid-template-columns: repeat(2, 1fr);
    }
    .cards {
        grid-template-columns: 1fr;
    }
    .kpi-value { font-size: 20px; }
}
