:root {
  --bg: #f2f2f7; --card: #ffffff; --text: #1c1c1e; --muted: #6e6e73; --line: rgba(60,60,67,.14);
  --blue: #007aff; --green: #248a3d; --orange: #b25000; --red: #d70015; --fill: rgba(120,120,128,.12);
  --orange-bg: #fff4e5; --red-bg: #ffebee;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --text: #f2f2f7; --muted: #98989f; --line: rgba(84,84,88,.6);
    --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --fill: rgba(120,120,128,.24);
    --orange-bg: #3a2a10; --red-bg: #3a1514; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-size: 30px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.error { color: var(--red); font-size: 14px; min-height: 1em; margin: 4px 0; }
button { font: inherit; font-size: 15px; border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; background: var(--fill); color: var(--blue); }
button.primary { background: var(--blue); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 14px; }
button.danger-text { background: transparent; color: var(--red); padding-left: 0; }
button.wide { display: block; width: 100%; margin: 4px 0 20px; text-align: left; font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; font-size: 16px; width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
input[type=checkbox] { width: auto; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--card); border-radius: 14px; }
.auth-card { width: 100%; max-width: 360px; padding: 28px 24px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.auth-card img { margin: 0 auto; }

main { max-width: 760px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px 40px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin: 12px 0 16px; }
.top p { margin: 2px 0 0; font-size: 14px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric { background: var(--card); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric span { font-size: 13px; }
.metric b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric.warn { background: var(--orange-bg); }
.metric.warn b, .metric.warn span { color: var(--orange); }
@media (max-width: 520px) { .metrics { grid-template-columns: 1fr 1fr; } .metric:last-child { grid-column: span 2; } h1 { font-size: 26px; } }

.banner { background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; font-size: 15px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner ol { margin: 6px 0 0; padding-left: 20px; }

.group h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 18px 4px 6px; text-transform: none; }
.list { background: var(--card); border-radius: 14px; overflow: hidden; }
.prog { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.prog:first-child { border-top: 0; }
.prog:hover { background: var(--fill); }
.prog .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog .sub { font-size: 13px; color: var(--muted); }
.prog .sub .due { color: var(--orange); }
.prog .sub .fresh { color: var(--green); }
.prog .sub .exp { color: var(--red); }
.prog .bal { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.prog .bal small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.prog.archived { opacity: .55; }

.settings { padding: 14px 16px; margin-top: 8px; }
.row-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.row-line.col { flex-direction: column; align-items: stretch; gap: 6px; }
.row-line input[type=number] { width: 70px; display: inline-block; text-align: center; padding: 6px; }
.copy-line { display: flex; gap: 8px; align-items: center; justify-content: space-between; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.sheet-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; max-height: 88vh; overflow: auto; }
.sheet-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.sheet-body label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; }
.hist { font-size: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.hist div { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.hist .up { color: var(--green); } .hist .down { color: var(--red); }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1c1c1e; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 10; max-width: calc(100vw - 32px); }

/* approval page for AI apps */
.auth-hint { color: var(--muted); font-size: 14px; margin: 0; }
.auth-card label { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 13px; color: var(--muted); }
.auth-error { color: var(--red); font-size: 14px; min-height: 1em; margin: 0; }
.warn-box { background: var(--orange-bg); color: var(--orange); border-radius: 10px; padding: 10px 12px; font-size: 14px; text-align: left; margin: 0; }
.access-pick { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.auth-card .pick { flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: 15px; cursor: pointer; }
.pick input { width: auto; margin-top: 3px; }
.pick span { display: flex; flex-direction: column; gap: 2px; }
.pick small { color: var(--muted); font-size: 13px; }
.text-btn { background: transparent; }
