:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d9e0e8;
  --text: #182230;
  --muted: #667085;
  --brand: #2563eb;
  --brand-soft: #dbeafe;
  --ok: #16803c;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b42318;
  --bad-soft: #fee4e2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--brand);
  font-weight: 700;
  margin-right: 12px;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  margin: 0 auto;
  max-width: 1280px;
  padding: 28px 20px 40px;
}

.shell.wide {
  max-width: 1480px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 22px;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.top-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 42px;
  margin: 0;
  padding: 0 13px;
  text-decoration: none;
}

.nav-button:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}

.icon-button:disabled {
  cursor: wait;
  opacity: .55;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.subscription-summary {
  grid-template-columns: 1fr 1.2fr 1.2fr 1fr;
}

.summary,
.panel,
.alerts {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary {
  padding: 16px;
}

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

.label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.summary strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.summary small {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 6px;
}

.alerts {
  border-color: #f4c790;
  color: var(--warn);
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
}

.panel-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.table-wrap {
  overflow-x: auto;
}

.stacked-panel {
  margin-top: 16px;
}

table {
  border-collapse: collapse;
  min-width: 960px;
  width: 100%;
}

.clients-table {
  min-width: 960px;
}

.subscriptions-table {
  min-width: 1180px;
}

.daily-table {
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.client-name {
  font-weight: 800;
  margin-bottom: 3px;
}

.muted {
  font-size: 12px;
  line-height: 1.5;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  margin-top: 8px;
  padding: 3px 9px;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.usage-cell {
  min-width: 180px;
}

.usage-line {
  display: flex;
  font-size: 13px;
  font-weight: 800;
  justify-content: space-between;
  margin-bottom: 8px;
}

.bar {
  background: #e5e7eb;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar span {
  background: var(--brand);
  display: block;
  height: 100%;
}

.loading {
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.error {
  color: var(--bad);
}

@media (max-width: 820px) {
  .shell {
    padding: 18px 12px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .summary-grid,
  .subscription-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .summary-grid,
  .subscription-summary {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}

.error {
  color: var(--bad);
}

@media (max-width: 860px) {
  .shell {
    padding: 20px 12px 28px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 24px;
  }
}

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

/* AnyDoor-inspired dark monitor refresh */
:root {
  color-scheme: dark;
  --bg: #050507;
  --surface: rgba(28, 28, 32, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.055);
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.17);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --brand: #0a84ff;
  --brand-soft: rgba(10, 132, 255, 0.16);
  --ok: #30d158;
  --ok-soft: rgba(48, 209, 88, 0.14);
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, 0.14);
  --bad: #ff453a;
  --bad-soft: rgba(255, 69, 58, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
}

html,
body {
  min-height: 100%;
  background: var(--bg);
}

body {
  background:
    radial-gradient(900px 600px at 80% -10%, rgba(10, 132, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 30%, rgba(191, 90, 242, 0.1), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(48, 209, 88, 0.06), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.5;
}

a {
  color: var(--text);
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 0.5px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
}

a:hover {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}

.shell {
  max-width: 1320px;
  padding: 92px 28px 48px;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  min-height: 68px;
  padding: 14px 28px;
  border-bottom: 0.5px solid var(--line);
  background: rgba(5, 5, 7, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
}

.eyebrow {
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  background: linear-gradient(180deg, #fff 28%, #8b8b94 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -0.04em;
}

h2 {
  color: var(--text);
  letter-spacing: -0.02em;
}

.icon-button {
  width: 44px;
  height: 44px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.summary-grid {
  gap: 14px;
  margin-bottom: 18px;
}

.summary,
.panel,
.alerts {
  background: linear-gradient(180deg, rgba(38, 38, 42, 0.92), rgba(18, 18, 22, 0.9));
  border: 0.5px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset, 0 24px 60px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(28px) saturate(160%);
}

.summary {
  min-height: 134px;
  padding: 18px;
}

.label,
.muted,
.summary small,
.panel-head p {
  color: var(--muted);
}

.label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.summary strong {
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(22px, 2.3vw, 32px);
}

.alerts {
  background: rgba(255, 159, 10, 0.12);
  border-color: rgba(255, 159, 10, 0.28);
}

.panel {
  overflow: hidden;
}

.panel-head {
  border-bottom: 0.5px solid var(--line);
  padding: 18px 20px;
}

.table-wrap {
  background: rgba(0, 0, 0, 0.18);
}

table {
  min-width: 960px;
}

.clients-table {
  min-width: 960px;
}

.subscriptions-table {
  min-width: 1180px;
}

.daily-table {
  min-width: 980px;
}

th,
td {
  border-bottom: 0.5px solid var(--line);
}

th {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  font-size: 11px;
  letter-spacing: 0.1em;
}

td {
  color: var(--text);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.035);
}

.client-name,
.usage-line {
  color: var(--text);
}

.badge {
  border: 0.5px solid currentColor;
}

.bar {
  height: 9px;
  background: rgba(255, 255, 255, 0.09);
}

.bar span {
  background: linear-gradient(90deg, var(--brand), #bf5af2);
  box-shadow: 0 0 18px rgba(10, 132, 255, 0.36);
}

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

@media (max-width: 860px) {
  .shell {
    padding: 82px 14px 32px;
  }

  .topbar {
    padding: 12px 16px;
  }
}

.alerts[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .panel {
    overflow: visible;
  }

  .table-wrap {
    background: transparent;
    overflow: visible;
  }

  table {
    border-collapse: separate;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  tr {
    background: rgba(255, 255, 255, 0.035);
    border: 0.5px solid var(--line);
    border-radius: 16px;
    display: block;
    overflow: hidden;
    padding: 12px 14px;
  }

  td {
    align-items: start;
    border-bottom: 0;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(76px, 30%) minmax(0, 1fr);
    padding: 8px 0;
  }

  td::before {
    color: var(--muted);
    content: "";
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .clients-table td:nth-child(1)::before { content: "客户"; }
  .clients-table td:nth-child(2)::before { content: "节点"; }
  .clients-table td:nth-child(3)::before { content: "今日"; }
  .clients-table td:nth-child(4)::before { content: "用量"; }
  .clients-table td:nth-child(5)::before { content: "剩余"; }
  .clients-table td:nth-child(6)::before { content: "到期"; }
  .clients-table td:nth-child(7)::before { content: "订阅"; }

  .subscriptions-table td:nth-child(1)::before { content: "订阅"; }
  .subscriptions-table td:nth-child(2)::before { content: "节点"; }
  .subscriptions-table td:nth-child(3)::before { content: "额度"; }
  .subscriptions-table td:nth-child(4)::before { content: "用量"; }
  .subscriptions-table td:nth-child(5)::before { content: "今日"; }
  .subscriptions-table td:nth-child(6)::before { content: "到期"; }
  .subscriptions-table td:nth-child(7)::before { content: "链接"; }

  .daily-table td:nth-child(1)::before { content: "日期"; }
  .daily-table td:nth-child(2)::before { content: "订阅"; }
  .daily-table td:nth-child(3)::before { content: "当日"; }
  .daily-table td:nth-child(4)::before { content: "累计"; }
  .daily-table td:nth-child(5)::before { content: "次数"; }
  .daily-table td:nth-child(6)::before { content: "采集"; }

  td.loading {
    display: block;
    padding: 22px 0;
  }

  td.loading::before {
    content: none;
  }

  .usage-line {
    max-width: 100%;
  }

  td a {
    margin: 0 8px 8px 0;
  }
}
