:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --warn: #d97706;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-hover: #1e293b;
  --rack-bg: #1f2937;
  --rack-unit: #f8fafc;
  --rack-unit-alt: #f1f5f9;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 20px 50px rgb(15 23 42 / 0.25);
  --radius: 10px;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #0f172a;
    --border: #1f2a3c;
    --border-strong: #334155;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-soft: #172554;
    --danger: #f87171;
    --danger-soft: #3f1d1d;
    --sidebar: #070b14;
    --sidebar-hover: #111827;
    --rack-bg: #030712;
    --rack-unit: #1e293b;
    --rack-unit-alt: #1a2433;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; margin: 16px 0; }
.ok { color: var(--ok); font-weight: 600; }
.boot, .loading { padding: 48px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 272px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh;
  overflow-y: auto; padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 4px 8px 16px; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .tree a {
  display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); padding: 7px 10px; border-radius: 7px;
}
.nav a:hover, .tree a:hover { background: var(--sidebar-hover); text-decoration: none; color: #fff; }
.nav a.active, .tree a.active { background: var(--primary); color: #fff; }
.tree-head { margin: 20px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--sidebar-muted); }
.tree { font-size: 13px; }
.tree a { padding: 4px 8px; }
.tree a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree svg { width: 15px; height: 15px; opacity: 0.75; }
.tree details > summary { list-style: none; display: flex; align-items: center; cursor: pointer; }
.tree details > summary::-webkit-details-marker { display: none; }
.tree details > summary::before {
  content: '▸'; width: 14px; flex-shrink: 0; color: var(--sidebar-muted); font-size: 11px; transition: transform 0.15s; text-align: center;
}
.tree details[open] > summary::before { transform: rotate(90deg); }
.tree summary > a { flex: 1; min-width: 0; }
.tree-leaf { padding-left: 14px; }
.tree-children { padding-left: 12px; border-left: 1px solid #1e293b; margin-left: 7px; }
.tree-empty { color: var(--sidebar-muted); padding: 0 10px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.top-search { flex: 1; max-width: 560px; }
.top-search input { width: 100%; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 4px 8px; border-radius: 99px; }
.user-chip:hover { background: var(--surface); text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; }
.menu-btn { display: none; }
.main { padding: 24px 28px 64px; max-width: 1500px; width: 100%; }

/* ---------- Generic UI ---------- */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type='color'] { padding: 2px; height: 36px; width: 64px; }
textarea { resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500;
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--muted); }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 3px 9px; font-size: 12.5px; }
.btn-block { width: 100%; padding: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { font-size: 13px; padding: 2px 6px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs .sep { color: var(--border-strong); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.subtitle { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-link { margin-left: auto; font-size: 13px; font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tile {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; color: var(--text); box-shadow: var(--shadow); transition: border-color 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tile-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.tile-stats { display: flex; gap: 12px; margin-top: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.meter { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; margin: 10px 0 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; color: var(--text); box-shadow: var(--shadow);
}
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-icon { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; }
.onboarding { margin-bottom: 20px; border-left: 4px solid var(--primary); }
.onboarding h2 { margin-top: 0; font-size: 18px; }

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 24px; margin: 0 0 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
}
.info-grid dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.info-grid dd { margin: 2px 0 0; white-space: pre-line; word-break: break-word; }

.badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
.page-head h1 .badge, .page-head h1 .status { font-size: 12px; }
.status { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.status-active { color: var(--ok); }
.status-planned { color: var(--primary); }
.status-offline { color: var(--warn); }
.status-decommissioned { color: var(--muted); text-decoration: line-through; }
.role { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.role-admin { color: var(--danger); }
.role-editor { color: var(--primary); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 8px; vertical-align: -1px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; }
.tab {
  font: inherit; background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { border: 0; box-shadow: none; border-radius: 0; margin: -4px -8px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.hl { background: color-mix(in srgb, var(--primary) 12%, transparent) !important; }
.table tr.inactive { opacity: 0.55; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 4px; }
.filter-input { width: 200px; }
.empty-inline { text-align: center; padding: 32px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state { text-align: center; padding: 64px 16px; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: 0; }
.link-list a { display: flex; align-items: center; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- History ---------- */
.act { font-weight: 600; font-size: 12.5px; }
.act-create { color: var(--ok); }
.act-update { color: var(--primary); }
.act-delete { color: var(--danger); }
.changes { margin: 4px 0 0; padding-left: 16px; font-size: 12.5px; color: var(--muted); }
.changes b { color: var(--text); font-weight: 500; }

/* ---------- Modals & forms ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgb(15 23 42 / 0.5); z-index: 100; display: grid; place-items: center;
  padding: 16px; animation: fade 0.12s ease-out;
}
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop 0.15s ease-out;
}
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } }
.confirm-text { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 500; font-size: 13px; }
.req { color: var(--danger); margin-left: 2px; }
.help { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; flex-wrap: wrap; }
.check .help { flex-basis: 100%; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; padding: 10px; border: 1px solid var(--border); border-radius: 7px; max-height: 200px; overflow-y: auto; }
.form-heading { margin: 8px 0 -4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
.form-error { background: var(--danger-soft); color: var(--danger); border-radius: 7px; padding: 8px 12px; font-weight: 500; }
.listbox { min-height: 180px; }
.connect-from { margin-top: 0; padding: 10px 12px; background: var(--primary-soft); border-radius: 7px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 13px; }

.pg-editor { display: flex; flex-direction: column; gap: 6px; }
.pg-row { display: grid; grid-template-columns: 1.4fr 0.6fr 0.6fr 1fr 0.7fr 1fr auto auto; gap: 6px; align-items: center; }
.pg-head { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.pg-editor > .btn { align-self: flex-start; }

.toast-container, #toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg);
  max-width: 420px; animation: pop 0.15s ease-out; transition: opacity 0.3s, transform 0.3s;
}
.toast-error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-content: center; padding: 16px; background: radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--primary) 18%, var(--bg)), var(--bg) 60%); }
.login-card { width: min(400px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { margin: 18px 0 4px; font-size: 22px; }
.login-card > p { margin: 0 0 20px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.login-brand img { width: 34px; height: 34px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; }
.otp-input { font-size: 22px; letter-spacing: 0.3em; text-align: center; font-family: var(--mono); }

/* ---------- Meta panel ---------- */
.meta-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; align-items: start; }
.meta-panel .card + .card { margin-top: 0; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px; border: 2px dashed var(--border-strong);
  border-radius: var(--radius); cursor: pointer; color: var(--muted); margin-bottom: 14px; text-align: center;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.thumb { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100px; object-fit: cover; display: block; }
.thumb figcaption { display: flex; align-items: center; gap: 2px; padding: 4px 6px; font-size: 12px; }
.thumb figcaption span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list { list-style: none; padding: 0; margin: 0 0 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-list .muted { font-size: 12px; margin-left: auto; }
.note-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.note-form textarea { width: 100%; }
.notes { list-style: none; padding: 0; margin: 0; }
.note { border-left: 3px solid var(--primary); padding: 6px 12px; margin-bottom: 10px; background: var(--surface-2); border-radius: 0 7px 7px 0; }
.note-head { display: flex; gap: 10px; align-items: center; font-size: 12.5px; }
.note-head .icon-btn { margin-left: auto; }
.note-body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }

/* ---------- Rack ---------- */
.rack-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.rack-pair { display: flex; gap: 28px; flex-wrap: wrap; flex: 0 1 760px; }
.rack-side { flex: 1 1 260px; max-width: 420px; }
.rack-col { display: flex; flex-direction: column; gap: 6px; }
.rack-label { font-weight: 600; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.rack-frame { background: var(--rack-bg); padding: 10px 6px; border-radius: 6px; box-shadow: var(--shadow); }
.rack { position: relative; width: 340px; background: var(--rack-unit); }
.ru {
  position: absolute; left: 0; right: 0; height: 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.ru:nth-child(even) { background: var(--rack-unit-alt); }
.ru-num { font: 10px var(--mono); color: var(--muted); width: 22px; text-align: center; user-select: none; }
.ru:hover { background: var(--primary-soft); cursor: copy; }
.rdev {
  position: absolute; left: 24px; right: 24px; z-index: 2; display: flex; flex-direction: column; justify-content: center;
  padding: 0 10px; color: #fff; border-radius: 3px; overflow: hidden; line-height: 1.2;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 92%, #fff), var(--c));
  border: 1px solid color-mix(in srgb, var(--c) 70%, #000); box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.2);
  cursor: pointer;
}
.rdev:hover { text-decoration: none; outline: 2px solid var(--primary); outline-offset: 1px; z-index: 3; }
.rdev.dragging { opacity: 0.35; }
.rdev-name { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rdev-meta { font-size: 10.5px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rdev[style*='height:24px'] { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.rdev.ghost {
  background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--c) 30%, var(--rack-unit)) 0 6px, color-mix(in srgb, var(--c) 15%, var(--rack-unit)) 6px 12px);
  color: var(--text); border-style: dashed;
}
.rdev-shelf, .rdev-cablemgmt { color: #fff; }
.drop-ghost {
  position: absolute; left: 24px; right: 24px; z-index: 4; border: 2px dashed var(--primary); background: color-mix(in srgb, var(--primary) 18%, transparent);
  border-radius: 3px; pointer-events: none; display: grid; place-items: center; font-weight: 600; font-size: 12px; color: var(--primary);
}
.rack-side .card + .card { margin-top: 14px; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.drag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.drag-list li { padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; cursor: grab; background: var(--surface-2); display: flex; align-items: center; gap: 4px; }
.drag-list li .muted { margin-left: auto; font-size: 12px; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: var(--c); margin-right: 8px; vertical-align: -2px; }
.legend i.hatch { background: repeating-linear-gradient(45deg, var(--border-strong) 0 3px, transparent 3px 6px); border: 1px dashed var(--muted); }

/* ---------- Ports ---------- */
.faceplates { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.faceplate-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.faceplate-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.faceplate { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.fp-port {
  font: 10.5px var(--mono); height: 32px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--muted); cursor: pointer; padding: 0 2px; overflow: hidden; position: relative;
}
.fp-port span { position: relative; z-index: 1; }
.fp-port.on { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); border-color: var(--ok); color: var(--text); font-weight: 600; }
.fp-port.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--cable, var(--ok)); }
.fp-port:hover { border-color: var(--primary); }
.fp-SFP, .fp-SFPplus, .fp-SFP28, .fp-QSFPplus, .fp-QSFP28, .fp-LC, .fp-SC { border-radius: 2px; border-style: double; border-width: 3px; }
.cable-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.cable-chip::before { content: ''; width: 18px; height: 5px; border-radius: 3px; background: var(--cable); border: 1px solid var(--border-strong); }
.ports-table td { vertical-align: middle; }

/* ---------- Trace ---------- */
.trace { display: flex; flex-direction: column; align-items: stretch; gap: 0; max-width: 520px; margin: 8px auto; }
.trace-node {
  border: 1px solid var(--border); border-left: 5px solid var(--c); border-radius: 8px; padding: 10px 14px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 2px;
}
.trace-node.start { box-shadow: 0 0 0 2px var(--primary); }
.trace-node > a { font-weight: 600; font-size: 15px; }
.trace-ports { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.trace-port { font-family: var(--mono); font-size: 12.5px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 8px; }
.trace-port i { font-style: normal; color: var(--muted); font-family: system-ui, sans-serif; font-size: 11px; }
.trace-cable { display: flex; align-items: center; gap: 12px; padding: 0 0 0 28px; min-height: 52px; }
.trace-line { width: 5px; align-self: stretch; background: var(--cable); border-radius: 3px; border: 1px solid var(--border-strong); }
.trace-cable-label { font-family: var(--mono); font-size: 13px; display: flex; flex-direction: column; }
.trace-cable-label small { font-family: system-ui, sans-serif; color: var(--muted); }

/* ---------- Floor plan ---------- */
.plan-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.chip { font: inherit; font-size: 13px; padding: 3px 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.hint { color: var(--primary); font-weight: 500; font-size: 13px; }
.floorplan { position: relative; display: inline-block; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.floorplan img { display: block; max-width: 100%; height: auto; user-select: none; }
.floorplan.placing { cursor: crosshair; }
.floorplan.placing .plan-marker { pointer-events: none; }
.plan-marker {
  position: absolute; transform: translate(-50%, -50%); background: var(--primary); color: #fff; font-weight: 700; font-size: 12px;
  padding: 3px 9px; border-radius: 6px; box-shadow: 0 2px 6px rgb(0 0 0 / 0.35); border: 2px solid #fff; white-space: nowrap;
}
.plan-marker:hover { text-decoration: none; background: var(--primary-hover); transform: translate(-50%, -50%) scale(1.08); }

/* ---------- Search, profile ---------- */
.search-big input { width: 100%; font-size: 17px; padding: 12px 16px; margin-bottom: 16px; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.result-list li:last-child { border-bottom: 0; }
.search-group + .search-group { margin-top: 12px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 8px; width: fit-content; margin: 8px auto; }
.secret { user-select: all; }
.steps { padding-left: 18px; margin-top: 0; }
.viewer-img { max-width: 100%; display: block; margin: auto; }

/* ---------- IPAM ---------- */
.tenant-select { min-width: 200px; }
.ipam-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.util { display: flex; align-items: center; gap: 8px; font-size: 12.5px; white-space: nowrap; }
.util .meter { flex: 1; margin: 0; min-width: 60px; }
.meter.mid span { background: var(--warn); }
.meter.high span { background: var(--danger); }
.tree-mark { color: var(--muted); margin-right: 6px; }
.vlan-chip {
  display: inline-block; min-width: 30px; text-align: center; font: 600 11.5px var(--mono); padding: 1px 6px; border-radius: 5px;
  background: color-mix(in srgb, #7c3aed 14%, transparent); color: #7c3aed; border: 1px solid color-mix(in srgb, #7c3aed 35%, transparent);
}
@media (prefers-color-scheme: dark) { .vlan-chip { color: #c4b5fd; } }
.vlan-link:hover { text-decoration: none; }
.vlan-link:hover .vlan-chip { background: #7c3aed; color: #fff; }
.vlan-cell { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.vlan-tag { font-size: 10px; font-weight: 700; color: var(--muted); margin-left: 4px; }
.vlan-tag:first-child { margin-left: 0; }
.ip-status { font-size: 12px; font-weight: 600; }
.ip-active { color: var(--ok); }
.ip-reserved { color: var(--warn); }
.ip-dhcp { color: var(--primary); }
.ip-deprecated { color: var(--muted); text-decoration: line-through; }
.addr-map { display: grid; grid-template-columns: repeat(32, minmax(0, 1fr)); gap: 2px; max-width: 1100px; }
.addr-map.dense { grid-template-columns: repeat(64, minmax(0, 1fr)); }
.am-cell {
  font: 9px var(--mono); aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid var(--border); border-radius: 3px;
  background: var(--surface); color: var(--muted); cursor: pointer; overflow: hidden;
}
.addr-map.dense .am-cell { font-size: 0; }
.am-cell:hover { outline: 2px solid var(--primary); z-index: 1; }
i.am-cell { display: inline-block; width: 14px; height: 14px; vertical-align: -3px; margin-right: 6px; cursor: default; }
.am-cell.ip-active { background: var(--ok); border-color: var(--ok); color: #fff; }
.am-cell.ip-reserved { background: var(--warn); border-color: var(--warn); color: #fff; }
.am-cell.ip-dhcp { background: var(--primary); border-color: var(--primary); color: #fff; }
.am-cell.ip-deprecated { background: var(--border-strong); color: var(--surface); }
.am-cell.gateway { background: repeating-linear-gradient(45deg, var(--ok) 0 3px, transparent 3px 6px); }
.am-cell.edge { background: var(--surface-2); color: transparent; cursor: default; opacity: 0.5; }
.am-cell.child { background: color-mix(in srgb, #7c3aed 18%, var(--surface)); }
.legend-row { flex-direction: row; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.vlan-ports { list-style: none; padding: 0; margin: 0; }
.vlan-ports li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.vlan-ports li:last-child { border-bottom: 0; }
.vlan-ports a:hover { text-decoration: none; }

/* ---------- Floors & plan editor ---------- */
.floor-switch { min-width: 160px; }
.floor-stack { display: flex; flex-direction: column; gap: 8px; }
.floor-row {
  display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 16px; padding: 14px 18px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.floor-row:hover { border-color: var(--primary); text-decoration: none; }
.floor-level { font: 700 13px var(--mono); text-align: center; padding: 6px 0; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.floor-name { display: flex; flex-direction: column; }
.floor-row .tile-stats { margin: 0; }
.plan-editor { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.plan-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.plan-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg-btn { font: inherit; font-size: 13px; padding: 5px 11px; border: 0; background: transparent; color: var(--text); cursor: pointer; border-right: 1px solid var(--border); }
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--surface-2); }
.seg-btn.active { background: var(--primary); color: #fff; }
.plan-hint { font-size: 12.5px; color: var(--muted); flex-basis: 100%; }
.plan-canvas {
  position: relative; width: 100%; max-height: calc(100vh - 250px); min-height: 320px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); overflow: hidden; box-shadow: var(--shadow);
}
.plan-canvas.drop-target { outline: 3px dashed var(--primary); outline-offset: -3px; }
.plan-svg { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; cursor: grab; }
.plan-svg:active { cursor: grabbing; }
.plan-svg.drawing { cursor: crosshair; }
.plan-svg .plan-bg { fill: #fff; }
.plan-svg .grid-line { fill: none; stroke: #e2e8f0; stroke-width: 1; }
.plan-room polygon { fill: color-mix(in srgb, var(--rc) 16%, transparent); stroke: var(--rc); stroke-width: 2.5; vector-effect: non-scaling-stroke; cursor: pointer; }
.plan-room:hover polygon { fill: color-mix(in srgb, var(--rc) 26%, transparent); }
.plan-room.selected polygon { fill: color-mix(in srgb, var(--rc) 30%, transparent); stroke-width: 3.5; stroke-dasharray: 8 4; }
.plan-svg.drawing .plan-room, .plan-svg.drawing .fp-marker { pointer-events: none; }
.room-label { text-anchor: start; font-weight: 700; fill: #0f172a; paint-order: stroke; stroke: rgb(255 255 255 / 0.85); stroke-width: 4px; pointer-events: none; }
.room-sub { text-anchor: start; fill: #475569; pointer-events: none; paint-order: stroke; stroke: rgb(255 255 255 / 0.85); stroke-width: 3px; }
.plan-handle { fill: #fff; stroke: var(--primary); stroke-width: 2.5; vector-effect: non-scaling-stroke; cursor: move; }
.fp-marker { cursor: move; }
.fp-marker.rack rect { fill: #334155; stroke: #0f172a; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.fp-marker.rack .rack-lines { stroke: #94a3b8; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.fp-marker.device circle { fill: var(--mc); stroke: #fff; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.fp-marker.selected rect, .fp-marker.selected circle { stroke: var(--primary); stroke-width: 4; }
.marker-icon { text-anchor: middle; fill: #fff; pointer-events: none; }
.marker-label { text-anchor: middle; font-weight: 600; fill: #0f172a; paint-order: stroke; stroke: #fff; stroke-width: 3px; pointer-events: none; }
.plan-draft { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; pointer-events: none; }
.plan-draft.fill { fill: color-mix(in srgb, var(--primary) 15%, transparent); }
.plan-draft-pt { fill: var(--primary); pointer-events: none; }
.plan-draft-pt.first { fill: #fff; stroke: var(--primary); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.plan-empty-note { position: absolute; left: 12px; bottom: 12px; right: 12px; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; pointer-events: none; width: fit-content; }
.plan-side .card + .card { margin-top: 12px; }
.plan-side .card { padding: 14px 16px; }
.palette { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 300px; overflow-y: auto; }
.palette li {
  display: grid; grid-template-columns: auto 1fr; column-gap: 2px; align-items: center; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface-2); cursor: grab; font-size: 13px;
}
.palette li:hover { border-color: var(--primary); }
.palette li .muted { grid-column: 2; font-size: 11.5px; }
.pal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend i.round { border-radius: 50%; }

/* ---------- Branding ---------- */
.brand-logo { width: auto !important; max-width: 140px; height: 30px; object-fit: contain; background: #fff; border-radius: 5px; padding: 2px 4px; }
.brand.custom span { font-size: 15px; }
.login-brand .brand-logo { height: 40px; max-width: 200px; }
.logo-preview { display: grid; place-items: center; min-height: 110px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fff; padding: 12px; margin-bottom: 8px; }
.logo-preview img { max-height: 90px; max-width: 100%; object-fit: contain; }
.tenant-logo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tenant-logo img { max-height: 48px; max-width: 200px; object-fit: contain; background: #fff; border-radius: 6px; padding: 4px 8px; border: 1px solid var(--border); }

/* ---------- Import ---------- */
.import-step { margin-bottom: 16px; }
.step-no { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; }
.dropzone.compact { margin: 0; padding: 10px; flex-direction: row; justify-content: center; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 16px; margin-bottom: 8px; }
.map-row { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.map-row.mapped span { color: var(--primary); }
.sheet-pick { max-width: 320px; margin-bottom: 12px; }
.preview-table { font-size: 12.5px; }
.preview-table th.mapped { color: var(--primary); }
.map-tag { font-size: 10.5px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.import-options { margin: 14px 0 6px; gap: 6px; }
.import-stats { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
.import-stats .stat { grid-template-columns: 1fr; text-align: center; }
.stat-bad .stat-value { color: var(--danger); }
.import-actions { margin-top: 12px; }
.import-actions summary { cursor: pointer; color: var(--primary); margin-bottom: 8px; }

/* ---------- Plan import ---------- */
.pdf-preview { display: grid; place-items: center; min-height: 240px; max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; margin: 12px 0 6px; }
.pdf-preview canvas { max-width: 100%; height: auto; display: block; }
.layer-list { max-height: 45vh; margin-top: 8px; }

/* ---------- Discovery ---------- */
.source-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); margin-bottom: 16px; }
.source-cards .card + .card { margin-top: 0; }
.source-card { display: flex; flex-direction: column; gap: 6px; }
.source-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.source-target { font-family: var(--mono); word-break: break-all; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.st-new { color: var(--primary); }
.st-ok { color: var(--ok); }
.st-warn, .st-warn-text { color: var(--warn); }
.st-bad { color: var(--danger); }
.discovery-stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.discovery-stats .stat { grid-template-columns: 1fr; text-align: center; }
.discovery-table td { vertical-align: top; }
.change { font-size: 12px; color: var(--warn); }
.change s { color: var(--muted); }
.unreachable { margin-bottom: 16px; }
.unreachable summary { cursor: pointer; }
.apply-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; position: sticky; bottom: 12px; border-color: var(--primary); }
.apply-bar .btn-primary { margin-left: auto; }
.scan-progress { display: flex; align-items: center; gap: 16px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.discovery-help { margin-top: 16px; }
.warn-card { border-left: 4px solid var(--warn); margin-bottom: 16px; }
.warn-card ul { margin: 6px 0 0; padding-left: 18px; }
.client-filter { margin-bottom: 10px; }
.client-filter input { width: min(320px, 100%); }
.discovery-help ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Credentials ---------- */
.pw-field { display: flex; gap: 6px; }
.pw-field input { flex: 1; font-family: var(--mono); }
.cred-table td { vertical-align: middle; }
[data-pw-out].revealed { background: var(--primary-soft); padding: 1px 6px; border-radius: 4px; user-select: all; }
.act-reveal { color: var(--warn); }

/* ---------- Plan placement pop-up ---------- */
.type-palette { max-height: 52vh; }
.type-item { grid-template-columns: auto 1fr !important; column-gap: 10px !important; }
.type-item .muted { grid-column: 2; }
.type-glyph { grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 14px; }
.pp-modes { margin-bottom: 14px; }
.pp-grid { display: grid; grid-template-columns: minmax(240px, 0.9fr) 1.3fr; gap: 18px; }
.pp-filter { display: flex; gap: 6px; margin-bottom: 8px; }
.pp-filter input { flex: 1; }
.pp-tpl-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pp-tpl-list li { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.pp-tpl-list li:last-child { border-bottom: 0; }
.pp-tpl-list li:hover { background: var(--surface-2); }
.pp-tpl-list li.active { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.pp-ex-q { width: 100%; margin-bottom: 8px; }
.pp-cred summary { cursor: pointer; color: var(--primary); margin-bottom: 8px; }
@media (max-width: 860px) { .pp-grid { grid-template-columns: 1fr; } }

/* ---------- Rack port view & patch cables ---------- */
.rack-toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.rack-pair { position: relative; }
.rack-layout.with-ports .rack-pair { flex: 1 1 100%; max-width: none; }
.rack.ports { width: 640px; }
.rdev.pm { flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px; padding: 2px 6px; cursor: default; }
.rdev.pm:hover { outline: none; }
.rdev-head { width: 112px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; cursor: grab; }
.rdev-head .rdev-name { color: #fff; font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rdev-head .rdev-name:hover { text-decoration: underline; }
.rdev.ghost .rdev-head .rdev-name { color: var(--text); }
.rdev-ports { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 0; overflow: hidden; }
.pblock { display: grid; grid-auto-flow: column; grid-auto-columns: 12px; gap: 2px; padding: 2px; background: rgb(0 0 0 / 0.22); border-radius: 3px; }
.rp { width: 12px; height: 12px; box-sizing: border-box; border-radius: 2px; background: #0f172a; border: 1px solid #64748b; cursor: crosshair; touch-action: none; }
.rp:hover { border-color: #fff; }
.rp.on { background: var(--cable, #22c55e); border-color: rgb(255 255 255 / 0.7); }
.rp-fiber { border-radius: 0; box-shadow: inset 0 0 0 2px #0f172a; }
.rp-fiber.on { box-shadow: inset 0 0 0 2px rgb(0 0 0 / 0.35); }
.rp-other { border-radius: 50%; }
.rp.hl, .rp.target { outline: 2px solid #facc15; outline-offset: 1px; z-index: 6; position: relative; }
.cable-layer { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; z-index: 5; }
.cable-line { fill: none; stroke-width: 2.5; stroke-linecap: round; opacity: 0.92; }
.cable-shadow { fill: none; stroke: rgb(0 0 0 / 0.35); stroke-width: 4.5; stroke-linecap: round; }
.cable.hl .cable-line { stroke-width: 4; opacity: 1; }
.cable-draft { fill: none; stroke: #facc15; stroke-width: 2.5; stroke-dasharray: 6 4; }
.legend i.lg-port { width: 12px; height: 12px; border-radius: 2px; background: #0f172a; border: 1px solid #64748b; }
.legend i.lg-port.on { background: #22c55e; }
.legend i.lg-port.stub { background: linear-gradient(#22c55e, #22c55e) center / 2px 100% no-repeat, var(--surface); border-color: transparent; }
.legend i.lg-cable { height: 4px; border-radius: 2px; background: var(--cable); vertical-align: 2px; }
.port-info { margin: 0; }
.room-racks-head { margin-top: 24px; }

/* ---------- Report / WiFi export dialogs ---------- */
.layout-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.layout-opt { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; }
.layout-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.layout-opt input { position: absolute; opacity: 0; }
.layout-opt small { grid-column: 2; color: var(--muted); }
.lo-prev { grid-row: span 2; width: 42px; height: 58px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); display: grid; gap: 3px; padding: 4px; }
.lo-prev.cards { grid-template-columns: 1fr 1fr; }
.lo-prev i { background: var(--primary); border-radius: 3px; opacity: 0.7; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; width: 280px; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.menu-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-block; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .user-name { display: none; }
  .main { padding: 16px 16px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .grid-2, .meta-panel { grid-template-columns: 1fr; }
  .rack { width: min(340px, calc(100vw - 60px)); }
  .rack.ports { width: 640px; }
  .rack-layout.with-ports .rack-pair { overflow-x: auto; }
  .pg-row { grid-template-columns: 1fr 1fr; }
  .pg-head { display: none; }
  .plan-editor { grid-template-columns: 1fr; }
  .floor-row { grid-template-columns: 56px 1fr; }
  .floor-row .tile-stats { grid-column: 1 / -1; }
  .addr-map, .addr-map.dense { grid-template-columns: repeat(16, minmax(0, 1fr)); }
  .page-head h1 { font-size: 22px; }
}
@media print {
  .sidebar, .topbar, .page-actions, .tabs, .row-actions { display: none !important; }
  .shell { display: block; }
}

/* ---- API tokens & agents ---- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.card-head .card-title { margin: 0; }
.secret-once { display: flex; gap: 8px; align-items: center; background: var(--bg-soft, #f1f5f9); border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0 12px; }
.secret-once code { flex: 1; word-break: break-all; font-size: 13px; user-select: all; }
pre.cmd { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre; margin: 6px 0; user-select: all; }
.install-steps li { margin-bottom: 10px; }
.os-tabs { margin: 8px 0 10px; }
.agent-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.agent-state::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--muted, #94a3b8); }
.agent-state.on { color: #15803d; }
.agent-state.on::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.agent-state.off { color: var(--danger); }
.agent-state.off::before { background: var(--danger); }
.agents-card { margin-bottom: 18px; }

/* ---- RMM ---- */
.meter { position: relative; display: inline-block; width: 84px; height: 18px; border-radius: 9px; background: var(--bg-soft, #eef2f7); overflow: hidden; vertical-align: middle; }
.meter i { position: absolute; inset: 0 auto 0 0; background: #22c55e; opacity: .55; }
.meter.warn i { background: #f59e0b; }
.meter.crit i { background: var(--danger); opacity: .7; }
.meter b { position: relative; display: block; text-align: center; font-size: 11.5px; line-height: 18px; font-weight: 600; }
.rmm-table td { vertical-align: middle; }
.os-ico { font-size: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; max-width: 420px; }
.charts { display: grid; gap: 12px; margin-bottom: 14px; }
.chart-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 2px; }
.spark { width: 100%; height: 90px; display: block; background: var(--bg-soft, #f8fafc); border-radius: 6px; }
.spark .grid { stroke: var(--border); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.volumes { display: grid; gap: 10px; }
.volume .small { display: flex; gap: 6px; margin-bottom: 3px; }
.volume .right { margin-left: auto; }
.volume .meter { width: 100%; }
.alert-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.install-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin: 8px 0; }
.install-grid pre.cmd { white-space: pre-wrap; word-break: break-all; }
.key-card { margin-bottom: 14px; }
.job-output { max-height: 50vh; overflow: auto; white-space: pre-wrap; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.rmm-card { margin-bottom: 16px; }
.rmm-mini { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 13px; }

/* ---- records, knowledge base ---- */
.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.doc-tile .doc-excerpt { margin-top: 6px; line-height: 1.4; }
.markdown { line-height: 1.6; max-width: 900px; }
.markdown h2, .markdown h3, .markdown h4, .markdown h5 { margin: 1.2em 0 .4em; }
.markdown h2:first-child { margin-top: 0; }
.markdown blockquote { border-left: 3px solid var(--primary); margin: .6em 0; padding: .2em .9em; color: var(--muted, #64748b); }
.markdown code { background: var(--bg-soft, #f1f5f9); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.markdown ul.md-check { list-style: none; padding-left: .4em; }
.md-table { width: auto; margin: .6em 0; }
.deadline-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.stats.compact { margin: 0; }
@media print { .sidebar, .page-actions, .topbar, .crumbs { display: none !important; } .markdown { box-shadow: none; border: 0; } }

.weekday-pick { display: flex; gap: 12px; flex-wrap: wrap; }

.lh-file { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.svc-start { font-size: 12px; padding: 3px 6px; margin-left: 4px; }

/* ---- letterhead print area editor ---- */
.lh-editor-wrap { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 22px; align-items: start; }
@media (max-width: 760px) { .lh-editor-wrap { grid-template-columns: 1fr; } }
.lh-editor { position: relative; width: 100%; aspect-ratio: 210 / 297; background: #fff; border: 1px solid var(--border); box-shadow: 0 4px 18px rgba(15, 23, 42, .12); user-select: none; touch-action: none; overflow: hidden; }
.lh-bg, .lh-bg img { position: absolute; inset: 0; width: 100%; height: 100%; }
.lh-bg { display: flex; align-items: center; justify-content: center; }
.lh-blank { font-size: 13px; }
.lh-area { position: absolute; border: 2px dashed #2563eb; background: rgba(37, 99, 235, .10); cursor: move; box-sizing: border-box; }
.lh-sample { position: absolute; inset: 8px; display: flex; flex-direction: column; gap: 6px; overflow: hidden; opacity: .55; pointer-events: none; }
.lh-sample i { display: block; height: 5px; border-radius: 3px; background: #64748b; }
.lh-sample i:nth-child(1) { width: 55%; height: 9px; background: #2563eb; }
.lh-sample i:nth-child(3n) { width: 80%; } .lh-sample i:nth-child(4n) { width: 65%; }
.lh-h { position: absolute; background: #2563eb; border-radius: 4px; }
.lh-h.top, .lh-h.bottom { left: 50%; width: 44px; height: 8px; margin-left: -22px; cursor: ns-resize; }
.lh-h.top { top: -5px; } .lh-h.bottom { bottom: -5px; }
.lh-h.left, .lh-h.right { top: 50%; width: 8px; height: 44px; margin-top: -22px; cursor: ew-resize; }
.lh-h.left { left: -5px; } .lh-h.right { right: -5px; }
.lh-pageno { position: absolute; font-size: 9px; color: #475569; background: rgba(255, 255, 255, .8); padding: 0 2px; pointer-events: none; }
.lh-side .lh-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lh-side .check { display: flex; margin: 6px 0; }
.lh-tabs { margin-bottom: 8px; }

/* ---- personal dashboard ---- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: start; }
.dash-grid > .card { margin: 0; min-width: 0; }
.w-s { grid-column: span 4; } .w-m { grid-column: span 6; } .w-l { grid-column: span 12; }
@media (max-width: 1100px) { .w-s { grid-column: span 6; } .w-m { grid-column: span 12; } }
@media (max-width: 700px) { .w-s, .w-m, .w-l { grid-column: span 12; } }
.dash-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dash-head .card-title { margin: 0; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.dash-icon { display: inline-flex; width: 18px; height: 18px; color: var(--primary); flex: none; }
.dash-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dash-tools { display: flex; align-items: center; gap: 4px; }
.dash-sizes { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.dash-sizes button { border: 0; background: transparent; font-size: 11px; padding: 3px 7px; cursor: pointer; color: var(--muted, #64748b); }
.dash-sizes button.active { background: var(--primary); color: #fff; }
.dash-grid.editing .dash-tile { outline: 2px dashed var(--border); outline-offset: -2px; cursor: grab; }
.dash-grid.editing .dash-body { pointer-events: none; opacity: .65; max-height: 220px; overflow: hidden; }
.dash-tile.dragging { opacity: .35; }
.dash-grip { cursor: grab; color: var(--muted, #94a3b8); font-size: 16px; }
.dash-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.dash-list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.dash-more { display: inline-block; margin-top: 10px; font-size: 13px; }
.dash-ok { color: #15803d; margin: 4px 0; }
.dash-note { font-size: 13.5px; }
.dash-search { display: flex; gap: 8px; } .dash-search input { flex: 1; min-width: 0; }
.dash-catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.dash-cat { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; text-align: left; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface, #fff); cursor: pointer; color: inherit; font: inherit; }
.dash-cat:hover { border-color: var(--primary); }
.dash-cat .dash-icon { grid-row: span 2; margin-top: 2px; }
.dash-cat small { grid-column: 2; }
.spinner.small { width: 18px; height: 18px; }

/* =====================================================================
   Responsive: phone → tablet → desktop → ultra-wide
   ===================================================================== */
/* dynamic viewport height (mobile browser toolbars) */
.modal { max-height: calc(100dvh - 32px); }
.sidebar { height: 100dvh; }

/* tables inside cards that have no scroll wrapper of their own: the card scrolls sideways on small screens */
.card { min-width: 0; }
@media (max-width: 1024px) { .card:has(> .table), .card:has(> table) { overflow-x: auto; } }

/* tablet / small laptop: slimmer sidebar, less padding */
@media (min-width: 861px) and (max-width: 1280px) {
  .shell { grid-template-columns: 228px 1fr; }
  .sidebar { padding: 14px 8px 20px; }
  .main { padding: 20px 20px 56px; }
  .topbar { padding: 10px 20px; }
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
}

/* phone */
@media (max-width: 600px) {
  .main { padding: 12px 12px 40px; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .logout-text { display: none; }
  .logout-btn { padding: 6px 8px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; gap: 0 8px; }
  .stat .stat-icon { display: none; }
  .stat-value { font-size: 20px; }
  .page-head { margin-bottom: 14px; }
  .page-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .page-actions .btn { flex: 1 1 auto; }
  .card { padding: 14px; }
  .cards { grid-template-columns: 1fr; }
  /* dialogs as a full-height sheet */
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .modal-foot { border-radius: 0; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  /* larger tap targets */
  .icon-btn { padding: 8px 10px; }
  .icon-btn.sm { padding: 6px 8px; font-size: 15px; }
  .btn-sm { padding: 6px 10px; }
  .tabs { margin-left: -12px; margin-right: -12px; padding: 0 12px; }
  .toolbar input[type=search] { min-width: 0; flex-basis: 100%; max-width: none; }
  .dash-head .card-title { font-size: 15px; }
}

/* touch devices: drag & drop does not work, so the dashboard offers move buttons */
.dash-move { display: none; }
@media (pointer: coarse) {
  .dash-move { display: inline-flex; }
  .dash-grip { display: none; }
}

/* large desktop and ultra-wide: use the space, keep it centred */
@media (min-width: 1700px) {
  .main { max-width: 2000px; margin: 0 auto; }
  .topbar .top-search { max-width: 720px; }
}
@media (min-width: 2200px) {
  .main { max-width: 2600px; padding-left: 40px; padding-right: 40px; }
  .w-s { grid-column: span 3; } .w-m { grid-column: span 6; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
@media (min-width: 2560px) {
  html { font-size: 15px; }
  body { font-size: 15px; }
  .shell { grid-template-columns: 300px 1fr; }
}
@media (min-width: 3000px) {
  .main { max-width: 3200px; }
  .w-s { grid-column: span 2; } .w-m { grid-column: span 4; } .w-l { grid-column: span 12; }
}

/* RMM: self-service requests */
.ss-pre { white-space: pre-line; }

/* Wiki */
.wiki-tenant { width: auto; max-width: 260px; }
.wiki-layout { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; align-items: start; }
.wiki-side { position: sticky; top: 12px; max-height: calc(100dvh - 120px); overflow: auto; padding: 12px; }
.wiki-search { margin-bottom: 10px; }
.wiki-tree-list { list-style: none; margin: 0; padding: 0; }
.wiki-tree-list .wiki-tree-list { padding-left: 14px; border-left: 1px solid var(--border); margin-left: 8px; }
.wiki-tree-list a { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.wiki-tree-list a:hover { background: var(--surface-2); }
.wiki-tree-list a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.wiki-tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wiki-flag { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.wiki-central { border: 1px solid var(--border-strong); border-radius: 99px; padding: 0 6px; }
.wiki-results { display: flex; flex-direction: column; gap: 4px; }
.wiki-results a { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
.wiki-results a:hover, .wiki-results a.active { background: var(--primary-soft); }
.wiki-main { min-width: 0; }
.wiki-page-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px; }
.wiki-title { margin: 2px 0 6px; font-size: 22px; }
.wiki-actions { margin-top: 0; align-self: flex-start; }
.wiki-body { font-size: 15px; line-height: 1.65; }
.markdown .md-img, .md-img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; }
.wiki-files, .wiki-children { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 12px; }
.wiki-files h3, .wiki-children h3 { font-size: 14px; margin: 0 0 6px; }
.wiki-files ul, .wiki-children ul { margin: 0; padding-left: 18px; }
.wiki-ref { margin-top: 16px; }
.wiki-editor-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wiki-preview { flex-basis: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; max-height: 60vh; overflow: auto; }
.wiki-rev { margin-top: 16px; }
@media (max-width: 860px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-side { position: static; max-height: none; }
}

/* Sign-in with Microsoft, security wizard */
.btn-ms { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--surface); border-color: var(--border-strong); font-weight: 600; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12.5px; margin: 14px 0 4px; }
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.qr-box { display: flex; justify-content: center; margin: 12px 0; }
.qr-box img { background: #fff; padding: 8px; border-radius: 8px; }
.wiz-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.wiz-steps span { font-size: 12.5px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.wiz-steps span.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.wiz-steps span.done { color: var(--ok); border-color: var(--ok); }
.wiz-body ol, .wiz-body ul { padding-left: 20px; margin: 6px 0 12px; }
.wiz-body li { margin: 4px 0; }
.wiz-copy { display: flex; gap: 6px; align-items: center; margin: 4px 0 10px; }
.wiz-copy code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; }
.wiz-result { margin-top: 8px; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border); }
.wiz-result.ok { border-color: var(--ok); color: var(--ok); }
.wiz-result.fail { border-color: var(--danger); color: var(--danger); }
.sec-status { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 10px 0; }
.sec-status dt { color: var(--muted); }
.sec-status dd { margin: 0; }
.wiz-auto { border: 1px solid var(--primary); border-radius: 10px; padding: 12px 16px; margin: 10px 0 14px; background: var(--primary-soft); }
.wiz-auto h4 { margin: 0 0 4px; font-size: 15px; }
.wiz-code-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.wiz-code-box code { font-size: 24px; font-weight: 700; letter-spacing: 0.15em; padding: 6px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; }
.wiz-progress { list-style: none; padding-left: 0; margin: 8px 0 0; }
.wiz-progress li { margin: 3px 0; }
.wiz-manual summary { cursor: pointer; font-weight: 500; margin: 6px 0; }

/* Markdown extras: callouts, table of contents, diagrams */
.md-callout { border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.md-callout p { margin: 4px 0; }
.md-callout-title { font-weight: 700; margin-bottom: 2px; }
.md-callout.md-tip { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.md-callout.md-warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.md-callout.md-danger { border-color: var(--danger); background: var(--danger-soft); }
.md-toc { border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; margin: 10px 0 16px; background: var(--surface-2); display: inline-block; min-width: 240px; }
.md-toc-title { font-weight: 700; margin-bottom: 4px; }
.md-toc ul { list-style: none; padding: 0; margin: 0; }
.md-toc .md-toc-3 { padding-left: 14px; }
.md-toc .md-toc-4, .md-toc .md-toc-5 { padding-left: 28px; font-size: 13px; }
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.markdown del { color: var(--muted); }
.mermaid { white-space: pre; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.md-diagram { white-space: normal; text-align: center; margin: 14px 0; overflow-x: auto; }
.md-diagram svg, .wed-dia-preview svg { display: block; width: 100% !important; height: auto !important; margin: 0 auto; fill: initial; stroke: initial; stroke-width: initial; }
.md-diagram-error { white-space: pre-wrap; color: var(--danger); border: 1px dashed var(--danger); border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 13px; }
pre.cmd[data-lang]::before { content: attr(data-lang); display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; }

/* Wiki editor */
.modal.full { width: min(1400px, 100%); height: calc(100dvh - 32px); }
.modal.full .modal-body { flex: 1; min-height: 0; }
.wed-backdrop { padding: 12px; place-items: stretch; }
.wed { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; width: min(1600px, 100%); height: calc(100dvh - 24px); margin: 0 auto; overflow: hidden; }
.wed-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.wed-title { flex: 1 1 320px; font-size: 20px; font-weight: 700; border: 0; background: transparent; padding: 4px 0; }
.wed-title:focus { outline: none; box-shadow: inset 0 -2px 0 var(--primary); }
.wed-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wed-meta select { width: auto; max-width: 260px; }
.wed-sort { width: 70px; }
.wed-note { margin: 0; padding: 6px 16px; background: var(--primary-soft); }
.wed-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: relative; }
.wed-group { display: flex; gap: 2px; padding-right: 6px; border-right: 1px solid var(--border); position: relative; }
.wed-group:last-of-type { border-right: 0; }
.wed-view { margin-left: auto; }
.wed-btn { border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.wed-btn:hover { background: var(--surface); border-color: var(--border); }
.wed-btn.active { background: var(--primary); color: #fff; }
.wed-btn[data-tool=bold] { font-weight: 800; }
.wed-btn[data-tool=italic] { font-style: italic; }
.wed-btn[data-tool=strike] { text-decoration: line-through; }
.wed-menu { position: absolute; top: 100%; left: 0; z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; padding: 4px; min-width: 150px; }
.wed-menu button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 6px; font: inherit; cursor: pointer; color: var(--text); }
.wed-menu button:hover { background: var(--primary-soft); }
.wed-split { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.wed-split[data-mode=edit] { grid-template-columns: 1fr; }
.wed-split[data-mode=edit] .wed-preview { display: none; }
.wed-split[data-mode=preview] { grid-template-columns: 1fr; }
.wed-split[data-mode=preview] .wed-text { display: none; }
.wed-text { resize: none; border: 0; border-radius: 0; padding: 16px 20px; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; height: 100%; background: var(--surface); }
.wed-text:focus { outline: none; box-shadow: none; }
.wed-text.drop { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.wed-preview { overflow: auto; padding: 16px 24px; border-left: 1px solid var(--border); font-size: 15px; line-height: 1.65; }
.wed-foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.wed-spacer { flex: 1; }
.wed-grid-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.wed-grid-wrap { overflow: auto; max-height: 60vh; }
.wed-grid { border-collapse: collapse; }
.wed-grid td { padding: 2px; }
.wed-grid input { min-width: 120px; }
.wed-grid tr.head input { font-weight: 700; background: var(--surface-2); }
.wed-grid select { font-size: 12px; padding: 2px 4px; }
.wed-dia { display: grid; grid-template-columns: minmax(300px, 2fr) 3fr; gap: 16px; height: 100%; }
.wed-dia-left { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.wed-dia-code { flex: 1; min-height: 200px; font-size: 13px; resize: none; }
.wed-dia-preview { border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; display: flex; align-items: center; justify-content: center; }
.wiki-import-log { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; font-size: 13px; }
@media (max-width: 900px) {
  .wed-backdrop { padding: 0; }
  .wed { height: 100dvh; border-radius: 0; }
  .wed-split[data-mode=split] { grid-template-columns: 1fr; }
  .wed-split[data-mode=split] .wed-preview { display: none; }
  .wed-dia { grid-template-columns: 1fr; }
  .wed-view { margin-left: 0; }
}
