:root {
    --ink: #14231f;
    --muted: #687873;
    --paper: #f5f3ed;
    --card: #fffefb;
    --line: #deddd5;
    --green: #176b51;
    --green-dark: #0e4a39;
    --lime: #d8ee83;
    --danger: #9a2f2f;
    --shadow: 0 18px 55px rgba(20, 35, 31, .08);
}

* { box-sizing: border-box; }
.login-shell { max-width: 580px; }
.login-card { margin-top: 48px; padding: 32px; }
.login-card h2 { font: 700 36px Georgia, serif; margin: 12px 0; }
.login-form { display: grid; gap: 20px; margin-top: 28px; }
.login-form label { display: grid; gap: 8px; font-size: 14px; font-weight: 700; }
.login-form input { width: 100%; }
.signout-form { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background:
        radial-gradient(circle at 84% 3%, rgba(216, 238, 131, .42), transparent 27rem),
        var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 36px; }
.topbar { min-height: 92px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid rgba(20, 35, 31, .13); }
.brand-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: white; background: var(--green); font: 800 22px/1 Georgia, serif; box-shadow: 0 8px 20px rgba(23, 107, 81, .2); }
.topbar h1 { margin: 2px 0 0; font: 700 20px/1.15 Georgia, serif; }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.rate-badge { margin-left: auto; padding: 9px 13px; border: 1px solid rgba(23, 107, 81, .22); border-radius: 999px; background: rgba(255, 255, 255, .55); color: var(--green-dark); font-size: 13px; font-weight: 700; }

.report-tabs { display: flex; gap: 8px; padding-top: 24px; }
.report-tab { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.55); font-size: 14px; font-weight: 750; text-decoration: none; transition: border-color .15s ease, color .15s ease, background .15s ease; }
.report-tab span { color: #96a19d; font-size: 11px; letter-spacing: .08em; }
.report-tab:hover { color: var(--green-dark); border-color: rgba(23, 107, 81, .35); }
.report-tab.is-active { color: white; border-color: var(--green); background: var(--green); box-shadow: 0 8px 20px rgba(23, 107, 81, .16); }
.report-tab.is-active span { color: var(--lime); }

.report-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 58px 0 30px; }
.report-heading h2 { margin: 7px 0 8px; font: 700 clamp(34px, 5vw, 56px)/1.03 Georgia, serif; letter-spacing: -.03em; }
.muted { margin: 0; color: var(--muted); }
.period-form { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: var(--shadow); }
.period-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
select, input, button, .download-button { min-height: 42px; border-radius: 10px; font: inherit; }
select, input { border: 1px solid var(--line); padding: 0 12px; color: var(--ink); background: var(--card); }
select { min-width: 130px; padding-right: 36px; }
select[name="company_id"] { width: min(330px, 42vw); }
.customer-line { margin: 12px 0 0; color: var(--green-dark); font-size: 14px; }
.company-exclusions { width: 280px; max-width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 13px; }
.company-exclusions summary { cursor: pointer; color: var(--green-dark); font-weight: 750; }
.company-exclusions > p { margin: 12px 0; }
.company-exclusion-options { max-height: 220px; overflow-y: auto; margin-bottom: 12px; }
.period-form .company-exclusion-options label { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; font-weight: 500; letter-spacing: normal; text-transform: none; color: var(--ink); }
.company-exclusion-options input { min-height: 0; width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--green); }
button, .download-button { border: 0; padding: 0 18px; cursor: pointer; font-weight: 750; text-decoration: none; transition: transform .15s ease, background .15s ease; }
button:hover, .download-button:hover { transform: translateY(-1px); }
.primary-button { color: white; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }

.summary-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.metric { min-height: 160px; display: flex; flex-direction: column; justify-content: space-between; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.metric > span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { font: 700 38px/1 Georgia, serif; letter-spacing: -.02em; }
.metric small { color: var(--muted); }
.metric-featured { color: white; border-color: var(--green); background: var(--green); }
.metric-featured > span, .metric-featured small { color: rgba(255,255,255,.75); }
.metric-featured strong { color: var(--lime); font-size: 46px; }

.details-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px; border-bottom: 1px solid var(--line); }
.card-header h2 { margin: 5px 0 0; font: 700 25px/1.1 Georgia, serif; }
.download-button { display: inline-flex; align-items: center; color: var(--green-dark); background: var(--lime); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 13px 20px; color: var(--muted); background: #f2f1eb; font-size: 11px; letter-spacing: .07em; text-align: left; text-transform: uppercase; }
td { padding: 16px 20px; border-top: 1px solid #eceae3; }
tbody tr:hover { background: #faf9f4; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
code { padding: 4px 7px; border-radius: 6px; color: var(--green-dark); background: #edf3ee; font: 600 12px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.alert { margin-bottom: 24px; padding: 16px 18px; border: 1px solid #e6b6b6; border-radius: 12px; color: var(--danger); background: #fff1f1; }
.notice { margin: -6px 0 22px; padding: 13px 16px; border: 1px solid rgba(23, 107, 81, .2); border-radius: 12px; color: var(--green-dark); background: rgba(216, 238, 131, .22); font-size: 13px; }
.rate-editor { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.rate-editor h2 { margin: 5px 0 6px; font: 700 24px/1.1 Georgia, serif; }
.rate-editor p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.rate-form { display: flex; align-items: end; gap: 10px; }
.rate-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.rate-form input { width: 160px; }
.tenant-summary { margin-bottom: 22px; }
.text-link { color: var(--green); font-weight: 750; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.sort-status { color: var(--muted); font-size: 12px; font-weight: 700; }
.rank { width: 72px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.compact-button { min-height: 34px; padding: 0 12px; font-size: 12px; white-space: nowrap; }
footer { padding: 25px 2px 0; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 800px) {
    .report-heading { align-items: stretch; flex-direction: column; padding-top: 36px; }
    .period-form { width: 100%; }
    .period-form label { flex: 1; }
    select { width: 100%; }
    select[name="company_id"] { width: 100%; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .metric-featured { grid-column: 1 / -1; }
    .rate-editor { align-items: stretch; flex-direction: column; }
}

@media (max-width: 560px) {
    .page-shell { width: min(100% - 24px, 1180px); }
    .rate-badge { display: none; }
    .report-tabs { flex-direction: column; }
    .period-form { align-items: stretch; flex-direction: column; }
    .summary-grid { grid-template-columns: 1fr; }
    .metric-featured { grid-column: auto; }
    .card-header { align-items: stretch; flex-direction: column; }
    .download-button { justify-content: center; }
    .rate-form { align-items: stretch; flex-direction: column; }
    .rate-form input { width: 100%; }
}
.exclusion-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.exclusion-status p { margin: 8px 0 0; }
.exclusion-manager .card-header p { margin-top: 10px; }
.exclusion-company-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); padding: 18px 26px; gap: 4px 20px; }
.exclusion-company { display: flex; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; font-size: 14px; }
.exclusion-company input { min-height: 0; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--green); }
.exclusion-company small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 560px) { .exclusion-status { align-items: stretch; flex-direction: column; } }
