/* MiCityAI — Clerk Dashboard */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232733;
    --border: #2d3140;
    --text: #e4e6ef;
    --text-dim: #8b8fa3;
    --accent: #4a9eff;
    --accent-dim: #2d6bb5;
    --green: #34d399;
    --red: #f87171;
    --yellow: #fbbf24;
    --orange: #fb923c;
    --radius: 8px;
    --font: 'IBM Plex Sans', -apple-system, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "tnum";
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 16px; font-weight: 700; color: var(--accent); }
.city-name { font-size: 14px; font-weight: 600; }
.city-pop { font-size: 12px; color: var(--text-dim); }
.header-right { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-text { font-size: 12px; color: var(--text-dim); }

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0;
    overflow-x: auto;
}
.tab {
    flex: 1;
    min-width: 80px;
    padding: 10px 0;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    text-align: center;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab Content */
.tab-content { display: none; padding: 16px 20px; }
.tab-content.active { display: block; }

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.card.full-width { margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.card-subtitle { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }

/* Lists */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.list-item:last-child { border-bottom: none; }
.list-item.done { opacity: 0.5; }
.list-date { color: var(--text-dim); min-width: 90px; }
.list-name { flex: 1; margin: 0 12px; }
.list-value { font-weight: 600; font-feature-settings: "tnum"; }

/* Badges */
.badge-pending { background: var(--yellow); color: #000; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-complete { background: var(--green); color: #000; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-overdue { background: var(--red); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-open { background: var(--orange); color: #000; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { text-align: center; padding: 12px; background: var(--surface-2); border-radius: var(--radius); }
.stat-value { display: block; font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { display: block; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.stat.large { padding: 20px; }
.stat.large .stat-value { font-size: 36px; }

/* Ask */
.ask-container { display: flex; gap: 8px; margin-bottom: 16px; }
.ask-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
}
.ask-input:focus { border-color: var(--accent); }
.ask-result { background: var(--surface-2); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.ask-answer { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
.ask-sources { font-size: 11px; color: var(--text-dim); margin-top: 12px; }
.ask-examples ul { list-style: none; padding: 0; }
.ask-examples li { padding: 6px 12px; cursor: pointer; border-radius: 4px; font-size: 13px; color: var(--accent); }
.ask-examples li:hover { background: var(--surface-2); }
.ask-examples h4 { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }

/* Buttons */
.btn-primary {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}
.btn-secondary:hover { background: var(--border); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 8px; border-bottom: 2px solid var(--border); color: var(--text-dim); font-weight: 600; }
.table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.row-done { opacity: 0.5; }
.row-overdue { background: rgba(248, 113, 113, 0.08); }

/* Report Buttons */
.report-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.council-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* Settings */
.settings-list { font-size: 13px; }
.setting-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }

/* Empty State */
.empty { color: var(--text-dim); font-size: 13px; font-style: italic; padding: 12px 0; }

/* Radar / Alert Badges */
.badge-radar { padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.3px; }
.badge-urgent { background: var(--red); color: #fff; }
.badge-soon { background: var(--yellow); color: #000; }
.badge-watch { background: var(--green); color: #000; }
.badge-overdue-r { background: #991b1b; color: #fff; }

/* Grant card */
.grant-card { background: var(--surface-2); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; border-left: 3px solid var(--border); }
.grant-card.tier-urgent { border-left-color: var(--red); }
.grant-card.tier-soon { border-left-color: var(--yellow); }
.grant-card.tier-watch { border-left-color: var(--green); }
.grant-card .grant-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.grant-card .grant-title { font-weight: 600; font-size: 13px; flex: 1; }
.grant-card .grant-meta { font-size: 11px; color: var(--text-dim); }
.grant-card .grant-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.grant-card .grant-fit { font-size: 10px; font-weight: 600; margin-left: 8px; white-space: nowrap; }

/* PA category accordion */
.pa-cat { background: var(--surface-2); border-radius: var(--radius); margin-bottom: 6px; overflow: hidden; }
.pa-cat-header { padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 13px; }
.pa-cat-header:hover { background: var(--border); }
.pa-cat-body { display: none; padding: 0 12px 12px; font-size: 12px; color: var(--text-dim); }
.pa-cat-body.open { display: block; }
.pa-cat-body ul { margin: 8px 0 0 16px; list-style: disc; }
.pa-cat-body li { margin-bottom: 4px; }


/* ─── Infrastructure Tab ──────────────────────────────────────────────────── */

.infra-card { margin-bottom: 20px; }
.infra-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}


/* ─── Water Loss ──────────────────────────────────────────────────────────── */

.status-pill {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}
.status-good { background: rgba(52, 211, 153, 0.15); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.status-watch { background: rgba(251, 191, 36, 0.15); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.3); }
.status-critical { background: rgba(248, 113, 113, 0.15); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.3); }

.recovery-project-card {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 14px;
    border-left: 3px solid var(--accent);
}
.recovery-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
}
.recovery-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.recovery-meta strong { color: var(--text); }
.recovery-desc { font-size: 12px; color: var(--text-dim); }


/* ─── Heat Map / Clusters ─────────────────────────────────────────────────── */

.cluster-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.cluster-row:last-child { border-bottom: none; }
.cluster-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    min-width: 28px;
    text-align: center;
    padding-top: 2px;
}
.cluster-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.cluster-meta { display: flex; gap: 12px; font-size: 12px; }
.cluster-count { color: var(--text-dim); }
.cluster-trend { font-weight: 600; }

.score-pill {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
}

.cip-textarea-wrap { margin-top: 4px; }
.cip-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px 14px;
    font-size: 12px;
    font-family: var(--font);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    resize: vertical;
    outline: none;
    line-height: 1.6;
}


/* ─── Equipment Fleet ─────────────────────────────────────────────────────── */

.fleet-table td { vertical-align: middle; }

.fleet-status-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.fleet-green { background: rgba(52, 211, 153, 0.15); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.fleet-yellow { background: rgba(251, 191, 36, 0.15); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.3); }
.fleet-red { background: rgba(248, 113, 113, 0.15); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.3); }

.lc-bar-wrap {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 4px;
    overflow: hidden;
}
.lc-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* TCO Comparison */
.tco-unit-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text-dim);
}
.tco-options {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.tco-option {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
    position: relative;
}
.tco-recommended {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.tco-recommended::before {
    content: 'RECOMMENDED';
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}
.tco-opt-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.tco-opt-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.tco-opt-period { font-size: 12px; font-weight: 400; color: var(--text-dim); }
.tco-opt-note { font-size: 11px; color: var(--text-dim); margin-top: 6px; }
.tco-rec {
    font-size: 12px;
    color: var(--text-dim);
    text-align: right;
}
.tco-rec strong { color: var(--accent); }

/* Grant Flags */
.fleet-grants-list { display: flex; flex-direction: column; gap: 8px; }
.grant-flag {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: var(--radius);
}
.grant-flag-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    margin-top: 2px;
}
.flag-eligible { background: rgba(52, 211, 153, 0.2); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.4); }
.flag-check { background: rgba(251, 191, 36, 0.2); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.4); }
.grant-flag-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.grant-flag-note { font-size: 12px; color: var(--text-dim); }

/* 5-Year Forecast */
.forecast-banner {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.forecast-total { display: flex; justify-content: space-between; align-items: center; }
.forecast-label { font-size: 13px; color: var(--text-dim); }
.forecast-value { font-size: 24px; font-weight: 700; color: var(--red); }
.forecast-note { font-size: 12px; color: var(--text-dim); }


/* ─── Rate Sufficiency ────────────────────────────────────────────────────── */

.rate-adjustment-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
}
.rate-adj-label { font-size: 13px; color: var(--text-dim); }
.rate-adj-value { font-size: 24px; font-weight: 700; }


/* ─── Legislative Watch ───────────────────────────────────────────────────── */

.session-status-badge {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.session-active { background: rgba(52, 211, 153, 0.15); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.session-adjourned { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }

.leg-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.leg-introduced { background: rgba(74, 158, 255, 0.15); color: var(--accent); border: 1px solid rgba(74, 158, 255, 0.3); }
.leg-committee { background: rgba(251, 191, 36, 0.15); color: var(--yellow); border: 1px solid rgba(251, 191, 36, 0.3); }
.leg-passed { background: rgba(52, 211, 153, 0.15); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.leg-signed { background: rgba(52, 211, 153, 0.25); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.5); }
.leg-failed { background: rgba(248, 113, 113, 0.15); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.3); }


/* ─── Tax Explainer ───────────────────────────────────────────────────────── */

.field-label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.input-prefix {
    padding: 10px 12px;
    background: var(--border);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 14px;
    color: var(--text-dim);
}
.input-with-prefix {
    border-radius: 0 var(--radius) var(--radius) 0;
}
.ask-container .input-prefix + .ask-input {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.tax-breakdown {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.tax-step {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.tax-step.highlight {
    border-color: var(--accent);
    background: rgba(74, 158, 255, 0.06);
}
.tax-step-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.tax-step-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.tax-final { font-size: 28px; color: var(--accent); }
.tax-step-note { font-size: 11px; color: var(--text-dim); }
.tax-arrow {
    text-align: center;
    color: var(--text-dim);
    font-size: 18px;
    line-height: 1.2;
    padding: 4px 0;
}

.tax-yoy {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.tax-yoy-label { font-size: 12px; color: var(--text-dim); }
.tax-yoy-value { font-size: 15px; font-weight: 700; }

.tax-plain-english {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.7;
    padding: 14px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border-left: 3px solid var(--accent);
}


/* Responsive */
@media (max-width: 900px) {
    .tco-options { grid-template-columns: 1fr; }
    .stats-grid[style*="grid-template-columns:1fr 1fr 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
    .nav-tabs { overflow-x: auto; }
    .tab { font-size: 12px; white-space: nowrap; }
    .infra-card-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
