/* ============================================================
   ShortLink console — Apple HIG-inspired design system
   Light & dark · responsive · vanilla CSS, no dependencies
   ============================================================ */

:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'PingFang SC',
    'Helvetica Neue', 'Segoe UI', 'Noto Sans', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --card-translucent: rgba(255, 255, 255, 0.78);
  --sidebar: rgba(245, 245, 247, 0.82);
  --text: #1d1d1f;
  --text-2: #515154;
  --muted: #86868b;
  --hairline: rgba(0, 0, 0, 0.09);
  --hairline-strong: rgba(0, 0, 0, 0.16);
  --fill: rgba(120, 120, 128, 0.1);
  --fill-2: rgba(120, 120, 128, 0.16);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --on-accent: #ffffff;
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --gray-badge: #8e8e93;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.12);
  --shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.24);
  --chart-bar: #0071e3;
  --chart-grid: rgba(0, 0, 0, 0.06);
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;
  --radius-xl: 22px;
  --focus-ring: 0 0 0 3.5px rgba(0, 113, 227, 0.32);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #101012;
  --bg-elevated: #1c1c1e;
  --card: #1c1c1e;
  --card-translucent: rgba(28, 28, 30, 0.78);
  --sidebar: rgba(16, 16, 18, 0.82);
  --text: #f5f5f7;
  --text-2: #c7c7cc;
  --muted: #98989d;
  --hairline: rgba(255, 255, 255, 0.11);
  --hairline-strong: rgba(255, 255, 255, 0.2);
  --fill: rgba(120, 120, 128, 0.22);
  --fill-2: rgba(120, 120, 128, 0.3);
  --accent: #0a84ff;
  --accent-hover: #3395ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --green-soft: rgba(48, 209, 88, 0.16);
  --green: #30d158;
  --orange: #ff9f0a;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.6);
  --chart-bar: #0a84ff;
  --chart-grid: rgba(255, 255, 255, 0.07);
  --focus-ring: 0 0 0 3.5px rgba(10, 132, 255, 0.4);
  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

::selection { background: var(--accent-soft); }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus-ring); border-radius: var(--radius-s); }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--fill-2); border-radius: 99px; border: 2.5px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- boot splash ---------------- */

.boot-splash {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
}
.boot-mark {
  width: 56px; height: 56px; border-radius: 15px;
  background: linear-gradient(180deg, #2f9bff, #0a63e8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  animation: bootPulse 1.2s ease-in-out infinite;
}
.boot-mark svg { width: 32px; height: 32px; }
@keyframes bootPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.92); opacity: 0.75; } }

/* ---------------- auth screens ---------------- */

.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(10, 132, 255, 0.16), transparent 60%),
    radial-gradient(800px 500px at 95% 108%, rgba(88, 86, 214, 0.13), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--card-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
  padding: 36px 32px 30px;
  text-align: center;
}
.auth-appicon {
  width: 72px; height: 72px; border-radius: 19px; margin: 0 auto 16px;
  background: linear-gradient(180deg, #2f9bff, #0a63e8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 28px rgba(10, 100, 230, 0.35);
}
.auth-appicon svg { width: 40px; height: 40px; }
.auth-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 4px 0 24px; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px; margin: 18px 0;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--hairline);
}

/* ---------------- forms ---------------- */

.field { text-align: left; margin-bottom: 14px; }
.field > label {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; padding-left: 2px;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--fill);
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  padding: 10px 14px;
  font-size: 15px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
.textarea { min-height: 74px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; background: var(--bg-elevated);
  border-color: var(--accent); box-shadow: var(--focus-ring);
}
.input.mono { font-family: var(--mono); font-size: 14px; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; cursor: pointer;
}
.field-hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; padding-left: 2px; }
.field-error { font-size: 12.5px; color: var(--red); margin-top: 5px; padding-left: 2px; }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn .input { flex: 1; }

.search-box { position: relative; }
.search-box .input { padding-left: 36px; }
.search-box > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}

/* segmented control */
.seg {
  display: inline-flex; background: var(--fill-2);
  border-radius: 9px; padding: 2px; gap: 2px;
}
.seg button {
  border: none; background: transparent; cursor: pointer;
  padding: 5px 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
  color: var(--text-2); white-space: nowrap;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg button.on {
  background: var(--card); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}
:root[data-theme='dark'] .seg button.on { background: #636366; }

/* switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; z-index: 1; margin: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--fill-2); transition: background 0.2s;
}
.switch i::after {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  top: 2px; left: 2px; background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: var(--focus-ring); }

/* checkbox rows */
.check-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-m); cursor: pointer; user-select: none;
  border: 1px solid var(--hairline);
  transition: background 0.15s;
}
.check-row:hover { background: var(--fill); }
.check-row input {
  width: 18px; height: 18px; accent-color: var(--accent);
  cursor: pointer; flex: none;
}

/* color input */
.color-input {
  width: 44px; height: 32px; padding: 2px; border: 1px solid var(--hairline);
  border-radius: 8px; background: var(--fill); cursor: pointer;
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; cursor: pointer; border-radius: var(--radius-m);
  font-weight: 600; font-size: 14.5px; line-height: 1;
  padding: 0 18px; height: 40px;
  transition: transform 0.12s, filter 0.15s, background 0.15s;
  text-decoration: none !important; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:hover { background: var(--fill-2); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-danger-soft:hover { background: var(--red); color: #fff; }
.btn-lg { height: 48px; font-size: 16px; border-radius: 13px; padding: 0 24px; }
.btn-sm { height: 32px; font-size: 13px; padding: 0 12px; border-radius: var(--radius-s); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn .spin { width: 15px; height: 15px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-s);
  border: none; background: transparent; color: var(--text-2);
  cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.12s;
  flex: none;
}
.icon-btn:hover { background: var(--fill); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------------- app layout ---------------- */

.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 242px; flex: none;
  background: var(--sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 18px;
}
.sidebar-brand .mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(180deg, #2f9bff, #0a63e8);
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .mark svg { width: 22px; height: 22px; }
.sidebar-brand .name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.sidebar-brand .name small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.nav-section { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8.5px 10px; border-radius: var(--radius-m);
  color: var(--text-2); font-weight: 500; font-size: 14.5px;
  cursor: pointer; transition: background 0.14s, color 0.14s;
  margin-bottom: 1px;
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--fill); color: var(--text); text-decoration: none; }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item.on svg { opacity: 1; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-m); cursor: pointer; transition: background 0.14s;
}
.user-chip:hover { background: var(--fill); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #5e5ce6, #0a84ff);
  color: #fff; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-chip .who { min-width: 0; flex: 1; }
.user-chip .who b { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .who span { display: block; font-size: 11.5px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  background: var(--card-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
  padding-top: max(14px, env(safe-area-inset-top));
}
.topbar h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }

.content {
  width: 100%; max-width: 1160px;
  margin: 0 auto; padding: 26px 28px 60px;
  flex: 1;
}

/* ---------------- cards & lists ---------------- */

.card {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
}
.card + .card, .card + .card-grid, .card-grid + .card { margin-top: 18px; }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .right { margin-left: auto; font-weight: 400; font-size: 13px; color: var(--muted); }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius-l); box-shadow: var(--shadow-1);
  padding: 16px 18px 14px;
}
.stat-tile .label { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-tile .label svg { width: 15px; height: 15px; }
.stat-tile .value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-tile .delta { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* table */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--fill); }
.tbl .num { font-variant-numeric: tabular-nums; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-pill {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  background: var(--fill); border-radius: 7px; padding: 3px 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.link-url { color: var(--text); font-weight: 500; }
.link-url:hover { color: var(--accent); text-decoration: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2.5px 9px;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--fill); color: var(--muted); }

.row-actions { display: flex; gap: 2px; justify-content: flex-end; }

/* empty state */
.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 10px; }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 3px; }
.empty .btn { margin-top: 16px; }

/* filter bar */
.filter-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .search-box { flex: 1; min-width: 200px; max-width: 340px; }
.filter-bar .select { width: auto; }

/* pagination */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; font-size: 13px; color: var(--muted);
}
.pager .pages { display: flex; gap: 6px; }

/* ---------------- dropdown menus ---------------- */

.menu {
  position: fixed; z-index: 90;
  background: var(--card-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-2);
  padding: 5px; min-width: 190px;
  animation: menuIn 0.13s ease-out;
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.96) translateY(-3px); } to { opacity: 1; transform: none; } }
.menu button, .menu a {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 11px; border: none; background: none; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; color: var(--text);
  text-align: left; text-decoration: none;
}
.menu button svg, .menu a svg { width: 16px; height: 16px; color: var(--text-2); }
.menu button:hover, .menu a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.menu button:hover svg, .menu a:hover svg { color: var(--accent); }
.menu button.danger, .menu a.danger { color: var(--red); }
.menu button.danger svg, .menu a.danger svg { color: var(--red); }
.menu button.danger:hover, .menu a.danger:hover { background: var(--red-soft); color: var(--red); }
.menu .menu-sep { height: 1px; background: var(--hairline); margin: 5px 8px; }

/* ---------------- modals ---------------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  animation: fadeIn 0.16s ease-out;
}
:root[data-theme='dark'] .modal-overlay { background: rgba(0, 0, 0, 0.55); }
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 60px); max-height: calc(100dvh - 60px);
  display: flex; flex-direction: column;
  animation: modalIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px 0;
}
.modal-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; flex: 1; margin: 0; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}

.modal.wide { max-width: 760px; }

/* ---------------- toasts ---------------- */

.toast-zone {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 40px);
  padding-bottom: env(safe-area-inset-bottom);
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: var(--card-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--hairline);
  border-radius: 99px; box-shadow: var(--shadow-2);
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok svg { color: var(--green); }
.toast.err svg { color: var(--red); }
.toast.gone { animation: toastOut 0.25s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------------- charts ---------------- */

.chart { position: relative; }
.chart-plot {
  display: flex; align-items: flex-end; gap: 5px;
  height: 168px; position: relative;
  border-bottom: 1px solid var(--hairline-strong);
}
.chart-gridline {
  position: absolute; left: 0; right: 0; height: 1px;
  background: var(--chart-grid); pointer-events: none;
}
.bar-col {
  flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  height: 100%; position: relative; cursor: default;
  border-radius: 4px;
}
.bar {
  width: 100%; max-width: 34px; margin: 0 auto;
  background: var(--chart-bar);
  border-radius: 4px 4px 0 0;
  min-height: 0;
  opacity: 0.92;
  transition: opacity 0.15s, filter 0.15s;
}
.bar-col:hover .bar { opacity: 1; filter: brightness(1.08); }
.bar-col.zero .bar { min-height: 3px; background: var(--fill-2); opacity: 1; }
.chart-x {
  display: flex; gap: 5px; margin-top: 7px;
}
.chart-x span {
  flex: 1; text-align: center; font-size: 10.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-tip {
  position: fixed; z-index: 110; pointer-events: none;
  background: var(--card-translucent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline);
  border-radius: 10px; box-shadow: var(--shadow-2);
  padding: 7px 11px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tip b { font-variant-numeric: tabular-nums; }

/* top links / recent list */
.hlist { display: flex; flex-direction: column; }
.hlist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--hairline);
}
.hlist-item:last-child { border-bottom: none; }
.hlist-item .grow { flex: 1; min-width: 0; }
.hlist-item .t1 { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hlist-item .t2 { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hlist-item .metric { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.hlist-item .metric small { font-weight: 500; color: var(--muted); font-size: 11px; }

/* ---------------- misc ---------------- */

.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--fill-2); border-top-color: var(--accent);
  animation: rot 0.7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.skeleton {
  border-radius: var(--radius-s);
  background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 50%, var(--fill) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  height: 16px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.divider { height: 1px; background: var(--hairline); margin: 16px 0; border: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius-m); padding: 12px 14px; font-size: 13.5px;
  background: var(--accent-soft); color: var(--text);
}
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--accent); }
.alert.warn { background: var(--orange-soft); }
.alert.warn svg { color: var(--orange); }

.crumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--muted); text-transform: uppercase;
  margin: 20px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.perm-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }

.scope-list { display: flex; flex-direction: column; gap: 8px; }

.key-reveal {
  font-family: var(--mono); font-size: 14px;
  background: var(--fill); border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-m); padding: 14px;
  word-break: break-all; user-select: all;
}

/* ---------------- responsive ---------------- */

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 39;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.18s;
}

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-104%);
    transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: none; height: 100dvh;
    background: var(--bg-elevated);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .sidebar.open { transform: none; box-shadow: var(--shadow-modal); }
  .sidebar-backdrop.show { display: block; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 48px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-tile { padding: 13px 14px 11px; }
  .stat-tile .value { font-size: 24px; }

  /* tables become stacked cards */
  .tbl-wrap { overflow: visible; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { display: none; }
  .tbl tr {
    border: 1px solid var(--hairline); border-radius: var(--radius-l);
    padding: 6px 4px; margin-bottom: 10px; background: var(--card);
  }
  .tbl tbody tr:hover { background: var(--card); }
  .tbl td { border: none; padding: 7px 12px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
  .tbl td::before {
    content: attr(data-th); color: var(--muted); font-size: 12px; font-weight: 600;
    flex: none;
  }
  .tbl td.clean::before { display: none; }
  .tbl td .truncate { max-width: 52vw; }
  .row-actions { justify-content: flex-start; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92dvh; animation: sheetIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head { padding-top: 14px; position: relative; }
  .modal-head::before {
    content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4.5px; border-radius: 99px; background: var(--fill-2);
  }
  @keyframes sheetIn { from { transform: translateY(60px); opacity: 0.6; } to { transform: none; opacity: 1; } }
  .filter-bar .search-box { max-width: none; }
  .filter-bar { gap: 8px; }
  .filter-bar .select { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* print */
@media print {
  .sidebar, .topbar, .toast-zone, .row-actions, .filter-bar, .pager { display: none !important; }
}
