:root {
    --bg:      #f4f6f9;
    --bg2:     #ffffff;
    --accent:  #1a5c9e;
    --accent2: #2272c3;
    --navy:    #1a2332;
    --text:    #1a2332;
    --muted:   #5a6a7a;
    --border:  #d0d7e0;
    --danger:  #c0392b;
    --success: #1e8449;
    --warn:    #c8820a;
    --zero:    #b8c2ce;
    --shadow:  0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Barlow', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Nav ---- */
nav {
    background: var(--navy);
    border-bottom: 3px solid var(--accent);
    display: flex; align-items: stretch; padding: 0; min-height: 64px;
}
.nav-brand {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 24px; background: #ffffff;
    border-right: 3px solid var(--accent); text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand img { height: 42px; width: auto; display: block; }
.nav-brand-text {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.95rem; font-weight: 700; color: var(--navy);
    letter-spacing: 0.08em; text-transform: uppercase;
}
nav a.nav-link {
    color: #ffffff; text-decoration: none; padding: 0 20px;
    font-size: 0.85rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; transition: color 0.15s, background 0.15s;
    border-right: 1px solid #2e3d55; display: flex; align-items: center;
}
nav a.nav-link:hover, nav a.nav-link.active {
    color: #ffffff; background: var(--accent2); text-decoration: none;
}

.container { max-width: 1800px; margin: 0 auto; padding: 28px 24px; }

/* ---- Page header ---- */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--border);
    flex-wrap: wrap; gap: 16px;
}
.page-title {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.8rem;
    font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.page-title span { color: var(--accent); }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.page-sub strong { color: var(--text); }
.head-actions { display: flex; align-items: flex-end; gap: 12px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
    border: none; border-radius: 4px; font-family: 'Barlow', sans-serif;
    font-size: 0.85rem; font-weight: 500; letter-spacing: 0.04em;
    text-transform: uppercase; cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: #f0f5fc; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

.icon-btn {
    border: none; background: none; cursor: pointer; font-size: 15px;
    padding: 4px 7px; border-radius: 4px; color: var(--muted); line-height: 1;
}
.icon-btn:hover { background: #f0f5fc; color: var(--accent); }
.del-btn:hover { background: #fdf0ee; color: var(--danger); }

/* ---- Alerts ---- */
.alert { padding: 12px 18px; border-radius: 4px; margin-bottom: 20px; font-size: 0.9rem; border-left: 4px solid; }
.alert-success { background: #eafaf1; border-color: var(--success); color: #1a6e3c; }
.alert-warning { background: #fef9ec; border-color: var(--warn); color: #7d5a00; }
.alert-error,
.alert-danger { background: #fdf0ee; border-color: var(--danger); color: #922b21; }
.alert-info { background: #eaf4fb; border-color: #2980b9; color: #1a5276; }

/* ---- Stat pills / quarter strip ---- */
.stat-row { display: flex; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.stat-pill {
    flex: 1; min-width: 130px;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 14px 20px; font-family: 'Barlow Condensed', sans-serif; box-shadow: var(--shadow);
}
.stat-pill.accent { background: var(--navy); border-color: var(--navy); }
.stat-pill.accent .stat-num { color: #fff; }
.stat-pill.accent .stat-lbl { color: #aeb9c7; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-num.small { font-size: 1.1rem; }
.stat-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }

.sort-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sort-label select {
    display: block; margin-top: 6px; padding: 8px 12px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px; font-family: 'Barlow', sans-serif; font-size: 0.9rem; cursor: pointer;
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.grid thead tr { background: #f8f9fb; }
table.grid th {
    padding: 11px 14px; text-align: left; font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--border);
    white-space: nowrap; position: sticky; top: 0; background: #f8f9fb; z-index: 1;
}
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover td { background: #f0f5fc; }
table.grid td.company { font-weight: 500; }
.zero { color: var(--zero); }
.total-col { background: #eef4fb; }
table.grid thead .total-col { background: #e6eef8; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
table.grid thead .sticky-col { background: #f8f9fb; z-index: 2; }
table.grid tbody tr:hover .sticky-col { background: #f0f5fc; }
table.grid tfoot td {
    border-top: 2px solid var(--navy); background: #f8f9fb;
    font-variant-numeric: tabular-nums; font-weight: 700;
}
table.grid tfoot .sticky-col { background: #f8f9fb; }
.actions-col { text-align: center; width: 74px; }

/* ---- Cards / charts ---- */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 0.9rem; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
    background: #f8f9fb; border-radius: 6px 6px 0 0;
}
.card-body { padding: 20px; }

/* Legacy two-column layout (kept for any other page). */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.chart-card.wide { grid-column: 1 / -1; }

/* Dashboard: 2x2 grid of charts. */
.chart-grid-2x2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-grid-2x2 .card-body { padding: 16px; height: 300px; }
.chart-grid-2x2 canvas { width: 100% !important; height: 100% !important; }
@media (max-width: 820px) { .chart-grid-2x2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* ---- Modal ---- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(26,35,50,.55);
    align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 6px; width: 100%; max-width: 540px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3); border-top: 4px solid var(--accent); }
.modal-head {
    padding: 16px 22px; border-bottom: 1px solid var(--border);
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--text);
}
.modal-body { padding: 22px; }
.field { display: block; margin-bottom: 18px; }
.field-label {
    display: block; margin-bottom: 6px; font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.field input, .modal input.minput {
    width: 100%; padding: 9px 13px; background: #fff; color: var(--text);
    border: 1px solid var(--border); border-radius: 4px;
    font-family: 'Barlow', sans-serif; font-size: 0.92rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .modal input.minput:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12);
}
.month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 6px; }
.mfield { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.mfield input { margin-top: 4px; padding: 7px 10px; font-size: 0.9rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* ---- Login ---- */
.login-wrap { display: flex; justify-content: center; margin-top: 60px; }
.login-card {
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    border-top: 4px solid var(--accent); box-shadow: var(--shadow);
    padding: 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-card h2 {
    font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--text); margin-bottom: 6px;
}
.login-card p { color: var(--muted); font-size: 0.88rem; margin-bottom: 18px; }
.login-card input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 4px;
    font-size: 1.1rem; margin-bottom: 18px; text-align: center; letter-spacing: 6px;
    font-family: 'Barlow', sans-serif;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(26,92,158,0.12); }
.login-card .btn { width: 100%; justify-content: center; }

/* ---- Footer ---- */
.foot {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1800px; margin: 20px auto 0; padding: 20px 24px 30px;
    border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem;
}
.foot .mono { font-family: 'Barlow Condensed', sans-serif; letter-spacing: 0.05em; text-transform: uppercase; }
@media (max-width: 640px) { .foot { flex-direction: column; gap: 6px; text-align: center; } }
