:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: rgba(255,255,255,.92);
  --line: #e3e9f3;
  --ink: #17223b;
  --muted: #72809a;
  --primary: #5b5ce8;
  --primary-2: #3388f5;
  --success: #17a568;
  --warning: #d89120;
  --danger: #d9435b;
  --shadow: 0 18px 50px rgba(38,55,94,.11);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background:
  radial-gradient(circle at 8% 0%, rgba(88,92,232,.14), transparent 28%),
  radial-gradient(circle at 100% 10%, rgba(46,151,245,.12), transparent 24%),
  var(--bg); }
button,input,select,textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(380px,1.1fr) minmax(420px,.9fr); }
.auth-brand { display: flex; flex-direction: column; justify-content: center; padding: 9vw; color: #fff; background: linear-gradient(145deg,#4e45d5,#267de9); }
.brand-mark { display: grid; width: 68px; height: 68px; place-items: center; margin-bottom: 28px; border: 1px solid rgba(255,255,255,.24); border-radius: 22px; background: rgba(255,255,255,.14); font-size: 30px; box-shadow: 0 20px 40px rgba(15,21,87,.2); }
.auth-brand h1 { max-width: 680px; margin: 0; font-size: clamp(34px,5vw,64px); line-height: 1.08; letter-spacing: -.04em; }
.auth-brand p { max-width: 620px; margin: 24px 0 0; color: rgba(255,255,255,.78); font-size: 16px; line-height: 1.8; }
.auth-points { display: grid; gap: 12px; margin-top: 38px; }
.auth-points span { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.auth-points span::before { content: "✓"; display: grid; width: 24px; height: 24px; place-items: center; border-radius: 8px; background: rgba(255,255,255,.16); }
.auth-side { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(430px,100%); padding: 34px; border: 1px solid rgba(255,255,255,.9); border-radius: 26px; background: rgba(255,255,255,.87); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-card h2 { margin: 0 0 7px; font-size: 25px; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 22px; padding: 5px; border-radius: 13px; background: #edf1f8; }
.auth-tabs button { padding: 9px; border: 0; border-radius: 9px; color: #748098; background: transparent; }
.auth-tabs button.active { color: #fff; background: linear-gradient(135deg,var(--primary),var(--primary-2)); box-shadow: 0 7px 18px rgba(74,83,220,.22); }

.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field > span { color: #526078; font-size: 12px; font-weight: 700; }
.field small { color: #8994a8; font-size: 10px; }
input,select,textarea { width: 100%; border: 1px solid #dbe3ef; border-radius: 11px; outline: none; background: #fff; color: var(--ink); transition: .2s; }
input,select { height: 42px; padding: 0 12px; }
textarea { min-height: 96px; padding: 11px 12px; resize: vertical; line-height: 1.55; }
input:focus,select:focus,textarea:focus { border-color: #7d76ea; box-shadow: 0 0 0 4px rgba(91,92,232,.1); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; border: 1px solid #dbe3ef; border-radius: 11px; color: #41506a; background: #fff; font-weight: 700; }
.button.primary { border-color: transparent; color: #fff; background: linear-gradient(135deg,var(--primary),var(--primary-2)); box-shadow: 0 9px 22px rgba(73,82,218,.2); }
.button.danger { color: var(--danger); background: #fff3f5; border-color: #ffd7de; }
.button.ghost { background: #f2f5fa; }
.button.wide { width: 100%; }
.button.small { min-height: 31px; padding: 0 10px; border-radius: 8px; font-size: 11px; }
.button:disabled { cursor: wait; opacity: .55; }

.layout { display: grid; min-height: 100vh; grid-template-columns: 244px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; color: #fff; background: linear-gradient(180deg,#1e2851,#25205b); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 24px; }
.sidebar-brand b { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 13px; background: linear-gradient(135deg,#786cf2,#36a0f5); font-size: 18px; }
.sidebar-brand strong,.sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand small { margin-top: 3px; color: #9ea9d0; font-size: 9px; }
.nav { display: grid; gap: 5px; }
.nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 11px; color: #b8c1df; background: transparent; text-align: left; }
.nav button.active,.nav button:hover { color: #fff; background: rgba(255,255,255,.1); }
.sidebar-footer { position: absolute; right: 16px; bottom: 20px; left: 16px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.07); }
.sidebar-footer strong,.sidebar-footer span { display: block; }
.sidebar-footer strong { font-size: 11px; }
.sidebar-footer span { margin: 4px 0 10px; color: #9ea9c7; font-size: 9px; }

.main { min-width: 0; padding: 27px 30px 45px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 25px; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; color: #5b61a8; background: #edf0ff; font-size: 10px; font-weight: 800; }
.badge.success { color: #18865a; background: #e7f8ef; }
.badge.warning { color: #9c6a18; background: #fff3dc; }
.badge.danger { color: #ba3048; background: #ffedf1; }

.grid { display: grid; gap: 15px; }
.stats-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.two-col { grid-template-columns: repeat(2,minmax(0,1fr)); }
.card { padding: 19px; border: 1px solid rgba(219,226,239,.9); border-radius: 18px; background: var(--panel); box-shadow: 0 10px 35px rgba(42,55,88,.06); }
.card h2,.card h3 { margin: 0; }
.card h2 { font-size: 15px; }
.card h3 { font-size: 13px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; }
.stat-card strong { display: block; margin-top: 12px; font-size: 28px; }
.stat-card em { display: block; margin-top: 6px; color: #8b96a9; font-size: 9px; font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.form-grid .field { margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 15px; padding: 5px; border-radius: 12px; background: #eef2f8; }
.segmented label { display: flex; align-items: center; justify-content: center; min-height: 37px; border-radius: 9px; color: #717e94; cursor: pointer; font-size: 11px; font-weight: 700; }
.segmented label:has(input:checked) { color: #fff; background: linear-gradient(135deg,var(--primary),var(--primary-2)); }
.segmented input { display: none; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th,td { padding: 11px 12px; border-bottom: 1px solid #edf1f6; text-align: left; font-size: 10px; }
th { color: #7d899d; background: #f7f9fc; font-weight: 800; }
td { color: #46546d; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
.actions { display: flex; gap: 6px; }
.empty { padding: 30px; color: #909aad; text-align: center; font-size: 11px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar input { width: min(320px,100%); }

.template-list { display: grid; gap: 9px; }
.template-item { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfe; }
.template-item strong,.template-item span { display: block; }
.template-item strong { font-size: 11px; }
.template-item span { margin-top: 3px; color: #8590a4; font-size: 9px; }
.template-item .actions { flex: 0 0 auto; }

.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(16,24,47,.42); backdrop-filter: blur(6px); }
.modal-card { width: min(850px,100%); max-height: calc(100vh - 56px); overflow: auto; padding: 23px; border-radius: 20px; background: #fff; box-shadow: 0 30px 90px rgba(16,25,55,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 10px; color: #718099; background: #edf1f7; }
.detail-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-section h3 { margin: 0 0 10px; font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.kv div { padding: 10px; border-radius: 10px; background: #f5f7fb; }
.kv span,.kv strong { display: block; overflow-wrap: anywhere; }
.kv span { color: #8a95a7; font-size: 8px; }
.kv strong { margin-top: 4px; font-size: 10px; }
.code-output { max-height: 220px; overflow: auto; padding: 13px; border-radius: 12px; color: #d8e3ff; background: #18213d; font: 11px/1.8 ui-monospace,Consolas,monospace; white-space: pre-wrap; }
.json-preview { max-height: 260px; overflow: auto; padding: 12px; border-radius: 10px; background: #f4f6fa; font: 9px/1.6 ui-monospace,Consolas,monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 360px; padding: 12px 16px; border-radius: 12px; color: #fff; background: #18213b; box-shadow: 0 15px 40px rgba(0,0,0,.23); font-size: 11px; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .layout { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar-brand div,.nav span,.sidebar-footer { display: none; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .nav button { justify-content: center; }
  .main { padding-inline: 18px; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .auth-side { padding: 18px; }
  .auth-card { padding: 24px; }
  .layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 10px; }
  .sidebar-brand,.sidebar-footer { display: none; }
  .nav { grid-template-columns: repeat(4,1fr); }
  .nav button { padding: 9px 3px; font-size: 10px; }
  .main { padding: 18px 12px 35px; }
  .topbar { align-items: flex-start; gap: 10px; }
  .stats-grid,.form-grid,.kv { grid-template-columns: 1fr; }
}
