:root {
    --primary: #0047AB;
    --primary-light: #1e5bc4;
    --primary-dark: #003892;
    --gold: #f1c40f;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --teal: #0d9488;
    --border: #e5e7eb;
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .05);
    --shadow-md: 0 6px 18px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 19px;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.chrome {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #fff;
}
.top-header {
    min-height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 20px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: none; }
.logo-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; display: grid; place-items: center; font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 71, 171, .25);
}
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.brand-name span { color: var(--gold); }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.user-chip { display: flex; align-items: center; gap: 8px; color: #334155; font-size: 17px; font-weight: 600; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: #e8eefb; color: var(--primary); display: grid; place-items: center; font-size: 16px;
}
.link-quiet { color: #475569; font-size: 16px; font-weight: 600; }
.rate-bar {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: #003892; border-bottom: 3px solid #f1c40f; overflow-x: auto;
}
.rate-label { font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #dbeafe; white-space: nowrap; }
.rate-chip {
    display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap;
    background: #fff; border: 0; border-radius: 999px;
    padding: 6px 14px; color: #0f172a; text-decoration: none; font-size: 16px; font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
}
.rate-chip strong { font-size: 19px; }
.rate-chip.pms { background: #dbeafe; color: #1e3a8a; }
.rate-chip.pms strong { color: #1d4ed8; }
.rate-chip.hobc { background: #f1c40f; color: #713f12; }
.rate-chip.hobc strong { color: #78350f; }
.rate-chip.hsd { background: #bbf7d0; color: #14532d; }
.rate-chip.hsd strong { color: #166534; }
.rate-chip.missing { background: #ffedd5; color: #9a3412; }
.rate-chip.missing strong { color: #c2410c; }
.rate-chip:hover { text-decoration: none; filter: brightness(.97); }

.horizontal-nav {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
}
.nav-menu { display: flex; flex-wrap: wrap; gap: 2px; list-style: none; margin: 0; padding: 0; overflow: visible; }
.nav-menu a {
    display: block; padding: 12px 12px; color: #475569; font-size: 16px; font-weight: 600;
    border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none;
}
.nav-menu a:hover, .nav-menu summary:hover { color: var(--primary); background: #f8fafc; text-decoration: none; }
.nav-menu a.active, .nav-menu summary.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-menu summary {
    display: block; padding: 12px 12px; color: #475569; font-size: 16px; font-weight: 600;
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.nav-drop { position: relative; }
.nav-drop summary {
    list-style: none;
    cursor: pointer;
}
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary::after { content: " \25BE"; font-size: 13px; }
.nav-drop-menu {
    display: none; position: absolute; top: 100%; left: 0; min-width: 280px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-md); padding: 6px; z-index: 40;
}
.nav-drop[open] .nav-drop-menu,
.nav-drop:hover .nav-drop-menu,
.nav-drop:focus-within .nav-drop-menu { display: block; }
.nav-drop:hover::details-content,
.nav-drop[open]::details-content,
.nav-drop:focus-within::details-content { display: block; content-visibility: visible; }
.nav-menu > li:nth-last-child(-n+2) .nav-drop-menu { left: auto; right: 0; }
.nav-drop-menu a { border-bottom: 0; border-radius: 8px; padding: 8px 10px; line-height: 1.3; }
.nav-drop-menu a small { display: block; font-weight: 500; color: var(--muted); font-size: 14px; margin-top: 2px; }
.task-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.task-row a {
    display: block; background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.task-row a strong { display: block; color: var(--primary); font-size: 17px; }
.task-row a span { display: block; color: var(--muted); font-size: 15px; margin-top: 4px; font-weight: 500; }
.task-row a:hover { border-color: var(--primary); text-decoration: none; }
.start-card { border-left: 4px solid var(--gold); }
.start-card ol { margin: 0; padding-left: 18px; }
.start-card li { margin: 6px 0; }

.page { padding: 18px 20px 40px; max-width: 1280px; margin: 0 auto; }
.card:has(table.data) { overflow-x: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.sub { color: var(--muted); font-size: 16px; margin-top: 3px; }

.card {
    background: var(--card); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 12px; font-size: 19px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
    box-shadow: var(--shadow); border-left: 4px solid var(--primary);
}
.stat .label { color: var(--muted); font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 23px; font-weight: 700; margin-top: 4px; line-height: 1.25; overflow-wrap: anywhere; }
.stat .meta { margin-top: 6px; color: var(--muted); font-size: 15px; font-weight: 600; }
.stat.green { border-left-color: var(--green); }
.stat.amber { border-left-color: var(--amber); }
.stat.teal { border-left-color: var(--teal); }
.stat.red { border-left-color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

table.data { width: 100%; border-collapse: collapse; font-size: 16.5px; }
table.data th { text-align: left; font-size: 15px; color: #64748b; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tr:hover td { background: #f8fafc; }
table.data .num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.print-customer { display: none; }
td.row-actions { white-space: normal; }
td.row-actions form { display: inline-flex; gap: 6px; align-items: center; margin: 0 0 0 6px; vertical-align: middle; }
td.row-actions input, td.row-actions select { width: auto; min-width: 140px; }

.btn, button.btn, a.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600;
    font-size: 16px; cursor: pointer; text-decoration: none; box-shadow: 0 2px 4px rgba(0, 71, 171, .2);
}
.btn:hover { text-decoration: none; filter: brightness(1.05); color: #fff; }
.btn.secondary { background: #fff; color: #334155; border: 1px solid var(--border); box-shadow: none; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #fecaca; box-shadow: none; }
.btn.small { padding: 5px 10px; font-size: 15px; }

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: span 4; }
label { font-size: 15px; font-weight: 600; color: #475569; }
input, select, textarea {
    border: 1px solid #dbe1ea; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 17px;
    background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0, 71, 171, .2); border-color: var(--primary); }
textarea { min-height: 70px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    flex: 0 0 60px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    padding: 0;
    border: 0;
    position: absolute;
    outline: none;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    transition: 0.4s;
    border-radius: 34px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background: #fff;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:focus + .toggle-slider { box-shadow: 0 0 1px var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(26px); }
.toggle-slider:hover { box-shadow: 0 4px 8px rgba(0, 0, 0, .3); }
.toggle-switch input:checked + .toggle-slider:hover { background: var(--primary-light); }
.toggle-label { font-weight: 600; color: #34495e; font-size: 17px; }

.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 17px; }
.alert.success { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; }
.alert.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.info { background: #eff6ff; color: #1e3a8a; border: 1px solid #dbeafe; }

.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 15px; font-weight: 700; }
.badge.pms { background: #dbeafe; color: #1d4ed8; }
.badge.hobc { background: #fef3c7; color: #b45309; }
.badge.hsd { background: #dcfce7; color: #166534; }
.badge.paid { background: #dcfce7; color: #166534; }
.badge.unpaid { background: #fee2e2; color: #b91c1c; }
.badge.partial { background: #fef3c7; color: #b45309; }
.badge.off { background: #f1f5f9; color: #64748b; }

.pumps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.pump-card h2 { display: flex; justify-content: space-between; align-items: center; }
.nozzles { display: flex; flex-wrap: wrap; gap: 8px; }
.nozzle-chip { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-width: 140px; background: #f8fafc; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filter-bar .field { min-width: 160px; }
.page > form.filter-bar {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 12px; box-shadow: var(--shadow);
}
.filter-bar > input, .filter-bar > select, .filter-bar > button { width: auto; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center; font-size: 16px; }
.bar-track { height: 14px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 999px; min-width: 2px; }
.pie-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pie {
    width: 160px; height: 160px; border-radius: 50%;
    box-shadow: inset 0 0 0 18px #fff;
}
.pie-legend { list-style: none; margin: 0; padding: 0; font-size: 16px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 10px; }
.meter-total { display: flex; justify-content: flex-end; gap: 18px; margin-top: 10px; font-size: 17px; }
.meter-total strong { font-variant-numeric: tabular-nums; }
.meter-grand { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.meter-bad { color: var(--red); font-weight: 700; }
.help { color: var(--muted); font-size: 16px; line-height: 1.5; }
.total-row td { font-weight: 700; background: #f8fafc; }

.login-wrap {
    min-height: 100vh; display: grid; place-items: center;
    background: radial-gradient(circle at top left, #1e5bc4, #003892 55%, #001a44);
    padding: 24px;
}
.login-card { width: 420px; max-width: 100%; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .logo-mark { margin-bottom: 4px; }
.login-card h1 { margin: 8px 0 4px; font-size: 27px; }
.login-card .gold { color: var(--gold); }
.field-error { color: var(--red); font-size: 16px; margin-bottom: 8px; }

.print-only { display: none; }
@media print {
    .top-header, .horizontal-nav, .rate-bar, .no-print { display: none !important; }
    .print-only { display: block; }
    body { background: #fff; }
    .page { max-width: none; padding: 0; }
    .card { box-shadow: none; }
}

@media (max-width: 1000px) {
    .grid-2, .grid-3, .pumps, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .stats, .grid-2, .grid-3, .pumps, .form-grid { grid-template-columns: 1fr; }
    .field.span-2, .field.span-4 { grid-column: auto; }
    body { -webkit-text-size-adjust: 100%; }
    .page { padding: 12px 12px 28px; }
    .page-head h1 { font-size: 23px; }
    .top-header { padding: 8px 12px; }
    .brand-name { font-size: 19px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-chip > span:not(.avatar) { display: none; }
    .link-quiet { min-height: 44px; display: inline-flex; align-items: center; }
    .btn, button.btn, a.btn { min-height: 44px; }
    .btn.small { min-height: 36px; }
    input, select, textarea { font-size: 19px; min-height: 44px; }
    .nav-menu { flex-wrap: wrap; overflow: visible; }
    .nav-menu a, .nav-menu summary { padding: 10px 12px; min-height: 44px; }
    .nav-drop:hover .nav-drop-menu { display: none; }
    .nav-drop[open] .nav-drop-menu,
    .nav-drop[open]:hover .nav-drop-menu {
        display: block; position: static; min-width: 0; box-shadow: none; border: 0; padding: 0 0 8px 8px;
    }
    .page > form.filter-bar, .filter-bar .field { width: 100%; min-width: 0; }
    .filter-bar > input, .filter-bar > select, .filter-bar > button { width: 100%; }
    .actions .btn { flex: 1 1 auto; }
    .bar-row { grid-template-columns: 1fr; }
    .meter-grand, .meter-total { align-items: stretch; }
    .meter-grand .btn { width: 100%; }
    .pie { width: 140px; height: 140px; }
    table.stack-table thead { display: none; }
    table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
    table.stack-table tr {
        border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 8px 10px; background: #fff;
    }
    table.stack-table td {
        display: flex; justify-content: space-between; align-items: center; gap: 10px;
        border: 0; text-align: right; padding: 6px 0;
    }
    table.stack-table td::before {
        content: attr(data-label); font-weight: 600; color: #64748b; font-size: 15px; text-align: left;
    }
    table.stack-table td .help { text-align: right; }
    table.stack-table input, table.stack-table select { width: 58%; min-width: 0; }
    .card:has(table.data) { -webkit-overflow-scrolling: touch; }
}
