:root {
  color-scheme: light;
  --bg: #f3f7fd;
  --surface: #ffffff;
  --surface-soft: #f7f9fd;
  --surface-strong: #eaf0f8;
  --ink: #14213d;
  --ink-soft: #5c6980;
  --ink-faint: #8993a6;
  --line: #e2e8f1;
  --line-strong: #cbd5e3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e9f0ff;
  --accent: #0f9f8e;
  --peak: #f97316;
  --peak-soft: #fff0e6;
  --flat: #d9a400;
  --flat-soft: #fff8dc;
  --valley: #0f9f8e;
  --valley-soft: #e4f8f5;
  --income: #16a36a;
  --income-soft: #e6f8ef;
  --expense: #e8792d;
  --expense-soft: #fff0e5;
  --danger: #d84a4a;
  --danger-soft: #fff0f0;
  --shadow: 0 20px 55px rgba(37, 76, 140, 0.09);
  --shadow-small: 0 8px 24px rgba(37, 76, 140, 0.09);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-sans: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 4% -8%, rgba(97, 159, 255, 0.19), transparent 29rem),
    radial-gradient(circle at 96% 24%, rgba(45, 212, 191, 0.12), transparent 30rem),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 46%, #f6f9fd 100%),
    var(--bg);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

body.auth-locked {
  overflow: hidden;
}

.auth-gate {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 16% 8%, rgba(96, 165, 250, 0.28), transparent 28rem),
    radial-gradient(circle at 88% 90%, rgba(45, 212, 191, 0.2), transparent 27rem),
    #eef5ff;
}

.auth-shell {
  display: grid;
  width: min(980px, 100%);
  min-height: 590px;
  grid-template-columns: minmax(0, 1.03fr) minmax(400px, 0.97fr);
  margin: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: 0 35px 100px rgba(30, 76, 155, 0.2);
}

.auth-intro {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  overflow: hidden;
  color: #ffffff;
  background:
    radial-gradient(circle at 92% 5%, rgba(255, 255, 255, 0.18), transparent 18rem),
    linear-gradient(145deg, #174ec8, #397ef4);
}

.auth-intro::after {
  position: absolute;
  right: -130px;
  bottom: -180px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  box-shadow:
    0 0 0 48px rgba(255, 255, 255, 0.035),
    0 0 0 104px rgba(255, 255, 255, 0.02);
  content: "";
  pointer-events: none;
}

.auth-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
}

.auth-intro > div {
  position: relative;
  z-index: 1;
}

.auth-intro .eyebrow {
  color: rgba(255, 255, 255, 0.62);
}

.auth-intro h1 {
  max-width: 430px;
  margin-bottom: 20px;
  color: #ffffff;
  font-size: clamp(38px, 4.8vw, 58px);
  font-weight: 650;
  letter-spacing: -0.05em;
  line-height: 1.08;
}

.auth-intro p:not(.eyebrow) {
  max-width: 400px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.75;
}

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

.auth-features span {
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
}

.auth-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 42px;
  background: var(--surface);
}

.auth-loading {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.auth-loading p,
.auth-subtitle,
.auth-unavailable p {
  margin-bottom: 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.auth-spinner {
  width: 30px;
  height: 30px;
  margin-bottom: 6px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: auth-spin 800ms linear infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.auth-tab {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.auth-tab.is-active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(37, 76, 140, 0.1);
}

.auth-form {
  display: grid;
  gap: 15px;
  margin-top: 28px;
}

.auth-form h2,
.auth-unavailable h2 {
  margin-bottom: 5px;
  font-size: 25px;
}

.auth-form input {
  height: 48px;
  background: var(--surface-soft);
}

.auth-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 11px;
}

.auth-password-help {
  margin: 0;
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.auth-unavailable {
  display: grid;
  gap: 15px;
}

.auth-unavailable p {
  font-size: 13px;
  line-height: 1.7;
}

.cached-account {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.cached-account > span {
  color: var(--ink-faint);
  font-size: 10px;
}

.cached-account > strong {
  overflow: hidden;
  margin-bottom: 4px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-glow {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(4px);
  opacity: 0.4;
}

.page-glow--one {
  top: 40%;
  left: -320px;
  background: rgba(96, 165, 250, 0.16);
}

.page-glow--two {
  right: -300px;
  bottom: 5%;
  background: rgba(45, 212, 191, 0.12);
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 6px 4px 28px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(145deg, #2668f4, #4d8dff);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.24);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand small {
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 12px;
}

.module-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-small);
}

.module-tab {
  min-width: 64px;
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.module-tab.is-active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(218, 226, 238, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
}

.account-chip {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 12px;
  border: 1px solid rgba(218, 226, 238, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
}

.account-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.account-main:hover .account-copy strong {
  color: var(--primary);
}

.account-main:disabled {
  cursor: default;
}

.account-main:disabled:hover .account-copy strong {
  color: inherit;
}

.sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 3px rgba(137, 147, 166, 0.12);
}

.sync-dot.is-online {
  background: #17a673;
  box-shadow: 0 0 0 3px rgba(23, 166, 115, 0.13);
}

.sync-dot.is-syncing {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
  animation: sync-pulse 900ms ease-in-out infinite alternate;
}

.sync-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(216, 74, 74, 0.13);
}

@keyframes sync-pulse {
  to {
    opacity: 0.45;
  }
}

.account-copy {
  display: grid;
  line-height: 1.18;
}

.account-copy small {
  color: var(--ink-faint);
  font-size: 9px;
}

.account-copy strong {
  max-width: 105px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 10px;
}

.logout-button:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: center;
  padding: 24px;
  background: rgba(18, 32, 58, 0.42);
  backdrop-filter: blur(5px);
}

body.modal-open {
  overflow: hidden;
}

.account-modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  margin: auto;
  padding: 28px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(20, 42, 82, 0.25);
}

.account-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.account-modal-header h2 {
  font-size: 24px;
}

.modal-close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-soft);
  background: var(--surface-soft);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--surface-strong);
}

.modal-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.account-overview {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid #dce7f7;
  border-radius: 16px;
  background: linear-gradient(135deg, #f3f8ff, #f9fcff);
}

.account-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border-radius: 14px;
  color: #ffffff;
  background: linear-gradient(145deg, #2467ed, #4d8dff);
  font-size: 18px;
  font-weight: 700;
}

.account-overview > div {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}

.account-overview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-overview > div span {
  color: var(--ink-faint);
  font-size: 10px;
}

.manager-sync {
  margin-left: auto;
  padding: 5px 9px;
  border-radius: 999px;
  color: #14805d;
  background: #e5f7ef;
  font-size: 10px;
  white-space: nowrap;
}

.account-section {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.account-section h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

.account-section > p,
.account-section-heading p {
  color: var(--ink-faint);
  font-size: 11px;
}

.account-form {
  display: grid;
  gap: 12px;
  margin-top: 0;
}

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

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

.account-section-heading h3 {
  margin-bottom: 3px;
}

.account-section-heading p {
  margin-bottom: 0;
}

.admin-user-list {
  display: grid;
  gap: 8px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.admin-user-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.admin-user-copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-copy small {
  color: var(--ink-faint);
  font-size: 10px;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
}

.admin-user-actions button {
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  cursor: pointer;
  font-size: 10px;
}

.admin-user-actions button:hover {
  background: #dce9ff;
}

.admin-user-actions button.is-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.role-badge {
  display: inline-block;
  width: fit-content;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 9px;
  font-weight: 600;
  vertical-align: 1px;
}

.account-section--danger {
  margin-top: 30px;
  padding: 18px;
  border: 1px solid #f1d8d8;
  border-radius: 14px;
  background: var(--danger-soft);
}

.account-section--danger h3 {
  margin-bottom: 5px;
  color: var(--danger);
}

.account-section--danger > p {
  margin-bottom: 14px;
}

.delete-account-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 0;
}

.account-delete-button {
  border-color: transparent;
  color: #ffffff;
  background: var(--danger);
}

.account-delete-button:hover {
  background: #c83f3f;
}

.top-actions a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 13px;
  transition: background 160ms ease, color 160ms ease;
}

.top-actions a:hover {
  color: var(--ink);
  background: var(--surface);
}

.dashboard {
  position: relative;
  padding: 38px;
  overflow: hidden;
  border: 1px solid rgba(222, 231, 243, 0.95);
  border-radius: 32px;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(96, 165, 250, 0.13), transparent 23rem),
    linear-gradient(150deg, #ffffff 0%, #fbfdff 62%, #f3f8ff 100%);
  box-shadow: 0 26px 70px rgba(37, 76, 140, 0.12);
}

.dashboard::after {
  position: absolute;
  top: -180px;
  right: -110px;
  width: 470px;
  height: 470px;
  border: 1px solid rgba(37, 99, 235, 0.07);
  border-radius: 50%;
  box-shadow:
    0 0 0 58px rgba(37, 99, 235, 0.025),
    0 0 0 120px rgba(37, 99, 235, 0.016);
  content: "";
  pointer-events: none;
}

.dashboard-heading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.dashboard .eyebrow {
  color: #7b8ba3;
}

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

h1 {
  max-width: 620px;
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 650;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.period-switch-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eff4fb;
}

.segment {
  min-width: 66px;
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.segment.is-active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24);
}

.period-picker {
  display: flex;
  align-items: center;
  gap: 4px;
}

.period-label {
  min-width: 116px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.icon-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.summary-region {
  position: relative;
  z-index: 1;
  margin-top: 34px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-width: 0;
  padding: 20px 21px 18px;
  border: 1px solid #e6edf7;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #f7faff);
}

.metric--primary {
  border-color: transparent;
  color: #ffffff;
  background: linear-gradient(140deg, #1e5fd9, #4285f4);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
}

.metric-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-label {
  color: var(--ink-soft);
  font-size: 12px;
}

.metric--primary .metric-label {
  color: rgba(255, 255, 255, 0.74);
}

.metric-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: var(--primary);
  background: var(--primary-soft);
}

.metric--primary .metric-icon {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.metric-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.metric--primary .metric-icon svg {
  fill: currentColor;
  stroke: none;
}

.metric-value {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 20px 0 5px;
  font-family: var(--font-mono);
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1;
}

.metric-value small {
  margin-left: 1px;
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}

.metric-value .currency {
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0;
}

.metric-context {
  min-height: 18px;
  margin-bottom: 0;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric--primary .metric-value small,
.metric--primary .metric-value .currency,
.metric--primary .metric-context {
  color: rgba(255, 255, 255, 0.72);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(250px, 0.72fr);
  gap: 12px;
  margin-top: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart-panel,
.breakdown-panel {
  color: var(--ink);
  background: #f8faff;
  box-shadow: none;
}

.chart-panel {
  position: relative;
  min-width: 0;
  padding: 22px 22px 14px;
}

.breakdown-panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading .eyebrow {
  margin-bottom: 4px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 13px;
  padding-top: 4px;
  color: var(--ink-soft);
  font-size: 11px;
}

.legend span,
.breakdown-row > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.legend-dot--peak {
  background: var(--peak);
}

.legend-dot--flat {
  background: var(--flat);
}

.legend-dot--valley {
  background: var(--valley);
}

.chart-wrap {
  position: relative;
  min-height: 260px;
  margin-top: 14px;
}

#usage-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid-line {
  stroke: rgba(138, 145, 140, 0.18);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 11px;
}

.chart-bar {
  transition: opacity 140ms ease;
}

.chart-bar:hover {
  opacity: 0.78;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.chart-hit:focus {
  outline: none;
}

.chart-focus-ring {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
  opacity: 0.7;
}

.chart-empty {
  position: absolute;
  inset: 80px 28px auto;
  margin: 0;
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  width: max-content;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-small);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.55;
  transform: translate(-50%, calc(-100% - 10px));
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 2px;
}

.donut-wrap {
  display: grid;
  min-height: 164px;
  place-items: center;
  padding: 12px 0 6px;
}

.donut {
  display: grid;
  width: 134px;
  height: 134px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--peak) 0 33.3%, var(--flat) 33.3% 66.6%, var(--valley) 66.6% 100%);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 29, 0.06);
}

.donut::before {
  grid-area: 1 / 1;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #f8faff;
  box-shadow: 0 0 0 1px rgba(23, 33, 29, 0.035);
  content: "";
}

.donut > span {
  z-index: 1;
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.donut strong {
  max-width: 76px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
}

.donut small {
  color: var(--ink-faint);
  font-size: 10px;
}

.breakdown-list {
  display: grid;
  gap: 9px;
  padding-top: 6px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 12px;
}

.breakdown-row strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.breakdown-row strong small {
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 400;
}

.finance-dashboard {
  position: relative;
  padding: 38px;
  overflow: hidden;
  border: 1px solid rgba(222, 231, 243, 0.95);
  border-radius: 32px;
  background:
    radial-gradient(circle at 88% 0%, rgba(22, 163, 106, 0.1), transparent 22rem),
    linear-gradient(150deg, #ffffff 0%, #fbfefc 65%, #f5fbf8 100%);
  box-shadow: 0 26px 70px rgba(37, 76, 140, 0.1);
}

.finance-dashboard .period-switch-wrap {
  position: relative;
  z-index: 1;
}

.finance-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.finance-metric {
  min-width: 0;
  padding: 20px 21px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.finance-metric--income {
  border-color: #d2efdf;
  background: linear-gradient(145deg, #ffffff, #f2fcf7);
}

.finance-metric--expense {
  border-color: #f4dfcf;
  background: linear-gradient(145deg, #ffffff, #fff9f4);
}

.finance-metric--balance {
  border-color: #dbe5f7;
  background: linear-gradient(145deg, #ffffff, #f5f9ff);
}

.finance-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 12px;
}

.finance-metric-symbol {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}

.finance-metric--income .finance-metric-symbol {
  color: var(--income);
  background: var(--income-soft);
}

.finance-metric--expense .finance-metric-symbol {
  color: var(--expense);
  background: var(--expense-soft);
}

.finance-metric--balance .finance-metric-symbol {
  color: var(--primary);
  background: var(--primary-soft);
}

.finance-metric > p {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 20px 0 5px;
  font-family: var(--font-mono);
  line-height: 1;
}

.finance-metric > p strong {
  overflow: hidden;
  font-size: clamp(25px, 3.5vw, 36px);
  font-weight: 600;
  letter-spacing: -0.05em;
  text-overflow: ellipsis;
}

.finance-metric--income > p strong {
  color: var(--income);
}

.finance-metric--expense > p strong {
  color: var(--expense);
}

.finance-metric--balance > p strong {
  color: var(--primary);
}

.finance-metric .currency {
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 14px;
}

.finance-metric > small {
  display: block;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finance-metric--balance.is-negative > p strong {
  color: var(--danger);
}

.finance-overview-grid {
  margin-top: 12px;
}

.finance-chart-panel,
.finance-category-panel {
  border-color: #e3eaf2;
  background: #ffffff;
}

.legend-dot--income {
  background: var(--income);
}

.legend-dot--expense {
  background: var(--expense);
}

.finance-category-panel {
  padding: 22px;
}

.finance-category-list {
  display: grid;
  gap: 13px;
  margin-top: 22px;
}

.finance-category-row {
  display: grid;
  gap: 6px;
}

.finance-category-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 11px;
}

.finance-category-meta strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
}

.finance-category-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.finance-category-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--expense);
}

.finance-category-empty {
  margin: 30px 0 8px;
  color: var(--ink-faint);
  font-size: 11px;
  text-align: center;
}

.finance-entry-panel,
.finance-records-panel,
.finance-yearly-panel {
  margin-top: 18px;
  padding: 26px;
}

.finance-entry-panel h2,
.finance-records-panel h2,
.finance-yearly-panel h2 {
  font-size: 22px;
}

.finance-type-switch {
  display: inline-flex;
  gap: 4px;
  margin-top: 20px;
  padding: 4px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.finance-type-button {
  min-width: 74px;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.finance-type-button[data-finance-type="income"].is-active {
  color: #ffffff;
  background: var(--income);
}

.finance-type-button[data-finance-type="expense"].is-active {
  color: #ffffff;
  background: var(--expense);
}

.finance-form-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(150px, 0.9fr) minmax(140px, 0.8fr) minmax(220px, 1.5fr);
  gap: 12px;
}

select {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  color: var(--ink);
  background:
    linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%) calc(100% - 16px) 20px / 5px 5px no-repeat,
    linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%) calc(100% - 11px) 20px / 5px 5px no-repeat,
    var(--surface);
  font: inherit;
  font-size: 14px;
  appearance: none;
}

select:focus {
  border-color: var(--valley);
  box-shadow: 0 0 0 3px rgba(15, 159, 142, 0.12);
}

.finance-form-grid label > span small {
  color: var(--ink-faint);
  font-size: 10px;
}

.finance-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.finance-form-footer > p {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.finance-form-footer > p strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 22px;
}

.finance-form-footer .currency {
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 11px;
}

.finance-form-footer .form-actions {
  padding-top: 0;
}

.finance-records-panel {
  margin-top: 18px;
}

.finance-record-note {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.finance-record-note.is-empty {
  color: var(--ink-faint);
}

.finance-type-badge {
  display: inline-block;
  min-width: 34px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  text-align: center;
}

.finance-type-badge--income {
  color: var(--income);
  background: var(--income-soft);
}

.finance-type-badge--expense {
  color: var(--expense);
  background: var(--expense-soft);
}

.finance-amount--income {
  color: var(--income);
}

.finance-amount--expense {
  color: var(--expense);
}

.finance-yearly-panel {
  margin-top: 18px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.72fr);
  align-items: start;
  gap: 18px;
  margin-top: 18px;
}

.entry-panel,
.settings-panel,
.data-panel,
.records-panel,
.yearly-panel {
  padding: 26px;
}

.entry-panel h2,
.settings-panel h2,
.data-panel h2,
.records-panel h2,
.yearly-panel h2 {
  font-size: 22px;
}

.text-button {
  padding: 6px 0;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.text-button:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.text-button--danger {
  margin-top: 18px;
  color: var(--danger);
}

form {
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  font-size: 15px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover {
  border-color: var(--line-strong);
}

input:focus {
  border-color: var(--valley);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 159, 142, 0.12);
}

input::placeholder {
  color: var(--ink-faint);
  opacity: 0.72;
}

input[type="date"] {
  max-width: 230px;
}

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

.form-row--date {
  grid-template-columns: minmax(0, 230px);
  padding-bottom: 18px;
}

.fixed-rate-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border: 1px solid #dce7f7;
  border-radius: 14px;
  background: linear-gradient(135deg, #f4f8ff, #f9fcff);
}

.fixed-rate-copy > span,
.fixed-rate-copy > strong {
  display: block;
}

.fixed-rate-copy > span {
  color: var(--ink-faint);
  font-size: 10px;
}

.fixed-rate-copy > strong {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
}

.fixed-rate-values {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  color: var(--ink-soft);
  font-size: 11px;
}

.fixed-rate-values span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.fixed-rate-values b {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.fixed-rate-strip .text-button {
  color: var(--primary);
  white-space: nowrap;
  text-decoration-color: currentColor;
}

.usage-entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 18px 0 2px;
}

.usage-field {
  gap: 12px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 14px;
}

.usage-field--peak {
  background: var(--peak-soft);
}

.usage-field--flat {
  background: var(--flat-soft);
}

.usage-field--valley {
  background: var(--valley-soft);
}

.usage-field-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-field-title strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.usage-field .input-wrap input {
  border-color: rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.8);
}

.input-wrap {
  position: relative;
  display: block;
}

.input-wrap input {
  padding-right: 55px;
  font-family: var(--font-mono);
}

.input-wrap em {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--ink-faint);
  font-size: 10px;
  font-style: normal;
  pointer-events: none;
  transform: translateY(-50%);
}

.tariff-group {
  padding: 17px 0;
  border-top: 1px solid var(--line);
}

.tariff-group-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}

.tariff-group-heading strong {
  font-size: 13px;
  font-weight: 600;
}

.tariff-group-heading small {
  margin-left: auto;
  color: var(--ink-faint);
  font-size: 11px;
}

.tariff-badge {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.tariff-badge--peak {
  color: #9e3f1f;
  background: var(--peak-soft);
}

.tariff-badge--flat {
  color: #89610d;
  background: var(--flat-soft);
}

.tariff-badge--valley {
  color: #17645c;
  background: var(--valley-soft);
}

.entry-preview {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px 14px;
  padding: 18px 0 2px;
  border-top: 1px solid var(--line);
}

.entry-preview > span {
  margin-right: auto;
  color: var(--ink-soft);
  font-size: 12px;
}

.entry-preview strong {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
}

.entry-preview .currency {
  margin-right: 2px;
  color: var(--ink-soft);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 16px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  transition: transform 140ms ease, background 160ms ease, border-color 160ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  color: #fdfaf3;
  background: var(--primary);
}

.button--primary:hover {
  background: var(--primary-hover);
}

.button--secondary {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.button--secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.button--block {
  width: 100%;
}

.save-hint,
.helper-text {
  color: var(--ink-faint);
  font-size: 11px;
}

.helper-text {
  margin-bottom: 0;
}

.field-error {
  min-height: 17px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 12px;
}

.side-stack {
  display: grid;
  gap: 18px;
}

.settings-panel form {
  display: grid;
  gap: 13px;
}

.rate-year-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.rate-year-picker > span {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}

.rate-year-picker .icon-button {
  color: var(--ink-soft);
}

.settings-panel .helper-text {
  margin-top: 1px;
}

.data-panel .helper-text {
  margin: 12px 0 16px;
}

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

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.records-panel,
.yearly-panel {
  margin-top: 18px;
}

.records-heading {
  align-items: flex-end;
}

.record-count {
  margin: 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  padding: 8px 10px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: right;
  white-space: nowrap;
}

td {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  padding-left: 0;
  text-align: left;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

td:nth-last-child(-n + 3),
th:nth-last-child(-n + 3) {
  font-family: var(--font-mono);
}

td strong {
  color: var(--ink);
  font-weight: 600;
}

.record-date {
  color: var(--ink);
  font-weight: 600;
}

.record-weekday {
  margin-left: 7px;
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 400;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.row-action {
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
}

.row-action:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.row-action--delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  display: grid;
  justify-items: center;
  padding: 40px 20px 32px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 18px;
  color: var(--ink-faint);
  background: var(--surface-soft);
}

.empty-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.empty-state p {
  max-width: 400px;
  margin-bottom: 17px;
  color: var(--ink-faint);
  font-size: 12px;
}

.year-strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  min-height: 130px;
  margin-top: 26px;
  padding: 0 2px;
}

.year-month {
  display: flex;
  min-width: 0;
  height: 110px;
  flex-direction: column;
  justify-content: flex-end;
  gap: 7px;
  border: 0;
  color: var(--ink-faint);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.year-month-bar-wrap {
  display: flex;
  height: 80px;
  align-items: flex-end;
  justify-content: center;
}

.year-month-bar {
  width: min(24px, 78%);
  min-height: 2px;
  border-radius: 5px 5px 2px 2px;
  background: var(--surface-strong);
  transition: height 220ms ease, background 160ms ease;
}

.year-month.has-data .year-month-bar {
  background: var(--valley);
}

.year-month:hover .year-month-bar {
  background: var(--primary);
}

.year-month.is-current {
  color: var(--ink);
  font-weight: 700;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 4px 0;
  color: var(--ink-faint);
  font-size: 10px;
}

footer p {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f8f4eb;
  background: #14213d;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.26);
  outline-offset: 2px;
}

.dashboard button:focus-visible,
.dashboard a:focus-visible {
  outline-color: rgba(37, 99, 235, 0.34);
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 28px, 760px);
  }

  .auth-shell {
    max-width: 560px;
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .auth-intro {
    display: none;
  }

  .dashboard {
    padding: 30px;
  }

  .finance-dashboard {
    padding: 30px;
  }

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

  .overview-grid,
  .work-grid {
    grid-template-columns: 1fr;
  }

  .breakdown-panel {
    display: grid;
    grid-template-columns: 1fr 160px 1fr;
    align-items: center;
    gap: 12px;
  }

  .breakdown-panel .panel-heading {
    align-self: start;
  }

  .donut-wrap {
    min-height: 0;
  }

  .breakdown-list {
    padding-top: 0;
  }

  .side-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .auth-gate {
    padding: 10px;
  }

  .auth-shell {
    border-radius: 24px;
  }

  .auth-card {
    padding: 28px 22px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .account-modal {
    max-height: calc(100vh - 20px);
    padding: 20px;
    border-radius: 20px;
  }

  .account-form-row {
    grid-template-columns: 1fr;
  }

  .delete-account-form {
    grid-template-columns: 1fr;
  }

  .delete-account-form .button {
    width: 100%;
  }

  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: flex-start;
  }

  .app-shell {
    width: min(100% - 20px, 600px);
    padding-top: 14px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 4px 2px 18px;
  }

  .module-switch {
    margin-left: auto;
  }

  .module-tab {
    min-width: 56px;
    padding-inline: 11px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .account-chip {
    height: 38px;
    padding-left: 10px;
  }

  .account-copy strong {
    max-width: 80px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .brand small {
    display: none;
  }

  .top-actions {
    gap: 0;
    padding: 3px;
  }

  .top-actions a {
    padding: 8px 10px;
    font-size: 12px;
  }

  #electricity-nav a:first-child {
    display: none;
  }

  .dashboard {
    padding: 25px 20px 18px;
    border-radius: 24px;
  }

  .finance-dashboard {
    padding: 25px 20px 18px;
    border-radius: 24px;
  }

  .dashboard-heading {
    flex-direction: column;
    gap: 20px;
  }

  h1 {
    max-width: none;
    font-size: clamp(25px, 7vw, 29px);
    text-wrap: balance;
  }

  .period-switch-wrap {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .period-label {
    min-width: 98px;
  }

  .summary-region {
    margin-top: 24px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .finance-metric-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .metric {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 15px 16px;
  }

  .metric-topline {
    grid-column: 1;
  }

  .metric-icon {
    display: none;
  }

  .metric-value {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
    font-size: 27px;
  }

  .metric-context {
    grid-column: 1;
  }

  .finance-metric {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 15px 16px;
  }

  .finance-metric-top {
    grid-column: 1;
  }

  .finance-metric > p {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
  }

  .finance-metric > p strong {
    font-size: 26px;
  }

  .finance-metric > small {
    grid-column: 1;
  }

  .overview-grid {
    gap: 8px;
    margin-top: 8px;
  }

  .chart-panel,
  .breakdown-panel {
    padding: 18px;
  }

  .chart-panel {
    padding-bottom: 10px;
  }

  .chart-wrap {
    min-height: 210px;
    margin-top: 8px;
  }

  .chart-empty {
    inset: 72px 18px auto;
  }

  .breakdown-panel {
    grid-template-columns: 1fr 120px;
  }

  .breakdown-panel .panel-heading {
    grid-column: 1 / -1;
  }

  .donut-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  .breakdown-list {
    grid-column: 2;
    grid-row: 2;
  }

  .donut {
    width: 108px;
    height: 108px;
  }

  .donut::before {
    width: 70px;
    height: 70px;
  }

  .work-grid {
    gap: 10px;
    margin-top: 10px;
  }

  .entry-panel,
  .settings-panel,
  .data-panel,
  .records-panel,
  .yearly-panel {
    padding: 20px;
  }

  .finance-entry-panel,
  .finance-records-panel,
  .finance-yearly-panel {
    margin-top: 10px;
    padding: 20px;
  }

  .side-stack {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .records-panel,
  .yearly-panel {
    margin-top: 10px;
  }

  .form-row {
    gap: 9px;
  }

  .form-row--date {
    grid-template-columns: 1fr;
  }

  .fixed-rate-strip {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 13px 14px;
  }

  .fixed-rate-values {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .usage-entry-grid {
    gap: 7px;
  }

  .usage-field {
    gap: 10px;
    padding: 10px;
  }

  .usage-field-title {
    gap: 5px;
  }

  .usage-field-title strong {
    font-size: 11px;
  }

  .usage-field .input-wrap input {
    padding-right: 27px;
    padding-left: 10px;
    font-size: 16px;
  }

  .usage-field .input-wrap em {
    right: 8px;
  }

  input[type="date"] {
    max-width: none;
  }

  .tariff-group-heading small {
    display: none;
  }

  .form-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .finance-form-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .finance-form-footer .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions .button {
    width: 100%;
  }

  .year-strip {
    gap: 2px;
    overflow: hidden;
  }

  .year-month {
    font-size: 9px;
  }

  .year-month-bar {
    width: 64%;
  }

  footer {
    flex-direction: column;
    gap: 5px;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 420px) {
  .brand strong {
    font-size: 14px;
  }

  .top-actions a {
    padding: 7px 8px;
    font-size: 11px;
  }

  .module-tab {
    min-width: 52px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .segmented {
    flex: 1;
  }

  .segment {
    min-width: 0;
    flex: 1;
  }

  .period-picker {
    flex: 0 0 auto;
  }

  .period-label {
    min-width: 84px;
    font-size: 12px;
  }

  .dashboard {
    padding-inline: 17px;
  }

  .legend {
    gap: 7px;
  }

  .breakdown-panel {
    grid-template-columns: 1fr;
  }

  .breakdown-panel .panel-heading {
    grid-column: 1;
  }

  .donut-wrap,
  .breakdown-list {
    grid-column: 1;
  }

  .donut-wrap {
    grid-row: 2;
  }

  .breakdown-list {
    grid-row: 3;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .entry-panel,
  .settings-panel,
  .data-panel,
  .records-panel,
  .yearly-panel {
    padding: 18px;
  }

  .finance-entry-panel,
  .finance-records-panel,
  .finance-yearly-panel {
    padding: 18px;
  }

  .finance-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .usage-entry-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c1424;
    --surface: #111c2f;
    --surface-soft: #16233a;
    --surface-strong: #23334e;
    --ink: #eef4ff;
    --ink-soft: #aab8cf;
    --ink-faint: #7485a1;
    --line: #26344c;
    --line-strong: #354866;
    --primary: #4f8cff;
    --primary-hover: #6aa0ff;
    --primary-soft: #1b3156;
    --peak-soft: #39251e;
    --flat-soft: #342e19;
    --valley-soft: #133632;
    --danger: #ff9999;
    --danger-soft: #3a2226;
    --shadow: 0 20px 55px rgba(0, 0, 0, 0.25);
    --shadow-small: 0 8px 24px rgba(0, 0, 0, 0.3);
  }

  body {
    background:
      radial-gradient(circle at 4% -8%, rgba(79, 140, 255, 0.15), transparent 29rem),
      radial-gradient(circle at 96% 24%, rgba(45, 212, 191, 0.08), transparent 30rem),
      var(--bg);
  }

  .auth-gate {
    background:
      radial-gradient(circle at 16% 8%, rgba(79, 140, 255, 0.17), transparent 28rem),
      radial-gradient(circle at 88% 90%, rgba(45, 212, 191, 0.08), transparent 27rem),
      var(--bg);
  }

  .auth-shell {
    border-color: var(--line);
  }

  .top-actions {
    background: rgba(17, 28, 47, 0.82);
  }

  .module-switch {
    background: rgba(17, 28, 47, 0.82);
  }

  .account-chip {
    border-color: var(--line);
    background: rgba(17, 28, 47, 0.82);
  }

  .account-overview {
    border-color: var(--line);
    background: linear-gradient(135deg, #142238, #111c2f);
  }

  .manager-sync {
    color: #79dfb5;
    background: #173b30;
  }

  .admin-user-actions button:hover {
    background: #23416d;
  }

  .account-section--danger {
    border-color: #5b3034;
  }

  .top-actions a:hover {
    background: var(--surface-soft);
  }

  .dashboard {
    background:
      radial-gradient(circle at 90% 0%, rgba(79, 140, 255, 0.09), transparent 23rem),
      linear-gradient(150deg, #111c2f 0%, #101a2c 65%, #11203a 100%);
  }

  .finance-dashboard {
    background:
      radial-gradient(circle at 88% 0%, rgba(22, 163, 106, 0.08), transparent 22rem),
      linear-gradient(150deg, #111c2f 0%, #101a2c 65%, #11251f 100%);
  }

  .finance-metric,
  .finance-chart-panel,
  .finance-category-panel {
    border-color: var(--line);
    background: #121e32;
  }

  .finance-metric--income {
    border-color: #1c493a;
    background: linear-gradient(145deg, #132238, #12291f);
  }

  .finance-metric--expense {
    border-color: #523828;
    background: linear-gradient(145deg, #132238, #2a211b);
  }

  .finance-metric--balance {
    border-color: #273d61;
    background: linear-gradient(145deg, #132238, #17263f);
  }

  .segment.is-active {
    color: #ffffff;
    background: var(--primary);
  }

  .metric {
    background: linear-gradient(145deg, #142238, #15243c);
    border-color: #26344c;
  }

  .metric--primary {
    border-color: transparent;
    background: linear-gradient(140deg, #1e5fd9, #3b7ef0);
  }

  .chart-panel,
  .breakdown-panel {
    background: #101a2c;
  }

  .donut::before {
    background: #101a2c;
  }

  .fixed-rate-strip {
    border-color: var(--line);
    background: linear-gradient(135deg, #142238, #111c2f);
  }

  .usage-field .input-wrap input {
    border-color: var(--line);
    background: var(--surface-soft);
  }

  input:focus {
    background: var(--surface-soft);
  }

  .button--primary {
    color: #ffffff;
  }

  .toast {
    border-color: var(--line);
    color: var(--ink);
    background: var(--surface-soft);
  }
}
