:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #1557ff;
  --brand-ink: #ffffff;
  --ok-bg: #e7f6ec; --ok-ink: #137a37;
  --warn-bg: #fff4e0; --warn-ink: #9a5b00;
  --bad-bg: #fde8e8; --bad-ink: #b11d1d;
  --pending-bg: #e8f0fe; --pending-ink: #1a4fc4;
  --neutral-bg: #eef0f3; --neutral-ink: #4b5563;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #171a21; --ink: #e7eaf0; --muted: #9aa3b2;
    --line: #262b36; --brand: #4d82ff; --neutral-bg: #222733; --neutral-ink: #c0c7d4;
    --ok-bg: #17331f; --ok-ink: #5fd081; --warn-bg: #3a2c12; --warn-ink: #f2b65a;
    --bad-bg: #3a1b1b; --bad-ink: #f08a8a; --pending-bg: #182a4d; --pending-ink: #86a9ff;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 6px; font-size: 13px; }

.nav { display: flex; align-items: center; gap: 10px; }
.nav__user { color: var(--muted); font-size: 14px; max-width: 42vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.nav__logout { margin: 0; }
.nav__link { color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 4px; }
.nav__link.is-active { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--brand); }

.container { max-width: 880px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.card--auth { max-width: 400px; margin: 8vh auto 0; }
.card__title { margin: 0 0 4px; font-size: 20px; }
.card__sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.card__foot { margin: 18px 0 0; font-size: 13px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; color: var(--muted); }
.field__input {
  width: 100%; padding: 12px 12px; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  appearance: none;
}
.field__input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 16px; font-size: 15px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn--primary { background: var(--brand); color: var(--brand-ink); width: 100%; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert--error { background: var(--bad-bg); color: var(--bad-ink); }
.alert--ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert--warn { background: var(--warn-bg); color: var(--warn-ink); }

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

.page-head { margin: 6px 0 16px; }
.page-head__title { margin: 0; font-size: 22px; }
.page-head__sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

.svc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.svc {
  display: block; color: inherit; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.svc__main { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.svc:hover { border-color: var(--brand); }
.svc__name { font-weight: 600; font-size: 16px; }
.svc__domain { font-size: 13px; margin-top: 2px; }
.svc__meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 16px; }
.svc__row { display: flex; justify-content: space-between; gap: 8px; font-size: 14px;
  border-top: 1px dashed var(--line); padding-top: 8px; }
.svc__row .k { color: var(--muted); }
.svc__row .v { text-align: right; font-weight: 500; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge--pending { background: var(--pending-bg); color: var(--pending-ink); }
.badge--neutral { background: var(--neutral-bg); color: var(--neutral-ink); }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 40px; }

a { color: var(--brand); }
.small { font-size: 13px; }
.crumb { margin: 0 0 8px; font-size: 14px; }
.crumb a { text-decoration: none; }
.page-head--row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.container > .card { margin-bottom: 16px; }
.card__h { margin: 0 0 12px; font-size: 16px; }
.card--narrow { max-width: 480px; }
.card--danger { border-color: var(--bad-ink); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
[data-copy] { cursor: copy; }
[data-copy].is-copied::after { content: " 已复制"; color: var(--ok-ink); font-family: inherit; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--danger { color: var(--bad-ink); border-color: var(--bad-ink); }
.btn--primary.btn--danger { background: var(--bad-ink); color: #fff; }
.btn--link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 8px 0; font-weight: 500; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
select.field__input { appearance: auto; }
.cycles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.cycle { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.cycle input { margin: 0 0 4px; }
.cycle:has(input:checked) { border-color: var(--brand); outline: 1px solid var(--brand); }
.cycle__name { font-size: 13px; color: var(--muted); }
.cycle__price { font-weight: 700; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl .num { text-align: right; }
.tbl tfoot th { border-bottom: none; }
.tbl--list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.bar { display: block; width: 100%; height: 8px; margin-top: 4px; accent-color: var(--brand); }
.bar--in { accent-color: var(--ok-ink); }
.traffic summary { cursor: pointer; color: var(--brand); margin: 8px 0; }
.paylist { display: grid; gap: 8px; margin-bottom: 8px; }
.payopt { margin: 0; }
.payopt__btn { width: 100%; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.inline { margin: 0; }
.codes { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.8; }
.qr { image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.container--wide { max-width: 1200px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); color: inherit; text-decoration: none; }
.stat__n { font-size: 24px; font-weight: 700; }
.stat__k { font-size: 13px; color: var(--muted); }
.stat--warn { border-color: var(--warn-ink); }
.stat--bad { border-color: var(--bad-ink); }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin .tbl .form { gap: 6px; }
.thread { display: grid; gap: 10px; margin-bottom: 16px; }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.msg--staff { border-left: 3px solid var(--brand); }
.msg__meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.msg__body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.secret { padding: 2px 6px; border-radius: 6px; background: var(--card); }
textarea.field__input { resize: vertical; font-size: 13px; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .nav { gap: 6px; }
  .tbl--list th:nth-child(4), .tbl--list td:nth-child(4) { display: none; }
  .svc__meta { grid-template-columns: 1fr; }
  .nav__user { max-width: 32vw; }
}

/* announcements (11-22) */
.alert--info { background: var(--pending-bg); color: var(--pending-ink); }
.notice a { color: inherit; text-decoration: underline; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
.searchbar--wrap { flex-wrap: wrap; }
.searchbar--wrap .field__input { flex: 1 1 160px; min-width: 0; }
.pager { display: flex; gap: 8px; margin-top: 12px; }

/* ticket attachments (11-22) */
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att { display: flex; flex-direction: column; gap: 2px; max-width: 220px; text-decoration: none; }
.att img { max-width: 220px; max-height: 160px; width: auto; height: auto; border: 1px solid var(--line); border-radius: 8px; object-fit: contain; background: var(--card); }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* snapshots / firewall (11-22) */
.fw .field__input { min-width: 0; width: 100%; padding: 6px 8px; }
.fw td { vertical-align: middle; }
@media (max-width: 640px) { .fw { display: block; overflow-x: auto; } }

/* ── 宽屏布局（11-24）：≥1024px 时登录后的页面用左侧导航 + 加宽内容区；手机 / 平板保持原来的单栏 ── */
.nav__user { display: none; }
.svc-head { display: none; }
@media (min-width: 1024px) {
  body.has-side { padding-left: 232px; }
  body.has-side .topbar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 232px;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0;
    padding: 22px 14px 18px; border-bottom: none; border-right: 1px solid var(--line); overflow-y: auto;
  }
  body.has-side .brand { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 20px; font-size: 20px; }
  body.has-side .brand span { margin-left: 0; font-size: 12px; letter-spacing: .08em; }
  body.has-side .nav { flex-direction: column; align-items: stretch; gap: 2px; flex: 1; }
  body.has-side .nav__link { padding: 10px 12px; border-radius: 8px; font-size: 15px; color: var(--ink); }
  body.has-side .nav__link:hover { background: var(--neutral-bg); }
  body.has-side .nav__link.is-active { border-bottom: none; background: var(--pending-bg); color: var(--pending-ink); }
  body.has-side .nav__user {
    display: block; max-width: none; margin-top: auto; padding: 14px 12px 8px;
    border-top: 1px solid var(--line); font-size: 13px;
  }
  body.has-side .nav__logout { padding: 0 12px; }
  body.has-side .nav__logout .btn { width: 100%; }

  body.has-side .container { max-width: 1240px; padding: 28px 36px; }
  body.has-side .page-head { margin: 0 0 20px; }
  body.has-side .page-head__title { font-size: 26px; }
  body.has-side .footer { text-align: left; padding: 8px 36px 32px; }
  body.has-side .card { padding: 24px 26px; }
  body.has-side .btn--primary { width: auto; min-width: 140px; }
  body.has-side .card--auth .btn--primary, body.has-side .payopt__btn { width: 100%; }
  body.has-side .tbl th, body.has-side .tbl td { padding: 12px 16px; }
  body.has-side .tbl--list { border-collapse: separate; border-spacing: 0; overflow: hidden; box-shadow: var(--shadow); }
  body.has-side .tbl--list thead th { background: var(--bg); font-size: 13px; font-weight: 600; color: var(--muted); }
  body.has-side .tbl--list tbody tr:last-child td { border-bottom: none; }
  body.has-side .tbl--list tbody tr:hover td { background: var(--bg); }

  /* 服务列表：卡片 → 一行一台的表格 */
  body.has-side .svc-head, body.has-side .svc {
    display: grid; align-items: center; column-gap: 20px;
    grid-template-columns: minmax(240px, 2.4fr) minmax(150px, 1.3fr) minmax(100px, 1fr) minmax(130px, 1.1fr) 80px 88px;
  }
  body.has-side .svc-head {
    padding: 11px 20px; font-size: 13px; font-weight: 600; color: var(--muted);
    background: var(--bg); border: 1px solid var(--line); border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  body.has-side .svc-head span:last-child { text-align: right; }
  body.has-side .svc-list {
    gap: 0; background: var(--card); border: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); overflow: hidden;
  }
  body.has-side .svc { border: none; border-radius: 0; box-shadow: none; padding: 14px 20px; border-top: 1px solid var(--line); }
  body.has-side .svc-list li:first-child .svc { border-top: none; }
  body.has-side .svc:hover { background: var(--bg); }
  body.has-side .svc__main, body.has-side .svc__meta { display: contents; }
  body.has-side .svc__main { margin: 0; }
  body.has-side .svc__name { font-size: 15px; overflow-wrap: anywhere; }
  body.has-side .svc__main .badge { order: 9; justify-self: end; }
  body.has-side .svc__row { display: block; border-top: none; padding-top: 0; }
  body.has-side .svc__row .k { display: none; }
  body.has-side .svc__row .v { text-align: left; }
}
@media (min-width: 1500px) {
  body.has-side { padding-left: 248px; }
  body.has-side .topbar { width: 248px; }
}
@media (min-width: 1024px) {
  body.has-side .card--narrow { max-width: 640px; }
}
/* 手机：导航项多了以后不换行、不竖排，品牌一行、导航一行（可横向滑动） */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .brand, .brand span { white-space: nowrap; }
  .nav { width: 100%; overflow-x: auto; }
  .nav__link { white-space: nowrap; flex: none; }
  .nav__logout { margin-left: auto; flex: none; }
  .nav__logout .btn { white-space: nowrap; }
}
