/* Vela · 扬帆 — design system. Light + Dark themes. No emoji; Phosphor icons. */
:root {
  --primary: #4361ee;
  --primary-600: #3a53d8;
  --primary-700: #2f44b8;
  --primary-soft: rgba(67, 97, 238, 0.10);
  --accent: #f59e0b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --transition: .18s ease;
}

/* ---------- Light (default, matches dashboard.tag.ad) ---------- */
:root[data-theme="light"] {
  --bg: #f3f5fb;
  --bg-elev: #ffffff;
  --bg-soft: #f7f8fc;
  --bg-hover: #eef1fa;
  --card: #ffffff;
  --border: #e6e9f2;
  --border-strong: #d6dbe9;
  --text: #2b2d42;
  --text-2: #5a6376;
  --text-muted: #8d99ae;
  --shadow: 0 2px 14px rgba(43, 45, 66, .07);
  --shadow-lg: 0 12px 40px rgba(43, 45, 66, .14);
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, .85);
}

/* ---------- Dark (polished slate) ---------- */
:root[data-theme="dark"] {
  --bg: #0b0e16;
  --bg-elev: #121726;
  --bg-soft: #161c2d;
  --bg-hover: #1c2336;
  --card: #131929;
  --border: #232c41;
  --border-strong: #2d384f;
  --text: #e7ecf5;
  --text-2: #a9b3c7;
  --text-muted: #6b7689;
  --shadow: 0 2px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, .5);
  --sidebar-bg: #0f1420;
  --topbar-bg: rgba(15, 20, 32, .82);
  --primary-soft: rgba(67, 97, 238, 0.18);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { height: 100vh; display: grid; place-items: center; font-size: 32px; color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition); white-space: nowrap; color: var(--text);
  background: var(--bg-elev);
}
.btn i { font-size: 17px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 8px; width: 38px; height: 38px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13px; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); color: var(--text);
  font-family: inherit; font-size: 14px; transition: var(--transition);
}
.textarea { resize: vertical; min-height: 90px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.input-group { display: flex; align-items: center; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-elev); overflow: hidden; transition: var(--transition); }
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-group .addon { padding: 0 12px; color: var(--text-muted); }
.input-group input { border: none; background: transparent; padding: 11px 12px 11px 0; flex: 1; color: var(--text); font-size: 14px; }
.input-group input:focus { outline: none; }

/* ---------- Cards / layout primitives ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.grid { display: grid; gap: 18px; }
.row { display: flex; gap: 14px; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 600; background: var(--bg-hover); color: var(--text-2); }
.chip.green { background: rgba(34,197,94,.14); color: #16a34a; }
.chip.amber { background: rgba(245,158,11,.16); color: #d97706; }
.chip.red { background: rgba(239,68,68,.14); color: #dc2626; }
.chip.blue { background: var(--primary-soft); color: var(--primary); }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--info)); color: #fff; font-size: 20px; }
.brand .name { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand .sub { font-size: 11px; color: var(--text-muted); }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { margin: 8px 0; }
.nav-group .gl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); padding: 8px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font-weight: 500; transition: var(--transition); margin: 1px 0; }
.nav-item i { font-size: 19px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-soft); }
.nav-item.active i { color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 40; display: flex; align-items: center;
  gap: 14px; padding: 0 24px; background: var(--topbar-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .page-title { font-weight: 700; font-size: 16px; }
.topbar .grow { flex: 1; }
.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.page-head p { color: var(--text-muted); margin-top: 3px; }

/* top bar controls */
.tbtn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-elev); color: var(--text-2);
  cursor: pointer; transition: var(--transition); font-size: 18px; }
.tbtn:hover { background: var(--bg-hover); color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { padding: 7px 11px; background: var(--bg-elev); border: none; color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 13px; font-family: inherit; }
.seg button.on { background: var(--primary); color: #fff; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,var(--primary),var(--info));
  color: #fff; display: grid; place-items: center; font-weight: 700; cursor: pointer; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; }
.stat .top { display: flex; align-items: center; justify-content: space-between; }
.stat .ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 21px; background: var(--primary-soft); color: var(--primary); }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 10px; }
.stat .l { color: var(--text-muted); font-size: 13px; }
.stat .d { font-size: 12px; font-weight: 600; margin-top: 4px; }
.up { color: var(--success); } .down { color: var(--danger); }

/* ---------- Table ---------- */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); padding: 11px 14px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tbl tr:hover td { background: var(--bg-soft); }
.tbl tr:last-child td { border-bottom: none; }

/* ---------- Auth page ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 460px; }
.auth-cover { background: linear-gradient(150deg, var(--primary) 0%, #2f44b8 55%, #1f2a6b 100%); position: relative; overflow: hidden; display: grid; place-items: center; color: #fff; }
.auth-cover .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; }
.auth-cover .b1 { width: 340px; height: 340px; background: #6ea8ff; top: -60px; left: -60px; }
.auth-cover .b2 { width: 300px; height: 300px; background: var(--accent); bottom: -80px; right: -40px; opacity: .35; }
.auth-hero { position: relative; z-index: 2; max-width: 440px; padding: 40px; }
.auth-hero h2 { font-size: 30px; font-weight: 800; line-height: 1.25; }
.auth-hero p { margin-top: 14px; opacity: .9; font-size: 15px; }
.auth-hero ul { margin-top: 24px; list-style: none; display: grid; gap: 12px; }
.auth-hero li { display: flex; align-items: center; gap: 11px; font-weight: 500; }
.auth-hero li i { font-size: 20px; background: rgba(255,255,255,.18); width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.auth-form-wrap { display: grid; place-items: center; padding: 30px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-card h1 { font-size: 22px; font-weight: 800; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 22px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--text-muted); font-size: 13px; }
.auth-switch a { color: var(--primary); font-weight: 600; cursor: pointer; }
.auth-corner { position: absolute; top: 18px; right: 22px; display: flex; gap: 8px; z-index: 5; }
.test-hint { margin-top: 16px; padding: 11px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-muted); background: var(--bg-soft); }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty i { font-size: 46px; opacity: .5; display: block; margin-bottom: 12px; }
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 9999; display: grid; gap: 10px; }
.toast { background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--primary); box-shadow: var(--shadow-lg); border-radius: var(--radius-sm); padding: 12px 16px; min-width: 240px; display: flex; gap: 10px; align-items: center; animation: slidein .25s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.skeleton { background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-soft) 50%, var(--bg-hover) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes stagedmove { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.terminal { background: #0a0e16; color: #7CFC9A; font-family: 'SFMono-Regular', ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.7; padding: 18px; border-radius: var(--radius); min-height: 280px; max-height: 420px; overflow-y: auto; border: 1px solid #1d2433; }
.terminal .ln { white-space: pre-wrap; }
.terminal .ok { color: #7CFC9A; } .terminal .dim { color: #5a6b80; } .terminal .warn { color: #f5c451; }

.mobile-only { display: none; }
.sidebar-scrim { display: none; }

@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 49; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-cover { display: none; }
  /* stack any fixed multi-column grids */
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  /* tables scroll horizontally instead of overflowing */
  .card-pad { overflow-x: auto; }
  table.tbl { min-width: 520px; }
  .page-head h1 { font-size: 19px; }
  .stat .v { font-size: 22px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .seg button { padding: 6px 9px; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
}
