/* Cryptonico — plain CSS, no build step. CSP: no inline styles anywhere. */
:root {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-ink: #ffffff;
    --accent-soft: #e8efff;
    --danger: #dc2626;
    --ok: #15803d;
    --warn: #b45309;
    --top: #0b1220;
    --top-ink: #e2e8f0;
    --side: #0f172a;
    --side-ink: #cbd5e1;
    --side-hover: #1e293b;
    --side-active: #1d4ed8;
    --radius: 8px;
    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --panel: #111827;
        --panel-2: #0f172a;
        --line: #1f2937;
        --text: #e5e7eb;
        --muted: #94a3b8;
        --accent: #3b82f6;
        --accent-soft: #172554;
        --danger: #f87171;
        --ok: #4ade80;
        --warn: #fbbf24;
        --top: #030712;
        --side: #0a0f1c;
        --side-hover: #172033;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.prewrap { white-space: pre-wrap; }
.pad { padding: 6px 10px; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    height: 52px; padding: 0 16px;
    background: var(--top); color: var(--top-ink);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: inherit; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: linear-gradient(135deg, #3b82f6, #22d3ee);
    box-shadow: inset 0 0 0 5px rgba(11, 18, 32, .55);
}
.brand-lg { font-size: 20px; justify-content: center; margin-bottom: 18px; }
.brand-lg .brand-mark { width: 28px; height: 28px; }
.topsearch { flex: 1; max-width: 520px; }
.topsearch input {
    width: 100%; height: 34px; border-radius: 6px; border: 1px solid #1f2a44;
    background: #111a2e; color: var(--top-ink); padding: 0 12px;
}
.topsearch input::placeholder { color: #64748b; }
.topnav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topnav > a { color: var(--top-ink); padding: 6px 10px; border-radius: 6px; }
.topnav > a:hover, .topnav > a.active { background: #1e293b; text-decoration: none; }
.sidebar-toggle { display: none; color: var(--top-ink); }

/* dropdown menus via <details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 6px; user-select: none; }
.menu > summary::-webkit-details-marker { display: none; }
.topnav .menu > summary:hover { background: #1e293b; }
.menu-pop {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 30;
    background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: 6px;
}
.menu-pop a, .menu-pop .linklike {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border-radius: 6px;
    color: var(--text); text-align: left;
}
.menu-pop a:hover, .menu-pop .linklike:hover { background: var(--panel-2); text-decoration: none; }
.menu-meta { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: 12px; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

.topnav .nav-menu > summary { color: var(--top-ink); }
.topnav .nav-menu > summary.active { background: #1e293b; }
.nav-menu .menu-pop { left: 0; right: auto; }
.vault-pop { min-width: 260px; max-height: 70vh; overflow-y: auto; }
.vault-pop a.current { background: var(--accent-soft); font-weight: 600; }
.vault-pop .count { margin-left: auto; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

.company-pop { min-width: 280px; }
.menu-scroll { max-height: 60vh; overflow-y: auto; }
.menu-filter { margin: 2px 0 6px; }
.company-pop a.current { background: var(--accent-soft); font-weight: 600; }
.company-pop .count { margin-left: auto; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
    width: 270px; flex: none; background: var(--side); color: var(--side-ink);
    padding: 12px 8px; overflow-y: auto; max-height: calc(100vh - 52px); position: sticky; top: 52px;
}
.content { flex: 1; min-width: 0; padding: 20px 24px 40px; }
.narrow { max-width: 640px; }

.side-section + .side-section { margin-top: 18px; }
.side-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 0 8px 6px;
}
.side-head .icon-btn { color: var(--side-ink); }
.vault-list, .tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; }
.vault-list a, .tree a {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--side-ink);
}
.vault-list a:hover, .tree a:hover { background: var(--side-hover); text-decoration: none; }
.vault-list a.active, .tree a.active { background: var(--side-active); color: #fff; }
.count { font-size: 11px; color: #64748b; }
a.active .count { color: #c7d2fe; }
.ico { width: 12px; color: #64748b; font-size: 11px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.lg { width: 22px; height: 22px; }
.c-blue { background: #3b82f6; } .c-green { background: #22c55e; } .c-orange { background: #f97316; }
.c-red { background: #ef4444; } .c-purple { background: #a855f7; } .c-gray { background: #94a3b8; }

/* ---------- buttons & forms ---------- */
.btn, .mini {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: var(--panel); color: var(--text);
    border-radius: 6px; cursor: pointer; font: inherit; white-space: nowrap;
}
.btn { height: 34px; padding: 0 12px; }
.mini { height: 24px; padding: 0 8px; font-size: 12px; }
.btn:hover, .mini:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-ghost { color: var(--danger) !important; }
.btn.block { width: 100%; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; color: inherit; }
.icon-btn:hover { background: rgba(148, 163, 184, .15); text-decoration: none; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], select, textarea {
    width: 100%; font: inherit; color: var(--text); background: var(--panel);
    border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 400; font-size: 13px; }
.check input { width: auto; }
.input-row { display: flex; gap: 6px; align-items: center; }
.input-row input { flex: 1; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .3em; text-align: center; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.span-2 { grid-column: span 2; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.actions.left { justify-content: flex-start; flex-wrap: wrap; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline-form select { width: auto; flex: 1; min-width: 180px; }

fieldset.colors { border: 0; padding: 0; margin: 0; display: flex; gap: 10px; align-items: center; }
fieldset.colors legend { font-weight: 500; margin-bottom: 6px; }
.swatch { flex-direction: row; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch input:checked + .dot { outline: 3px solid var(--accent); outline-offset: 2px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); margin-top: 16px; }

/* ---------- page header / toolbar ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.crumbs a { color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.crumbs .sep { color: var(--muted); }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .filter { max-width: 280px; }
.toolbar select { width: auto; }
.toolbar form { display: inline; }
.menu-pop.right { right: 0; }

/* ---------- tables ---------- */
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list.card { padding: 0; }
.list th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.list td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr[data-href] { cursor: pointer; }
.list tbody tr:hover { background: var(--panel-2); }
.list tr.dim td { opacity: .55; }
.list a { color: var(--text); font-weight: 500; }
.w-ico { width: 52px; }
.w-act { width: 1%; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }
.small-table td { font-size: 12.5px; }

.type-ico {
    display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 22px;
    border-radius: 5px; font: 700 10px/1 var(--mono); letter-spacing: .04em; color: #fff; background: #64748b;
}
.t-rdp { background: #2563eb; } .t-ssh { background: #0f766e; } .t-vnc { background: #7c3aed; }
.t-web { background: #0891b2; } .t-credential { background: #b45309; } .t-note { background: #475569; }
.t-folder { background: #ca8a04; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--accent-soft); color: var(--accent); margin: 1px 2px 1px 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.off { color: var(--danger); }
.role-view { color: var(--muted); } .role-use { color: var(--accent); } .role-edit { color: var(--ok); } .role-manage { color: #a855f7; }
.act { font-family: var(--mono); font-size: 12px; }
.act-hot { color: var(--warn); font-weight: 600; }
.act-bad { color: var(--danger); }

/* ---------- entry detail ---------- */
.entry-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.entry-head h1 { margin: 0; }
.entry-head .type-ico { width: 46px; height: 30px; font-size: 11px; }
dl.fields { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; }
dl.fields dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
dl.fields dd { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.secret { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; width: 100%; }
.secret-mask { font-family: var(--mono); letter-spacing: .1em; color: var(--muted); }
.secret-value {
    margin: 0; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
    font: 13px/1.4 var(--mono); white-space: pre-wrap; word-break: break-all; max-width: 100%; flex-basis: 100%;
}
.entry-foot { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
.row-line { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.row-line a { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- companies & devices ---------- */
.narrow.wide { max-width: 860px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 18px; }
.split .card + .card { margin-top: 0; }
dl.fields.compact { grid-template-columns: 130px 1fr; gap: 6px 12px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.type-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; border-radius: 8px;
    border: 1px solid var(--line); color: var(--text); background: var(--panel-2);
}
.type-tile:hover { border-color: var(--accent); text-decoration: none; }
.type-tile.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.type-tile strong { font-size: 20px; line-height: 1; }
.type-tile span:last-child { font-size: 12px; color: var(--muted); }
.toolbar h2 { margin: 0; }
.danger-inline { margin-top: 24px; }
.vault-list .type-ico { width: 34px; height: 18px; font-size: 9px; }
.d-computer { background: #2563eb; } .d-laptop { background: #3b82f6; } .d-server { background: #1e40af; }
.d-virtual_machine { background: #6366f1; } .d-printer { background: #64748b; } .d-network { background: #0f766e; }
.d-firewall { background: #b91c1c; } .d-wifi { background: #0891b2; } .d-nas { background: #7c3aed; }
.d-ups { background: #ca8a04; } .d-camera { background: #475569; } .d-phone { background: #db2777; }
.d-website { background: #0284c7; } .d-other { background: #6b7280; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.type-tree, .type-tree ul { list-style: none; margin: 0; padding: 0; }
.type-tree ul { padding: 2px 0 6px 22px; }
.type-tree summary {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
    list-style: none; color: var(--side-ink); user-select: none;
}
.type-tree summary::-webkit-details-marker { display: none; }
.type-tree summary:hover { background: var(--side-hover); }
.type-tree summary.active { background: var(--side-active); color: #fff; }
.type-tree .caret { width: 10px; font-size: 10px; color: #64748b; transition: transform .12s; }
.type-tree details[open] > summary .caret { transform: rotate(90deg); }
.type-tree .type-ico { width: 34px; height: 18px; font-size: 9px; }
.type-tree a { display: flex; align-items: center; padding: 4px 8px; border-radius: 6px; color: var(--side-ink); font-size: 13px; }
.type-tree a:hover { background: var(--side-hover); text-decoration: none; }
.type-tree a.active { background: var(--side-active); color: #fff; }
.type-tree a.retired { opacity: .5; text-decoration: line-through; }
.type-tree a.muted-link { color: #64748b; font-size: 12px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.form-sub { margin: 8px 0 -4px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; }

.add-box { margin-bottom: 16px; padding: 12px 16px; }
.add-box > summary { list-style: none; display: inline-flex; }
.add-box > summary::-webkit-details-marker { display: none; }
.add-box[open] > summary { margin-bottom: 14px; }
dialog.dialog.wide { width: min(640px, 94vw); }
.tabs .badge { margin-left: 4px; }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
    display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid var(--line); color: var(--text);
}
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat strong { font-size: 28px; line-height: 1; }
.stat span { color: var(--muted); font-size: 13px; }
.stat-bad { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.stat-bad strong { color: var(--danger); }
.stat-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.stat-warn strong { color: var(--warn); }
.dash-card h2 { margin-bottom: 12px; }
.dash-card .list { border: 0; }
@media (max-width: 860px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }


.connect-pop { min-width: 300px; }
.connect-pop a { align-items: flex-start; }
.remote-bar { display: flex; align-items: center; gap: 8px; margin: -8px 0 10px; flex-wrap: wrap; }
.remote-bar .grow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.remote-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; height: calc(100vh - 52px - 110px); min-height: 420px; }
.remote-wrap:fullscreen { border-radius: 0; height: 100vh; }
.remote { width: 100%; height: 100%; outline: none; display: flex; align-items: center; justify-content: center; cursor: default; }
.remote-msg { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); max-width: 520px; padding: 14px 18px; border-radius: 8px; background: #111827; color: #e5e7eb; border: 1px solid #374151; text-align: center; }

ol.steps { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.section-title { margin: 22px 0 10px; }

/* ---------- misc ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: color-mix(in srgb, var(--ok) 10%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.flash.err { background: color-mix(in srgb, var(--danger) 10%, var(--panel)); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.flash.warn { background: color-mix(in srgb, var(--warn) 10%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.temp-pass { display: flex; flex-direction: column; gap: 8px; }
code.big { font-size: 18px; padding: 4px 10px; background: var(--panel); border-radius: 6px; border: 1px solid var(--line); user-select: all; }
.empty { text-align: center; padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel); }
.empty.big { max-width: 560px; margin: 40px auto; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
    background: #0f172a; color: #e2e8f0; padding: 9px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: 13px;
}
dialog.dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(440px, 92vw); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(2, 6, 23, .55); }

/* ---------- guest pages ---------- */
body.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a33, transparent), var(--bg); }
.guest-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 20px 50px rgba(2, 6, 23, .12); }
.guest-card h1 { font-size: 18px; }
.qr { display: flex; justify-content: center; margin: 10px 0; }
.qr img { background: #fff; padding: 8px; border-radius: 8px; }
.secret-key code { font-size: 13px; padding: 4px 8px; background: var(--panel-2); border-radius: 6px; user-select: all; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
    .sidebar-toggle { display: inline-block; }
    .sidebar { position: fixed; left: 0; top: 52px; bottom: 0; z-index: 15; transform: translateX(-100%); transition: transform .15s; max-height: none; }
    body.sidebar-open .sidebar { transform: none; }
    .content { padding: 16px; }
    .topsearch { display: none; }
    .hide-sm { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    dl.fields { grid-template-columns: 1fr; gap: 2px; }
    dl.fields dd { margin-bottom: 8px; }
}
