/* VPN Hub panel */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e3e5e9;
  --border-strong: #d0d4da;
  --text: #1f2329;
  --text-2: #3d434b;
  --muted: #6b717a;
  --faint: #9aa0a8;
  --primary: #1c5ad9;
  --primary-hover: #1449b8;
  --primary-soft: #e8effc;
  --primary-softer: #f4f7fe;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --warning: #c77700;
  --warning-soft: #fff4e0;
  --neutral-soft: #eef0f3;
  --rx: #1c5ad9;
  --tx: #7cb3f5;
  --table-head: #f9fafb;
  --row-hover: #fafbfc;
  --code-bg: #f6f8fa;
  --btn-disabled-bg: #e9ebee;
  --btn-disabled-fg: #9aa0a8;
  --switch-off: #cdd2d9;
  --warn-border: #f0b44c;
  --warn-fg: #7a4a00;
  --err-border: #f1a7a1;
  --err-fg: #9c1c13;
  --ok-border: #a6dcb7;
  --ok-fg: #11632f;
  --disc-bg: #fff1ef;
  --disc-fg: #c2410c;
  --danger-hover: #b9271d;
  --tip-bg: #1f2329;
  --tip-fg: #ffffff;
  --overlay: rgba(17, 24, 39, .42);
  --overlay-soft: rgba(17, 24, 39, .3);
  --focus-ring: rgba(28, 90, 217, .12);
  --hover-col: rgba(28, 90, 217, .06);
  --spinner-track: rgba(28, 90, 217, .2);
  --radius: 4px;
  --shadow: 0 8px 28px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --sidebar-w: 288px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

/* dark theme: set on <html data-theme="dark"> (automatic from the OS, or chosen in the user menu) */
:root[data-theme="dark"] {
  --bg: #0f1216;
  --surface: #171b21;
  --border: #2a3039;
  --border-strong: #3a414c;
  --text: #e8ebef;
  --text-2: #c4c9d0;
  --muted: #8d95a0;
  --faint: #646c77;
  --primary: #4f86ee;
  --primary-hover: #6a99f1;
  --primary-soft: #1c2a45;
  --primary-softer: #1a2130;
  --success: #43bf72;
  --success-soft: #16291e;
  --danger: #f0665c;
  --danger-soft: #3a1d1b;
  --warning: #e3a644;
  --warning-soft: #33280f;
  --neutral-soft: #242a32;
  --rx: #4f86ee;
  --tx: #9fc2f8;
  --table-head: #1c2128;
  --row-hover: #1b2027;
  --code-bg: #11151a;
  --btn-disabled-bg: #232930;
  --btn-disabled-fg: #6a727d;
  --switch-off: #3a414c;
  --warn-border: #7a5a1c;
  --warn-fg: #f2c879;
  --err-border: #7c302b;
  --err-fg: #f6a49d;
  --ok-border: #2d6b45;
  --ok-fg: #92ddad;
  --disc-bg: #3a2318;
  --disc-fg: #f5a06e;
  --danger-hover: #d9534a;
  --tip-bg: #2a3039;
  --tip-fg: #e8ebef;
  --overlay: rgba(0, 0, 0, .62);
  --overlay-soft: rgba(0, 0, 0, .5);
  --focus-ring: rgba(79, 134, 238, .28);
  --hover-col: rgba(79, 134, 238, .1);
  --spinner-track: rgba(79, 134, 238, .25);
  --shadow: 0 10px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45;
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }
.mono { font-variant-numeric: tabular-nums; }
code, .code-font { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
  transition: width .18s ease;
}
.sidebar .brand {
  height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 24px;
  border-bottom: 1px solid var(--border); font-weight: 650; font-size: 17px; color: var(--text);
  white-space: nowrap; overflow: hidden;
}
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: #fff;
  display: grid; place-items: center; flex: none; }
.brand-mark svg.i { width: 18px; height: 18px; stroke-width: 2; }
.nav { flex: 1; overflow-y: auto; padding: 16px 0; }
.nav-group { margin-bottom: 0 !important; }
.nav-group { margin-bottom: 4px; }
.nav-head {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 0 24px; height: 64px;
  background: none; border: 0; cursor: pointer; color: var(--text-2); font-size: 16px; text-align: left;
  white-space: nowrap;
}
.nav-head:hover { color: var(--text); background: var(--primary-softer); }
.nav-head .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-head .chev { color: var(--text-2); transition: transform .15s; }
.nav-group.open .nav-head .chev { transform: rotate(180deg); }
.nav-group.active .nav-head, .nav-group.active .nav-head .chev { color: var(--primary); }
.nav-items { display: none; margin: 4px 0 12px 38px; border-left: 2px solid var(--border); }
.nav-group.open .nav-items { display: block; }
.nav-items a {
  display: block; padding: 9px 18px 9px 25px; margin-left: -2px; border-left: 2px solid transparent;
  color: var(--text-2); font-size: 16px; white-space: nowrap;
}
.nav-items a:hover { color: var(--text); text-decoration: none; }
.nav-items a.active { color: var(--primary); border-left-color: var(--primary); }
.sidebar-foot { border-top: 1px solid var(--border); height: 64px; display: flex; align-items: center; padding: 0 18px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid transparent; background: none; cursor: pointer; color: var(--text-2); position: relative;
}
.icon-btn:hover { background: var(--neutral-soft); color: var(--text); }
.icon-btn.bordered { border-color: var(--border); background: var(--surface); }
.app.collapsed .sidebar { width: 72px; }
.app.collapsed .sidebar .brand span, .app.collapsed .nav-head .label, .app.collapsed .nav-head .chev,
.app.collapsed .nav-items { display: none !important; }
.app.collapsed .nav-head { justify-content: center; padding: 0; }
.app.collapsed .sidebar .brand { padding: 0; justify-content: center; }
.app.collapsed .sidebar-foot svg { transform: rotate(180deg); }
.app.collapsed .sidebar-foot { justify-content: center; padding: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 40px 0 32px;
}
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--text-2); min-width: 0; flex: 1; }
.crumbs a { color: var(--text-2); white-space: nowrap; }
.crumbs .sep { color: var(--muted); }
.crumbs .sep svg.i { width: 16px; height: 16px; }
.crumbs .current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.search-btn {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 9px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; color: var(--text-2);
}
.search-btn:hover { border-color: var(--border-strong); }
.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border: 1px solid var(--border);
  border-radius: 4px; color: var(--primary); font-size: 12px; font-weight: 600; background: var(--surface); }
.badge-dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.user-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; cursor: pointer; padding: 4px; color: var(--text-2); }
.user-btn .name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; color: var(--text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex: none; background: #3b1d6e; }
.avatar svg { width: 100%; height: 100%; display: block; }
.menu-toggle { display: none; }

.content { padding: 0 40px 48px 32px; width: 100%; }

/* ---------------------------------------------------------------- tabs */
.tabrow { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 16px; }
.tabs {
  display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; flex: 1 0 auto; max-width: 100%; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 0 24px; height: 38px; display: flex; align-items: center; color: var(--text-2); font-size: 16px;
  white-space: nowrap; border-right: 0;
}
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--primary-softer); }
.tabs a.active { background: var(--primary-soft); color: var(--primary); }
.tablinks { display: flex; align-items: center; gap: 28px; flex: none; margin-left: auto; }
.link-btn { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--primary); font-size: 14.5px; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- cards */
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 20px; min-width: 0; }

.stack > * + * { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 8px; min-height: 36px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -.01em; flex: 1; min-width: 0; color: var(--text); }
.card-head h3 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; }
.card-head .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.card-sub { margin: -8px 0 16px; color: var(--muted); font-size: 14px; max-width: 760px; }
.help-dot { color: var(--text-2); display: inline-grid; place-items: center; cursor: help; position: relative; }
.help-dot svg.i { width: 20px; height: 20px; }

/* key / value */
.kv { margin: 0 0 0 0; }
.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 8px;
  border-bottom: 1px solid var(--border); min-height: 37px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { color: var(--text-2); font-size: 14.5px; }
.kv-row dd { margin: 0; text-align: right; color: var(--text-2); font-size: 14.5px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kv-row dd .val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--text-2); display: inline-grid; place-items: center; }
.copy:hover { color: var(--primary); }
.copy svg.i { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--primary);
  font-size: 14.5px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-softer); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn:disabled { background: var(--btn-disabled-bg); border-color: var(--btn-disabled-bg); color: var(--btn-disabled-fg); cursor: not-allowed; }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13.5px; }
.btn.lg { height: 38px; padding: 0 18px; font-size: 15px; }
.btn .spinner { width: 14px; height: 14px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; color: var(--text-2); }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--border-strong); z-index: 1; }

/* ---------------------------------------------------------------- forms */
.input, select.input, textarea.input {
  width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); outline: none; font-size: 14.5px;
}
textarea.input { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
.input:disabled { background: var(--neutral-soft); color: var(--muted); }
.search { position: relative; margin-bottom: 16px; }
.search svg.i { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 15px; height: 15px; }
.search .input { padding-left: 26px; height: 30px; font-size: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { margin: 0; flex: 1; min-width: 200px; }
.toolbar select.input { width: auto; height: 30px; font-size: 14px; }
.field { margin-bottom: 16px; }
.field label, .field .label { display: block; font-size: 13.5px; font-weight: 550; color: var(--text-2); margin-bottom: 6px; }
.hint, .field .hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.field label.switch { display: flex; font-weight: 400; font-size: 14.5px; margin-bottom: 0; color: var(--text-2); }
.field .req { color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0 16px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14.5px; color: var(--text-2); }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--switch-off); position: relative;
  cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); }
.form-error { margin-bottom: 14px; }
.form-error:not(.show) { display: none !important; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 0; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }

/* ---------------------------------------------------------------- alerts */
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--primary); border-radius: var(--radius);
  background: var(--surface); color: var(--primary); font-size: 14.5px;
}
.alert svg.i { margin-top: 1px; }
.alert .grow { flex: 1; }
.alert.warn { border-color: var(--warn-border); background: var(--warning-soft); color: var(--warn-fg); }
.alert.error { border-color: var(--err-border); background: var(--danger-soft); color: var(--err-fg); }
.alert.success { border-color: var(--ok-border); background: var(--success-soft); color: var(--ok-fg); }
.alert.compact { padding: 10px 12px; font-size: 13.5px; }
.alert .btn { margin-left: auto; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--text-2); background: var(--table-head); padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13.5px; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: var(--row-hover); }
table.t td.actions { width: 1%; white-space: nowrap; text-align: right; }
table.t .strong { color: var(--text); font-weight: 550; }
table.t .sub { display: block; font-size: 12.5px; color: var(--muted); }
table.t tr.clickable { cursor: pointer; }
.name-cell { display: flex; align-items: center; gap: 10px; }
.name-cell .ico { width: 30px; height: 30px; border-radius: 6px; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; flex: none; }
.name-cell .ico.off { background: var(--neutral-soft); color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 12px; color: var(--muted); font-size: 13.5px; }
.pager select.input { width: auto; height: 28px; font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 3px; background: var(--neutral-soft); color: var(--text-2);
  font-size: 13px; font-variant-numeric: tabular-nums; }

/* status badges */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 13px; font-weight: 550; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.online, .status.running, .status.connect { background: var(--success-soft); color: var(--success); }
.status.offline, .status.stopped { background: var(--neutral-soft); color: var(--muted); }
.status.disabled { background: var(--neutral-soft); color: var(--faint); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.status.starting, .status.stopping, .status.pending { background: var(--warning-soft); color: var(--warning); }
.status.disconnect { background: var(--disc-bg); color: var(--disc-fg); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.gray { background: var(--neutral-soft); color: var(--muted); }

/* stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.01em; color: var(--text); }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.legend-sq { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.minibar { height: 6px; background: var(--neutral-soft); border-radius: 3px; overflow: hidden; min-width: 80px; }
.minibar span { display: block; height: 100%; background: var(--primary); }

/* chart */
.chart { width: 100%; height: 280px; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .bar-rx { fill: var(--rx); }
.chart .bar-tx { fill: var(--tx); }
.chart .hover-col { fill: transparent; }
.chart .hover-col:hover { fill: var(--hover-col); }
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip { position: fixed; pointer-events: none; background: var(--tip-bg); color: var(--tip-fg); font-size: 12.5px; padding: 7px 10px;
  border-radius: 4px; z-index: 200; box-shadow: var(--shadow); white-space: nowrap; }

/* ---------------------------------------------------------------- menus, modals, drawers */
.menu {
  position: fixed; z-index: 120; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow); padding: 6px 0; animation: pop .1s ease-out;
}
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 14px; background: none; border: 0;
  text-align: left; cursor: pointer; color: var(--text-2); font-size: 14px; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--primary-softer); color: var(--text); }
.menu .danger { color: var(--danger); }
.menu .danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu .menu-head { padding: 8px 14px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu .menu-head strong { display: block; color: var(--text); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.notif { width: 380px; max-height: 460px; overflow-y: auto; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.notif-item:hover { background: var(--primary-softer); }
.notif-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.notif-item .when { color: var(--muted); font-size: 12.5px; }
.notif-empty { padding: 28px 14px; text-align: center; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 100; display: flex; align-items: flex-start;
  justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); border-radius: 6px; width: 100%; max-width: 560px; box-shadow: var(--shadow); animation: pop .14s ease-out; }
.modal.wide { max-width: 760px; }
.modal.xwide { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; }
.modal-head h3 { margin: 0; font-size: 19px; font-weight: 600; flex: 1; }
.modal-body { padding: 4px 20px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; }
.modal-body p { margin: 0 0 12px; color: var(--text-2); }
pre.log { background: #11151b; color: #d6dde6; padding: 14px; border-radius: 4px; max-height: 60vh; overflow: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; margin: 0; white-space: pre-wrap; word-break: break-all; }
pre.code { background: var(--code-bg); border: 1px solid var(--border); padding: 10px 12px; border-radius: 4px; font-family: var(--mono);
  font-size: 12.5px; margin: 6px 0 12px; overflow-x: auto; white-space: pre; }

.drawer-overlay { position: fixed; inset: 0; background: var(--overlay-soft); z-index: 100; animation: fade .12s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; background: var(--surface); z-index: 101;
  box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { margin: 0; flex: 1; font-size: 19px; font-weight: 600; }
.drawer-body { padding: 8px 20px 24px; overflow-y: auto; flex: 1; }
.drawer-body h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 6px 8px; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 8px; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 16px 40px; color: var(--text-2); }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: 13px; display: grid; place-items: center; }
.steps > li strong { color: var(--text); }
.subtabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; color: var(--text-2); margin-bottom: -1px; }
.subtabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* palette */
.palette { width: 100%; max-width: 620px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; animation: pop .12s ease-out; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; height: 52px; border: 0; outline: none; font-size: 16px; background: none; }
.palette-results { max-height: 420px; overflow-y: auto; padding: 6px 0; }
.palette-section { padding: 8px 16px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; color: var(--text-2); }
.palette-item.sel, .palette-item:hover { background: var(--primary-soft); color: var(--text); }
.palette-item .meta { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--success); border-radius: 4px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 14px; animation: slide .16s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }

.fab { position: fixed; right: 0; bottom: 48px; width: 40px; height: 46px; background: var(--surface); border: 1px solid var(--border);
  border-right: 0; border-radius: 4px 0 0 4px; display: grid; place-items: center; cursor: pointer; color: var(--text-2); z-index: 20; }
.fab:hover { color: var(--primary); }

.spinner { width: 18px; height: 18px; border: 2px solid var(--spinner-track); border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; }
.btn.primary .spinner { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 48px; display: grid; place-items: center; }
.empty-pad { padding: 4px 0; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 32px 32px 28px; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 19px; margin-bottom: 24px; }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; font-weight: 600; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.auth-card .btn { width: 100%; }

/* activity list */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.activity li:last-child { border-bottom: 0; }
.activity .when { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .app.collapsed .sidebar { width: var(--sidebar-w); }
  .app.collapsed .sidebar .brand span, .app.collapsed .nav-head .label, .app.collapsed .nav-head .chev { display: initial !important; }
  .app.collapsed .nav-group.open .nav-items { display: block !important; }
  .app.collapsed .nav-head { justify-content: flex-start; padding: 0 24px; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 0 16px 40px; }
  .sidebar-foot { display: none; }
  .user-btn .name { display: none; }
}
@media (max-width: 600px) {
  .grid.four { grid-template-columns: 1fr 1fr; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .card-head h2 { font-size: 20px; }
  .search-btn .kbd { display: none; }
  .crumbs a, .crumbs .sep { display: none; }
  .tabs { flex-basis: 100%; }
  .tablinks { margin-left: 0; }
  .tablinks { justify-content: flex-start; gap: 16px; }
  .drawer { width: 100%; }
}

/* ---------------------------------------------------------------- theme extras */
.menu button .check-mark { margin-left: auto; color: var(--primary); }
.menu .menu-label { padding: 6px 14px 2px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.theme-switch { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.theme-switch button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid transparent;
  border-radius: var(--radius); background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { border-color: var(--border); background: var(--surface); color: var(--text); }
:root[data-theme="dark"] pre.log { border: 1px solid var(--border); background: #0b0e12; }
:root[data-theme="dark"] .brand-mark { background: #2f6ae0; }
:root[data-theme="dark"] .btn.primary { background: #2f6ae0; border-color: #2f6ae0; }
:root[data-theme="dark"] .btn.primary:hover:not(:disabled) { background: #3d78ea; border-color: #3d78ea; }
:root[data-theme="dark"] .badge-dot { box-shadow: 0 0 0 2px var(--surface); }
