/* BESTCAR OTA 网关控制台
   布局:左侧导航 + 右侧工作区;窄屏时导航变成顶部横向标签。 */
:root {
  --bg: #f4f3f0;
  --panel: #ffffff;
  --panel-2: #f9f8f6;
  --ink: #1b2233;
  --ink-2: #4a5163;
  --muted: #7d8394;
  --line: #e4e2dc;
  --line-2: #efede8;
  --nav: #17203a;
  --nav-ink: #c9cfdd;
  --nav-active: #ffffff;
  --gold: #b88a3e;
  --gold-soft: #f5ecdc;
  --brand: #22305a;
  --brand-soft: #e7ebf5;
  --ok: #1f8a5b;
  --ok-soft: #e2f3ea;
  --warn: #b7791f;
  --warn-soft: #fbf0dc;
  --bad: #c0392b;
  --bad-soft: #fbe6e3;
  --idle: #a3a8b5;
  --idle-soft: #eef0f3;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06), 0 4px 16px rgba(23, 32, 58, .04);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
[v-cloak] { display: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── 框架 ── */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100%; }
.nav { background: var(--nav); color: var(--nav-ink); display: flex; flex-direction: column; padding: 20px 12px; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { padding: 4px 10px 18px; }
.brand b { display: block; color: #fff; font-size: 15px; letter-spacing: .04em; }
.brand span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .1); color: var(--nav-active); }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav .foot { margin-top: auto; padding: 10px; font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.nav .foot button { background: none; border: 1px solid rgba(255, 255, 255, .18); color: var(--nav-ink); border-radius: 7px; padding: 5px 10px; cursor: pointer; }
.nav .foot button:hover { color: #fff; border-color: rgba(255, 255, 255, .35); }

.main { padding: 26px max(28px, env(safe-area-inset-right, 0px)) 48px 28px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { font-size: 21px; margin: 0; letter-spacing: .01em; text-wrap: balance; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--r); background: var(--warn-soft); color: #7a4f0e; margin-bottom: 16px; border: 1px solid #efd9ad; }
.banner.bad { background: var(--bad-soft); color: #8a2a1f; border-color: #f0c3bd; }

/* ── 面板 ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel > h2, .panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line-2); font-size: 14px; font-weight: 600; }
.panel-h h2 { margin: 0; font-size: 14px; }
.panel .body { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ── 数字 ── */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }

/* ── 产品线状态 ── */
.lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.line-card .envs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.env { padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.env + .env { border-left: 1px solid var(--line-2); }
.env .t { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.env .base { font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); flex: none; box-shadow: 0 0 0 3px var(--idle-soft); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

/* ── 标签 ── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--idle-soft); color: var(--ink-2); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.live { background: var(--gold-soft); color: #8a6420; }
.pill.test { background: var(--brand-soft); color: var(--brand); }
.pill.line-premium { background: #ece7f6; color: #4b3a86; }
.pill.line-economy { background: #e3f0f1; color: #1f6670; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 9px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbfaf7; }
td.r, th.r { text-align: right; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }

/* ── 表单 ── */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: #cfccc4; background: #fcfbf9; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1a2647; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%;
}
textarea { min-height: 76px; resize: vertical; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.filters .field { width: 150px; }
.filters .field.wide { width: 220px; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form .full { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); cursor: pointer; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; padding: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12.5px; background: #fff; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); }
.chip input { margin: 0; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: #cfd3dc; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

/* 弹窗 */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 22, 38, .42); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; width: min(520px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal h3 { margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.modal .body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }
.keybox { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px dashed #cfc9bb; border-radius: 8px; padding: 12px; overflow-wrap: anywhere; user-select: all; }
.note { font-size: 12.5px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: #7a4f0e; }

/* 提示 */
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: min(420px, calc(100vw - 32px)); }
.toast.bad { background: var(--bad); }

/* 图表 */
.chart { width: 100%; height: 150px; display: block; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.ticks { display: flex; gap: 2px; height: 26px; align-items: stretch; }
.ticks span { flex: 1; min-width: 2px; border-radius: 2px; background: var(--ok); opacity: .85; }
.ticks span.bad { background: var(--bad); }
.ticks.empty { align-items: center; color: var(--muted); font-size: 12px; }

/* 账号详情 */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 6px; }
.back:hover { color: var(--ink); }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.scope-line { border-top: 1px solid var(--line-2); padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.scope-line:first-of-type { border-top: none; }
.seg { align-self: flex-start; display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 5px 12px; cursor: pointer; font-size: 12.5px; }
.seg button.on { background: var(--brand); color: #fff; }

/* 登录 */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--nav); }
.login form { background: var(--panel); border-radius: 16px; padding: 30px 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.login h1 { margin: 0; font-size: 19px; }
.login .sub { margin: -8px 0 6px; color: var(--muted); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; }
.err { color: var(--bad); font-size: 13px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lines { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto; padding: calc(8px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 8px max(10px, env(safe-area-inset-left, 0px)); gap: 2px; z-index: 20; }
  .brand, .nav .foot { display: none; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .main { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3, .form { grid-template-columns: minmax(0, 1fr); }
  .line-card .envs { grid-template-columns: minmax(0, 1fr); }
  .env + .env { border-left: none; border-top: 1px solid var(--line-2); }
  .filters .field, .filters .field.wide { width: calc(50% - 5px); }
  .table-wrap table { min-width: 720px; }
  .table-wrap td { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
