:root {
    color-scheme: light;
    --ink: #121820;
    --muted: #637082;
    --line: #d9e0e8;
    --surface: #f7f8f5;
    --panel: #ffffff;
    --accent: #bf6f2f;
    --accent-dark: #7c431e;
    --good: #1f7a57;
    --warn: #9b5428;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}

button,
input,
textarea,
select {
    font: inherit;
}

.shell {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

.topbar,
.section-heading,
.due-strip {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 4.4rem);
    line-height: 0.95;
}

h2 {
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.toggle-link,
.primary-button,
.ghost-button,
.icon-button {
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    text-decoration: none;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.toggle-link,
.primary-button {
    background: var(--ink);
    color: #fff;
    font-weight: 750;
}

.ghost-button {
    background: transparent;
    border-color: var(--line);
    color: var(--ink);
    white-space: nowrap;
}

.ghost-button.danger {
    color: #9a3412;
}

.compact {
    width: auto;
    margin-top: 0;
}

.icon-button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    border-color: var(--line);
    background: transparent;
    color: var(--ink);
    font-size: 1.35rem;
    line-height: 1;
}

.toggle-link:hover,
.primary-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin: 28px 0 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
}

.metrics div {
    min-height: 112px;
    padding: 18px;
    background: var(--panel);
}

.metrics span,
.section-heading span,
.due-strip p,
small {
    color: var(--muted);
}

.metrics strong {
    display: block;
    margin-top: 10px;
    font-size: clamp(1.5rem, 2vw, 2.4rem);
    letter-spacing: 0;
}

.due-strip {
    align-items: stretch;
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbf7ef;
}

.due-strip h2,
.due-strip p {
    margin-bottom: 0;
}

.due-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.due-list span {
    align-self: center;
    border: 1px solid rgba(124, 67, 30, 0.18);
    border-radius: 999px;
    padding: 6px 10px;
    background: #fff;
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 700;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
    border-bottom: 1px solid var(--line);
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
}

.filter-bar label {
    margin-bottom: 0;
}

.filter-bar select {
    width: min(280px, 100%);
}

.tab-button {
    min-height: 42px;
    border: 0;
    border-bottom: 3px solid transparent;
    padding: 0 14px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 800;
}

.tab-button.active {
    border-bottom-color: var(--accent);
    color: var(--ink);
}

.tab-panel[hidden] {
    display: none;
}

.workspace {
    display: grid;
    gap: 28px;
}

.panel,
.table-section,
.projection-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.panel {
    padding: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.wide,
.form-grid > div:has(textarea) {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #27313d;
    font-size: 0.86rem;
    font-weight: 750;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="color"],
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 11px;
    background: #fff;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

input[type="color"] {
    padding: 4px;
}

.form-grid ul {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #9a3412;
}

div[id$="_billingCycle"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

div[id$="_billingCycle"] label,
.form-grid div:has(input[type="checkbox"]) label {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    min-height: 42px;
}

.primary-button {
    margin-top: 14px;
    width: 100%;
}

.primary-button.compact {
    margin-top: 0;
    width: auto;
}

.section-heading {
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    margin-bottom: 0;
}

.table-wrap {
    overflow-x: auto;
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: var(--line);
}

.month-card {
    min-height: 210px;
    background: var(--panel);
}

.month-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #eef3f6;
    border-bottom: 1px solid var(--line);
}

.month-heading h3 {
    margin: 0;
    font-size: 0.98rem;
}

.month-heading strong {
    white-space: nowrap;
}

.month-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0 16px 14px;
    background: #eef3f6;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.82rem;
}

.month-items {
    display: grid;
    gap: 8px;
    margin: 16px;
    padding: 0;
    list-style: none;
}

.month-items li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

.month-items b {
    font-size: 0.9rem;
    white-space: nowrap;
}

.month-items .quiet {
    display: block;
    color: var(--muted);
}

.with-dot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.category-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--dot-color);
    box-shadow: inset 0 0 0 1px rgba(18, 24, 32, 0.12);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

th,
td {
    padding: 13px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

td small {
    display: block;
    margin-top: 2px;
}

tr:last-child td {
    border-bottom: 0;
}

.muted-row {
    color: var(--muted);
    background: #fafafa;
}

.status {
    display: inline-flex;
    min-width: 74px;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.78rem;
    font-weight: 800;
}

.status.on {
    background: #e8f4ee;
    color: var(--good);
}

.status.off {
    background: #f1f2f4;
    color: var(--muted);
}

.row-actions + .row-actions {
    margin-top: 6px;
}

td > .ghost-button + .row-actions {
    margin-top: 6px;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.flash {
    margin-top: 18px;
    border: 1px solid #b9dec9;
    border-radius: 8px;
    padding: 12px 14px;
    background: #eef9f2;
    color: #155b3f;
    font-weight: 750;
}

.flash.error {
    border-color: #f0b4a4;
    background: #fff1ed;
    color: #9a3412;
}

.auth-shell {
    display: grid;
    min-height: 100svh;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(460px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    background: var(--panel);
}

.auth-panel h1 {
    margin-bottom: 24px;
    font-size: clamp(2rem, 5vw, 3.4rem);
}

.auth-panel form {
    display: grid;
    gap: 14px;
}

.auth-copy,
.auth-link {
    color: var(--muted);
}

.auth-link {
    margin: 18px 0 0;
}

.modal {
    width: min(720px, calc(100% - 28px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0;
    background: var(--panel);
    color: var(--ink);
    box-shadow: 0 24px 80px rgba(18, 24, 32, 0.28);
}

.modal::backdrop {
    background: rgba(18, 24, 32, 0.45);
}

.modal-heading,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
}

.modal-heading {
    border-bottom: 1px solid var(--line);
}

.modal-heading h2 {
    margin-bottom: 0;
}

.modal form {
    padding: 18px;
}

.modal-body {
    padding: 18px;
}

.modal-body form {
    padding: 0;
}

.modal-actions {
    justify-content: flex-end;
    padding: 18px 0 0;
}

.compact-form-grid {
    grid-template-columns: 1fr 120px;
}

.category-list {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.category-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.category-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

@media (max-width: 920px) {
    .topbar,
    .due-strip {
        align-items: flex-start;
        flex-direction: column;
    }

    .metrics,
    .month-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .due-list {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    .shell {
        width: min(100% - 20px, 1480px);
        padding-top: 18px;
    }

    .metrics,
    .month-grid,
    .compact-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .metrics div {
        min-height: 92px;
    }

    .toolbar,
    .filter-bar,
    .filter-bar select,
    .tabs,
    .tab-button,
    .toggle-link,
    .toolbar .compact {
        width: 100%;
    }
}
