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

:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface2: #f7f8fa;
    --border: #e2e5ea;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #6c5ce7;
    --primary-hover: #5a4bd1;
    --primary-dim: rgba(108,92,231,0.08);
    --danger: #e74c3c;
    --danger-hover: #d63031;
    --success: #2ecc71;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 240px;
    --sidebar-collapsed: 60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ---------- Lock Screen ---------- */

.lock-card {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 48px 40px;
    width: 420px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.lock-icon { color: var(--primary); margin-bottom: 16px; }

.lock-card h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }

.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ---------- Inputs & Buttons ---------- */

.input-group { position: relative; margin-bottom: 16px; }
.input-group input { width: 100%; padding-right: 44px; }

input, textarea, select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
input::placeholder, textarea::placeholder { color: #adb5bd; }

.toggle-pw {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px;
}
.toggle-pw:hover { color: var(--text); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #adb5bd; background: var(--surface2); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-full { width: 100%; padding: 14px; }

.btn-icon {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 6px; border-radius: 6px; transition: all 0.2s; display: inline-flex; align-items: center;
}
.btn-icon:hover { color: var(--primary); background: var(--primary-dim); }

.error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------- Sidebar ---------- */

.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 20;
    transition: width 0.25s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-header { justify-content: center; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 16px; border-bottom: 1px solid var(--border);
}

.sidebar-header h2 { font-size: 18px; font-weight: 700; white-space: nowrap; color: var(--primary); }

/* Sidebar top actions */
.sidebar-top-actions {
    padding: 8px 8px 4px; display: flex; gap: 6px; align-items: center;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.search-box-sm { flex: 1; }
.search-box-sm input {
    width: 100%; padding: 6px 10px; font-size: 12px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); outline: none;
}
.search-box-sm input:focus { border-color: var(--primary); }

/* Category tree */
.sidebar-tree {
    flex: 1; overflow-y: auto; padding: 4px 4px;
    min-height: 200px;
}

.tree-node { user-select: none; }
.tree-node-row {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 8px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; color: var(--text-muted);
    transition: all 0.12s;
}
.tree-node-row:hover { background: var(--surface2); color: var(--text); }
.tree-node-row.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.tree-toggle {
    width: 16px; height: 16px; display: inline-flex; align-items: center;
    justify-content: center; flex-shrink: 0; font-size: 10px; color: var(--text-muted);
}
.tree-icon { flex-shrink: 0; font-size: 14px; }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions {
    display: none; gap: 2px;
}
.tree-node-row:hover .tree-actions { display: flex; }
.tree-actions button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px; font-size: 14px; line-height: 1; border-radius: 4px;
}
.tree-actions button:hover { color: var(--primary); background: var(--primary-dim); }
.tree-children { padding-left: 16px; }
.tree-empty { padding: 16px; text-align: center; font-size: 12px; color: var(--text-muted); }

.sidebar-nav { padding: 4px 8px; overflow-y: auto; }

/* Bottom collapsed section */
.sidebar-bottom-section {
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.bottom-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px; cursor: pointer;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    transition: color 0.15s;
}
.bottom-toggle:hover { color: var(--text); }
.bottom-toggle-arrow { font-size: 9px; transition: transform 0.2s; }
.bottom-toggle-arrow.open { transform: rotate(90deg); }

.sidebar-nav-collapsed {
    padding: 0 6px 6px; max-height: 200px; overflow-y: auto;
}

.nav-item-sm {
    display: flex; align-items: center; gap: 6px;
    width: 100%; padding: 5px 10px;
    background: none; border: none; color: var(--text-muted);
    border-radius: 4px; cursor: pointer;
    font-size: 12px; text-align: left;
    transition: all 0.12s; white-space: nowrap;
}
.nav-item-sm:hover { color: var(--text); background: var(--surface2); }
.nav-item-sm.active { color: var(--primary); background: var(--primary-dim); font-weight: 600; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 10px 14px;
    background: none; border: none; color: var(--text-muted);
    border-radius: var(--radius-sm); cursor: pointer;
    font-size: 14px; text-align: left;
    transition: all 0.15s; white-space: nowrap;
}
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--primary); background: var(--primary-dim); font-weight: 600; }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
    padding: 12px 8px; border-top: 1px solid var(--border);
}

/* ---------- Content Area ---------- */

.content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

.sidebar.collapsed ~ .content { margin-left: var(--sidebar-collapsed); }

.content-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.content-header h1 { font-size: 20px; font-weight: 700; }

.header-right { display: flex; align-items: center; gap: 12px; }

.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0 12px;
}
.search-box input { background: transparent; border: none; width: 220px; padding: 10px 0; }
.search-box input:focus { border: none; box-shadow: none; }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* ---------- List View ---------- */

.main { padding: 20px 32px; }

.records-list {
    display: flex; flex-direction: column; gap: 0;
}

.list-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.list-table thead th {
    background: var(--surface2);
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}

.list-table thead th.sortable-th:hover {
    color: var(--primary); background: var(--primary-dim);
}

.list-table tbody tr {
    transition: background 0.15s;
}
.list-table tbody tr:hover { background: var(--surface2); }

.list-table tbody td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.list-table tbody tr:last-child td { border-bottom: none; }

.list-table .col-name {
    font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}

.list-avatar {
    width: 28px; height: 28px; border-radius: 6px;
    background: var(--primary); color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px; flex-shrink: 0;
}

.list-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 12px;
    background: var(--primary-dim); color: var(--primary); border: 1px solid rgba(108,92,231,0.2);
    font-weight: 600; white-space: nowrap;
}

.list-table a { color: var(--primary); text-decoration: none; }
.list-table a:hover { text-decoration: underline; }

.list-actions { display: flex; gap: 2px; white-space: nowrap; }

.secret-cell {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

.secret-masked {
    letter-spacing: 3px; color: #adb5bd; font-size: 12px;
}

.secret-revealed {
    color: var(--text);
    font-size: 13px;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.mono {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 13px;
}

/* ---------- Copy Toast ---------- */

.copy-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--success); color: white;
    padding: 10px 24px; border-radius: 8px; font-size: 13px; font-weight: 600;
    z-index: 999; opacity: 0; transition: opacity 0.3s; pointer-events: none;
    box-shadow: 0 4px 12px rgba(46,204,113,0.3);
}
.copy-toast.show { opacity: 1; }

/* ---------- Modal ---------- */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
}

.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px;
    width: 600px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal-sm { width: 400px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.modal-header h2 { font-size: 18px; }

.btn-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer;
}
.btn-close:hover { color: var(--text); }

.form-group { margin-bottom: 16px; flex: 1; }

.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 6px;
}

.form-row { display: flex; gap: 16px; }

.modal-footer {
    display: flex; justify-content: flex-end; gap: 12px;
    margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ---------- Global Search ---------- */

.global-search-box input { width: 260px; }

.global-search-results {
    padding: 0 32px 20px;
}

.gs-result {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.15s;
}
.gs-result:hover { background: var(--surface2); }

.gs-result-section {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--primary);
    background: var(--primary-dim); padding: 2px 8px; border-radius: 4px;
    white-space: nowrap; flex-shrink: 0;
}

.gs-result-title { font-weight: 600; font-size: 14px; }

.gs-result-matches {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
}

.gs-result-matches mark {
    background: rgba(108,92,231,0.15); color: var(--primary);
    padding: 0 2px; border-radius: 2px;
}

.gs-empty { text-align: center; color: var(--text-muted); padding: 24px; font-size: 14px; }

.gs-close {
    text-align: right; margin-bottom: 8px;
}

/* ---------- File Cards ---------- */

.file-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px;
    display: flex; align-items: center; gap: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.file-card:hover { border-color: var(--primary); box-shadow: 0 4px 16px rgba(108,92,231,0.1); }

.file-icon {
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--primary-dim); color: var(--primary);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; }
.file-info h4 { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.file-actions { display: flex; gap: 4px; }

/* ---------- Workspace Panels ---------- */

.workspace-welcome {
    text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.workspace-welcome h2 { font-size: 20px; color: var(--text); margin-bottom: 8px; }
.workspace-welcome p { font-size: 14px; }

.ws-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.ws-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; cursor: pointer; user-select: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
.ws-panel-header.open { border-bottom-color: var(--border); }
.ws-panel-header:hover { background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0; }

.ws-panel-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600;
}
.ws-panel-badge {
    font-size: 10px; padding: 2px 8px; border-radius: 12px;
    background: var(--primary-dim); color: var(--primary); font-weight: 600;
}
.ws-panel-actions { display: flex; gap: 4px; }
.ws-panel-body { padding: 12px 16px; }
.ws-panel-body.collapsed { display: none; }

.ws-add-section {
    display: flex; align-items: center; justify-content: center;
    padding: 24px; border: 2px dashed var(--border); border-radius: var(--radius);
    color: var(--text-muted); cursor: pointer; font-size: 14px;
    transition: all 0.15s;
}
.ws-add-section:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

/* Section type picker */
.type-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0;
}
.type-card {
    padding: 16px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    text-align: center; cursor: pointer; transition: all 0.15s;
    background: var(--surface);
}
.type-card:hover { border-color: var(--primary); background: var(--primary-dim); }
.type-card.selected { border-color: var(--primary); background: var(--primary-dim); box-shadow: 0 0 0 2px var(--primary); }
.type-card-icon { font-size: 24px; margin-bottom: 6px; }
.type-card-name { font-size: 13px; font-weight: 600; }
.type-card-desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* Simple field designer */
.field-designer-row {
    display: flex; gap: 8px; align-items: center; padding: 8px 12px;
    background: var(--surface2); border-radius: var(--radius-sm); margin-bottom: 6px;
}
.field-designer-row input { flex: 1; }
.field-designer-row .lock-toggle {
    display: flex; align-items: center; gap: 4px; cursor: pointer;
    padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); font-size: 12px; color: var(--text-muted); transition: all 0.15s;
}
.field-designer-row .lock-toggle.active {
    background: #fff3cd; border-color: #ffc107; color: #856404;
}
.field-designer-row .lock-toggle:hover { border-color: var(--primary); }
.field-designer-row .remove-field {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 18px; padding: 0 4px;
}
.field-designer-row .remove-field:hover { color: var(--danger); }

/* ---------- Category Notes Panel ---------- */

.ws-notes-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.ws-notes-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 600;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    user-select: none;
}
.ws-notes-header:hover { background: var(--surface2); border-radius: var(--radius) var(--radius) 0 0; }
.ws-notes-status { font-size: 11px; font-weight: 400; color: var(--success); }
.ws-notes-body { padding: 0; }
.ws-notes-body.collapsed { display: none; }
.ws-notes-body .ql-toolbar { border-left: none; border-right: none; border-top: none; }
.ws-notes-body .ql-container { border: none; }
.ws-notes-body .ql-editor { min-height: 80px; max-height: 300px; }

/* ---------- Rich Text Editor ---------- */

.ql-container { font-family: inherit; font-size: 14px; }
.ql-editor { min-height: 120px; max-height: 300px; overflow-y: auto; }
.ql-toolbar { background: var(--surface2); border-color: var(--border) !important; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ql-container.ql-snow { border-color: var(--border) !important; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.ql-editor.ql-blank::before { color: var(--text-muted); }
.rich-text-display { font-size: 13px; line-height: 1.6; }
.rich-text-display p { margin-bottom: 4px; }
.rich-text-display ul, .rich-text-display ol { padding-left: 20px; }

/* ---------- Record Links ---------- */

.links-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.links-section h4 { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }

.link-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    background: var(--surface2); border-radius: var(--radius-sm); margin-bottom: 4px;
    font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.link-item:hover { background: var(--primary-dim); }
.link-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--border); color: var(--text-muted); }
.link-name { flex: 1; font-weight: 500; }
.link-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; }
.link-remove:hover { color: var(--danger); }

.link-search-box { position: relative; margin-top: 8px; }
.link-search-box input { width: 100%; }
.link-search-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
    background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.link-search-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    cursor: pointer; font-size: 13px; transition: background 0.1s;
}
.link-search-item:hover { background: var(--primary-dim); }
.link-search-item .link-badge { flex-shrink: 0; }

/* ---------- Search Page (Full Screen) ---------- */

.search-page {
    position: fixed; inset: 0; z-index: 150;
    background: var(--bg);
    display: flex; flex-direction: column;
    animation: searchPageIn 0.15s ease-out;
}
@keyframes searchPageIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.search-page-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 32px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.search-page-input {
    flex: 1; font-size: 20px; font-weight: 500;
    background: transparent; border: none; outline: none;
    color: var(--text); padding: 8px 0;
}
.search-page-input::placeholder { color: #bbb; }

.search-page-close {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-muted); cursor: pointer; padding: 6px 14px;
    font-size: 13px; transition: all 0.15s;
}
.search-page-close:hover { background: var(--surface2); color: var(--text); }

.search-page-body {
    flex: 1; overflow-y: auto; padding: 20px 32px;
}

.search-page-status {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.search-page-status h2 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

.search-page-loading {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 40px;
}
.search-page-bar {
    width: 320px; height: 3px; background: var(--border); border-radius: 3px;
    overflow: hidden; position: relative;
}
.search-page-bar::after {
    content: ''; position: absolute; top: 0; left: -40%;
    width: 40%; height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: searchSlide 0.8s ease-in-out infinite;
}

.search-page-count {
    font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}

/* ---------- Search Group Header ---------- */

.search-group-header {
    font-size: 12px; color: var(--primary); text-transform: uppercase;
    margin: 20px 0 8px; padding: 6px 12px; border-radius: var(--radius-sm);
    transition: background 0.15s; display: inline-block;
}
.search-group-header:hover { background: var(--primary-dim); }
.search-group-header span { opacity: 0; transition: opacity 0.15s; }
.search-group-header:hover span { opacity: 1; }

/* ---------- Search Result Cards ---------- */

.search-result-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    transition: border-color 0.15s;
}
.search-result-card:hover { border-color: var(--primary); }

.search-result-header {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.search-result-title { flex: 1; font-size: 15px; }

.search-result-fields {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px;
}

.search-result-field {
    display: flex; flex-direction: column; gap: 1px; padding: 4px 0;
}
.search-result-label {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted);
}
.search-result-value {
    font-size: 13px; color: var(--text); word-break: break-word;
    line-height: 1.4; font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

@media (max-width: 768px) {
    .search-result-fields { grid-template-columns: 1fr; }
}

/* ---------- Search Loading ---------- */

.search-loading {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 40px 20px; color: var(--text-muted);
}

.search-loading-bar {
    width: 280px; height: 3px; background: var(--border); border-radius: 3px;
    overflow: hidden; position: relative;
}
.search-loading-bar::after {
    content: ''; position: absolute; top: 0; left: -40%;
    width: 40%; height: 100%; background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: searchSlide 1s ease-in-out infinite;
}
@keyframes searchSlide {
    0% { left: -40%; }
    100% { left: 100%; }
}

.search-loading-text {
    font-size: 13px; font-weight: 500;
    animation: searchPulse 1.5s ease-in-out infinite;
}
@keyframes searchPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.search-loading-dots::after {
    content: ''; animation: dots 1.5s steps(3, end) infinite;
}
@keyframes dots {
    0% { content: ''; }
    33% { content: '.'; }
    66% { content: '..'; }
    100% { content: '...'; }
}

/* ---------- Dialog (replaces alert/prompt) ---------- */

.dialog-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px); display: flex; align-items: center;
    justify-content: center; z-index: 300;
}
.dialog-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px; width: 420px; max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
.dialog-box h3 { font-size: 17px; margin-bottom: 12px; }
.dialog-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
.dialog-box input { margin-bottom: 16px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Nav Divider ---------- */

.nav-divider { height: 1px; background: var(--border); margin: 8px 14px; }

/* ---------- User Info ---------- */

.user-info {
    padding: 8px 14px; font-size: 12px; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.user-info .user-avatar {
    width: 24px; height: 24px; border-radius: 6px;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 10px; flex-shrink: 0;
}
.user-info .user-name { font-weight: 600; color: var(--text); }
.user-info .user-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }

/* ---------- Audit Log Table ---------- */

.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table th {
    text-align: left; padding: 8px 12px; background: var(--surface2);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.audit-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.audit-table tr:hover { background: var(--surface2); }

.audit-action {
    font-size: 11px; padding: 2px 8px; border-radius: 4px;
    font-weight: 600; display: inline-block;
}
.audit-action.login { background: #d4edda; color: #155724; }
.audit-action.secret_revealed { background: #fff3cd; color: #856404; }
.audit-action.record_created, .audit-action.record_updated { background: #cce5ff; color: #004085; }
.audit-action.record_deleted, .audit-action.file_deleted { background: #f8d7da; color: #721c24; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 16px; }

/* ---------- Attachment List ---------- */

.attach-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 0;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.attach-item:last-child { border-bottom: none; }
.attach-name { flex: 1; }
.attach-size { color: var(--text-muted); font-size: 11px; }

/* ---------- MFA Setup ---------- */

.mfa-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* ---------- Empty State ---------- */

.empty-state {
    text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.empty-state svg { margin-bottom: 20px; opacity: 0.2; }
.empty-state h2 { font-size: 20px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .sidebar .sidebar-header h2, .sidebar .nav-item span, .sidebar .sidebar-footer span { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 12px; }
    .sidebar .sidebar-header { justify-content: center; }
    .content { margin-left: var(--sidebar-collapsed); }
    .content-header { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
    .header-right { flex-wrap: wrap; width: 100%; }
    .search-box input { width: 140px; }
    .main { padding: 16px; }
    .records-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .lock-card { width: 90%; padding: 32px 24px; }
}
