/* ============================================================
   WEBVAULT — design system
   Tailwind (CDN) handles layout utilities; this file owns the
   visual language, tokens and components so the app renders
   identically with or without the CDN.
   ============================================================ */

:root {
  --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #070a0f;
  --bg-grad-a: #0a1018;
  --bg-grad-b: #06090d;
  --panel: #0e141e;
  --panel-2: #121a26;
  --panel-3: #172130;
  --border: #1e2a3b;
  --border-strong: #2a3a51;
  --text: #e8eef7;
  --text-dim: #a5b6c9;
  --muted: #7189a3;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --accent-ink: #04212b;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --star: #fbbf24;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, .85);
  --radius: 12px;
  --sidebar-w: 272px;
}

html[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-grad-a: #ffffff;
  --bg-grad-b: #eef3f9;
  --panel: #ffffff;
  --panel-2: #f7fafd;
  --panel-3: #eef3f9;
  --border: #dbe4ef;
  --border-strong: #c2d0e0;
  --text: #0d1a29;
  --text-dim: #35475c;
  --muted: #69809a;
  --accent: #0891b2;
  --accent-2: #4f46e5;
  --accent-ink: #ffffff;
  --ok: #059669;
  --warn: #b45309;
  --danger: #dc2626;
  --star: #d97706;
  --shadow: 0 16px 40px -22px rgba(15, 35, 60, .45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 82% -10%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(900px 520px at 8% 0%, rgba(34, 211, 238, .12), transparent 62%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
  background-attachment: fixed;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: rgba(34, 211, 238, .3); }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3d5372; background-clip: content-box; }

/* ---------- app frame ---------- */
#app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
#app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }

/* ---------- sidebar ---------- */
#sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 22%), var(--panel);
  overflow: hidden;
}
#sidebar > .side-scroll { overflow-y: auto; flex: 1; min-height: 0; padding: 0 14px 18px; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #04121a;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.5px;
  box-shadow: 0 6px 18px -8px rgba(34, 211, 238, .9);
  flex: none;
}
.brand-name { font-weight: 700; letter-spacing: .14em; font-size: 13px; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }

.side-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted);
  padding: 18px 4px 8px;
}
.side-head .count-pill {
  font-size: 10px; letter-spacing: 0; padding: 1px 6px; border-radius: 6px;
  background: var(--panel-3); color: var(--text-dim); border: 1px solid var(--border);
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  background: none;
  text-align: left;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item[aria-pressed="true"] {
  background: linear-gradient(90deg, rgba(34, 211, 238, .16), rgba(99, 102, 241, .1));
  border-color: rgba(34, 211, 238, .35);
  color: var(--text);
}
.nav-item .nav-ico { width: 16px; text-align: center; opacity: .9; flex: none; }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-count {
  font-size: 10.5px; font-variant-numeric: tabular-nums;
  color: var(--muted); background: var(--panel-3);
  border-radius: 6px; padding: 1px 6px; flex: none;
}
.nav-item[aria-pressed="true"] .nav-count { color: var(--text); background: rgba(34, 211, 238, .18); }
.nav-item.dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px; flex: none;
  background: var(--cat-color, var(--border-strong));
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 6px; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: pointer;
  transition: all .12s ease;
  max-width: 100%;
}
.tag-pill:hover { border-color: var(--border-strong); color: var(--text); }
.tag-pill[aria-pressed="true"] {
  background: rgba(34, 211, 238, .16);
  border-color: rgba(34, 211, 238, .55);
  color: var(--text);
}
.tag-pill .tag-n { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel);
}
.storage-meter { height: 3px; border-radius: 99px; background: var(--panel-3); overflow: hidden; margin-top: 5px; }
.storage-meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- main ---------- */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(14px);
  z-index: 20;
}

.search-wrap { position: relative; flex: 1; min-width: 0; max-width: 720px; }
.search-wrap .search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; display: grid; place-items: center;
}
#search {
  width: 100%;
  height: 38px;
  padding: 0 92px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
#search::placeholder { color: var(--muted); }
#search:focus {
  border-color: rgba(34, 211, 238, .6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .12);
  background: var(--panel);
}
.search-meta {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
#search.clearable ~ .search-meta { pointer-events: auto; }
.search-clear {
  pointer-events: auto;
  width: 20px; height: 20px; border-radius: 6px; border: 0;
  background: var(--panel-3); color: var(--text-dim);
  display: none; place-items: center; cursor: pointer;
}
.search-clear:hover { color: var(--text); background: var(--border-strong); }
.search-wrap.has-value .search-clear { display: grid; }

.speed-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 5px;
  background: rgba(52, 211, 153, .12); color: var(--ok);
  border: 1px solid rgba(52, 211, 153, .25);
  opacity: 0; transition: opacity .25s ease;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.speed-badge.show { opacity: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease, color .12s ease;
}
.btn:hover { background: var(--panel-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 8px 20px -12px rgba(34, 211, 238, .9);
}
.btn-primary:hover { filter: brightness(1.07); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .1); }
.btn-danger:hover { background: rgba(248, 113, 113, .18); border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: var(--border); }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all .12s ease;
  flex: none;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); border-color: var(--border); }
.icon-btn.on { color: var(--star); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* segmented control */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 7px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--panel-3); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* select */
.select {
  height: 34px; padding: 0 30px 0 10px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237189a3' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600;
  appearance: none; cursor: pointer; outline: none;
}
.select:focus { border-color: rgba(34, 211, 238, .6); box-shadow: 0 0 0 3px rgba(34, 211, 238, .1); }

/* ---------- filter chips row ---------- */
#filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 55%, transparent);
  min-height: 44px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 6px 3px 9px;
  border-radius: 99px;
  background: rgba(34, 211, 238, .13);
  border: 1px solid rgba(34, 211, 238, .32);
  color: var(--text);
  max-width: 320px;
}
.chip .chip-x {
  width: 15px; height: 15px; border-radius: 99px; border: 0;
  background: rgba(255, 255, 255, .1); color: inherit;
  display: grid; place-items: center; cursor: pointer; font-size: 11px; line-height: 1;
}
.chip .chip-x:hover { background: rgba(255, 255, 255, .22); }
.chip b { font-weight: 700; opacity: .65; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.result-count { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.result-count b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- content area ---------- */
#content { flex: 1; min-height: 0; overflow: auto; position: relative; }
#content-inner { padding: 0; }

/* table view */
.table-wrap { width: 100%; }
table.vtable { width: 100%; border-collapse: separate; border-spacing: 0; }
table.vtable thead th {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(8px);
  text-align: left;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
table.vtable thead th.sortable { cursor: pointer; }
table.vtable thead th.sortable:hover { color: var(--text); }
table.vtable thead th .sort-ind { opacity: .45; margin-left: 4px; font-size: 9px; }
table.vtable thead th.sorted { color: var(--accent); }
table.vtable thead th.sorted .sort-ind { opacity: 1; }
table.vtable tbody tr {
  cursor: pointer;
  transition: background .1s ease;
}
table.vtable tbody tr:hover { background: var(--panel-2); }
table.vtable tbody tr.selected { background: rgba(34, 211, 238, .09); }
table.vtable tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  vertical-align: middle;
  font-size: 12.8px;
}
table.vtable tbody tr:last-child td { border-bottom: 0; }
.cell-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-title .t-main { min-width: 0; }
.cell-title .t-name {
  font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 420px;
}
.cell-title .t-host {
  font-size: 10.8px; color: var(--muted); font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px;
}
.fav {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: var(--panel-3);
  object-fit: contain;
  padding: 2px;
  border: 1px solid var(--border);
}
.fav-fallback {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #04121a;
  background: linear-gradient(135deg, hsl(var(--h, 190) 80% 62%), hsl(calc(var(--h, 190) + 45) 75% 55%));
  border: 1px solid rgba(255, 255, 255, .18);
}
.row-tags { display: flex; gap: 4px; flex-wrap: wrap; max-width: 260px; }
.mini-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 5px;
  background: var(--panel-3); color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
td.col-cat, td.col-updated { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .42; transition: opacity .12s ease; }
tr:hover .row-actions, tr.selected .row-actions { opacity: 1; }

/* status */
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.status-dot i { width: 7px; height: 7px; border-radius: 99px; display: inline-block; }
.st-active { color: var(--ok); }
.st-active i { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.st-archived { color: var(--muted); }
.st-archived i { background: var(--muted); }
.st-favorite { color: var(--star); }
.st-favorite i { background: var(--star); box-shadow: 0 0 0 3px rgba(251, 191, 36, .16); }

/* checkbox */
.cbx {
  appearance: none; width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid var(--border-strong); background: var(--panel);
  cursor: pointer; display: inline-grid; place-content: center; flex: none;
  transition: all .1s ease;
}
.cbx:hover { border-color: var(--accent); }
.cbx:checked { background: var(--accent); border-color: var(--accent); }
.cbx:checked::after {
  content: ""; width: 8px; height: 4.5px;
  border-left: 2px solid #04121a; border-bottom: 2px solid #04121a;
  transform: rotate(-45deg) translateY(-1px);
}
.cbx:indeterminate { background: var(--accent); border-color: var(--accent); }
.cbx:indeterminate::after { content: ""; width: 8px; height: 2px; background: #04121a; }

/* card grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px 18px 8px;
}
.vcard {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px 13px 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, .028), transparent 40%), var(--panel);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
  min-height: 168px;
}
.vcard:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}
.vcard.selected { border-color: rgba(34, 211, 238, .6); box-shadow: 0 0 0 1px rgba(34, 211, 238, .35); }
.vcard-top { display: flex; align-items: flex-start; gap: 9px; }
.vcard-title { font-weight: 650; font-size: 13.5px; line-height: 1.3; flex: 1; min-width: 0; }
.vcard-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 36px;
}
.vcard-url {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vcard-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 6px;
  padding-top: 9px;
  border-top: 1px dashed var(--border);
}
.vcard-cat {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim);
  padding: 2px 7px; border-radius: 5px;
  background: var(--panel-3); border: 1px solid var(--border);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vcard[data-status="favorite"] { border-color: rgba(251, 191, 36, .3); }
.vcard[data-status="archived"] { opacity: .78; }
.vcard-actions { margin-left: auto; display: flex; gap: 1px; }

/* ---------- pagination ---------- */
#pagination {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 18px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(10px);
  min-height: 46px;
}
.page-range { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-range b { color: var(--text); }
.pager { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.pg {
  min-width: 28px; height: 28px; padding: 0 7px;
  border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--text-dim); font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.pg:hover { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.pg[aria-current="true"] { background: rgba(34, 211, 238, .16); border-color: rgba(34, 211, 238, .45); color: var(--text); }
.pg[disabled] { opacity: .35; cursor: not-allowed; }
.pg-gap { color: var(--muted); padding: 0 2px; font-size: 12px; }
#jump { width: 52px; height: 28px; padding: 0 6px; text-align: center; font-size: 12px; }

/* ---------- empty / skeleton ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 70px 20px; text-align: center; color: var(--muted);
}
.empty-ico {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--accent);
}
.empty h3 { margin: 0; font-size: 15px; color: var(--text); font-weight: 650; }
.empty p { margin: 0; font-size: 12.8px; max-width: 380px; line-height: 1.6; }

/* ---------- drawer (add / edit) ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 7, 12, .62);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

#drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(520px, 100vw);
  display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -30px 0 70px -30px rgba(0, 0, 0, .85);
  transform: translateX(102%);
  transition: transform .22s cubic-bezier(.32, .72, .28, 1);
  visibility: hidden;
}
#drawer.open { transform: none; visibility: visible; }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel-2);
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.field .hint { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
.input, .textarea {
  width: 100%;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-size: 13px;
  padding: 9px 11px; outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input:focus, .textarea:focus {
  border-color: rgba(34, 211, 238, .6);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .12);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.input.err { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, .14); }
.field-error { font-size: 11.5px; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }

.url-row { display: flex; gap: 7px; align-items: stretch; }
.url-row .input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; }

.tag-editor {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  padding: 6px 7px; min-height: 40px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--panel-2);
  cursor: text;
}
.tag-editor:focus-within { border-color: rgba(34, 211, 238, .6); box-shadow: 0 0 0 3px rgba(34, 211, 238, .12); }
.tag-editor input {
  flex: 1; min-width: 90px; border: 0; background: transparent; outline: none;
  color: var(--text); font: inherit; font-size: 12.5px; padding: 3px 2px;
}
.tag-editor .chip { padding-right: 4px; }
.suggest-row { display: flex; flex-wrap: wrap; gap: 5px; }
.sugg {
  font-size: 11px; padding: 2px 7px; border-radius: 99px;
  border: 1px dashed var(--border-strong); background: transparent; color: var(--muted);
  cursor: pointer;
}
.sugg:hover { color: var(--text); border-color: var(--accent); border-style: solid; }

.preview-card {
  display: flex; gap: 10px; align-items: center;
  padding: 10px; border-radius: 10px;
  border: 1px dashed var(--border-strong); background: var(--panel-2);
}
.preview-card .p-name { font-weight: 600; font-size: 13px; }
.preview-card .p-url { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); word-break: break-all; }

/* ---------- modal (import / confirm) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(3, 7, 12, .66);
  backdrop-filter: blur(3px);
  visibility: hidden; opacity: 0;
  transition: opacity .16s ease, visibility .16s;
}
.modal.open { visibility: visible; opacity: 1; }
.modal-box {
  width: min(520px, 100%);
  max-height: min(86vh, 720px);
  display: flex; flex-direction: column;
  border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--panel); box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--panel-2); }

.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 11px;
  padding: 22px 16px; text-align: center; cursor: pointer;
  transition: all .14s ease; background: var(--panel-2);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent); background: rgba(34, 211, 238, .07);
}
.dropzone strong { display: block; font-size: 13px; margin-bottom: 3px; }
.dropzone span { font-size: 11.5px; color: var(--muted); }

.radio-row { display: flex; flex-direction: column; gap: 7px; }
.radio-opt {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-2); cursor: pointer;
}
.radio-opt:hover { border-color: var(--border-strong); }
.radio-opt input { margin-top: 2px; accent-color: var(--accent); }
.radio-opt b { font-size: 12.5px; font-weight: 650; display: block; }
.radio-opt small { font-size: 11.5px; color: var(--muted); line-height: 1.45; display: block; }

.import-log {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
  background: var(--panel-3); border-radius: 9px; padding: 10px 12px;
  max-height: 180px; overflow: auto; white-space: pre-wrap; color: var(--text-dim);
}

/* ---------- bulk bar ---------- */
#bulkbar {
  position: fixed; left: 50%; bottom: 22px; z-index: 55;
  transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 13px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--panel-2) 96%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(.32, .72, .28, 1), opacity .2s ease;
  opacity: 0;
  max-width: min(940px, calc(100vw - 40px));
}
#bulkbar.show { transform: translate(-50%, 0); opacity: 1; }
#bulkbar .bulk-n {
  font-size: 12.5px; font-weight: 700; padding: 0 6px 0 4px;
  white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
#bulkbar .bulk-n b { color: var(--accent); font-variant-numeric: tabular-nums; }
#bulkbar .vr { width: 1px; height: 20px; background: var(--border); }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; right: 18px; bottom: 74px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 9px;
  min-width: 240px; max-width: 400px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  animation: toast-in .18s ease;
}
.toast.out { animation: toast-out .16s ease forwards; }
.toast i.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ok); flex: none; }
.toast.warn i.dot { background: var(--warn); }
.toast.err i.dot { background: var(--danger); }
.toast .t-msg { flex: 1; }
.toast .t-act {
  border: 0; background: transparent; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; padding: 2px 4px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- misc ---------- */
.kbd {
  font-family: var(--font-mono); font-size: 10px;
  padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  color: var(--muted); background: var(--panel-3);
  white-space: nowrap;
}
.mono { font-family: var(--font-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.help-list { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 12.5px; align-items: center; }
.help-list span:nth-child(2) { color: var(--text-dim); }

#boot-error {
  position: fixed; inset: auto 18px 18px 18px; z-index: 100;
  display: none;
  padding: 12px 14px; border-radius: 10px;
  background: rgba(248, 113, 113, .12);
  border: 1px solid var(--danger); color: var(--text);
  font-size: 12.5px;
}
#boot-error.show { display: block; }

@media (max-width: 900px) {
  /* the sidebar becomes off-canvas, so the grid has no second item to place:
     switch the frame to block flow and give main its own height */
  #app-shell { display: block; }
  #main { height: 100vh; height: 100dvh; }
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 58;
    transform: translateX(-101%); transition: transform .2s ease;
  }
  body.side-open #sidebar { transform: none; }
  body.side-open #scrim-side { opacity: 1; pointer-events: auto; }
  table.vtable { table-layout: fixed; }
  .row-actions { opacity: 1; }
  table.vtable .col-hide-sm { display: none; }
  .cell-title .t-name, .cell-title .t-host { max-width: none; }
  #topbar { padding: 10px 12px; gap: 8px; }
  .grid-cards { padding: 12px; gap: 10px; }
  #filterbar, #pagination { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 620px) {
  .search-wrap .search-meta .kbd { display: none; }
  #topbar .hide-xs { display: none; }
}
/* ---------- popover menu ---------- */
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 7px 9px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-dim);
  font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--panel-3); color: var(--text); }
.menu-item svg { opacity: .8; flex: none; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(248, 113, 113, .12); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }

/* ---------- row focus (keyboard nav) ---------- */
table.vtable tbody tr.focused { background: rgba(99, 102, 241, .16); box-shadow: inset 2px 0 0 var(--accent); }
.vcard.focused { box-shadow: 0 0 0 1px var(--accent); }

/* hide native search clear button (we ship our own) */
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

/* ---------- responsive helpers ---------- */
.hide-lg-up { display: none; }
@media (max-width: 900px) {
  .hide-lg-up { display: inline-grid; }
  .hide-xs { display: none !important; }
}
@media (max-width: 620px) {
  .hide-sm { display: none !important; }
}

/* ---------- minimal utility fallbacks ----------
   The app is written against Tailwind's utility layer, which is loaded from
   assets/vendor/tailwind.js. These duplicates keep the layout intact if that
   file is missing, since a broken layout is worse than duplicated rules. */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-0\.5 { gap: 2px; }
.gap-1\.5 { gap: 6px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }
.min-w-0 { min-width: 0; }
.text-left { text-align: left; }
.w-full { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
