:root {
  color-scheme: light;
  --ink: #0b2438;
  --muted: #607386;
  --line: #d8e5ed;
  --canvas: #f3f8fb;
  --surface: #ffffff;
  --navy: #082f49;
  --blue: #0ea5e9;
  --blue-dark: #0c4a6e;
  --blue-soft: #e0f2fe;
  --aqua: #67e8f9;
  --green: #0b9f55;
  --green-soft: #e7f7ec;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 16px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.page-shell { min-height: 100vh; }
.card-surface { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 18px 44px rgba(8, 47, 73, .08); }
.eyebrow { margin: 0 0 .65rem; color: var(--blue); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 1rem; font-size: clamp(2.25rem, 5vw, 4.8rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin-bottom: .6rem; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.1; letter-spacing: -.025em; }
h3 { margin-bottom: .55rem; line-height: 1.15; }
.form-message { margin: 1rem 0 0; font-size: .9rem; }
.error-message { color: var(--danger); }

.login-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); min-height: 100vh; background: var(--navy); }
.brand-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 7vw, 7rem); color: #f0f9ff; background: radial-gradient(circle at 15% 20%, rgba(56, 189, 248, .26), transparent 27rem), linear-gradient(145deg, #082f49 0%, #075985 100%); }
.brand-logo { width: clamp(132px, 17vw, 192px); height: auto; margin-bottom: 2rem; border-radius: 50%; box-shadow: 0 18px 42px rgba(2, 132, 199, .2); }
.brand-panel .eyebrow { color: var(--aqua); }
.brand-panel h1 { max-width: 42rem; }
.brand-copy { max-width: 34rem; margin-bottom: 0; color: #cce8f5; font-size: clamp(1.05rem, 1.6vw, 1.28rem); }
.wave-line { width: min(100%, 28rem); height: 4rem; margin-top: 3rem; border-top: 2px solid rgba(224, 242, 254, .5); border-radius: 50%; transform: rotate(-3deg); }
.login-card { align-self: center; width: min(100% - 3rem, 31rem); margin: auto; padding: clamp(1.75rem, 5vw, 3rem); }
.card-heading { margin-bottom: 2rem; }
.card-heading p:last-child { margin-bottom: 0; color: var(--muted); }
label { display: block; margin: 1.15rem 0 .45rem; font-size: .9rem; font-weight: 700; }
input, select { width: 100%; padding: .78rem .85rem; color: var(--ink); background: #fbfdfe; border: 1px solid #b8ccd8; border-radius: 10px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(14, 165, 233, .15); }
.primary-button { width: 100%; margin-top: 1.75rem; padding: .88rem 1rem; color: #fff; background: var(--navy); border: 0; border-radius: 10px; font-weight: 800; transition: transform .15s ease, background .15s ease; }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }

.dashboard-view { min-height: 100vh; background: var(--canvas); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 1rem clamp(1.25rem, 5vw, 5rem); background: var(--surface); border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); font-weight: 850; text-decoration: none; }
.wordmark-logo { width: 42px; height: 42px; border-radius: 50%; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.account-name { color: var(--muted); font-size: .9rem; }
.text-button { padding: .45rem .7rem; color: var(--navy); background: transparent; border: 0; border-radius: 8px; font-weight: 750; }
.text-button:hover { background: var(--blue-soft); }
.dashboard-content { width: min(calc(100% - 3rem), 2200px); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) 0; }
.dashboard-intro { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 2rem; }
.dashboard-intro h1 { margin-bottom: .55rem; font-size: clamp(2.1rem, 5vw, 3.8rem); }
.intro-copy, .section-note { margin-bottom: 0; color: var(--muted); }
.intro-copy { font-size: 1.05rem; }
.status-pill { display: inline-flex; align-items: center; gap: .55rem; padding: .55rem .75rem; color: var(--blue-dark); background: var(--blue-soft); border-radius: 999px; font-size: .85rem; font-weight: 750; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #0891b2; }
.tab-nav { display: flex; gap: .35rem; margin-bottom: 2.25rem; padding: .35rem; background: #e9f1f5; border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.tab-button { flex: 0 0 auto; padding: .78rem 1.25rem; color: var(--muted); background: transparent; border: 0; border-radius: 10px; font-weight: 800; white-space: nowrap; }
.tab-button:hover { color: var(--ink); background: rgba(255, 255, 255, .7); }
.tab-button.is-active { color: #fff; background: var(--green); box-shadow: 0 7px 16px rgba(11, 159, 85, .2); }
.tab-view { min-width: 0; }
.view-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.25rem; }
.view-heading h2 { margin-bottom: .35rem; }
.period-controls { display: grid; grid-template-columns: auto minmax(8rem, 10rem) auto minmax(10rem, 12rem); align-items: center; gap: .5rem; min-width: 31rem; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.period-controls label { margin: 0; color: var(--muted); font-size: .8rem; }
.period-controls select { width: auto; padding: .55rem .65rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi-card { display: flex; align-items: flex-start; gap: .8rem; min-height: 146px; padding: 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 25px rgba(8, 47, 73, .05); }
.kpi-icon { display: grid; flex: 0 0 38px; place-items: center; width: 38px; height: 38px; color: var(--blue-dark); background: var(--blue-soft); border-radius: 50%; font-size: 1.35rem; font-weight: 850; }
.up-icon { color: #087443; background: var(--green-soft); }
.down-icon { color: #0369a1; background: #e7f1fb; }
.kpi-label { margin: .1rem 0 .45rem; color: var(--muted); font-size: .82rem; font-weight: 750; }
.kpi-card strong { display: block; margin-bottom: .2rem; color: var(--navy); font-size: clamp(1.45rem, 2.1vw, 2.1rem); line-height: 1.05; letter-spacing: -.055em; }
.kpi-card > div > p:last-child { margin: 0; color: var(--muted); font-size: .78rem; }
.overview-sync-kpi { grid-column: span 2; min-height: 146px; }
.overview-sync-content { flex: 1 1 auto; min-width: 0; }
.overview-sync-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.overview-sync-heading .kpi-label { margin-bottom: 0; }
.overview-sync-bubble { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .7rem; color: #087443; background: var(--green-soft); border-radius: 999px; font-size: .82rem; white-space: nowrap; }
.overview-sync-bubble strong { margin: 0; color: inherit; font-size: inherit; letter-spacing: normal; }
.overview-sync-bubble .status-dot { background: #0b9f55; }
.overview-sync-bubble.is-error { color: #b42318; background: #fee4e2; }
.overview-sync-bubble.is-error .status-dot { background: #c62828; }
.overview-sync-details { display: grid; gap: .35rem; margin: .85rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .82rem; line-height: 1.3; }
.overview-sync-details li::marker { color: var(--blue-dark); }
.overview-sync-details li { padding-left: .15rem; }
.overview-sync-countdown { white-space: nowrap; }
.overview-sync-kpi.is-error { border-color: #f3b4b0; }
.overview-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.detail-card { overflow: hidden; }
.panel-title { padding: .6rem 1rem; }
.panel-title h3 { margin: 0; color: var(--blue-dark); font-size: 1.1rem; text-align: center; }
.blue-title { background: var(--blue-soft); }
.green-title { background: var(--green-soft); }
.fact-list { margin: 0; padding: .55rem 1rem 1rem; }
.fact-list div { display: grid; grid-template-columns: minmax(8rem, 1fr) minmax(0, 1.5fr); gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.fact-list div:last-child { border-bottom: 0; }
.fact-list dt { color: var(--blue-dark); font-size: .83rem; }
.fact-list dd { margin: 0; color: var(--ink); font-size: .83rem; font-weight: 750; }
.chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.chart-card { min-width: 0; padding: 1.1rem 1rem 1rem; }
.chart-card h3 { margin-bottom: .15rem; color: var(--blue-dark); text-align: center; }
.chart-subtitle { margin-bottom: 1rem; color: var(--muted); font-size: .8rem; text-align: center; }
.bar-chart { min-height: 220px; }
.bars { display: flex; align-items: end; justify-content: space-around; gap: .35rem; min-height: 190px; padding: 0 .25rem; border-bottom: 1px solid var(--line); }
.bar-column { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: end; min-width: 0; height: 190px; outline: none; }
.bar-value { min-height: 1.1rem; color: var(--blue-dark); font-size: .65rem; font-weight: 800; line-height: 1.1; text-align: center; white-space: nowrap; transform: rotate(-45deg) translateY(-.25rem); transition: color .15s, font-weight .15s; }
.bar-track { display: flex; align-items: end; justify-content: center; width: 70%; height: 130px; }
.bar-fill { width: 100%; max-width: 34px; min-height: 0; background: linear-gradient(180deg, #2382c5, #1665a4); border-radius: 5px 5px 0 0; transition: transform .15s, background .15s, box-shadow .15s; }
.bar-label { margin-top: .45rem; color: var(--muted); font-size: .68rem; transition: color .15s, font-weight .15s; }
.bar-column:hover .bar-fill, .bar-column:focus-visible .bar-fill { background: #f28c28; transform: translateY(-5px) scaleY(1.02); box-shadow: 0 5px 10px rgba(242, 140, 40, .28); }
.bar-column:hover .bar-value, .bar-column:focus-visible .bar-value, .bar-column:hover .bar-label, .bar-column:focus-visible .bar-label { color: var(--ink); font-weight: 900; }
.bar-column:focus-visible { box-shadow: 0 0 0 3px rgba(10, 159, 224, .25); border-radius: 7px; }
.chart-empty { padding: 4rem 1rem; color: var(--muted); text-align: center; }
.comparison-panel { margin-top: 1rem; padding: 1.25rem; }
.comparison-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.comparison-heading h3 { margin-bottom: .25rem; color: var(--blue-dark); }
.comparison-controls { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem 1rem; padding: .9rem 1rem; background: #f8fbfd; border: 1px solid var(--line); border-radius: 16px; }
.comparison-control { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .8rem; font-weight: 750; }
.comparison-control label { margin: 0; }
.comparison-control select { width: auto; min-width: 9.5rem; padding: .55rem .65rem; }
.comparison-year-picker { position: relative; min-width: 12rem; }
.comparison-year-picker summary { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .65rem; color: var(--ink); background: var(--surface); border: 1px solid #b8ccd8; border-radius: 10px; font-weight: 750; cursor: pointer; list-style: none; }
.comparison-year-picker summary::-webkit-details-marker { display: none; }
.comparison-year-menu { position: absolute; z-index: 5; top: calc(100% + .4rem); left: 0; width: 18rem; padding: .75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 32px rgba(8, 47, 73, .18); }
.comparison-year-search { margin: 0; padding: .55rem .6rem; font-size: .8rem; }
.comparison-year-actions { display: flex; gap: .4rem; margin: .6rem 0; }
.comparison-year-actions button { padding: .4rem .55rem; color: var(--blue-dark); background: var(--blue-soft); border: 0; border-radius: 7px; font-size: .75rem; font-weight: 800; }
.comparison-year-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .2rem .5rem; max-height: 12rem; overflow: auto; }
.comparison-year-list label { display: flex; align-items: center; gap: .4rem; margin: 0; padding: .35rem .1rem; color: var(--muted); font-size: .8rem; font-weight: 650; }
.comparison-year-list input { width: auto; margin: 0; }
.comparison-bars-wrap { margin-top: 1rem; overflow-x: auto; }
.comparison-bars { display: grid; grid-template-columns: repeat(12, minmax(4.5rem, 1fr)); gap: .55rem; align-items: end; min-width: 760px; min-height: 255px; padding: 1rem .4rem 0; border-bottom: 1px solid var(--line); }
.comparison-month-column { min-width: 0; }
.comparison-month-group { display: flex; align-items: end; justify-content: center; gap: .22rem; height: 215px; min-width: 0; }
.comparison-bar-wrap { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: end; height: 100%; min-width: 0; outline: none; }
.comparison-bar-value { min-height: 1.2rem; color: var(--blue-dark); font-size: .55rem; font-weight: 800; line-height: 1; text-align: center; white-space: nowrap; transform: rotate(-45deg) translateY(-.25rem); transition: color .15s, font-weight .15s; }
.comparison-bar { width: min(1.15rem, 100%); min-height: 2px; background: var(--comparison-color, var(--blue-dark)); border-radius: 5px 5px 0 0; transition: transform .15s, background .15s, box-shadow .15s; }
.comparison-month-label { margin-top: .45rem; color: var(--muted); font-size: .7rem; font-weight: 650; text-align: center; transition: color .15s, font-weight .15s; }
.comparison-bar-wrap:hover .comparison-bar, .comparison-bar-wrap:focus-visible .comparison-bar { background: #f28c28; transform: translateY(-5px) scaleY(1.02); box-shadow: 0 5px 10px rgba(242, 140, 40, .28); }
.comparison-bar-wrap:hover .comparison-bar-value, .comparison-bar-wrap:focus-visible .comparison-bar-value { color: var(--ink); font-weight: 900; }
.comparison-month-column:has(.comparison-bar-wrap:hover) .comparison-month-label, .comparison-month-column:has(.comparison-bar-wrap:focus-visible) .comparison-month-label { color: var(--ink); font-weight: 900; }
.comparison-bar-wrap:focus-visible { box-shadow: 0 0 0 3px rgba(10, 159, 224, .25); border-radius: 7px; }
.comparison-legend { display: flex; flex-wrap: wrap; gap: .55rem 1rem; margin-top: .75rem; color: var(--muted); font-size: .75rem; }
.comparison-legend i { display: inline-block; width: .65rem; height: .65rem; margin-right: .3rem; border-radius: 3px; background: var(--comparison-color); vertical-align: -.05rem; }
.comparison-table-wrap { margin-top: 1rem; overflow-x: auto; }
.comparison-table { width: 100%; min-width: 38rem; border-collapse: collapse; font-size: .78rem; }
.comparison-table th, .comparison-table td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.comparison-table th:first-child, .comparison-table td:first-child { text-align: left; }
.comparison-table thead th { color: var(--muted); font-size: .68rem; text-transform: uppercase; }
.comparison-table tbody th { font-weight: 850; }
.comparison-table tbody td { color: var(--muted); }
.comparison-empty { margin: 0; padding: 4rem 1rem; color: var(--muted); text-align: center; }
.evidence-strip { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-top: 1rem; padding: 1.25rem 1.4rem; }
.evidence-strip h3 { margin-bottom: .35rem; }
.evidence-counts { display: flex; flex-wrap: wrap; justify-content: end; gap: .55rem; color: var(--muted); font-size: .8rem; }
.evidence-counts span { padding: .45rem .65rem; background: #f3f8fb; border-radius: 999px; white-space: nowrap; }
.evidence-counts strong { color: var(--ink); }
.data-status-panel { margin-top: 1rem; padding: 1.25rem; }
.data-status-heading { display: flex; align-items: start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.data-status-heading h2 { margin-bottom: .35rem; }
.data-status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.data-status-card { min-width: 0; padding: 1.1rem; background: #f8fbfd; border: 1px solid var(--line); border-radius: 18px; }
.data-status-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.data-status-card-heading strong { color: var(--navy); font-size: 1.15rem; }
.panel-label { margin: 0 0 .2rem; color: var(--muted); font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.data-status-badge { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .65rem; color: var(--blue-dark); background: var(--blue-soft); border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.data-status-badge.is-success { color: #087443; background: var(--green-soft); }
.data-status-badge.is-error { color: var(--danger); background: #fee4e2; }
.data-status-badge.is-success .status-dot { background: #0b9f55; }
.data-status-badge.is-error .status-dot { background: #c62828; }
.data-status-badge.is-running { color: #8a4b08; background: #fff1d6; }
.data-status-badge.is-not_configured { color: var(--blue-dark); background: var(--blue-soft); }
.data-status-details { margin: 0; }
.data-status-details div { display: grid; grid-template-columns: minmax(8rem, 1fr) minmax(0, 1.4fr); gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.data-status-details div:last-child { border-bottom: 0; }
.data-status-details dt { color: var(--muted); font-size: .8rem; }
.data-status-details dd { margin: 0; color: var(--ink); font-size: .8rem; font-weight: 750; text-align: right; overflow-wrap: anywhere; }
.data-status-message { margin: .9rem 0 0; color: var(--muted); font-size: .82rem; }
.data-status-action { margin-top: .7rem; padding: .4rem .6rem; color: var(--blue-dark); background: var(--blue-soft); }
.data-status-action:disabled { cursor: not-allowed; opacity: .55; }
.sync-log-list { display: grid; gap: .5rem; max-height: 12rem; margin: .75rem 0 0; padding: 0; overflow-y: auto; list-style: none; }
.sync-log-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .1rem .75rem; padding: .55rem .65rem; background: var(--surface); border-left: 3px solid var(--line); border-radius: 8px; font-size: .74rem; }
.sync-log-item.is-success { border-left-color: var(--green); }
.sync-log-item.is-error { border-left-color: var(--danger); }
.sync-log-item time { color: var(--muted); white-space: nowrap; }
.sync-log-item > span:last-child { grid-column: 1 / -1; color: var(--muted); overflow-wrap: anywhere; }

.usage-summary { display: flex; gap: .65rem; }
.usage-summary > div { display: flex; flex-direction: column; gap: .15rem; min-width: 9rem; padding: .7rem .85rem; background: var(--blue-soft); border: 1px solid #bae6fd; border-radius: 12px; }
.usage-summary span { color: var(--blue-dark); font-size: .72rem; font-weight: 750; }
.usage-summary strong { color: var(--ink); font-size: 1.1rem; letter-spacing: -.03em; }
.usage-controls { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1rem; padding: .9rem 1rem; }
.usage-control { min-width: 9rem; }
.usage-control label { margin: 0 0 .3rem; color: var(--muted); font-size: .75rem; }
.usage-control input, .usage-control select { width: auto; min-width: 8.5rem; padding: .55rem .65rem; }
.usage-clear { margin-bottom: .2rem; }
.usage-result-count { margin: 0 0 .45rem auto; color: var(--muted); font-size: .8rem; }
.billing-controls { display: flex; align-items: end; gap: 1rem; margin-bottom: 1rem; padding: .9rem 1rem; }
.billing-controls .usage-result-count { margin-left: auto; }
.tariff-form { padding: 1rem; }
.tariff-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem 1rem; }
.tariff-fields .usage-control, .tariff-form-footer .usage-control { min-width: 0; }
.tariff-fields .usage-control label, .tariff-form-footer .usage-control label { margin-top: 0; }
.tariff-fields input, .tariff-form-footer input { width: 100%; }
.tariff-form-footer { display: flex; align-items: end; gap: 1rem; margin-top: .25rem; }
.tariff-note-control { flex: 1 1 auto; }
.tariff-submit { flex: 0 0 auto; width: auto; margin-top: 0; padding: .72rem 1.1rem; }
.tariff-form-message { flex: 0 1 22rem; margin: 0 0 .55rem; color: var(--muted); font-size: .82rem; }
.tariff-form-message.is-success { color: #087443; }
.tariff-form-message.is-error { color: var(--danger); }
.settings-section { max-width: none; margin-top: 1.5rem; padding: 1.25rem; }
.settings-group { margin-top: 1rem; padding: 1.25rem 1.5rem; }
.settings-group-heading { margin-bottom: .25rem; }
.settings-group-heading h2 { margin-bottom: .3rem; color: var(--blue-dark); }
.settings-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.settings-card { display: flex; min-height: 15rem; flex-direction: column; padding: 1.5rem; }
.settings-card h3 { margin: .15rem 0 .75rem; color: var(--ink); font-size: 1.35rem; }
.settings-card p:not(.eyebrow) { margin-bottom: 1.25rem; color: var(--muted); line-height: 1.55; }
.settings-card-link { align-self: flex-start; margin-top: auto; padding: .3rem 0; color: var(--blue-dark); background: transparent; border: 0; font-size: .95rem; font-weight: 800; text-decoration: underline; cursor: pointer; }
.settings-detail { margin-top: 1rem; padding: 1.25rem 1.5rem; }
.back-settings-button { margin-bottom: 1.25rem; padding: .6rem .8rem; color: var(--navy); background: transparent; border: 1px solid #b8ccd8; border-radius: 10px; font-weight: 750; cursor: pointer; }
.back-settings-button:hover { background: var(--blue-soft); }
.settings-detail-heading { margin-bottom: .4rem; }
.settings-detail-heading h2 { margin-bottom: .3rem; color: var(--ink); }
.settings-subsection { padding: 1.25rem 0; border-top: 1px solid var(--line); }
.settings-subsection:first-of-type { margin-top: 1.25rem; }
.settings-state { color: var(--muted); font-size: .8rem; font-weight: 800; white-space: nowrap; }
.settings-warning { max-width: 54rem; margin: 0 0 1rem; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.settings-fields-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-fields input { width: 100%; }
.settings-actions { display: flex; align-items: center; gap: 1rem; margin-top: .25rem; }
.settings-actions .primary-button { width: auto; margin-top: 0; }
.settings-actions .form-message { margin: 0; }
.checkbox-control { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; font-weight: 750; }
.checkbox-control input { width: 1rem; height: 1rem; accent-color: var(--green); }
.users-table-wrap { overflow-x: auto; }
.users-table { min-width: 38rem; }
.users-table td:last-child, .users-table th:last-child { text-align: right; }
.user-status { display: inline-flex; padding: .28rem .55rem; border-radius: 999px; color: #087443; background: var(--green-soft); font-size: .75rem; font-weight: 800; }
.user-status.is-inactive { color: var(--danger); background: #fee4e2; }
.user-action { margin: 0; padding: .35rem .55rem; }
.toast-preferences-form { margin-top: 1.25rem; }
.toast-preference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 2rem; padding: 1.25rem; background: #f8fbfd; border: 1px solid var(--line); border-radius: 14px; }
.toast-select-control { display: grid; grid-template-columns: minmax(10rem, 1fr) minmax(12rem, 1.2fr); align-items: center; gap: 1rem; }
.toast-select-control label, .toast-duration-row label { color: var(--ink); font-size: .9rem; }
.toast-select-control select, .toast-duration-row select { width: 100%; }
.toast-duration-grid { display: grid; gap: .75rem; margin-top: 1.25rem; }
.toast-duration-row { display: grid; grid-template-columns: minmax(15rem, 1fr) 10rem 10rem; align-items: center; gap: 1rem; }
.toast-save-button { width: 100%; margin-top: 1.25rem; }
.toast-container { position: fixed; right: 1.25rem; z-index: 50; display: grid; gap: .65rem; width: min(25rem, calc(100vw - 2rem)); pointer-events: none; }
.toast-container.is-top-right { top: 1.25rem; }
.toast-container.is-centre-right { top: 50%; transform: translateY(-50%); }
.toast-container.is-bottom-right { bottom: 1.25rem; }
.toast { position: relative; display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; overflow: hidden; padding: .85rem 1rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; box-shadow: 0 14px 30px rgba(8, 47, 73, .18); pointer-events: auto; animation: toast-slide-in .2s ease-out; }
.toast.no-animation { animation: none; }
.toast.is-success { border-left-color: #0b9f55; background: #effaf3; }
.toast.is-warning { border-left-color: #b7791f; background: #fff8e6; }
.toast.is-error { border-left-color: #c62828; background: #fff0ef; }
.toast.tone-green { border-left-color: #0b9f55; background: #effaf3; }
.toast.tone-amber { border-left-color: #b7791f; background: #fff8e6; }
.toast.tone-red { border-left-color: #c62828; background: #fff0ef; }
.toast.tone-blue { border-left-color: #0284c7; background: #eff6ff; }
.toast-message { font-size: .85rem; line-height: 1.4; }
.toast-close { grid-column: 2; grid-row: 1; align-self: start; padding: 0 .15rem; color: var(--muted); background: transparent; border: 0; font-size: 1.1rem; cursor: pointer; }
.toast-progress { grid-column: 1 / -1; height: 3px; margin-top: .45rem; background: currentColor; opacity: .35; transform-origin: left; animation: toast-countdown var(--toast-duration) linear forwards; }
@keyframes toast-slide-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.billing-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.trusted-card { display: flex; align-items: baseline; gap: .6rem; padding: 1.05rem 1.25rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.trusted-card strong { color: var(--ink); font-size: 1.75rem; font-weight: 850; letter-spacing: -.04em; }
.data-section, .review-section { margin-top: 2.75rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1rem; }
.section-heading h3 { margin-bottom: 0; font-size: 1.5rem; }
.table-panel { overflow: hidden; }
.table-shell { overflow-x: auto; }
.usage-table-shell { max-height: min(72vh, 900px); overflow: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: .78rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.data-table thead th { color: var(--muted); background: #f7fbfd; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.usage-table thead th { position: sticky; top: 0; z-index: 3; background: #f7fbfd; box-shadow: 0 1px 0 var(--line); }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody th { color: var(--ink); font-weight: 750; }
.data-table tbody td { color: var(--muted); }
.data-table .notes-cell { min-width: 24rem; white-space: normal; }
.usage-table { min-width: 1180px; font-size: clamp(.63rem, .66vw, .8rem); }
.usage-table.is-standard { font-size: .82rem; }
.usage-table th, .usage-table td { padding: .48rem .42rem; }
.usage-table thead th { white-space: normal; line-height: 1.12; }
.usage-table .month-separator th { padding: .55rem .65rem; color: var(--blue-dark); background: #dfe7ea; font-size: 1.1em; text-align: left; }
.usage-table .month-total th, .usage-table .month-total td { color: var(--ink); background: #f1f4f5; border-bottom: 2px solid #bccbd2; font-weight: 800; }
.usage-table .usage-data-row { cursor: pointer; }
.usage-table .usage-data-row:hover th, .usage-table .usage-data-row:hover td { background: #fff8ef; }
.usage-table .usage-data-row.is-selected th, .usage-table .usage-data-row.is-selected td { color: var(--ink); background: #fff0df; border-bottom-color: #f4c38f; }
.usage-table .usage-data-row.is-selected th:first-child { box-shadow: inset 4px 0 0 #f28c28; }
.usage-table .usage-data-row:focus-visible { outline: 3px solid rgba(242, 140, 40, .45); outline-offset: -3px; }
.billing-table, .adjustments-table, .tariffs-table { font-size: .9rem; }
.billing-table.is-standard, .adjustments-table.is-standard, .tariffs-table.is-standard { font-size: .9rem; }
.billing-table { min-width: 1080px; }
.billing-table .bill-data-row { cursor: pointer; }
.billing-table .bill-data-row th, .billing-table .bill-data-row td { border-bottom: 1px solid var(--line); }
.billing-table .bill-data-row:hover th, .billing-table .bill-data-row:hover td { background: #fff8ef; }
.billing-table .bill-data-row:focus-visible { outline: 3px solid rgba(242, 140, 40, .45); outline-offset: -3px; }
.billing-table .bill-note-row td { padding-top: 0; padding-bottom: .78rem; color: var(--muted); border-bottom: 1px solid var(--line); white-space: normal; }
.billing-table .bill-note-row td { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.billing-table .bill-note-content { min-width: 0; }
.billing-table .bill-note-actions { display: inline-flex; flex: 0 0 auto; align-items: center; gap: .65rem; }
.billing-table .pdf-link { padding: .25rem .5rem; color: var(--blue-dark); font-size: .78rem; font-weight: 750; white-space: nowrap; }
.billing-table .bill-note-row strong { display: inline-block; margin-right: .65rem; color: var(--blue-dark); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.billing-table .bill-note-row span { display: inline; }
.bill-edit-button { flex: 0 0 auto; padding: .25rem .5rem; color: var(--blue-dark); font-size: .78rem; }
.bill-edit-dialog { width: min(760px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 80px rgba(8, 47, 73, .24); }
.bill-edit-dialog::backdrop { background: rgba(8, 47, 73, .4); }
.bill-edit-dialog form { padding: 1.5rem; }
.bill-notes-dialog { width: min(640px, calc(100vw - 2rem)); padding: 1.5rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 80px rgba(8, 47, 73, .24); }
.bill-notes-dialog::backdrop { background: rgba(8, 47, 73, .4); }
.bill-notes-text { margin: 1.25rem 0 .25rem; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }
.bill-context-menu { position: fixed; z-index: 50; display: grid; min-width: 180px; padding: .35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgba(8, 47, 73, .2); }
.bill-context-menu button { padding: .65rem .75rem; color: var(--ink); background: transparent; border: 0; border-radius: 8px; font: inherit; text-align: left; cursor: pointer; }
.bill-context-menu button:hover, .bill-context-menu button:focus-visible { background: #fff0df; outline: none; }
.bill-context-menu button:disabled { color: var(--muted); cursor: not-allowed; }
.bill-context-menu button:disabled:hover { background: transparent; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.dialog-heading h2 { margin: 0; }
.dialog-close { width: 2rem; height: 2rem; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.dialog-close:hover { color: var(--ink); background: var(--blue-soft); }
.bill-edit-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.bill-edit-wide { grid-column: 1 / -1; }
.bill-edit-fields input, .bill-edit-fields textarea { width: 100%; box-sizing: border-box; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }
.dialog-actions .primary-button { width: auto; margin-top: 0; }
.adjustments-table { min-width: 760px; }
.tariffs-table { min-width: 860px; }
.tariffs-table .tariff-row { cursor: pointer; }
.tariffs-table .tariff-row:hover th, .tariffs-table .tariff-row:hover td { background: #fff8ef; }
.tariffs-table .tariff-row.is-selected th, .tariffs-table .tariff-row.is-selected td { color: var(--ink); background: #fff0df; border-bottom-color: #f4c38f; }
.tariffs-table .tariff-row.is-selected th:first-child { box-shadow: inset 4px 0 0 #f28c28; }
.tariff-cancel { flex: 0 0 auto; margin-bottom: .55rem; }
.billing-table thead th, .adjustments-table thead th, .tariffs-table thead th { font-size: clamp(.62rem, .62vw, .75rem); line-height: 1.12; white-space: normal; }
.empty-cell { padding: 2rem !important; color: var(--muted) !important; text-align: center; }
.table-status { display: inline-flex; padding: .25rem .5rem; color: var(--blue-dark); background: var(--blue-soft); border-radius: 999px; font-size: .75rem; font-weight: 750; }
.review-list { display: grid; gap: 1rem; }
.review-card { padding: 1.35rem; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.review-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.review-card h3 { margin: 0; font-size: 1.25rem; }
.confidence-pill { padding: .35rem .6rem; color: var(--blue-dark); background: var(--blue-soft); border-radius: 999px; font-size: .8rem; font-weight: 750; white-space: nowrap; }
.review-facts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin: 1.25rem 0 .8rem; color: var(--muted); }
.review-facts strong { color: var(--ink); }
.review-source, .review-warning { margin: .4rem 0 0; color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.review-warning { color: #8a4b08; }
.review-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; }
.review-actions .primary-button { width: auto; margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card { min-height: 270px; }
  .comparison-heading { display: block; }
  .comparison-controls { align-items: stretch; flex-direction: column; }
  .comparison-control { justify-content: space-between; }
  .comparison-year-picker { flex: 1 1 auto; }
  .comparison-year-menu { width: min(18rem, calc(100vw - 5rem)); }
  .settings-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; }
  .brand-panel { min-height: 42vh; padding: 2.25rem 1.5rem 2.5rem; }
  .brand-logo { margin-bottom: 1.5rem; }
  .brand-panel h1 { max-width: 30rem; font-size: clamp(2.25rem, 12vw, 4rem); }
  .wave-line { margin-top: 2rem; }
  .login-card { width: min(100% - 2rem, 34rem); margin: -1rem auto 2rem; }
  .dashboard-intro, .view-heading, .evidence-strip { display: block; }
  .status-pill { margin-top: 1.25rem; }
  .period-controls { min-width: 0; margin-top: 1.25rem; }
  .usage-summary { margin-top: 1.25rem; }
  .evidence-counts { justify-content: start; margin-top: 1rem; }
  .data-status-heading { display: block; }
  .data-status-badge { margin-top: 1rem; }
  .data-status-grid { grid-template-columns: 1fr; }
  .settings-fields-three { grid-template-columns: 1fr 1fr; }
  .toast-preference-grid { grid-template-columns: 1fr; }
  .toast-duration-row { grid-template-columns: 1fr 1fr; }
  .toast-duration-row label { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .topbar { padding: .85rem 1rem; }
  .account-name { display: none; }
  .dashboard-content { width: min(calc(100% - 2rem), 2200px); padding: 2.25rem 0; }
  .dashboard-intro { margin-bottom: 1.4rem; }
  .tab-nav { margin-bottom: 1.5rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .kpi-card { display: block; min-height: 138px; padding: .9rem; }
  .kpi-icon { margin-bottom: .55rem; }
  .kpi-card strong { font-size: 1.5rem; }
  .overview-panels, .billing-summary { grid-template-columns: 1fr; gap: .65rem; }
  .period-controls { grid-template-columns: auto 1fr; }
  .period-controls select { width: 100%; }
  .usage-summary { display: grid; grid-template-columns: 1fr; gap: .5rem; }
  .usage-summary > div { min-width: 0; }
  .data-status-details div { grid-template-columns: minmax(7rem, 1fr) minmax(0, 1.2fr); }
  .tariff-fields { grid-template-columns: 1fr; }
  .billing-controls { align-items: flex-start; flex-wrap: wrap; }
  .billing-controls .usage-result-count { margin-left: 0; }
  .tariff-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tariff-form-footer { align-items: stretch; flex-direction: column; gap: .25rem; }
  .tariff-submit { width: 100%; }
  .tariff-form-message { margin: .4rem 0 0; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-actions { align-items: start; flex-wrap: wrap; }
  .settings-actions { align-items: stretch; flex-direction: column; gap: .5rem; }
  .settings-actions .primary-button { width: 100%; }
  .settings-card-grid { grid-template-columns: 1fr; }
  .settings-card { min-height: 0; }
  .settings-detail, .settings-group { padding: 1rem; }
  .toast-select-control, .toast-duration-row { grid-template-columns: 1fr; gap: .45rem; }
  .toast-duration-row label { grid-column: auto; }
  .toast-container { right: 1rem; left: 1rem; width: auto; }
  .section-heading { display: block; }
  .section-note { margin-top: .45rem; }
  .review-card-heading { display: block; }
  .confidence-pill { display: inline-block; margin-top: .75rem; }
  .review-actions { align-items: stretch; flex-direction: column; }
  .review-actions .primary-button { width: 100%; }
}
