:root {
    --bg: #f6f4ef;
    --panel: #ffffff;
    --text: #24211d;
    --muted: #706b63;
    --line: #ded8ce;
    --accent: #2f7567;
    --accent-dark: #205247;
    --danger: #a8443f;
    --success: #2f7651;
    --shadow: 0 18px 50px rgba(41, 34, 25, 0.10);
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px clamp(18px, 4vw, 42px);
    background: rgba(246, 244, 239, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
}

.nav,
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nav a,
.tabs a,
.button {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
}

.nav a.is-active,
.tabs a.is-active,
.button.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.hero-band,
.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: clamp(22px, 5vw, 42px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fdfcf8;
    box-shadow: var(--shadow);
}

.page-heading {
    align-items: center;
    padding-block: 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

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

h1 {
    max-width: 760px;
    margin-bottom: 0;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 0;
    font-size: 1.2rem;
}

.hero-result,
.metric,
.panel,
.meter-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.hero-result {
    min-width: 220px;
    padding: 18px;
}

.hero-result span,
.metric span,
.meter-card span {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.hero-result strong,
.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 1.9rem;
    line-height: 1.1;
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

.summary-grid,
.meter-grid,
.two-column {
    display: grid;
    gap: 14px;
}

.summary-grid {
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 14px;
}

.metric,
.panel,
.meter-card {
    padding: 18px;
}

.panel {
    margin-bottom: 14px;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.rows {
    display: grid;
    gap: 12px;
}

.usage-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(160px, 1fr) 130px;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}

.usage-row:first-child {
    border-top: 0;
}

.usage-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.swatch {
    flex: 0 0 auto;
    width: 16px;
    height: 44px;
    border-radius: 99px;
    background: var(--color);
}

.usage-main h3,
.meter-card h3 {
    margin-bottom: 2px;
}

.usage-main p,
.meter-card p,
.muted-panel p {
    margin-bottom: 0;
    color: var(--muted);
}

.bar {
    overflow: hidden;
    height: 10px;
    border-radius: 999px;
    background: #ece7dd;
}

.bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--color);
}

.balance {
    text-align: right;
}

.meter-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.meter-card strong {
    display: block;
    margin: 10px 0 4px;
    font-size: 1.6rem;
}

.meter-card.compact h3 {
    font-size: 1rem;
}

.tabs {
    margin-bottom: 14px;
}

.two-column {
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
}

.form-grid,
.form-stack,
.rates-form {
    display: grid;
    gap: 14px;
}

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

.form-grid .wide {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

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

.rate-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.rate-row legend {
    padding: 0 8px;
    font-weight: 900;
}

.rate-row legend span {
    color: var(--muted);
    font-weight: 700;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-box {
    width: min(420px, 100%);
}

.login-brand {
    justify-content: center;
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.alert {
    padding: 12px;
    border: 1px solid #e6b7b3;
    border-radius: 8px;
    background: #fff2f0;
    color: var(--danger);
    font-weight: 800;
}

@media (max-width: 820px) {
    .topbar,
    .hero-band,
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar {
        position: static;
    }

    .summary-grid,
    .two-column,
    .form-grid,
    .rate-row,
    .usage-row {
        grid-template-columns: 1fr;
    }

    .balance {
        text-align: left;
    }
}

textarea {
    width: 100%;
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
    resize: vertical;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.checkline {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.hint {
    color: var(--muted);
    font-size: 0.88rem;
}

.coefficients {
    margin: 10px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

.shared-advance {
    grid-template-columns: 1fr 1fr 1fr;
}

.user-pill {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
}

.line-chart {
    display: block;
    width: 100%;
    height: auto;
    min-height: 260px;
}

.line-chart line {
    stroke: var(--line);
    stroke-width: 2;
}

.line-chart polyline {
    fill: none;
    stroke: var(--accent);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.line-chart circle {
    fill: #fff;
    stroke: var(--accent-dark);
    stroke-width: 3;
}

.line-chart text {
    fill: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.changelog-box {
    overflow-x: auto;
    margin: 0;
    white-space: pre-wrap;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    line-height: 1.6;
}

.meter-settings-form {
    display: grid;
    gap: 16px;
}

.interval-chart {
    display: grid;
    gap: 12px;
}

.interval-bar {
    display: grid;
    grid-template-columns: 110px 140px 1fr 150px;
    gap: 12px;
    align-items: center;
}

.interval-bar small {
    color: var(--muted);
    font-weight: 800;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.button.danger {
    border-color: #e0b8b3;
    color: var(--danger);
}

.is-hidden-meter {
    opacity: 0.62;
}

@media (max-width: 820px) {
    .interval-bar {
        grid-template-columns: 1fr;
    }
}

.logout-link {
    border-color: #d9aaa4 !important;
    background: #fff2f0 !important;
    color: var(--danger) !important;
}

.menu-toggle {
    display: none;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 800;
    padding: 8px 13px;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.inline-form {
    display: inline;
}

@media (max-width: 820px) {
    .menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
    }

    body.nav-open .nav {
        display: flex;
    }
}

