:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --border: #e3e0d8;
  --text: #1f1e1b;
  --muted: #6b6860;
  --faint: #9a968c;
  --accent: #c96442;
  --accent-ink: #ffffff;
  --ok: #2f8f5b;
  --warn: #c98a12;
  --bad: #c2412d;
  --track: #ebe8e1;
  --series-a: #2b6cd4;
  --series-b: #d0671d;
  --grid: #ebe8e1;
  --shadow: 0 1px 2px rgba(20, 18, 12, .05), 0 2px 8px rgba(20, 18, 12, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #2a2824;
    --border: #36332e;
    --text: #ecebe7;
    --muted: #a8a49a;
    --faint: #7a766d;
    --accent: #d9775a;
    --accent-ink: #1a1512;
    --ok: #4cb37c;
    --warn: #e0a53a;
    --bad: #e5654f;
    --track: #33302b;
    --series-a: #6ea2f5;
    --series-b: #f0924d;
    --grid: #2f2c28;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171614;
  --surface: #211f1c;
  --surface-2: #2a2824;
  --border: #36332e;
  --text: #ecebe7;
  --muted: #a8a49a;
  --faint: #7a766d;
  --accent: #d9775a;
  --accent-ink: #1a1512;
  --ok: #4cb37c;
  --warn: #e0a53a;
  --bad: #e5654f;
  --track: #33302b;
  --series-a: #6ea2f5;
  --series-b: #f0924d;
  --grid: #2f2c28;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 16px 64px; }

/* 顶栏 */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; align-items: center; }

/* 本机 claude 任务数 */
.tasks-wrap { position: relative; }
.tasks-pill {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; line-height: 1.2;
}
.tasks-pill:hover { background: var(--surface-2); }
.tasks-pill b { font-size: 17px; color: var(--text); font-weight: 700; }
.tasks-pill.active b { color: var(--ok); }
.tasks-sub { color: var(--faint); border-left: 1px solid var(--border); padding-left: 8px; margin-left: 2px; }
.tasks-sub:empty { display: none; }
.tasks-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.tasks-pill.active .tasks-dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 143, 91, .45); } 100% { box-shadow: 0 0 0 7px rgba(47, 143, 91, 0); } }
@media (prefers-reduced-motion: reduce) { .tasks-pill.active .tasks-dot { animation: none; } }
.tasks-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tasks-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(420px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .14); padding: 6px 0;
}
.tp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 14px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tp-head span { color: var(--muted); font-size: 12.5px; }
.tp-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tp-main { min-width: 0; flex: 1; }
.tp-name { font-weight: 600; font-size: 14px; word-break: break-all; }
.tp-pid { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 4px; }
.tp-meta { color: var(--muted); font-size: 12.5px; word-break: break-all; }
.tp-foot { color: var(--faint); font-size: 12px; padding: 8px 14px 6px; }
.tasks-panel .empty { padding: 14px; }
.st { flex: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); margin-top: 1px; }
.st-busy { color: var(--ok); border-color: var(--ok); }
.st-unknown { color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; line-height: 1.2;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .seg button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 16px; height: 16px; }
.spin .ico { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warn);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}
.notice.err { border-left-color: var(--bad); }
.notice.ok { border-left-color: var(--ok); }

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; }
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.profile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.card-actions { display: flex; gap: 6px; flex: none; margin-left: auto; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.sm .ico { width: 14px; height: 14px; }
.profile-name { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 650; min-width: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; word-break: break-all; }
.meta b { color: var(--text); font-weight: 600; }

.sub-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 13.5px; padding: 7px 10px 7px 12px; background: var(--surface-2); border-radius: 8px; min-height: 40px; }
.sub-label { color: var(--muted); }
.sub-val { font-weight: 600; }
.sub-val.muted { color: var(--faint); font-weight: 400; }
.sub-days { font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--ok); }
.sub-days.warn { color: var(--warn); }
.sub-days.bad { color: var(--bad); }
.sub-row .btn.link { margin-left: auto; background: transparent; border-color: transparent; color: var(--accent); padding: 3px 6px; }
.sub-row .btn.link:hover { background: var(--surface); }
.date-input { font: inherit; font-size: 13.5px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.sub-hint { flex-basis: 100%; color: var(--faint); font-size: 12px; }

.win { margin-top: 14px; }
.win-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.win-label { font-size: 14px; font-weight: 600; }
.win-pct { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.win-pct small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.win-pct .used-tag { font-style: normal; font-size: 12px; font-weight: 500; color: var(--muted); margin-right: 5px; letter-spacing: 0; }
.bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 6px 0 5px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ok); min-width: 2px; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.win-reset { color: var(--muted); font-size: 12.5px; }
.win.minor .win-label { font-weight: 500; color: var(--muted); }
.win.minor .win-pct { font-size: 16px; }
.win.minor .bar { height: 5px; }

.foot { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.errline { color: var(--bad); }
.stale { color: var(--warn); }
.empty { color: var(--faint); font-size: 14px; padding: 18px 0 4px; }

/* 新增账号入口 */
.add-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 180px; cursor: pointer; font: inherit; color: var(--muted);
  border: 1.5px dashed var(--border); background: transparent; box-shadow: none; text-align: center;
}
.add-tile:hover { background: var(--surface); color: var(--text); border-color: var(--faint); }
.add-tile.pending { border-color: var(--accent); color: var(--text); }
.add-plus { font-size: 26px; line-height: 1; color: var(--accent); }
.add-title { font-size: 16px; font-weight: 650; }
.add-sub { font-size: 12.5px; color: var(--faint); max-width: 240px; }
.add-tile.pending .add-sub { color: var(--accent); }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(15, 13, 10, .45); display: grid; place-items: center; padding: 16px; }
.modal-card { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 48px rgba(0, 0, 0, .25); padding: 18px 20px 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.add-form { display: grid; gap: 6px; }
.add-form label { font-size: 13px; color: var(--muted); margin-top: 6px; }
.add-form input, .steps textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.steps textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; resize: vertical; margin-top: 6px; word-break: break-all; }
.name-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow: hidden; }
.name-input span { padding: 8px 2px 8px 10px; color: var(--muted); font-size: 14px; }
.name-input input { border: 0; border-radius: 0; padding-left: 0; background: transparent; }
.name-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.name-input input:focus-visible { outline: none; }
.field-hint { color: var(--faint); font-size: 12.5px; margin: 2px 0 0; }
.field-hint code { font-size: 12px; color: var(--muted); }
.form-err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 12px; font-size: 14px; }
.steps li::marker { color: var(--accent); font-weight: 700; }
.step-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
a.btn { text-decoration: none; }
.add-wait { display: flex; align-items: center; gap: 10px; padding: 22px 4px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.add-done { padding: 6px 2px; display: grid; gap: 6px; font-size: 14px; }
.add-done .big { font-size: 17px; font-weight: 700; }
.add-done.ok .big { color: var(--ok); }
.add-done.bad .big { color: var(--bad); }

/* 历史 */
.history { margin-top: 32px; display: grid; gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 19px; }
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 0; }
.hint.small { margin: 2px 0 10px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 11px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chart-head h3 { margin: 0; font-size: 15px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { position: relative; margin-top: 10px; min-height: 220px; }
.chart svg { display: block; max-width: 100%; overflow: visible; }
.chart .axis { fill: var(--faint); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .limit { stroke: var(--bad); stroke-width: 1; stroke-dasharray: 4 4; opacity: .5; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--surface); stroke-width: 1.5; }
.chart .cursor { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-empty { display: grid; place-items: center; height: 220px; color: var(--faint); font-size: 14px; }

.tip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.5;
  padding: 7px 10px; border-radius: 7px; max-width: 280px; box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.tip b { font-weight: 650; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
td.pct { font-weight: 650; }
td .mini { display: inline-block; width: 64px; height: 5px; background: var(--track); border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
td .mini > i { display: block; height: 100%; background: var(--ok); }
td .mini.warn > i { background: var(--warn); }
td .mini.bad > i { background: var(--bad); }
tr.active td { background: var(--surface-2); }

/* 登录 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.brand .dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.login-card .btn { justify-content: center; padding: 10px; }
.login-err { color: var(--bad); font-size: 13px; min-height: 1.2em; }

@media (max-width: 560px) {
  .wrap { padding-top: 20px; }
  .card { padding: 16px; }
  .top h1 { font-size: 21px; }
}
