/* ==================================================================
   AI 订阅 / 额度管家 · 样式表
   桌面三栏布局 / 移动端底部导航 + 卡片流
   ================================================================== */

:root {
  --bg: #080d1a;
  --bg-soft: #0c1426;
  --panel: #111b30;
  --panel-2: #16223a;
  --line: rgba(148, 163, 184, .13);
  --line-strong: rgba(148, 163, 184, .24);
  --text: #eef2ff;
  --text-2: #a6b3cc;
  --text-3: #6c7b98;
  --primary: #6d74f6;
  --primary-2: #8b7cf8;
  --cyan: #22d3ee;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #f43f5e;
  --purple: #a855f7;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 40px rgba(2, 6, 20, .38);
  --sidebar-w: 246px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(109, 116, 246, .16), transparent 62%),
    radial-gradient(900px 560px at 92% 4%, rgba(34, 211, 238, .09), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
a { color: var(--cyan); }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .22); border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; }

/* ---------------------------------------------------------------- 布局 */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 26px 16px 20px;
  background: linear-gradient(180deg, rgba(17, 27, 48, .92), rgba(9, 15, 30, .92));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--primary), #4f46e5);
  box-shadow: 0 8px 22px rgba(109, 116, 246, .38);
  color: #fff;
}
.brand-mark .icon { width: 20px; height: 20px; stroke-width: 2; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; }
.brand-mark.small .icon { width: 17px; height: 17px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: .3px; }
.brand-text span { font-size: 10px; color: var(--text-3); letter-spacing: .7px; text-transform: uppercase; }

.side-nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 11px 13px; border-radius: 11px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: background .18s, color .18s, transform .18s;
  text-align: left;
}
.nav-item .icon { width: 17px; height: 17px; }
.nav-item:hover { background: rgba(148, 163, 184, .08); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(109, 116, 246, .24), rgba(109, 116, 246, .07));
  color: #fff; box-shadow: inset 2px 0 0 var(--primary-2);
}

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.side-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px; border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, .09); border: 1px solid rgba(16, 185, 129, .2);
  color: var(--green);
}
.side-alert.warn { background: rgba(245, 158, 11, .09); border-color: rgba(245, 158, 11, .24); color: var(--amber); }
.side-alert.danger { background: rgba(244, 63, 94, .09); border-color: rgba(244, 63, 94, .24); color: var(--red); }
.side-alert .icon { width: 16px; height: 16px; margin-top: 2px; }
.side-alert div { display: flex; flex-direction: column; min-width: 0; }
.side-alert strong { font-size: 12.5px; color: var(--text); }
.side-alert span { font-size: 11px; color: var(--text-3); line-height: 1.45; }
.sync-line { display: flex; align-items: center; gap: 8px; padding: 0 4px; font-size: 11.5px; color: var(--text-3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.dot.error { background: var(--red); box-shadow: 0 0 0 3px rgba(244, 63, 94, .14); }
.dot.loading { background: var(--amber); box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); }

.main-area { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 34px 18px;
  background: rgba(8, 13, 26, .82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; font-weight: 650; letter-spacing: .2px; }
.topbar p { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.today-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.today-chip .icon { width: 14px; height: 14px; }
.mobile-brand { display: none; align-items: center; gap: 8px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 11px;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: transform .15s, box-shadow .15s, background .15s, opacity .15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #5b5be8); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, .3); }
.btn-primary:hover { box-shadow: 0 10px 26px rgba(99, 102, 241, .45); }
.btn-ghost { background: rgba(148, 163, 184, .1); color: var(--text-2); border: 1px solid var(--line); }
.btn-ghost:hover { background: rgba(148, 163, 184, .17); color: var(--text); }
.btn-danger { background: rgba(244, 63, 94, .16); color: #fda4af; border: 1px solid rgba(244, 63, 94, .3); }
.btn-danger:hover { background: rgba(244, 63, 94, .26); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 26px 34px 64px; }
.view { display: none; animation: fadeIn .28s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 告警条 */
.alert-banner {
  display: flex; align-items: flex-start; gap: 13px;
  padding: 15px 18px; margin-bottom: 20px;
  border-radius: var(--radius); border: 1px solid rgba(245, 158, 11, .28);
  background: linear-gradient(100deg, rgba(245, 158, 11, .14), rgba(245, 158, 11, .04));
  box-shadow: inset 3px 0 0 var(--amber);
}
.alert-banner.danger { border-color: rgba(244, 63, 94, .34); background: linear-gradient(100deg, rgba(244, 63, 94, .15), rgba(244, 63, 94, .04)); box-shadow: inset 3px 0 0 var(--red); }
.alert-banner.safe { border-color: rgba(16, 185, 129, .22); background: linear-gradient(100deg, rgba(16, 185, 129, .1), rgba(16, 185, 129, .02)); box-shadow: inset 3px 0 0 var(--green); }
.alert-banner > .icon { width: 20px; height: 20px; margin-top: 1px; color: var(--amber); }
.alert-banner.danger > .icon { color: var(--red); }
.alert-banner.safe > .icon { color: var(--green); }
.alert-banner-body { flex: 1; min-width: 0; }
.alert-banner strong { display: block; font-size: 13.5px; }
.alert-banner p { font-size: 12px; color: var(--text-2); margin-top: 3px; line-height: 1.6; overflow-wrap: anywhere; word-break: break-word; }
.alert-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.alert-chips span { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .07); color: var(--text-2); }

.setup-hint {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin: -4px 0 18px;
  border-radius: 14px; border: 1px solid rgba(34, 211, 238, .24);
  background: linear-gradient(100deg, rgba(34, 211, 238, .1), rgba(34, 211, 238, .02));
  box-shadow: inset 3px 0 0 rgba(34, 211, 238, .7);
  font-size: 12px;
}
.setup-hint > .icon { width: 18px; height: 18px; color: var(--cyan); flex: none; }
.setup-hint > span { flex: 1; min-width: 0; color: var(--text-2); line-height: 1.6; }
.setup-hint > span strong { color: var(--text); }
.setup-hint .btn { flex: none; padding: 7px 12px; font-size: 11.5px; }
@media (max-width: 820px) {
  .setup-hint { flex-wrap: wrap; gap: 9px; }
  .setup-hint .btn { width: 100%; }
}

/* ---------------------------------------------------------------- KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
  position: relative; overflow: hidden;
  padding: 19px 20px 17px; border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(22, 34, 58, .95), rgba(15, 24, 43, .9));
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.kpi-card::after { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%; right: -58px; top: -66px; opacity: .16; filter: blur(2px); background: var(--kc, var(--primary)); }
.kpi-accent-1 { --kc: #6d74f6; }
.kpi-accent-2 { --kc: #22d3ee; }
.kpi-accent-3 { --kc: #f59e0b; }
.kpi-accent-4 { --kc: #f43f5e; }
.kpi-head { display: flex; align-items: center; gap: 9px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(109, 116, 246, .16); background: color-mix(in srgb, var(--kc) 18%, transparent); color: var(--kc); }
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-label { font-size: 12.5px; color: var(--text-2); }
.kpi-value { font-size: 31px; font-weight: 700; letter-spacing: -.8px; margin: 13px 0 8px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--text-3); }
.kpi-tag { padding: 3px 8px; border-radius: 999px; background: rgba(148, 163, 184, .1); white-space: nowrap; }
.kpi-bar { height: 5px; border-radius: 9px; background: rgba(148, 163, 184, .14); margin-top: 11px; overflow: hidden; }
.kpi-bar i { display: block; height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, var(--cyan), var(--primary)); transition: width .5s ease; }

/* ---------------------------------------------------------------- 面板 */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.panel {
  padding: 19px 20px; border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(19, 29, 50, .94), rgba(13, 21, 38, .9));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 620; }
.panel-head h2 .icon { width: 17px; height: 17px; color: var(--primary-2); }
.panel-hint { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.text-btn { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--text-3); }
.text-btn:hover { color: var(--cyan); }
.text-btn .icon { width: 13px; height: 13px; }

.mini-list { display: flex; flex-direction: column; gap: 9px; max-height: 288px; overflow-y: auto; padding-right: 2px; }
.mini-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(148, 163, 184, .055); border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.mini-item:hover { border-color: var(--line-strong); background: rgba(148, 163, 184, .09); }
.mini-item.warn { background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .19); }
.mini-item.danger { background: rgba(244, 63, 94, .09); border-color: rgba(244, 63, 94, .22); }
.svc-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px rgba(255, 255, 255, .04); }
.mini-main { flex: 1; min-width: 0; }
.mini-main strong { display: block; font-size: 12.8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-main span { font-size: 11px; color: var(--text-3); }
.mini-right { text-align: right; flex: none; }
.mini-right strong { display: block; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mini-right span { font-size: 10.5px; color: var(--text-3); }
.badge-hot { color: #fb7185; }
.badge-warn { color: #fbbf24; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 34px 16px; text-align: center; color: var(--text-3); }
.empty .icon { width: 28px; height: 28px; opacity: .55; }
.empty strong { font-size: 13px; color: var(--text-2); font-weight: 550; }
.empty span { font-size: 11.5px; line-height: 1.6; }

.quota-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 22px; }
.qo-row { min-width: 0; }
.qo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.qo-name { display: flex; align-items: center; gap: 7px; font-size: 12px; min-width: 0; }
.qo-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.qo-val { font-size: 11px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.qo-bar { height: 7px; border-radius: 9px; background: rgba(148, 163, 184, .13); overflow: hidden; }
.qo-bar i { display: block; height: 100%; border-radius: 9px; transition: width .5s ease; }

/* ---------------------------------------------------------------- 工具栏 */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.search-box { display: flex; align-items: center; gap: 9px; flex: 1 1 260px; max-width: 380px; padding: 0 13px; height: 40px; border-radius: 11px; background: rgba(19, 29, 50, .9); border: 1px solid var(--line); color: var(--text-3); }
.search-box:focus-within { border-color: var(--primary); }
.search-box .icon { width: 16px; height: 16px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 12.8px; color: var(--text); }
.search-box input::placeholder { color: var(--text-3); }
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: rgba(19, 29, 50, .9); border: 1px solid var(--line); }
.segmented button { padding: 6px 12px; border-radius: 8px; font-size: 12px; color: var(--text-3); white-space: nowrap; transition: background .15s, color .15s; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: rgba(109, 116, 246, .24); color: #fff; }
.select-wrap { display: inline-flex; align-items: center; gap: 7px; padding: 0 11px; height: 38px; border-radius: 11px; background: rgba(19, 29, 50, .9); border: 1px solid var(--line); color: var(--text-3); }
.select-wrap .icon { width: 15px; height: 15px; }
.select-wrap select { border: 0; outline: 0; background: transparent; font-size: 12px; color: var(--text-2); cursor: pointer; padding-right: 2px; }
.select-wrap select option { background: #16223a; color: var(--text); }
.select-wrap.wide { flex: 1 1 230px; max-width: 330px; }
.select-wrap.wide select { flex: 1; }
.result-line { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--text-3); margin: 0 2px 13px; }

/* ---------------------------------------------------------------- 订阅卡片 */
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.sub-card {
  position: relative; overflow: hidden;
  padding: 17px 18px 15px; border-radius: var(--radius);
  background: linear-gradient(155deg, rgba(20, 31, 53, .96), rgba(13, 21, 38, .92));
  border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.sub-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 22px 46px rgba(2, 6, 20, .5); }
.sub-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--svc, var(--primary)); opacity: .85; }
.sub-card.is-low { border-color: rgba(244, 63, 94, .42); box-shadow: 0 0 0 1px rgba(244, 63, 94, .1), var(--shadow); }
.sub-card.is-renew { border-color: rgba(245, 158, 11, .34); }
.sub-card.is-paused { opacity: .72; }
.sc-top { display: flex; align-items: flex-start; gap: 11px; }
.sc-avatar { width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center; font-size: 15px; font-weight: 700; color: #fff; background: var(--svc, var(--primary)); box-shadow: 0 6px 16px rgba(0, 0, 0, .22); }
.sc-title { flex: 1; min-width: 0; }
.sc-title h3 { font-size: 14.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-title p { font-size: 11.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip .icon { width: 11px; height: 11px; stroke-width: 2.2; }
.chip-red { background: rgba(244, 63, 94, .16); color: #fda4af; }
.chip-amber { background: rgba(245, 158, 11, .16); color: #fcd34d; }
.chip-green { background: rgba(16, 185, 129, .15); color: #6ee7b7; }
.chip-gray { background: rgba(148, 163, 184, .13); color: var(--text-2); }
.chip-blue { background: rgba(109, 116, 246, .18); color: #b9bcff; }

.sc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0 13px; }
.sc-meta > div { min-width: 0; }
.sc-meta span { display: block; font-size: 10.5px; color: var(--text-3); }
.sc-meta strong { display: block; font-size: 13px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sc-meta strong.danger { color: #fb7185; }
.sc-meta strong.warn { color: #fbbf24; }

.sc-balance { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 13px; padding: 10px 12px; border-radius: 11px; background: rgba(34, 211, 238, .07); border: 1px solid rgba(34, 211, 238, .17); }
.sc-balance.is-low { background: rgba(244, 63, 94, .08); border-color: rgba(244, 63, 94, .26); }
.sc-balance > div:first-child { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; }
.sc-balance > div:first-child span { font-size: 10.5px; color: var(--text-3); }
.sc-balance strong { font-size: 19px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.sc-balance.empty strong { color: var(--text-3); font-size: 15px; font-weight: 500; }
.sc-balance-right { display: flex; flex-direction: column; align-items: flex-end; justify-self: end; text-align: right; gap: 5px; min-width: 0; }
.sc-balance-right small { font-size: 10px; color: var(--text-3); text-align: right; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sc-quota { background: rgba(148, 163, 184, .055); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; }
.sc-quota-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.sc-quota-head span { font-size: 10.5px; color: var(--text-3); }
.sc-quota-head strong { font-size: 12px; font-variant-numeric: tabular-nums; }
.sc-bar { height: 8px; border-radius: 9px; background: rgba(148, 163, 184, .14); overflow: hidden; }
.sc-bar i { display: block; height: 100%; border-radius: 9px; transition: width .5s ease; }
.sc-quota-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 7px; font-size: 10.5px; color: var(--text-3); }

.sc-actions { display: flex; gap: 6px; margin-top: 13px; flex-wrap: wrap; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgba(148, 163, 184, .09); color: var(--text-2); border: 1px solid var(--line); transition: background .15s, color .15s; }
.icon-btn:hover { background: rgba(109, 116, 246, .2); color: #fff; }
.icon-btn.danger:hover { background: rgba(244, 63, 94, .2); color: #fda4af; }
.icon-btn .icon { width: 15px; height: 15px; }
.sc-actions .grow-btn { flex: 1; min-width: 96px; height: 34px; padding: 0 11px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 600; background: rgba(109, 116, 246, .16); color: #c7c9ff; border: 1px solid rgba(109, 116, 246, .26); }
.sc-actions .grow-btn:hover { background: rgba(109, 116, 246, .3); }
.sc-actions .grow-btn .icon { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- 图表 / 历史 */
.usage-chart { display: flex; align-items: flex-end; gap: 6px; height: 176px; padding: 12px 6px 0; overflow-x: auto; }
.uc-col { flex: 1 0 20px; min-width: 20px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 7px; }
.uc-bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.uc-bar { width: 70%; max-width: 30px; min-height: 3px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--cyan), rgba(109, 116, 246, .55)); transition: height .45s ease; position: relative; }
.uc-bar.zero { background: rgba(148, 163, 184, .16); }
.uc-bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #0b1224; border: 1px solid var(--line-strong); border-radius: 7px; padding: 4px 8px; font-size: 10.5px; white-space: nowrap; color: var(--text); z-index: 3; }
.uc-label { font-size: 9.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.log-list { display: flex; flex-direction: column; gap: 8px; max-height: 330px; overflow-y: auto; padding-right: 3px; }
.log-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; background: rgba(148, 163, 184, .05); }
.log-kind { width: 27px; height: 27px; border-radius: 8px; flex: none; display: grid; place-items: center; }
.log-kind .icon { width: 14px; height: 14px; }
.log-kind.update { background: rgba(34, 211, 238, .13); color: var(--cyan); }
.log-kind.reset { background: rgba(168, 85, 247, .14); color: #d8b4fe; }
.log-kind.renew { background: rgba(16, 185, 129, .14); color: #6ee7b7; }
.log-kind.create { background: rgba(109, 116, 246, .16); color: #b9bcff; }
.log-kind.sync { background: rgba(34, 211, 238, .13); color: #67e8f9; }
.log-main { flex: 1; min-width: 0; }
.log-main strong { display: block; font-size: 12px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-main span { font-size: 10.5px; color: var(--text-3); }
.log-val { text-align: right; flex: none; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.log-val em { display: block; font-style: normal; font-size: 10px; color: var(--text-3); }

/* ---------------------------------------------------------------- 设置 */
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 550; color: var(--text-2); }
.field small { font-size: 10.5px; color: var(--text-3); line-height: 1.5; }
.field input, .field select, .field textarea, .modal input, .modal select, .modal textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: rgba(8, 14, 28, .7); border: 1px solid var(--line-strong);
  outline: 0; font-size: 13px; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus, .modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 116, 246, .14); }
.field textarea, .modal textarea { resize: vertical; min-height: 68px; }
.field select option, .modal select option { background: #16223a; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 44px; }
.input-suffix > span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--text-3); pointer-events: none; }
.form-stack .btn { align-self: flex-start; margin-top: 2px; }

.data-actions { display: flex; flex-direction: column; gap: 8px; }
.data-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: var(--radius-sm); background: rgba(148, 163, 184, .05); border: 1px solid var(--line); text-align: left; transition: background .15s, border-color .15s; }
.data-row:hover { background: rgba(148, 163, 184, .1); border-color: var(--line-strong); }
.data-icon { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; }
.data-icon .icon { width: 16px; height: 16px; }
.data-icon.green { background: rgba(16, 185, 129, .14); color: #6ee7b7; }
.data-icon.blue { background: rgba(34, 211, 238, .13); color: var(--cyan); }
.data-icon.purple { background: rgba(168, 85, 247, .14); color: #d8b4fe; }
.data-icon.red { background: rgba(244, 63, 94, .14); color: #fda4af; }
.data-row > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.data-row strong { font-size: 12.5px; font-weight: 600; }
.data-row small { font-size: 10.5px; color: var(--text-3); line-height: 1.5; }
.data-row .arrow { width: 15px; height: 15px; color: var(--text-3); }
.data-row.danger:hover { border-color: rgba(244, 63, 94, .36); }

.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.about-grid div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.about-grid span { font-size: 10.5px; color: var(--text-3); }
.about-grid strong { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.about-note { margin-top: 16px; padding: 11px 13px; border-radius: 10px; background: rgba(245, 158, 11, .09); border: 1px solid rgba(245, 158, 11, .2); color: #fcd34d; font-size: 11.5px; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(3, 7, 18, .72); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .18s ease; }
.modal { width: 100%; max-width: 580px; max-height: min(88vh, 860px); display: flex; flex-direction: column; border-radius: 20px; background: linear-gradient(160deg, #18253e, #0e1729); border: 1px solid var(--line-strong); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); overflow: hidden; animation: popIn .22s ease; }
.modal.narrow { max-width: 430px; }
/* 表单本身不参与布局，让 head/body/foot 直接成为 modal 的 flex 子项 */
.modal > form { display: contents; }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h3 { font-size: 16px; font-weight: 650; }
.modal-head p { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.modal-close { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--text-3); }
.modal-close:hover { background: rgba(148, 163, 184, .12); color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; border-top: 1px solid var(--line); background: rgba(8, 14, 28, .35); flex: none; }

.form-section { margin-bottom: 20px; }
.form-section:last-child { margin-bottom: 0; }
.form-section > h4 { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 650; color: var(--primary-2); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 12px; }
.form-section > h4::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch { width: 27px; height: 27px; border-radius: 8px; border: 2px solid transparent; transition: transform .15s, border-color .15s; }
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .18); }

.usage-current { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius-sm); background: rgba(148, 163, 184, .06); border: 1px solid var(--line); margin-bottom: 18px; }
.usage-ring { position: relative; width: 62px; height: 62px; flex: none; }
.usage-ring svg { width: 62px; height: 62px; transform: rotate(-90deg); }
.usage-ring circle { fill: none; stroke-width: 6; }
.usage-ring .bg { stroke: rgba(148, 163, 184, .16); }
.usage-ring .fg { stroke: var(--cyan); stroke-linecap: round; transition: stroke-dashoffset .4s; }
.usage-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.usage-current div:last-child { min-width: 0; }
.usage-current strong { display: block; font-size: 14px; }
.usage-current p { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.quick-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.quick-row button { padding: 6px 12px; border-radius: 8px; font-size: 12px; background: rgba(109, 116, 246, .14); color: #c7c9ff; border: 1px solid rgba(109, 116, 246, .24); }
.quick-row button:hover { background: rgba(109, 116, 246, .28); }
.mode-tabs { display: inline-flex; padding: 3px; border-radius: 9px; background: rgba(8, 14, 28, .6); border: 1px solid var(--line); }
.mode-tabs button { padding: 6px 13px; border-radius: 7px; font-size: 11.5px; color: var(--text-3); }
.mode-tabs button.active { background: rgba(109, 116, 246, .25); color: #fff; }
.confirm-text { font-size: 13px; color: var(--text-2); line-height: 1.7; }
.confirm-text strong { color: var(--text); }
.confirm-warn { margin-top: 12px; padding: 11px 13px; border-radius: 10px; background: rgba(244, 63, 94, .1); border: 1px solid rgba(244, 63, 94, .22); color: #fda4af; font-size: 11.5px; }

/* ---------------------------------------------------------------- Toast */
#toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 11px 15px; border-radius: 11px; background: #1a2740; border: 1px solid var(--line-strong); box-shadow: 0 14px 34px rgba(0, 0, 0, .45); font-size: 12.5px; animation: toastIn .22s ease; pointer-events: auto; max-width: min(360px, calc(100vw - 40px)); }
.toast .icon { width: 16px; height: 16px; }
.toast.success .icon { color: var(--green); }
.toast.error .icon { color: var(--red); }
.toast.info .icon { color: var(--cyan); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- 移动端导航 */
.bottom-nav { display: none; }

/* ================================================================== 响应式 */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quota-overview { grid-template-columns: 1fr; }
}

@media (max-width: 1000px) {
  :root { --sidebar-w: 210px; }
  .content { padding: 22px 22px 60px; }
  .topbar { padding: 18px 22px 16px; }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-around;
    height: calc(62px + env(safe-area-inset-bottom));
    padding: 0 6px env(safe-area-inset-bottom);
    background: rgba(12, 20, 38, .96); backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 10px; padding: 6px 0; }
  .bottom-nav button .icon { width: 19px; height: 19px; }
  .bottom-nav button.active { color: var(--primary-2); }
  .bottom-nav .fab { flex: none; width: 48px; height: 48px; margin: 0 8px; border-radius: 16px; background: linear-gradient(135deg, var(--primary), #5b5be8); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, .44); transform: translateY(-10px); }
  .bottom-nav .fab .icon { width: 23px; height: 23px; stroke-width: 2.2; }
  .bottom-nav .fab.active { color: #fff; }

  .topbar { padding: 14px 16px 13px; gap: 10px; }
  .topbar-left { display: flex; flex-direction: column; min-width: 0; }
  .mobile-brand { display: flex; }
  .topbar h1 { font-size: 15px; margin-top: 6px; }
  .topbar p { font-size: 10.5px; }
  .topbar-right .today-chip { display: none; }
  .topbar-right #btn-add { display: none; }
  .content { padding: 16px 14px calc(90px + env(safe-area-inset-bottom)); }
  .kpi-grid { gap: 11px; margin-bottom: 14px; }
  .two-col { gap: 14px; margin-bottom: 14px; }
  .panel { padding: 16px 15px; border-radius: 15px; }
  .sub-grid { grid-template-columns: 1fr; gap: 12px; }
  .toolbar { gap: 10px; }
  .search-box { max-width: none; flex: 1 1 100%; }
  .filter-row { width: 100%; justify-content: space-between; gap: 8px; }
  .segmented { overflow-x: auto; }
  .segmented button { padding: 6px 10px; }
  .select-wrap.wide { max-width: none; flex: 1 1 100%; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.narrow { max-width: none; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheetIn .24s ease; }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
  .modal-head { padding: 16px 18px; }
  .modal-body { padding: 17px 18px; }
  .modal-foot { padding: 13px 18px; }
  .modal-foot .btn { flex: 1; }
  #toast-root { right: 12px; left: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .kpi-card { padding: 14px 14px 13px; }
  .kpi-value { font-size: 25px; margin: 10px 0 7px; }
  .kpi-label { font-size: 11.5px; }
  .kpi-icon { width: 26px; height: 26px; }
  .kpi-foot { font-size: 10.5px; flex-wrap: wrap; gap: 4px; }
  .kpi-tag { font-size: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .about-grid { grid-template-columns: 1fr; }
  .alert-banner { padding: 13px 14px; }
  .usage-chart { height: 150px; gap: 4px; }
  .uc-col { min-width: 18px; }
  .sc-meta { gap: 8px; }
  .sc-actions .icon-btn { width: 38px; height: 38px; }
  .sc-actions .grow-btn { height: 38px; }
}

/* ---------------------------------------------------------------- 实时额度总览 */
.board-actions { display: flex; align-items: center; gap: 10px; }
.board-actions .btn { padding: 7px 12px; font-size: 11.5px; }
.quota-board { display: flex; flex-direction: column; gap: 9px; }
.qb-row {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(110px, .8fr) minmax(130px, .9fr) auto;
  align-items: center; gap: 14px; padding: 13px 14px; border-radius: 13px;
  background: rgba(148, 163, 184, .05); border: 1px solid var(--line);
  border-left: 3px solid var(--svc, var(--primary));
  transition: background .15s, border-color .15s;
}
.qb-row:hover { background: rgba(148, 163, 184, .095); }
.qb-row.is-low { border-color: rgba(244, 63, 94, .34); border-left-color: #f43f5e; background: rgba(244, 63, 94, .06); }
.qb-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.qb-id > div { min-width: 0; display: flex; flex-direction: column; }
.qb-id strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-id small { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-balance { display: flex; flex-direction: column; }
.qb-balance strong { font-size: 19px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.qb-balance strong.muted { color: var(--text-3); font-size: 14px; font-weight: 500; }
.qb-balance small { font-size: 10.5px; color: var(--text-3); }
.qb-source { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.qb-source small { font-size: 10.5px; color: var(--text-3); }
.qb-actions { display: flex; gap: 6px; }
.qb-actions button { padding: 6px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; background: rgba(109, 116, 246, .15); color: #c7c9ff; border: 1px solid rgba(109, 116, 246, .26); }
.qb-actions button:hover { background: rgba(109, 116, 246, .3); }
.qb-actions button.ghost { background: rgba(148, 163, 184, .09); color: var(--text-2); border-color: var(--line); }
.qb-actions button:disabled { opacity: .5; cursor: not-allowed; }
.board-note { margin-top: 13px; font-size: 11px; color: var(--text-3); line-height: 1.65; }
.board-note strong { color: var(--text-2); }
.chip-cyan { background: rgba(34, 211, 238, .14); color: #67e8f9; }
.chip-purple { background: rgba(168, 85, 247, .16); color: #d8b4fe; }

.adapter-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 16px; }
.adapter-item { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 10px; background: rgba(148, 163, 184, .05); border: 1px solid var(--line); min-width: 0; }
.adapter-item div { min-width: 0; display: flex; flex-direction: column; }
.adapter-item strong { font-size: 12px; font-weight: 600; }
.adapter-item small { font-size: 10.5px; color: var(--text-3); }
.adapter-item .chip { margin-left: auto; flex: none; }

.btn.is-loading .icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .topbar-right #btn-sync-all span { display: none; }
  .topbar-right #btn-sync-all { padding: 9px; }
  .board-actions .panel-hint { display: none; }
  .qb-row { grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
  .qb-id { grid-column: 1; grid-row: 1; }
  .qb-balance { grid-column: 2; grid-row: 1; text-align: right; align-items: flex-end; }
  .qb-source { grid-column: 1; grid-row: 2; }
  .qb-actions { grid-column: 1 / -1; grid-row: 3; }
  .qb-actions button { flex: 1; }
  .adapter-status { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
