:root {
  --bg: #f3f5fa;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6eaf2;
  --line-2: #eef1f7;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-soft: #eef2ff;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --cyan: #0891b2;
  --sidebar: #0b1220;
  --sidebar-2: #111a2e;
  --sidebar-ink: #c7d2e3;
  --sidebar-muted: #7b8aa5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }

/* ---------------------------------------------------------------- shell */
.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0d1526 60%, var(--sidebar-2) 100%);
  color: var(--sidebar-ink);
  padding: 18px 14px 14px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px;
  padding: 8px; box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}
.brand-mark span { background: rgba(255, 255, 255, 0.92); border-radius: 2px; }
.brand-mark span:nth-child(2) { opacity: 0.55; }
.brand-mark span:nth-child(3) { opacity: 0.7; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: 0.2px; color: #fff; }
.brand-text small { font-size: 10.5px; color: var(--sidebar-muted); letter-spacing: 0.6px; }
.brand-badge {
  margin-left: auto; font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: rgba(99, 102, 241, 0.16); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.25);
  font-family: var(--mono);
}

.tenant-switch {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer; transition: background 0.15s ease;
}
.tenant-switch:hover { background: rgba(255, 255, 255, 0.08); }
.tenant-avatar {
  width: 32px; height: 32px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
.tenant-meta { display: flex; flex-direction: column; min-width: 0; }
.tenant-label { font-size: 10px; color: var(--sidebar-muted); }
.tenant-meta strong { font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chevron { width: 16px; height: 16px; color: var(--sidebar-muted); margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 16px 4px 8px; scrollbar-width: thin; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-group-title {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 0 10px 7px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin: 2px 0; border-radius: 9px;
  color: var(--sidebar-ink); font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; color: var(--sidebar-muted); flex: 0 0 auto; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item:hover svg { color: #c7d2fe; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.28), rgba(79, 70, 229, 0.08));
  color: #fff;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: #818cf8;
}
.nav-item.active svg { color: #c7d2fe; }
.nav-count {
  margin-left: auto; font-size: 10.5px; font-family: var(--mono);
  color: #a5b4fc; background: rgba(99, 102, 241, 0.16);
  padding: 1px 6px; border-radius: 999px;
}
.nav-dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.12); }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.07); padding-top: 12px; }
.user-card { display: flex; align-items: center; gap: 9px; padding: 4px 6px; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { font-size: 12.5px; color: #fff; }
.user-meta small { font-size: 10.5px; color: var(--sidebar-muted); }
.user-card .icon-btn { margin-left: auto; }

/* ---------------------------------------------------------------- topbar */
.main { margin-left: 252px; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 16px 30px;
  background: rgba(243, 245, 250, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(230, 234, 242, 0.9);
}
.crumb { font-size: 11px; color: var(--muted-2); letter-spacing: 0.2px; }
.crumb span { margin: 0 3px; }
.topbar-title h1 { margin: 3px 0 0; font-size: 20px; letter-spacing: -0.2px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 0 12px; height: 38px; width: 280px;
  box-shadow: var(--shadow-sm);
}
.search svg { width: 16px; height: 16px; color: var(--muted-2); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; }
.search input::placeholder { color: var(--muted-2); }

.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
  color: var(--muted); box-shadow: var(--shadow-sm); position: relative;
}
.icon-btn:hover { color: var(--ink); border-color: #d7deea; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--sidebar-muted); width: 32px; height: 32px; }
.icon-btn-ghost:hover { background: rgba(255,255,255,0.08); color: #fff; }
.bell-dot { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 0 2px #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #d3dbe8; background: #fbfcfe; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
}
.btn-primary:hover { background: linear-gradient(135deg, #6d70f5, #4338ca); border-color: transparent; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f4f9; color: var(--ink); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-danger { color: var(--rose); border-color: #fecdd3; background: #fff; }
.btn-danger:hover { background: var(--rose-soft); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #c7d2fe, #a5b4fc); color: #312e81;
  font-weight: 700; font-size: 13px;
}
.avatar-sm { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.avatar-blue { background: linear-gradient(135deg, #bae6fd, #7dd3fc); color: #075985; }
.avatar-emerald { background: linear-gradient(135deg, #bbf7d0, #86efac); color: #166534; }
.avatar-amber { background: linear-gradient(135deg, #fde68a, #fcd34d); color: #92400e; }
.avatar-rose { background: linear-gradient(135deg, #fecdd3, #fda4af); color: #9f1239; }
.avatar-slate { background: linear-gradient(135deg, #e2e8f0, #cbd5e1); color: #334155; }

/* ---------------------------------------------------------------- view */
.view { padding: 26px 30px 44px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.2px; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 12.5px; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head { padding: 16px 18px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-size: 13.5px; font-weight: 700; letter-spacing: -0.1px; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line-2); background: #fbfcfe; display: flex; justify-content: space-between; align-items: center; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 16px 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: auto -20px -40px auto;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.10), transparent 65%);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.green { background: var(--emerald-soft); color: var(--emerald); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.rose { background: var(--rose-soft); color: var(--rose); }
.kpi-value { font-size: 25px; font-weight: 750; letter-spacing: -0.6px; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi-delta { font-size: 11.5px; display: inline-flex; align-items: center; gap: 4px; }
.delta-up { color: var(--emerald); }
.delta-down { color: var(--rose); }
.kpi-spark { position: absolute; right: 12px; bottom: 10px; opacity: 0.9; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.segmented {
  display: inline-flex; background: #eef1f7; padding: 3px; border-radius: 9px; gap: 2px;
}
.segmented button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.segmented button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,0.08); }
.filter-select, .input, .select {
  height: 36px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; padding: 0 11px; font-size: 12.5px; outline: none;
  box-shadow: var(--shadow-sm);
}
.input:focus, .select:focus, .filter-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
textarea.input { height: auto; padding: 8px 11px; resize: vertical; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-size: 11px; letter-spacing: 0.2px; color: var(--muted-2);
  font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line-2);
  background: #fbfcfe; white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: #fafbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cell-user { display: flex; align-items: center; gap: 9px; }
.cell-user .cell-sub { margin-top: 1px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-green { color: #047857; background: var(--emerald-soft); }
.pill-amber { color: #b45309; background: var(--amber-soft); }
.pill-red { color: #be123c; background: var(--rose-soft); }
.pill-gray { color: #475569; background: #f1f5f9; }
.pill-indigo { color: #4338ca; background: var(--brand-soft); }
.pill-cyan { color: #0e7490; background: #ecfeff; }
.pill-plain::before { display: none; }

.tag { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 6px; font-size: 10.5px; background: #f1f5f9; color: #475569; }
.tag + .tag { margin-left: 4px; }
.tag-indigo { background: var(--brand-soft); color: #4338ca; }

/* ---------------------------------------------------------------- charts */
.chart-box { position: relative; width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-stack { display: flex; flex-direction: column; justify-content: flex-end; width: 100%; max-width: 26px; height: 100%; gap: 3px; }
.bar-stack i { display: block; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, #818cf8, #6366f1); min-height: 3px; }
.bar-stack i.sub { background: #c7d2fe; }
.bar-label { font-size: 10px; color: var(--muted-2); white-space: nowrap; }

.progress { height: 6px; border-radius: 999px; background: #eef1f7; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #818cf8, #4f46e5); }
.progress.green > i { background: linear-gradient(90deg, #34d399, #059669); }
.progress.amber > i { background: linear-gradient(90deg, #fbbf24, #d97706); }
.progress.rose > i { background: linear-gradient(90deg, #fb7185, #e11d48); }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item:first-child { padding-top: 0; }
.list-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.list-icon svg { width: 17px; height: 17px; }
.list-main { flex: 1; min-width: 0; }
.list-main strong { display: block; font-size: 12.5px; font-weight: 600; }
.list-main small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.list-end { font-size: 11.5px; color: var(--muted); text-align: right; }

.metric-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line-2); }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); font-size: 12px; }
.metric-row strong { font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- plugins */
.plugin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.plugin-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.plugin-card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(15,23,42,0.10); border-color: #d8dff0; }
.plugin-top { display: flex; align-items: flex-start; gap: 11px; }
.plugin-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.plugin-icon svg { width: 21px; height: 21px; }
.bg-indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); }
.bg-emerald { background: linear-gradient(135deg, #34d399, #059669); }
.bg-amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.bg-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.bg-rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.bg-slate { background: linear-gradient(135deg, #94a3b8, #475569); }
.plugin-name { font-size: 13.5px; font-weight: 700; }
.plugin-pub { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.verified { color: #2563eb; display: inline-flex; }
.verified svg { width: 12px; height: 12px; }
.plugin-desc { font-size: 11.5px; color: var(--muted); line-height: 1.6; min-height: 38px; }
.plugin-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.plugin-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.plugin-price { font-size: 11.5px; color: var(--muted); }
.plugin-price strong { color: var(--ink); font-size: 12.5px; }

/* ---------------------------------------------------------------- devices */
.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.device-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow); }
.device-head { display: flex; align-items: center; gap: 10px; }
.device-status { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; flex: 0 0 auto; }
.device-status.online { background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12); }
.device-status.offline { background: #94a3b8; }
.device-status.warning { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12); }
.device-name { font-weight: 700; font-size: 12.5px; }
.device-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.device-capabilities { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 11px; }
.device-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- usage */
.quota-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.quota-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; background: #fff; }
.quota-label { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; }
.quota-value { font-size: 18px; font-weight: 750; margin: 6px 0 8px; letter-spacing: -0.3px; }
.quota-value small { font-size: 11px; color: var(--muted); font-weight: 500; }
.wallet-card {
  background: linear-gradient(135deg, #111a2e, #1e2a4a);
  color: #fff; border: 0; position: relative; overflow: hidden;
}
.wallet-card::after {
  content: ""; position: absolute; right: -50px; top: -60px; width: 220px; height: 220px;
  border-radius: 50%; background: radial-gradient(circle, rgba(99,102,241,0.45), transparent 65%);
}
.wallet-card .card-title, .wallet-card .muted { color: #cbd5e1; }
.wallet-amount { font-size: 30px; font-weight: 800; letter-spacing: -0.8px; margin: 8px 0 2px; }
.wallet-amount small { font-size: 12px; color: #94a3b8; font-weight: 500; }
.wallet-stats { display: flex; gap: 24px; margin-top: 16px; position: relative; z-index: 1; }
.wallet-stats div { display: flex; flex-direction: column; gap: 2px; }
.wallet-stats span { font-size: 10.5px; color: #94a3b8; }
.wallet-stats strong { font-size: 13px; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.field .hint { font-size: 10.5px; color: var(--muted-2); }
.field .input, .field .select { width: 100%; height: 38px; }
.checkbox-line { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--ink-2); }
.checkbox-line input { margin-top: 2px; accent-color: var(--brand); }
.perm-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.perm-item { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
.perm-item:last-child { border-bottom: 0; }
.perm-item .perm-main { flex: 1; }
.perm-item strong { display: block; font-size: 12px; }
.perm-item small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.risk { font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 700; }
.risk-low { background: var(--emerald-soft); color: #047857; }
.risk-mid { background: var(--amber-soft); color: #b45309; }
.risk-high { background: var(--rose-soft); color: #be123c; }

/* ---------------------------------------------------------------- modal / drawer */
.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn 0.15s ease;
}
.modal {
  width: min(680px, 100%); max-height: calc(100vh - 48px);
  background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(15,23,42,0.30);
  display: flex; flex-direction: column; overflow: hidden;
  animation: popIn 0.16s ease;
}
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head p { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line-2); background: #fbfcfe; display: flex; justify-content: flex-end; gap: 8px; }
.close-x { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.close-x:hover { background: #f1f5f9; color: var(--ink); }
.close-x svg { width: 18px; height: 18px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- toast */
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: #0f172a; color: #f8fafc; padding: 11px 14px;
  border-radius: 11px; box-shadow: 0 16px 40px rgba(15,23,42,0.3);
  font-size: 12.5px; max-width: 380px;
  animation: toastIn 0.18s ease;
}
.toast .toast-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; margin-top: 6px; flex: 0 0 auto; }
.toast.error .toast-dot { background: #fb7185; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- misc */
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 12.5px; }
.code-block {
  font-family: var(--mono); font-size: 11px; background: #0f172a; color: #cbd5e1;
  padding: 12px 14px; border-radius: 10px; overflow-x: auto; line-height: 1.7;
}
.kbd { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--muted); }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 11px; position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: 5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #c7d2fe; background: #fff; margin-top: 3px; flex: 0 0 auto; z-index: 1; }
.tl-dot.ok { border-color: #34d399; background: #ecfdf5; }
.tl-dot.warn { border-color: #fbbf24; background: #fffbeb; }
.tl-main { flex: 1; }
.tl-main strong { display: block; font-size: 12px; }
.tl-main small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.tl-time { font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }

@media (max-width: 1250px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plugin-grid, .device-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quota-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .sidebar { width: 76px; padding: 14px 8px; }
  .brand-text, .brand-badge, .tenant-meta, .tenant-switch .chevron, .nav-group-title, .nav-item span:not(.nav-count):not(.nav-dot), .nav-count, .user-meta, .user-card .icon-btn { display: none; }
  .main { margin-left: 76px; }
  .topbar { padding: 14px 18px; }
  .view { padding: 20px 18px 40px; }
  .search { width: 180px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .plugin-grid, .device-grid, .quota-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- switches / qr */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
  transition: background 0.15s ease; cursor: pointer;
}
.switch span::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform 0.15s ease;
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(16px); }

.qr {
  width: 168px; height: 168px; margin: 0 auto; display: grid;
  grid-template-columns: repeat(9, 1fr); gap: 3px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.qr span { border-radius: 1px; }

.avatar-indigo { background: linear-gradient(135deg, #c7d2fe, #a5b4fc); color: #312e81; }

.page-desc { margin: 0; color: var(--muted); font-size: 12.5px; }
.page-head { align-items: center; margin-bottom: 18px; }

.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 9px; border-radius: 999px;
  background: #f1f5f9; color: #64748b; font-size: 10.5px; font-weight: 600;
  border: 1px solid var(--line); white-space: nowrap;
}
.live-badge span { width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; }
.live-badge.live { background: var(--emerald-soft); color: #047857; border-color: #bbf7d0; }
.live-badge.live span { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.14); }

/* ---------------------------------------------------------------- auth */
.auth-screen {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.28), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.18), transparent 45%),
    #0b1220;
  padding: 24px;
}
.auth-card {
  width: min(400px, 100%); background: #fff; border-radius: 20px;
  padding: 28px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.35);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 34px; height: 34px; }
.auth-brand strong { display: block; font-size: 17px; letter-spacing: 0.2px; }
.auth-brand small { display: block; color: var(--muted); font-size: 10.5px; }
.auth-card h2 { margin: 0 0 4px; font-size: 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card .field > span { font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.auth-card .input { width: 100%; }
.auth-error {
  margin-top: 12px; padding: 8px 10px; border-radius: 8px;
  background: var(--rose-soft); color: #be123c; font-size: 11.5px;
}
.auth-hint {
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-2);
  color: var(--muted); font-size: 10.5px; text-align: center;
}
.auth-hint code { font-family: var(--mono); background: #f1f5f9; padding: 1px 4px; border-radius: 4px; }

.auth-divider {
  margin: 14px 0 10px; display: flex; align-items: center; gap: 10px;
  color: var(--muted-2); font-size: 10.5px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line-2);
}

.bell-count {
  position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px;
  padding: 0 4px; border-radius: 8px; background: #f43f5e; color: #fff;
  font-size: 9px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 0 0 2px #fff;
}
