/* ==========================================================================
   Successful Citizen — minimal command-center stylesheet
   Single accent (muted blue). Light by default, dark via [data-theme="dark"].
   ========================================================================== */

:root {
    --bg:           #ffffff;
    --bg-soft:      #fafafa;
    --bg-sunken:    #f5f5f6;
    --surface:      #ffffff;
    --border:       #e7e7e9;
    --border-strong:#d6d6d9;
    --ink:          #14161a;
    --ink-soft:     #4a4f57;
    --muted:        #8a8f98;
    --accent:       #2c5fbe;     /* muted blue — single accent across app */
    --accent-soft:  #eaf0fb;
    --warn:         #b6671a;
    --warn-soft:    #fff4e2;
    --danger:       #b03434;
    --danger-soft:  #fbe8e8;
    --ok:           #2e7d4f;
    --shadow:       0 1px 0 rgba(20,22,26,.04);
    --radius:       8px;
    --radius-sm:    4px;
    --gap:          18px;
    --gap-sm:       10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
            Arial, "Inter", "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
    --bg:            #0f1115;
    --bg-soft:       #14161b;
    --bg-sunken:     #0b0d11;
    --surface:       #181b21;
    --border:        #262931;
    --border-strong: #353944;
    --ink:           #e9eaee;
    --ink-soft:      #b6bac3;
    --muted:         #7a7f8a;
    --accent:        #5d8af0;
    --accent-soft:   #1d2940;
    --warn:          #d49751;
    --warn-soft:     #2a2014;
    --danger:        #d96363;
    --danger-soft:   #2c1717;
    --ok:            #6cc28d;
    --shadow:        0 1px 0 rgba(0,0,0,.3);
}

/* Base ------------------------------------------------------------------ */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
    margin: 0 0 .4em;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 .8em; }
hr.divider { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--bg-sunken); padding: 1px 5px; border-radius: 3px; }
pre.prewrap { white-space: pre-wrap; font-family: var(--mono); background: var(--bg-sunken); padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow-x: auto; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.warn { color: var(--warn); }

/* App shell ------------------------------------------------------------- */

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

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

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.logo-mark {
    width: 28px; height: 28px;
    background: var(--ink);
    color: var(--bg);
    border-radius: 6px;
    display: grid; place-items: center;
    font-weight: 700; font-size: 14px;
    letter-spacing: -0.02em;
}
[data-theme="dark"] .logo-mark { background: var(--ink); color: var(--bg); }
.brand-name { font-weight: 600; font-size: 0.98rem; }
.brand-tag { display: block; font-size: 0.72rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 0.92rem;
}
.nav a:hover { background: var(--bg-sunken); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.sidebar-foot {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--muted);
}
.sidebar-foot a { color: var(--ink-soft); }

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 12px;
}
.topbar-actions { display: flex; gap: 8px; }

.page-body { padding: 24px 28px 60px; max-width: 1200px; width: 100%; }

footer.app-foot {
    padding: 18px 28px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    text-align: left;
}

/* Buttons --------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font: inherit; font-size: 0.88rem;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-sunken); text-decoration: none; }
.btn-primary {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.btn-primary:hover { opacity: .9; background: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--ink); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { padding: 4px 9px; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

.link-btn {
    background: none; border: none; padding: 0;
    color: var(--accent); cursor: pointer; font: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

/* Forms ----------------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field > span {
    display: block; margin-bottom: 5px;
    font-size: 0.82rem; color: var(--ink-soft); font-weight: 500;
}
input[type="text"], input[type="number"], input[type="email"],
input[type="password"], input[type="date"], input[type="search"],
select, textarea {
    width: 100%;
    padding: 8px 11px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font: inherit;
    font-size: 0.9rem;
}
input[type="file"] { font-size: 0.85rem; }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-grid { display: flex; flex-direction: column; gap: var(--gap); }
.form-actions { display: flex; gap: 10px; padding: 4px 0 12px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { min-width: 140px; max-width: 240px; flex: 0 0 auto; }
.filters .muted { margin-left: auto; }

/* Cards / metrics / grids ---------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    margin-bottom: var(--gap);
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; }

.grid { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--gap);
    overflow: hidden;
}
.metric {
    background: var(--surface);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.metric-label { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.metric-value { font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.metric-value.warn { color: var(--warn); }
.metric-sub { font-size: 0.75rem; }

/* Project grid / list / cards ------------------------------------------ */

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.project-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--ink);
    transition: border-color .12s, transform .12s;
}
.project-card:hover { border-color: var(--border-strong); text-decoration: none; }
.project-card-head { display: flex; align-items: center; gap: 8px; }
.project-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card-meta { font-size: 0.78rem; }
.project-summary {
    font-size: 0.85rem; color: var(--ink-soft); margin: 4px 0 6px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-list { list-style: none; padding: 0; margin: 0; }
.project-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.project-list li:last-child { border-bottom: none; }
.project-list a { color: var(--ink); }
.project-list a:hover { text-decoration: none; color: var(--accent); }

/* Project detail page --------------------------------------------------- */

.project-header {
    display: flex; align-items: flex-start; gap: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--gap);
    flex-wrap: wrap;
}
.project-header-main { flex: 1; min-width: 260px; }
.project-h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; font-size: 1.5rem; }
.project-tagline { color: var(--ink-soft); margin: 0; font-size: 0.95rem; }
.project-meta-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.project-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.progress-block { display: flex; align-items: center; gap: 14px; margin: 18px 0; }
.progress-block .progress.big { flex: 1; height: 10px; }
.progress-percent { font-weight: 600; min-width: 48px; text-align: right; }

.progress {
    background: var(--bg-sunken);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
    position: relative;
}
.progress-bar {
    background: var(--accent);
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
}
.progress.big { height: 10px; }

.quick-status { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.quick-status select { max-width: 220px; }

.ai-card { border-left: 3px solid var(--accent); background: var(--accent-soft); }
[data-theme="dark"] .ai-card { background: var(--accent-soft); border-left-color: var(--accent); }

/* Tasks / milestones / notes / activity --------------------------------- */

.task-list { list-style: none; padding: 0; margin: 0 0 12px; }
.task-list li {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}
.task-list li:last-child { border-bottom: none; }
.task-row { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; }
.task-row .task-title { flex: 1; }
.task-title.done { text-decoration: line-through; color: var(--muted); }
.task-actions { display: flex; gap: 6px; align-items: center; }
.task-toggle-top {
    color: var(--muted); cursor: pointer; font-size: 1rem;
    background: none; border: none; padding: 2px 4px;
}
.task-toggle-top.is-top { color: var(--accent); }

.milestone-list, .note-list, .activity-list, .dump-list { list-style: none; padding: 0; margin: 0; }
.milestone-list li, .note-list li, .activity-list li, .dump-list li {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.milestone-list li:last-child, .note-list li:last-child,
.activity-list li:last-child, .dump-list li:last-child { border-bottom: none; }

.milestone-row { display: flex; align-items: center; gap: 8px; }
.milestone-row .milestone-title { flex: 1; }
.milestone-row .done { text-decoration: line-through; color: var(--muted); }

.note-list .note-body { white-space: pre-wrap; }
.note-list .note-meta { font-size: 0.78rem; color: var(--muted); margin-top: 3px; }

.activity-list li { display: flex; gap: 10px; align-items: baseline; font-size: 0.85rem; }
.activity-time { color: var(--muted); font-size: 0.78rem; min-width: 90px; }
.activity-event { color: var(--ink-soft); }

.dump-list li { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; }
.dump-body { white-space: pre-wrap; }
.dump-meta { display: flex; gap: 10px; font-size: 0.78rem; color: var(--muted); align-items: center; flex-wrap: wrap; }
.dump-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Status dots / pills / tags ------------------------------------------- */

.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted);
    display: inline-block;
    flex: 0 0 auto;
}
.dot.status-inbox    { background: #94a0b3; }
.dot.status-this-week  { background: #2c5fbe; }   /* accent */
.dot.status-this-quarter { background: #6589d6; }
.dot.status-parked   { background: #b69b5e; }
.dot.status-blocked  { background: #b03434; }
.dot.status-waiting  { background: #b6671a; }
.dot.status-shipped  { background: #2e7d4f; }
.dot.status-completed{ background: #2e7d4f; }
.dot.status-archived { background: #8a8f98; }

.pill {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    background: var(--bg-sunken);
    color: var(--ink-soft);
    border: 1px solid var(--border);
}
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag {
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 3px;
    background: var(--bg-sunken);
    color: var(--ink-soft);
    border: 1px solid var(--border);
}

.priority-p1 { color: var(--danger); font-weight: 600; }
.priority-p2 { color: var(--warn); font-weight: 600; }
.priority-p3 { color: var(--ink); }
.priority-p4 { color: var(--muted); }
.priority-p5 { color: var(--muted); font-style: italic; }

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

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--gap);
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--bg-soft);
}
.alert-warn    { background: var(--warn-soft);   border-color: #e8c891; color: var(--warn); }
.alert-error   { background: var(--danger-soft); border-color: #e3b3b3; color: var(--danger); }
.alert-success { background: #ebf5ee; border-color: #b8d8c2; color: var(--ok); }
[data-theme="dark"] .alert-success { background: #15291f; border-color: #234b34; color: var(--ok); }

/* Bar charts ------------------------------------------------------------ */

.bar-chart { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.bar-chart li { display: grid; grid-template-columns: 130px 1fr 38px; gap: 10px; align-items: center; }
.bar-label { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--bg-sunken); border-radius: 3px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 3px; }
.bar-value { font-size: 0.82rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Data tables ----------------------------------------------------------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-weight: 600; color: var(--ink-soft); background: var(--bg-soft); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table tr:last-child td { border-bottom: none; }

/* Settings KV grid ------------------------------------------------------ */

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.kv .muted { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.small-heading { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 8px; }
.export-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

/* Login ----------------------------------------------------------------- */

.auth-body {
    min-height: 100vh;
    display: grid; place-items: center;
    background: var(--bg-sunken);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    box-shadow: 0 8px 24px rgba(20,22,26,.06);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-foot { margin-top: 14px; text-align: center; color: var(--muted); font-size: 0.78rem; }

/* Mobile ---------------------------------------------------------------- */

.menu-toggle {
    display: none;
    background: none; border: none; padding: 6px;
    color: var(--ink); cursor: pointer; font-size: 1.3rem;
}

/* Hidden by default on every viewport — only shown on mobile when `.is-open` is added by JS. */
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 240px;
        z-index: 50;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 30px rgba(0,0,0,.15);
    }
    .sidebar.is-open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .sidebar-backdrop {
        position: fixed; inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 40;
        display: none;
    }
    .sidebar-backdrop.is-open { display: block; }
    .topbar { padding: 14px 16px; }
    .page-body { padding: 16px 16px 60px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .project-header { gap: 10px; }
    .project-h1 { font-size: 1.25rem; }
    .bar-chart li { grid-template-columns: 90px 1fr 32px; gap: 8px; }
    .filters input, .filters select { min-width: 0; max-width: none; flex: 1 1 calc(50% - 8px); }
    .topbar-actions .btn { padding: 6px 10px; font-size: 0.8rem; }
    .topbar-actions .btn-text { display: none; }
}

@media (max-width: 480px) {
    .metric-value { font-size: 1.2rem; }
    .metric { padding: 12px 13px; }
    .topbar h1 { font-size: 1.05rem; }
    .filters { gap: 6px; }
    .filters > * { flex: 1 1 100%; }
    .filters .btn { flex: 0 0 auto; }
    .project-actions .btn { font-size: 0.78rem; padding: 5px 9px; }
    .bar-chart li { grid-template-columns: 70px 1fr 28px; }
}
