/* 换票 —— 桌面三栏 / 手机左右滑动 */
:root {
  --bg: #f2f4f6;
  --card: #fff;
  --head: #fafbfc;
  --fg: #1b1f24;
  --muted: #6b7280;
  --line: #e4e7eb;
  --brand: #0a7d5a;
  --brand-fg: #fff;
  --danger: #c0392b;
  --ok: #0a7d5a;
  --shadow: 0 2px 12px rgba(0, 0, 0, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a; --card: #1c1f24; --head: #22262c; --fg: #e8eaed;
    --muted: #9aa1ab; --line: #2c3138; --brand: #12a074; --ok: #22c08a;
    --shadow: 0 2px 12px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.spacer { flex: 1; }

/* ── 通用控件 ─────────────────────────────────────────── */
.btn {
  font: inherit; font-size: 14px;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  cursor: pointer; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 7px 10px; font-size: 16px; line-height: 1; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

input[type=text], input[type=password], textarea {
  font: inherit; width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--fg);
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); flex: none; margin: 0; cursor: pointer; }

/* ── 登录 ─────────────────────────────────────────────── */
.login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0 0 6px; }
.msg { font-size: 13px; min-height: 18px; margin: 2px 0 0 !important; }
.msg.err { color: var(--danger); }

/* ── 主框架 ───────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
  position: relative; z-index: 30; flex: none;
}
.brand { font-weight: 700; font-size: 16px; }

.menu {
  position: absolute; right: 10px; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; min-width: 130px;
}
.menu button {
  font: inherit; font-size: 14px; text-align: left; padding: 10px 14px;
  background: none; border: 0; color: var(--fg); cursor: pointer;
}
.menu button:hover { background: var(--head); }

.tabs {
  display: flex; background: var(--card);
  border-bottom: 1px solid var(--line); flex: none;
}
.tab {
  flex: 1; font: inherit; font-size: 14px; padding: 9px 0;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 手机：三栏整宽，左右滑动 */
.panels {
  flex: 1; min-height: 0; display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--line);
}
.panel {
  flex: 0 0 100%; min-width: 100%; scroll-snap-align: start;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg);
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--head);
  border-bottom: 1px solid var(--line); flex: none;
}
.panel-title { font-weight: 600; font-size: 14px; }
.panel-title b { color: var(--muted); font-weight: 500; }
.mini { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; }
.panel-body {
  flex: 1; min-height: 0; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

/* ── 列表行 ───────────────────────────────────────────── */
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.row .main { flex: 1; min-width: 0; cursor: pointer; }
.row .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row.off { opacity: .5; }
/* 只作用于账号行：活动行的 .title 要保持块级，否则里面的文字截断(ellipsis)会失效 */
.row .title.acc-title { display: flex; align-items: center; gap: 8px; }
.row .acc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* token 巡检徽标 */
.hb {
  margin-left: auto; flex: none; white-space: nowrap;
  font-size: 11px; padding: 1px 6px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--head); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hb.ok { color: var(--ok); border-color: var(--ok); font-weight: 600; }
.hb.bad { color: var(--brand-fg); background: var(--danger); border-color: var(--danger); font-weight: 600; }
.badge {
  font-size: 11px; padding: 1px 6px; border-radius: 20px;
  background: var(--head); color: var(--muted); border: 1px solid var(--line);
  flex: none;
}
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--danger); border-color: var(--danger); }

/* ── 结果栏的活动切换器 ───────────────────────────────── */
.seg {
  display: flex; gap: 6px; padding: 8px 10px;
  overflow-x: auto; flex: none;
  background: var(--card); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  font: inherit; font-size: 13px; padding: 5px 10px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; flex: none;
}
.seg-btn .seg-t { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.seg-btn.active {
  background: var(--brand); border-color: var(--brand);
  color: var(--brand-fg); font-weight: 600;
}
.seg-btn.active .badge {
  background: transparent; color: var(--brand-fg);
  border-color: rgba(255, 255, 255, .55);
}

/* ── 结果卡片 ─────────────────────────────────────────── */
.rcard {
  margin: 10px; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.rcard > h3 {
  margin: 0; padding: 9px 12px; font-size: 13.5px;
  background: var(--head); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.rcard > h3 .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rcard .empty { padding: 14px 12px; color: var(--muted); font-size: 13px; }

.crow { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.crow:last-child { border-bottom: 0; }
.crow .who {
  font-size: 12.5px; color: var(--muted); margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
}
.crow .who-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .ts {
  margin-left: auto; flex: none; white-space: nowrap;
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cookie {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.45; word-break: break-all;
  background: var(--head); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; cursor: pointer; user-select: none;
}
.cookie:active { background: var(--brand); color: var(--brand-fg); }
.cookie .hint { color: var(--muted); font-size: 11px; }
.err-text { color: var(--danger); font-size: 12px; word-break: break-all; }

/* ── 弹窗 ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  width: 100%; max-width: 440px; max-height: 90dvh; overflow-y: auto;
  background: var(--card); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 11px;
}
.modal-card h2 { margin: 0; font-size: 17px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

/* ── 提示条 ───────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 90;
  background: rgba(20, 22, 26, .93); color: #fff;
  padding: 9px 16px; border-radius: 22px; font-size: 13.5px;
  max-width: 82vw; text-align: center; box-shadow: var(--shadow);
  pointer-events: none;
}

/* ── 桌面：三栏并排，各自滚动 ─────────────────────────── */
@media (min-width: 900px) {
  .tabs { display: none; }
  .panels {
    display: grid; grid-template-columns: 1fr 1fr 1.25fr;
    gap: 10px; padding: 10px; overflow: hidden;
  }
  .panel {
    min-width: 0; background: var(--card);
    border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  }
  .panel-head { border-radius: 12px 12px 0 0; }
  .panel-body { padding-bottom: 8px; }
  .row { background: transparent; }
  .rcard { margin: 10px; }
}
