/* SubKeeper — mobile-first, works as a home-screen web app */
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url(fonts/barlow-sc-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #E9EDF2;
  --surface: #FFFFFF;
  --surface-2: #F3F5F8;
  --ink: #142033;
  --muted: #5E6B7D;
  --faint: #8C97A6;
  --line: #D5DCE5;
  --accent: #2340A0;
  --accent-soft: #DCE3F7;
  --accent-ink: #FFFFFF;
  --soon: #B56C00;
  --soon-soft: #FBEBD0;
  --urgent: #C8283E;
  --urgent-soft: #F9DDE1;
  --ok: #1F7A55;
  --backdrop: rgba(20, 32, 51, .38);
  --tabbar: rgba(255, 255, 255, .86);
  --font: "Barlow SC", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", system-ui, sans-serif;
  --r-sheet: 22px;
  --r-group: 14px;
  --r-logo: 11px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1520; --surface: #16212F; --surface-2: #1C2939; --ink: #E6ECF4; --muted: #94A1B3; --faint: #6D7A8C;
    --line: #263345; --accent: #8DA6FF; --accent-soft: #23315A; --accent-ink: #0D1520;
    --soon: #F0B44C; --soon-soft: #3A2E17; --urgent: #FF6B7D; --urgent-soft: #3D1C24; --ok: #4CC38A;
    --backdrop: rgba(0, 0, 0, .55); --tabbar: rgba(22, 33, 47, .88);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1520; --surface: #16212F; --surface-2: #1C2939; --ink: #E6ECF4; --muted: #94A1B3; --faint: #6D7A8C;
  --line: #263345; --accent: #8DA6FF; --accent-soft: #23315A; --accent-ink: #0D1520;
  --soon: #F0B44C; --soon-soft: #3A2E17; --urgent: #FF6B7D; --urgent-soft: #3D1C24; --ok: #4CC38A;
  --backdrop: rgba(0, 0, 0, .55); --tabbar: rgba(22, 33, 47, .88);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-family: "Barlow SC", var(--font); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- shell */
#view {
  max-width: 640px; margin: 0 auto; outline: none;
  padding: calc(var(--safe-t) + 14px) 16px calc(96px + var(--safe-b));
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, minmax(0, 150px)); justify-content: space-around;
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + var(--safe-b));
  background: var(--tabbar); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
  color: var(--faint); text-decoration: none; font-size: 11px; letter-spacing: .02em;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tabbar a[data-tab="subs"] svg rect { fill: currentColor; stroke: none; opacity: .9; }
.tabbar a.on { color: var(--accent); }
.tabbar .brand { display: none; }
.btn.dk-btn, .col, .list-head, .dk-conv, .evs { display: none; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.page-head { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 4px; }
.page-head h1 { flex: 1; margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- summary + runway */
.summary { margin: 6px 0 14px; }
.summary .big { font-size: 44px; line-height: 1; font-weight: 600; letter-spacing: -.02em; }
.summary .big small { font-size: 17px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.summary .sub { margin-top: 6px; color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.summary .warn { color: var(--soon); }

.runway {
  position: relative; background: var(--surface); border-radius: var(--r-group);
  padding: 12px 14px 10px; margin-bottom: 18px; border: 1px solid var(--line);
}
.runway-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 8px; }
.runway-head b { font-weight: 600; }
.runway-track { position: relative; height: var(--rh, 52px); margin: 0 14px; }
.runway-track::before {
  content: ""; position: absolute; left: -14px; right: -14px; bottom: 9px; height: 2px; background: var(--line); border-radius: 1px;
}
.runway-zone { position: absolute; bottom: 9px; height: 2px; }
.runway-zone.z3 { left: -14px; width: calc(10% + 14px); background: var(--urgent); }
.runway-zone.z7 { left: 10%; width: 13.33%; background: var(--soon); }
.runway-tick { position: absolute; bottom: 5px; width: 1px; height: 10px; background: var(--faint); opacity: .6; }
.runway-dot {
  position: absolute; transform: translateX(-50%); width: 30px; height: 30px; border-radius: 9px; padding: 0;
  border: 2px solid var(--surface); background: var(--surface-2); cursor: pointer; box-shadow: 0 0 0 1px var(--line);
}
.runway-dot img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; background: #fff; }
.runway-dot .initial { font-size: 13px; border-radius: 7px; }
.runway-dot::after {
  content: ""; position: absolute; left: 50%; width: 1px; background: var(--faint);
  bottom: calc(-1 * var(--stem, 3px) - 2px); height: var(--stem, 3px);
}
.runway-dot:active { transform: translateX(-50%) scale(.94); }
.runway-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 2px; }
.runway-empty { color: var(--muted); font-size: 14px; padding: 6px 0 2px; }

/* ---------------------------------------------------------------- filters */
.search {
  display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 10px; height: 40px; margin-bottom: 10px;
}
.search svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 15px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .n { color: var(--faint); margin-left: 4px; font-size: 12px; }
.chip.on .n { color: inherit; opacity: .7; }

/* ---------------------------------------------------------------- list */
.group { margin-bottom: 20px; }
.group-title { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 0 4px 6px; }
.list { background: var(--surface); border-radius: var(--r-group); border: 1px solid var(--line); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border: 0; background: transparent;
  text-align: left; cursor: pointer; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 70px; right: 0; height: 1px; background: var(--line); }
.row:active { background: var(--surface-2); }
.row.off { opacity: .55; }
.logo {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-logo); background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line);
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.initial { font-weight: 700; font-size: 19px; color: #fff; width: 100%; height: 100%; display: grid; place-items: center; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; white-space: nowrap; overflow: hidden; }
.row-meta span { overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; flex: none; }
.row-price { display: block; font-size: 17px; font-weight: 600; }
.row-conv { font-size: 12px; color: var(--faint); }
.due { font-size: 13px; color: var(--muted); }
.due.soon { color: var(--soon); font-weight: 600; }
.due.urgent { color: var(--urgent); font-weight: 600; }
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border-radius: var(--r-group);
  border: 1px dashed var(--line);
}
.empty p { margin: 0 0 14px; }

.fab {
  position: fixed; right: max(18px, calc(50% - 320px + 18px)); bottom: calc(76px + var(--safe-b)); z-index: 21;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 8px 22px -6px rgba(35, 64, 160, .55);
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.fab:active { transform: scale(.95); }

/* ---------------------------------------------------------------- buttons & form */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:active { filter: brightness(.95); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--urgent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); padding: 0 8px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.form-group { background: var(--surface); border-radius: var(--r-group); border: 1px solid var(--line); margin-bottom: 16px; overflow: hidden; }
.form-title { font-size: 13px; color: var(--muted); margin: 0 4px 6px; }
.frow { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 4px 14px; position: relative; }
.frow + .frow::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.frow > label, .frow > .lbl { flex: none; width: 6.2em; color: var(--ink); font-size: 15px; }
.frow input:not([type=checkbox]), .frow select, .frow textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; padding: 10px 0;
}
.frow select { appearance: none; -webkit-appearance: none; padding-right: 18px; cursor: pointer;
  background: linear-gradient(45deg, transparent 50%, var(--faint) 50%) right 6px center / 6px 6px no-repeat,
              linear-gradient(-45deg, transparent 50%, var(--faint) 50%) right 0 center / 6px 6px no-repeat; }
.frow textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
.frow .hint { font-size: 13px; color: var(--faint); flex: none; }
.frow.stack { flex-direction: column; align-items: stretch; gap: 0; padding-top: 10px; }
.frow.stack > label { width: auto; font-size: 13px; color: var(--muted); }
.frow .split { flex: 1; display: flex; gap: 8px; min-width: 0; }
.frow .split > * { min-width: 0; }
.frow input::placeholder, .frow textarea::placeholder { color: var(--faint); }
.frow-note { font-size: 13px; color: var(--muted); padding: 0 14px 12px; margin-top: -4px; }
.frow.err label { color: var(--urgent); }
input[type=date] { min-height: 1.5em; }
input[type=date]::-webkit-date-and-time-value { text-align: left; }

.switch { position: relative; width: 50px; height: 30px; flex: none; margin-left: auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .18s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font-size: 16px; }

/* ---------------------------------------------------------------- sheet */
#layer { position: relative; z-index: 50; }
.backdrop { position: fixed; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .22s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - var(--safe-t) - 24px);
  display: flex; flex-direction: column; background: var(--bg); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  box-shadow: 0 -10px 40px -10px rgba(0,0,0,.25);
}
.sheet.tall { height: calc(100dvh - var(--safe-t) - 24px); }
.open .backdrop { opacity: 1; }
.open .sheet { transform: none; }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 7px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px; flex: none; min-height: 50px; }
.sheet-head h2 { flex: 1; margin: 0; text-align: center; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head .btn-ghost { min-width: 64px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 16px calc(20px + var(--safe-b)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 560px; max-height: 86vh; border-radius: var(--r-sheet);
    transform: translate(-50%, -46%); opacity: 0; transition: transform .22s, opacity .22s; }
  .sheet.tall { height: 86vh; }
  .open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .backdrop, .switch span, .switch span::after { transition: none; }
}

/* editor logo */
.logo-edit { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; }
.logo-edit .logo { width: 68px; height: 68px; border-radius: 16px; }
.logo-edit .initial { font-size: 28px; }
.logo-edit .btn-row { flex: 1; }
.conv-hint { font-size: 13px; color: var(--muted); padding: 0 4px; margin: -8px 0 16px; min-height: 1.2em; }
.sub-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

/* logo search */
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-bottom: 18px; }
.logo-cand {
  aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 10px;
  display: grid; place-items: center; cursor: pointer; position: relative; overflow: hidden;
}
.logo-cand.checker { background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 50% / 14px 14px; }
.logo-cand img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-cand small { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; color: var(--muted); background: var(--surface); padding: 1px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-cand.busy { opacity: .4; }
.loading { color: var(--muted); padding: 18px 4px; font-size: 14px; }
.err-text { color: var(--urgent); font-size: 13px; }

/* ---------------------------------------------------------------- calendar */
.cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.cal-head .month { flex: 1; font-size: 20px; font-weight: 600; }
.cal-total { color: var(--muted); font-size: 14px; margin: -4px 0 12px; }
.cal { background: var(--surface); border-radius: var(--r-group); border: 1px solid var(--line); padding: 8px 6px; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow div { text-align: center; font-size: 12px; color: var(--faint); padding-bottom: 4px; }
.cal-day {
  min-height: 58px; border: 0; background: transparent; border-radius: 10px; padding: 4px 2px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cal-day .d { font-size: 15px; width: 26px; height: 26px; line-height: 26px; border-radius: 50%; text-align: center; }
.cal-day.other .d { color: var(--faint); opacity: .5; }
.cal-day.today .d { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cal-day.sel { background: var(--accent-soft); }
.cal-day .marks { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.cal-day .marks i { width: 16px; height: 16px; border-radius: 5px; overflow: hidden; background: var(--surface-2); display: block; }
.cal-day .marks i img { width: 100%; height: 100%; object-fit: contain; }
.cal-day .marks i .initial { font-size: 9px; }
.cal-day .more { font-size: 10px; color: var(--muted); line-height: 16px; }

/* ---------------------------------------------------------------- stats */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group); padding: 12px 14px; }
.kpi .k { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 600; line-height: 1.25; }
.kpi .s { font-size: 12px; color: var(--faint); }
.kpi.wide { grid-column: 1 / -1; }
.budget { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.budget i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.budget.over i { background: var(--urgent); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group); padding: 14px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 150px; }
.months .m {
  display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; min-width: 0;
  border: 0; background: none; padding: 0; cursor: pointer; color: inherit;
}
.months .bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.months .bar { width: 100%; max-width: 22px; background: var(--accent); border-radius: 4px 4px 1px 1px; min-height: 2px; opacity: .85; }
.months .m.now .bar { opacity: 1; background: var(--soon); }
.months .lab { font-size: 11px; color: var(--faint); white-space: nowrap; }
.months .val { display: none; font-size: 11px; color: var(--muted); white-space: nowrap; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 18px; }
.stats-grid .panel { margin: 0; }
.stats-grid .span-all { grid-column: 1 / -1; }
.cal-side { margin-top: 18px; }
.month-detail { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 1.4em; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 14px; }
.hbar .track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.hbar .pct { color: var(--faint); margin-left: 6px; font-size: 12px; }
.mini-list .row { padding: 8px 0; }
.mini-list .row + .row::before { left: 56px; }
.mini-list .logo { width: 36px; height: 36px; border-radius: 9px; }
.mini-list .initial { font-size: 15px; }

/* ---------------------------------------------------------------- settings */
.set-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 4px 14px; border: 0;
  background: transparent; text-align: left; cursor: pointer; position: relative; font-size: 15px; color: var(--ink); text-decoration: none;
}
.set-row + .set-row::before, .frow + .set-row::before, .set-row + .frow::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.set-row:active { background: var(--surface-2); }
.set-row .t { flex: 1; }
.set-row .v { color: var(--muted); font-size: 14px; max-width: 55%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row .chev { width: 8px; height: 8px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); flex: none; }
.set-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.set-row .dot.on { background: var(--ok); }
.set-row.danger { color: var(--urgent); }
.set-foot { font-size: 12px; color: var(--faint); text-align: center; margin: 8px 0 24px; }
.set-foot a { color: inherit; }
.lookup-item { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; position: relative; min-height: 50px; }
.lookup-item + .lookup-item::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--line); }
.lookup-item input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; padding: 8px 0; }
.lookup-item .used { font-size: 12px; color: var(--faint); }

/* import */
.imp-sym { display: flex; align-items: center; gap: 10px; }
.imp-sym b { min-width: 3.2em; font-size: 17px; }
.imp-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; position: relative; }
.imp-row + .imp-row::before { content: ""; position: absolute; top: 0; left: 46px; right: 0; height: 1px; background: var(--line); }
.imp-row input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.imp-row .grow { flex: 1; min-width: 0; }
.imp-row .nm { font-weight: 500; }
.imp-row .mt { font-size: 13px; color: var(--muted); }
.imp-row select { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); padding: 3px 6px; font-size: 14px; }
.imp-row.bad .nm { color: var(--urgent); }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 6px; background: var(--soon-soft); color: var(--soon); margin-left: 6px; vertical-align: 2px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 12px 0; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------------------------------------------------------------- toast */
#toast {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translate(-50%, 12px); z-index: 80;
  max-width: min(90vw, 420px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--urgent); color: #fff; }

/* ---------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login { width: 100%; max-width: 340px; text-align: center; }
.login-mark { margin: 0 auto 14px; border-radius: 16px; }
.login h1 { margin: 0; font-size: 30px; font-weight: 700; }
.login-sub { margin: 2px 0 28px; color: var(--muted); }
.login form { text-align: left; }
.login-error { color: var(--urgent); font-size: 14px; margin: -4px 0 12px; }

/* ================================================================ tablet ≥ 720px */
@media (min-width: 720px) {
  #view { max-width: 760px; padding-left: 24px; padding-right: 24px; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .months { height: 190px; }
  .months .val { display: block; }
  #toast { bottom: calc(110px + var(--safe-b)); }
}

/* ================================================================ desktop ≥ 1024px */
@media (min-width: 1024px) {
  /* 底部标签栏 → 左侧导航 */
  #app { padding-left: 220px; }
  .tabbar {
    top: 0; right: auto; width: 220px; display: flex; flex-direction: column; justify-content: flex-start; gap: 2px;
    padding: 22px 12px; border-top: 0; border-right: 1px solid var(--line);
    background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .tabbar .brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-size: 18px; font-weight: 700; }
  .tabbar .brand img { border-radius: 8px; }
  .tabbar a { flex-direction: row; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 15px; color: var(--muted); }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a:hover { background: var(--surface-2); color: var(--ink); }
  .tabbar a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

  #view { max-width: 1200px; margin: 0 auto; padding: 28px 40px 56px; }
  #view[data-page="settings"] { max-width: 820px; }
  .page-head { margin-bottom: 10px; }
  .page-head h1 { font-size: 30px; }
  .fab { display: none; }
  .btn.dk-btn { display: inline-flex; }
  #toast { bottom: 32px; left: calc(50% + 110px); }

  /* 订阅页：概览与时间轴并排 */
  .subs-top { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 28px; align-items: center; margin-bottom: 22px; }
  .subs-top .summary, .subs-top .runway { margin: 0; }
  .summary .big { font-size: 48px; }
  .filters { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
  .filters .search { flex: 0 0 300px; margin: 0; }
  .filters .chips { flex: 1; flex-wrap: wrap; margin: 0; padding: 0; overflow: visible; }

  /* 订阅列表 → 表格 */
  .list.table .row, .list-head {
    display: grid; align-items: center; column-gap: 16px;
    grid-template-columns: 40px minmax(140px, 2fr) minmax(70px, 1fr) minmax(70px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr);
  }
  .list.table .col.col-pay, .list-head .col-pay { display: none; }
  .list-head { padding: 9px 18px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
  .list-head span:last-child { text-align: right; }
  .list.table .row { padding: 10px 18px; }
  .list.table .row + .row::before { left: 18px; }
  .list.table .logo { width: 40px; height: 40px; border-radius: 10px; }
  .list.table .row-meta, .list.table .m-due { display: none; }
  .list.table .col { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list.table .col-date { color: var(--ink); }
  .list.table .col-date .due { display: block; font-size: 12px; }
  .list.table .dk-conv { display: block; }
  .group-title { font-size: 14px; }

  /* 日历：大格子显示名称，右侧明细 */
  .cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
  .cal-side { margin-top: 0; position: sticky; top: 28px; }
  .cal { padding: 10px; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 108px; align-items: stretch; justify-content: flex-start; padding: 6px; gap: 4px; text-align: left; }
  .cal-day .d { align-self: flex-start; }
  .cal-day .marks { display: none; }
  .cal-day .evs { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .cal-day .ev {
    display: flex; align-items: center; gap: 5px; min-width: 0; padding: 2px 6px 2px 2px; border-radius: 6px;
    background: var(--surface-2); font-size: 12px; line-height: 16px; white-space: nowrap;
  }
  .cal-day .ev > span { overflow: hidden; text-overflow: ellipsis; }
  .cal-day .ev i { width: 16px; height: 16px; flex: none; border-radius: 4px; overflow: hidden; display: block; background: #fff; }
  .cal-day .ev i img { width: 100%; height: 100%; object-fit: contain; }
  .cal-day .ev i .initial { font-size: 9px; }
  .cal-day .ev.more { background: none; color: var(--muted); padding-left: 4px; }
  .cal-day.sel { background: var(--accent-soft); }

  /* 统计 */
  .kpi .v { font-size: 28px; }
  .months { height: 230px; gap: 10px; }
  .months .bar { max-width: 40px; }
}

/* 足够宽时再显示支付方式列 */
@media (min-width: 1280px) {
  .list.table .row, .list-head {
    grid-template-columns: 40px minmax(160px, 2.2fr) minmax(80px, 1fr) minmax(80px, 1fr) minmax(90px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr);
  }
  .list.table .col.col-pay { display: block; }
  .list-head .col-pay { display: inline; }
}

@media (hover: hover) {
  .row:hover, .cal-day:not(.other):hover, .set-row:hover { background: var(--surface-2); }
  .cal-day.sel:hover { background: var(--accent-soft); }
  .chip:not(.on):hover { border-color: var(--faint); }
}
