:root {
  color-scheme: light dark;
  --bg: #f4f2ec;
  --ink: #1a1a1a;
  --muted: #6b6b68;
  --line: #e5e2da;
  --panel: #ffffff;
  --panel-2: #faf8f2;
  --accent: #1a1a1a;
  --accent-soft: rgba(26, 26, 26, .05);
  --accent-2: #8c3a2e;
  --warn: #8a6a2e;
  --ok: #2b7a5e;
  --shadow: 0 18px 45px rgba(48, 40, 28, 0.08);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14140f;
    --ink: #ece9df;
    --muted: #8a8678;
    --line: #2b2a24;
    --panel: #1b1b17;
    --panel-2: #22221e;
    --accent: #ece9df;
    --accent-soft: rgba(236, 233, 223, .06);
    --accent-2: #c57a6e;
    --warn: #c8a55b;
    --ok: #6fa582;
    --shadow: 0 16px 50px rgba(0, 0, 0, .55);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--bg);
  background: var(--accent);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, opacity 150ms ease;
}

button:hover {
  opacity: .9;
}

button.secondary {
  color: var(--ink);
  background: var(--accent-soft);
}

button.danger {
  color: var(--accent-2);
  background: transparent;
}

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

input {
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--ink);
}

.shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 28px auto 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  font-weight: 600;
}

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

.segmented {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.segment {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  white-space: nowrap;
}

.segment.active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  opacity: 1;
}

.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary > div,
.card,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary > div {
  padding: 16px;
}

.summary span {
  display: block;
  font-size: 28px;
  font-weight: 600;
  font-family: var(--mono);
}

.summary small {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.card {
  padding: 16px;
}

.cardHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 18px;
}

.email {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.pill {
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(11, 122, 69, 0.35);
}

.pill.error {
  color: var(--accent-2);
  border-color: rgba(200, 70, 48, 0.35);
}

.meters {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.meter,
.balanceMeter {
  display: grid;
  gap: 7px;
}

.balanceMeter {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.meterTop,
.meterBottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.remaining {
  color: var(--ink);
  font-size: 23px;
  font-weight: 600;
  font-family: var(--mono);
}

.bar {
  height: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}

.fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.fill.warn {
  background: var(--warn);
}

.fill.danger {
  background: var(--accent-2);
}

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

.errorText {
  margin: 10px 0 0;
  color: var(--accent-2);
  font-size: 13px;
}

.empty {
  padding: 28px;
}

.empty h2 {
  margin: 0 0 8px;
}

.empty p {
  margin: 0;
  color: var(--muted);
}

.publicShell {
  width: min(1080px, calc(100vw - 32px));
}

.publicTopbar {
  align-items: center;
}

.publicMeta {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.publicMeta small {
  font-family: inherit;
}

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

.publicCard .meters {
  margin-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .actions input,
  .actions button,
  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

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

  .publicTopbar {
    align-items: stretch;
  }

  .publicMeta {
    justify-items: start;
  }

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