:root {
  color-scheme: light;
  --page: #f3f2ee;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6e68;
  --line: #e4e3dd;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --accent: #256abf;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0f0f0e;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #98978e;
    --line: #31312e;
    --series-1: #3987e5;
    --series-2: #d95926;
    --accent: #3987e5;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 10px; }
p { margin: 4px 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.error-text { color: var(--critical); }

button, input, select {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.check input { padding: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; }

#app { max-width: 1760px; margin: 0 auto; padding: 20px 16px 48px; }
.topbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tabs { display: flex; gap: 4px; margin: 16px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--ink-2); white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }

main { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.section-title { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: baseline; margin-top: 8px; }

/* 提醒 */
.alerts ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alerts li { display: flex; gap: 10px; align-items: baseline; }

/* 状态标签：图标 + 文字，颜色只是辅助 */
.chip { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chip i { font-style: normal; font-size: 10px; }
.chip.good i { color: var(--good); }
.chip.warning i { color: var(--warning); }
.chip.critical i { color: var(--critical); }
.chip.idle i { color: var(--muted); }

/* 额度条：每项固定两行 */
.meter { margin-top: 12px; }
.meter:first-of-type { margin-top: 0; }
.meter-head { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline; white-space: nowrap; }
.meter-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.meter-value { flex: none; margin-left: auto; font-variant-numeric: tabular-nums; }
.meter-value b { font-size: 15px; }
.meter-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; height: 20px; }
.meter-bar .chip { justify-content: flex-end; min-width: 7.2em; }
.meter-msg { height: 20px; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; }
.track { --fill: var(--accent); height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--fill) 18%, var(--surface)); overflow: hidden; }
.track span { display: block; height: 100%; border-radius: 99px; background: var(--fill); }
.track.warning { --fill: var(--warning); }
.track.critical { --fill: var(--critical); }

.tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.tiles > .tile { flex: 1 1 140px; }
.tile b { display: block; font-size: 24px; font-weight: 600; }

/* 柱状图 */
.chart-head { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.chart-head h3, .chart-head .legend { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 8px; font-size: 12.5px; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; }
.chart { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 0 8px; }
.y-axis { position: relative; height: 140px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.plot { position: relative; height: 140px; display: flex; border-bottom: 1px solid var(--line); }
.gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); pointer-events: none; }
.column { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column-reverse; align-items: center; padding: 0 1px; }
.column:hover, .column:focus-visible { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.column span { display: block; width: 100%; max-width: 24px; flex: none; }
.column span + span { margin-bottom: 0; border-bottom: 2px solid var(--surface); }
.column span.top { border-radius: 4px 4px 0 0; }
.x-axis { grid-column: 2; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }

#tooltip { position: fixed; z-index: 20; pointer-events: none; white-space: pre; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-variant-numeric: tabular-nums; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
td { white-space: nowrap; }
td.wrap { white-space: normal; word-break: break-all; min-width: 220px; }
.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-align: left; }
.link:hover { text-decoration: underline; }

dialog { width: min(1200px, calc(100% - 24px)); max-height: 88vh; padding: 0 16px 16px; background: var(--page); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; }
dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 0; background: var(--page); }
#dialog-body { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-all; }

/* 额度总览：固定列数，同一行的卡片等高 */
.quotas { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .quotas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .quotas { grid-template-columns: minmax(0, 1fr); } }

/* 额度卡片底部提示栏：贴着卡片底边，同一行卡片的提示栏底部对齐 */
.quotas > .card { display: flex; flex-direction: column; }
.card-foot { margin-top: auto; padding-top: 14px; }
.card-note { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr); padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); font-size: 12px; color: var(--ink-2); }
.note-table th, .note-table td { padding: 2px 0 2px 8px; border: 0; text-align: right; white-space: nowrap; vertical-align: baseline; font-size: 12px; font-weight: 400; color: var(--ink); }
.note-table th:first-child { padding-left: 0; text-align: left; color: var(--ink-2); }
.note-table thead th { font-size: 11.5px; color: var(--muted); }
.note-table small { margin-left: 5px; font-size: 11px; color: var(--muted); }
.card-note ul { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.note-table + ul { padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.card-note li b { margin-right: 8px; font-weight: 600; color: var(--ink); }

/* 资源卡片：一项一张；每个数据只占一行，所以同类卡片高度一致 */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.items.wide { grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.item { display: flex; flex-direction: column; gap: 10px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item-head > * { flex: none; }
.item-head h3 { flex: 0 1 auto; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.item-head .link { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.item p { margin: 0; }
.item-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.foot-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.foot-row button { flex: none; padding: 3px 12px; color: var(--ink); }
.divided { padding-top: 8px; border-top: 1px solid var(--line); }
.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.stats > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.stats > .wide { grid-column: 1 / -1; }
.stats dt { font-size: 12.5px; white-space: nowrap; }
.stats dd { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; word-break: normal; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats dd .chip, .stats dd .muted { margin-left: 6px; font-weight: 400; }
.tag { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; white-space: nowrap; }
.domains a + a { margin-left: 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.code { font: 12.5px/1.5 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
/* 长内容固定两行，点一下展开 */
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; height: 3em; overflow-wrap: anywhere; }
.clamp:focus { -webkit-line-clamp: unset; height: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); column-gap: 28px; margin: 0; padding: 0; list-style: none; }
.checks li { display: flex; justify-content: space-between; gap: 10px; min-width: 0; padding: 5px 0; border-bottom: 1px solid var(--line); }
.checks li span:first-child { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.alerts ul { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); column-gap: 24px; }

@media (max-width: 600px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  #app { padding-inline: 12px; }
  #progress { width: 100%; }
}
