/* Kept in sync by hand with app/colors.py / app/theme.py's Palette. */
:root {
    --navy: #0F2A43;
    --navy-light: #16374F;
    --teal: #1ABC9C;
    --teal-dark: #149174;
    --amber: #F5A623;
    --red: #E74C3C;
    --green: #2ECC71;
    --bg: #F4F6F8;
    --panel: #FFFFFF;
    --border: #E1E5EA;
    --text: #1F2933;
    --text-muted: #6B7785;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

.navbar {
    background: var(--navy);
    padding: 0;
}
.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 28px;
    color: #fff;
    text-decoration: none;
}
.brand:hover { text-decoration: none; background: var(--navy-light); }
.brand-icon { font-size: 38px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; gap: 3px; }
.brand-title { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.brand-subtitle { color: #9FB4C7; font-size: 12.5px; letter-spacing: .08em; font-weight: 600; }

.nav-bar {
    background: var(--navy-light);
    padding: 16px 28px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 22px 36px;
}
.nav-group { display: flex; flex-direction: column; gap: 8px; }
.nav-label {
    color: #8FA3B8;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
}
.nav-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.nav-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,255,255,0.06);
    color: #E4ECF4;
    padding: 7px 14px 7px 10px;
    border-radius: 20px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.08);
    transition: background .15s ease, transform .15s ease;
}
.nav-pill:hover {
    background: var(--teal);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}
.pill-icon { font-size: 17px; line-height: 1; }

.container { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 22px;
    margin-bottom: 18px;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.mini-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.mini-card h3 { margin: 6px 0 4px; font-size: 15px; color: var(--navy); }
.card-title-link { color: var(--navy); text-decoration: none; }
.card-title-link:hover { color: var(--teal-dark); text-decoration: underline; }
.mini-card p { margin: 0; font-size: 13px; color: var(--text-muted); }
.mini-card .metric { font-size: 26px; font-weight: 700; color: var(--teal-dark); }

h1, h2, h3 { color: var(--navy); }
.muted { color: var(--text-muted); font-size: 13.5px; }

.btn {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 9px 16px;
    font-size: 14px;
    cursor: pointer;
}
.btn:hover { background: var(--teal-dark); text-decoration: none; }
.btn.secondary { background: var(--panel); color: var(--navy); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red); }

table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th { text-align: left; background: var(--bg); padding: 8px 10px; border-bottom: 2px solid var(--border); position: sticky; top: 0; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
table.grid tr:nth-child(even) { background: #F7F9FB; }
table.grid th a { color: var(--navy); }

.form-control, .form-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--navy); }
.field .help { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.field .errorlist { color: var(--red); font-size: 12.5px; margin: 4px 0 0; padding: 0; list-style: none; }

.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; }
.messages li.success { background: #E5F8F1; color: #0B6B4F; }
.messages li.error { background: #FCEAE8; color: #A12D20; }

.error-banner { background: #FCEAE8; color: #A12D20; padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; }
.summary-banner { background: #E5F8F1; color: #0B6B4F; padding: 12px 14px; border-radius: 6px; margin-bottom: 16px; font-weight: 600; }

.preset-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.preset-bar a { font-size: 13px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 14px; color: var(--navy); }
.preset-bar a:hover { background: var(--bg); text-decoration: none; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13.5px; }

/* ===================== Mobile ===================== */
@media (max-width: 720px) {
    .container { padding: 16px 14px 40px; }

    .brand { padding: 16px 16px; gap: 12px; }
    .brand-icon { font-size: 28px; }
    .brand-title { font-size: 19px; }
    .brand-subtitle { font-size: 10.5px; }

    .nav-bar { padding: 12px 14px 14px; gap: 14px 18px; }
    .nav-pill { font-size: 12.5px; padding: 6px 11px 6px 9px; }
    .pill-icon { font-size: 15px; }

    h1 { font-size: 20px; }
    h2 { font-size: 17px; }

    .card-grid { grid-template-columns: 1fr; }

    .card, .mini-card { padding: 14px 14px; }

    /* Form rows that use inline flex+min-width on desktop should
       stack to one field per row on a narrow screen, full width */
    .field { min-width: 0 !important; width: 100%; }
    .toolbar > form,
    div[style*="display:flex"] {
        flex-direction: column;
        align-items: stretch !important;
    }
    .toolbar { flex-direction: row; } /* keep toolbar buttons inline, just wrap */

    table.grid { font-size: 12px; }
    table.grid th, table.grid td { padding: 6px 7px; }

    .preset-bar a { font-size: 12px; padding: 5px 9px; }

    /* Plotly's embedded chart div sometimes carries an inline min-width
       from its own JS sizing logic - force it to respect the viewport
       so it doesn't force horizontal scrolling on the whole page */
    .card > div { max-width: 100%; overflow-x: auto; }
}
