:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dfe4ea;
  --accent: #165dff;
  --accent-strong: #0b4bd4;
  --success: #067647;
  --danger: #b42318;
  --warning: #b54708;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --shadow: 0 12px 30px rgba(15, 23, 42, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  color: #e5e7eb;
  background: linear-gradient(180deg, var(--sidebar), #0b1220);
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 24px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #5b8cff, #165dff);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(22, 93, 255, .35);
}
.brand strong, .brand small { display: block; }
.brand strong { color: #fff; font-size: 16px; }
.brand small { color: #94a3b8; font-size: 11px; letter-spacing: .04em; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a {
  display: block;
  padding: 10px 12px;
  color: #cbd5e1;
  border-radius: 9px;
  transition: .15s ease;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.sidebar nav a.active { color: #fff; background: var(--sidebar-soft); box-shadow: inset 3px 0 var(--accent); }
.sidebar-foot { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-foot span, .sidebar-foot small { display: block; }
.sidebar-foot span { color: #fff; font-weight: 650; }
.sidebar-foot small { color: #94a3b8; }

.main { min-width: 0; padding: 24px 28px 42px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.topbar p { margin: 3px 0 0; color: var(--muted); }

.panel {
  margin-bottom: 18px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 17px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metric small { display: block; color: var(--muted); margin-bottom: 8px; }
.metric strong { display: block; font-size: 24px; line-height: 1.1; }
.metric .sub { margin-top: 8px; color: var(--muted); font-size: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
  transition: .15s ease;
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; }
.button.ghost { color: var(--text); background: #fff; border-color: var(--line); }
.button.ghost:hover { background: var(--panel-soft); }
.button.danger { background: var(--danger); border-color: var(--danger); }
.button.small-button { min-height: 32px; padding: 5px 10px; font-size: 12px; }

.alert { margin-bottom: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid; }
.alert.info { color: #1849a9; background: #eff4ff; border-color: #c7d7fe; }
.alert.error { color: #912018; background: #fef3f2; border-color: #fecdca; }
.alert.success { color: #05603a; background: #ecfdf3; border-color: #abefc6; }
.alert.warning { color: #93370d; background: #fffaeb; border-color: #fedf89; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 11px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #475467; background: var(--panel-soft); font-size: 12px; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
.small { color: var(--muted); font-size: 12px; }
.positive-text { color: var(--success); font-weight: 650; }
.negative-text { color: var(--danger); font-weight: 650; }

.pill { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; background: #eef2f6; color: #344054; font-size: 12px; font-weight: 650; }
.pill.active, .pill.paid, .pill.debited, .pill.refunded { color: var(--success); background: #ecfdf3; }
.pill.paused, .pill.pending { color: var(--warning); background: #fffaeb; }
.pill.archived, .pill.failed, .pill.expired, .pill.token_invalid { color: var(--danger); background: #fef3f2; }

form { margin: 0; }
label { display: grid; gap: 6px; color: #344054; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  outline: none;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,93,255,.12); }
input[type="checkbox"] { width: auto; min-height: auto; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.stack { display: grid; gap: 14px; }
.search { display: flex; gap: 10px; max-width: 650px; }
.search input { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { display: flex; align-items: center; gap: 7px; font-weight: 500; }

.details { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--line); }
.details > div { min-height: 76px; padding: 13px; background: #fff; }
.details small { display: block; color: var(--muted); margin-bottom: 5px; }
.details strong { font-size: 16px; }
.user-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); gap: 18px; align-items: start; }
.split-tables { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); }
.pagination .links { display: flex; gap: 8px; }
.pagination a { padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }

.bot-policy-list { display: grid; gap: 14px; }
.policy-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.policy-card h3 { margin: 0; }
.policy-card .policy-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 13px; }

.future { padding: 22px; border: 1px dashed #98a2b3; border-radius: 12px; background: var(--panel-soft); }
.future h3 { margin-top: 0; }
.code-block { overflow-x: auto; padding: 14px; border-radius: 10px; background: #101828; color: #d0d5dd; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #dbe7ff, transparent 36%), var(--bg); }
.login-card { width: min(430px, 100%); padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 70px rgba(15, 23, 42, .14); }
.login-card .brand { padding: 0 0 24px; color: var(--text); }
.login-card .brand small { color: var(--muted); }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card > p { margin: 0 0 20px; color: var(--muted); }

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

@media (max-width: 1180px) {
  .cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .details { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .user-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px 32px; }
  .topbar { align-items: flex-start; }
  .form-grid, .split-tables { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 520px) {
  .cards, .details { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .search { flex-direction: column; }
}

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button.small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.button.full { width: 100%; }
.muted { color: var(--muted); }
.center { text-align: center; }
.policy-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.danger-note { color: var(--danger); font-size: 12px; font-weight: 650; }
.confirm-box { padding: 10px 12px; border: 1px solid #fedf89; border-radius: 9px; background: #fffaeb; color: #93370d; }
dl, dt, dd { margin: 0; }
.details dt { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.details dd { font-weight: 650; }
.money.big { font-size: 22px; }
td small { display: block; color: var(--muted); margin-top: 2px; }
.future-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #eef4ff; color: var(--accent); font-size: 24px; font-weight: 800; }

.preview-invalid { border-color: #fda29b; background: #fef3f2; color: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
