:root {
  color-scheme: light;
  --canvas: #f0f3ee;
  --surface: #fafbf7;
  --ink: #172522;
  --muted: #52635e;
  --line: #d8e2d9;
  --accent: #2c6057;
  --good: #267052;
  --danger: #a32834;
  --danger-fill: #f9ecec;
  --radius: 16px;
  --overview-fill: #deebe1;
  --overview-line: #bbcfc1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.55 "Geist", "Inter", "Segoe UI Variable", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, p, dl, dd { margin: 0; }
button { font: inherit; cursor: pointer; }
button, summary { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.page-shell { max-width: 1180px; margin: 0 auto; padding: 22px 28px 32px; }

.site-header {
  position: sticky;
  top: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  margin-bottom: 24px;
  padding: 8px 12px 8px 14px;
  border: 1px solid #fff;
  border-radius: var(--radius);
  background: rgba(253, 254, 251, .85);
  box-shadow: 0 1px 2px rgba(24, 43, 38, .06), 0 10px 28px -20px rgba(24, 43, 38, .38);
}

@supports ((backdrop-filter: blur(16px)) or (-webkit-backdrop-filter: blur(16px))) {
  .site-header {
    background: rgba(253, 254, 251, .74);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }
}

.brand, .header-actions { display: flex; align-items: center; min-width: 0; }
.brand { gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #426d5e;
}
.brand-mark svg { width: 24px; height: 24px; }
h1 { font-size: 20px; font-weight: 700; line-height: 1.15; }
.brand-copy p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.header-actions { gap: 16px; }

.connection, .runtime-state, .account-phase {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.connection { color: var(--good); font-size: 13px; }
.connection.is-paused { color: var(--muted); }
.connection.offline { color: var(--danger); }

.connection::before, .runtime-state::before, .account-phase::before {
  content: "";
  flex: 0 0 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

#pause {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid #d1dad4;
  border-radius: 9px;
  background: rgba(255, 255, 255, .58);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
#pause:hover, #pause[aria-pressed=true] { border-color: #9aafa5; background: #e7efea; }
#pause svg { width: 15px; height: 15px; }

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) repeat(3, minmax(0, 1fr));
  align-items: end;
  padding: 26px 8px;
  border: 1px solid #c8d9cc;
  border-radius: var(--radius);
  background: linear-gradient(155deg, #edf5ee, var(--overview-fill));
  box-shadow: inset 0 1px rgba(255, 255, 255, .82);
}

.metric { min-width: 0; padding: 5px 22px 7px; }
.metric + .metric { border-inline-start: 1px solid var(--overview-line); }
.metric-label, .metric-note { display: block; color: var(--muted); font-size: 13px; }
.metric-value {
  display: block;
  margin: 6px 0 2px;
  font-size: clamp(21px, 2.55vw, 29px);
  font-weight: 660;
  line-height: 1.06;
  letter-spacing: -.035em;
}
.metric-balance .metric-value { margin-top: 7px; color: #254d40; font-size: clamp(34px, 4.2vw, 55px); }
.metric-note, .metric-value, .connection { overflow-wrap: anywhere; }
.metric-value, .balance-value, .gain-value, .recent-value, time, .account-state dd {
  font-variant-numeric: tabular-nums;
}
[data-tone=negative] { color: var(--danger); }

.runtime-strip {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 13px;
  margin: 13px 0 26px;
  padding-inline: 2px;
  color: var(--muted);
  font-size: 13px;
}
.runtime-state { color: var(--good); font-weight: 660; }
.runtime-state[data-tone=error] { color: var(--danger); }
.timezone { margin-left: auto; }

.error, .account-error {
  padding: 9px 11px;
  border: 1px solid #efd4d6;
  border-radius: 8px;
  background: var(--danger-fill);
  color: var(--danger);
  overflow-wrap: anywhere;
}
.error { margin-bottom: 18px; }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3px 16px;
  margin-bottom: 12px;
}
.section-title { display: flex; align-items: baseline; gap: 10px; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.account-count, .section-heading > p { color: var(--muted); font-size: 13px; }

.account-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.account-card {
  --card-padding: 18px;
  min-width: 0;
  padding: 14px var(--card-padding) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.account-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.account-name { flex: 1 1 135px; min-width: 0; }
.account-name h3 { font-size: 17px; font-weight: 690; line-height: 1.25; overflow-wrap: anywhere; }
.account-auth { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.account-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; max-width: 100%; }
.account-phase, .account-charges { color: var(--muted); font-size: 12px; }
.account-phase[data-tone=busy] { color: var(--accent); }
.account-phase[data-tone=error] { color: var(--danger); }
.account-charges {
  padding: 3px 8px;
  border: 1px solid #d8e2dc;
  border-radius: 7px;
  background: #edf3ef;
  color: var(--accent);
  white-space: nowrap;
}
.account-charges[data-tone=pending] { background: transparent; color: var(--muted); }

.account-funds {
  display: grid;
  grid-template-columns: minmax(0, 1.17fr) minmax(0, 1fr) minmax(0, .85fr);
  gap: 10px 14px;
  padding: 12px 0;
}
.account-recent .recent-value { margin-top: 3px; }

@media (max-width: 1100px) {
  .account-funds { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .account-recent {
    display: flex;
    grid-column: 1 / -1;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }
  .account-recent .recent-value { margin-top: 0; }
}

.balance-label, .gain-label, .recent-label, .gain-note { display: block; color: var(--muted); font-size: 12px; }
.balance-value, .gain-value, .recent-value {
  display: block;
  margin-top: 3px;
  font-size: 18px;
  font-weight: 660;
  line-height: 1.18;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.balance-value { font-size: 28px; }
.gain-note { margin-top: 2px; overflow-wrap: anywhere; }

.daily-status { display: grid; padding: 4px 0; border-top: 1px solid var(--line); }
.task-status {
  display: grid;
  grid-template-columns: 2em minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  font-size: 13px;
}
.task-label, .task-plan { color: var(--muted); }
.task-plan { font-size: 12px; }
.task-value { font-weight: 560; overflow-wrap: anywhere; }
.task-value[data-tone=good] { color: var(--good); }
.task-value[data-tone=error] { color: var(--danger); }

.account-details {
  margin-inline: calc(-1 * var(--card-padding));
  padding-inline: var(--card-padding);
  border-top: 1px solid var(--line);
}
.account-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.account-details summary:focus-visible { outline-offset: -2px; }
.account-details summary:hover { color: var(--accent); }
.account-details summary::-webkit-details-marker { display: none; }
.account-details summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}
.account-details[open] summary::after { transform: rotate(225deg) translateY(-2px); }
.account-state { display: grid; gap: 6px; padding: 1px 0 14px; }
.account-state > div { display: grid; grid-template-columns: minmax(6em, auto) 1fr; gap: 8px; font-size: 13px; }
.account-state dt { color: var(--muted); }
.account-state dd { min-width: 0; overflow-wrap: anywhere; }
.account-error { margin: 2px 0 9px; font-size: 12px; white-space: pre-wrap; }

.empty { grid-column: 1 / -1; padding: 35px 16px; text-align: center; color: var(--muted); }
.page-foot, .foot-meta { display: flex; flex-wrap: wrap; gap: 3px 16px; justify-content: space-between; }
.page-foot { margin-top: 16px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

@media (max-width: 800px) {
  .page-shell { padding-inline: 20px; }
  .metric { padding-inline: 15px; }
  .timezone { display: none; }
  .account-card { --card-padding: 14px; }
  .account-funds { gap: 8px 10px; }
  .balance-value { font-size: 25px; }
}

@media (max-width: 640px) {
  .page-shell { padding: 12px 14px 22px; }
  .site-header { top: 8px; gap: 9px; margin-bottom: 14px; padding: 7px 9px; }
  .brand { gap: 7px; }
  .brand-copy p { display: none; }
  .header-actions { gap: 9px; }
  .connection { font-size: 12px; }
  #pause { min-height: 40px; padding-inline: 9px; font-size: 12px; }
  .overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 14px;
  }
  .metric { padding: 11px 0; }
  .metric-balance, .metric:last-child { grid-column: 1 / -1; }
  .metric-balance { padding-block: 16px; }
  .metric-balance .metric-value { font-size: 39px; }
  .metric + .metric { border-inline-start: 0; border-top: 1px solid var(--overview-line); }
  .metric:nth-child(2) { padding-inline-end: 10px; }
  .metric:nth-child(3) { padding-inline-start: 10px; }
  .metric:last-child {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    column-gap: 12px;
  }
  .metric:last-child .metric-value { margin: 0; }
  .metric:last-child .metric-note { grid-row: 2; }
  .runtime-strip { margin: 10px 0 18px; font-size: 12px; }
  .section-heading { margin-bottom: 9px; }
  h2 { font-size: 21px; }
  .section-heading > p { font-size: 12px; }
  .account-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .account-card { padding-top: 13px; }
  .account-funds { padding-block: 11px; }
  .gain-value, .recent-value { font-size: 16px; }
  .account-details summary { min-height: 42px; }
}

@media (max-width: 360px) {
  .balance-value { font-size: clamp(21px, 7vw, 24px); }
}

@media (prefers-reduced-transparency: reduce) {
  .site-header { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .overview { background: var(--overview-fill); }
}
