:root {
    --bg: #0d1117;
    --bg-elev: #161b22;
    --bg-elev2: #1c2430;
    --border: #2a3441;
    --text: #e6edf3;
    --muted: #8b97a6;
    --primary: #2f81f7;
    --primary-hover: #4a91f9;
    --green: #2ea043;
    --red: #e5534b;
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

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

h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-block;
    width: 100%;
    padding: .7rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .95rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elev2); }

/* ---------------- Flash ---------------- */
.flash {
    padding: .7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid var(--border);
}
.flash-error { background: rgba(229,83,75,.12); border-color: rgba(229,83,75,.4); color: #ff9b95; }
.flash-success { background: rgba(46,160,67,.12); border-color: rgba(46,160,67,.4); color: #6ee787; }

/* ---------------- Auth pages ---------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth-wrap { width: 100%; max-width: 400px; }
.brand {
    display: flex; align-items: center; gap: .6rem;
    justify-content: center; margin-bottom: 1.5rem;
    color: var(--text); font-weight: 700; font-size: 1.3rem;
}
.brand:hover { text-decoration: none; }

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
}
.card h1 { margin-bottom: 1rem; }

.form { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.form label { font-size: .85rem; color: var(--muted); margin-top: .6rem; }
.form input {
    width: 100%;
    padding: .6rem .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: .95rem;
}
.form input:focus { outline: none; border-color: var(--primary); }
.form .btn { margin-top: 1rem; }

.pw-row { position: relative; display: flex; align-items: center; }
.pw-row input { padding-right: 4rem; }
.pw-toggle {
    position: absolute; right: .4rem;
    background: none; border: none; color: var(--muted);
    cursor: pointer; font-size: .8rem; padding: .3rem .5rem;
}

.divider { display: flex; align-items: center; text-align: center; color: var(--muted); margin: 1.25rem 0; gap: .75rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.stack { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.25rem; }
.card > .muted.center { margin-top: 1rem; margin-bottom: 0; }

/* ---------------- App shell ---------------- */
.app-body { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    display: flex; flex-direction: column;
}
.sidebar .brand { justify-content: flex-start; font-size: 1.15rem; margin-bottom: 1.5rem; }
.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav a {
    padding: .55rem .75rem; border-radius: 8px;
    color: var(--text); font-weight: 500; font-size: .95rem;
}
.nav a:hover { background: var(--bg-elev2); text-decoration: none; }
.nav a.active { background: var(--bg-elev2); color: var(--primary); }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.user-email { font-size: .8rem; color: var(--muted); margin-bottom: .5rem; word-break: break-all; }
.logout { font-size: .9rem; color: var(--muted); }

.content { padding: 2rem 2.5rem; max-width: 1100px; }
.page-head { margin-bottom: 1.5rem; }

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    display: flex; flex-direction: column; gap: .35rem;
}
.stat-label { font-size: .82rem; color: var(--muted); }
.stat-value { font-size: 1.6rem; font-weight: 700; }

.panel {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

@media (max-width: 720px) {
    .app-body { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: .75rem; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { margin: 0 0 0 auto; border: none; padding: 0; }
    .content { padding: 1.5rem; }
}
