/* ====================================================
   MBS ConnectDocs — Enterprise Document Management UI
   Design: Dark Navy + Amber Accent, Clean & Professional
   ==================================================== */
.doc-section {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 56px);
    background: var(--panel-bg); /* ← THIS FIXES WHITE */
    color: var(--text);
}

.page-container {
    padding: 16px;
}
:root {
    --navy-900: #0B1929;
    --navy-800: #0F2238;
    --navy-700: #142D4C;
    --navy-600: #1A3A60;
    --navy-500: #1E4472;
    --navy-400: #2A5A8C;
    --amber: #F59E0B;
    --amber-light: #FCD34D;
    --amber-dark: #D97706;
    --accent-blue: #3B82F6;
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --accent-orange: #F97316;
    --surface-1: #F8FAFC;
    --surface-2: #F1F5F9;
    --surface-3: #E2E8F0;
    --border: #CBD5E1;
    --border-light: #E2E8F0;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-light: #CBD5E1;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,.10), 0 1px 2px -1px rgba(0,0,0,.10);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -2px rgba(0,0,0,.10);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.10);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,.10), 0 8px 10px -6px rgba(0,0,0,.10);
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--surface-1); color: var(--text-primary); overflow: hidden; }

/* ============ SHELL ============ */
.app-shell { display: flex; flex-direction: column; height: 100vh; }

/* ============ TOP BAR ============ */
.top-bar {
    height: var(--topbar-height);
    background: var(--navy-900);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    z-index: 100;
    border-bottom: 1px solid var(--navy-700);
    flex-shrink: 0;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; min-width: var(--sidebar-width); }
.top-bar-center { flex: 1; max-width: 600px; margin: 0 auto; }
.top-bar-right { display: flex; align-items: center; margin-left: auto; }

.sidebar-toggle {
    background: none; border: none; color: var(--text-light); cursor: pointer;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius); transition: var(--transition); font-size: 18px;
}
.sidebar-toggle:hover { background: var(--navy-700); color: var(--white); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 34px; height: 34px; background: linear-gradient(135deg, var(--amber), var(--amber-dark));
    border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
    color: var(--navy-900); font-size: 18px; flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { color: var(--white); font-weight: 700; font-size: 14px; letter-spacing: -0.3px; }
.brand-tagline { color: var(--text-muted); font-size: 10px; letter-spacing: 0.5px; text-transform: uppercase; margin-top: 1px; }

/* Global Search */
.global-search {
    display: flex; align-items: center; gap: 10px;
    background: var(--navy-700); border: 1px solid var(--navy-500);
    border-radius: var(--radius-md); padding: 0 14px; height: 38px;
    transition: var(--transition);
}
.global-search:focus-within {
    background: var(--navy-600); border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.global-search i { color: var(--text-muted); font-size: 14px; }
.global-search input {
    background: none; border: none; outline: none; color: var(--white);
    font-size: 13.5px; width: 100%; font-family: inherit;
}
.global-search input::placeholder { color: var(--text-muted); }
.search-clear { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; line-height: 1; }
.search-clear:hover { color: var(--white); }

/* Top bar actions */
.top-bar-actions { display: flex; align-items: center; gap: 4px; }
.tb-btn {
    width: 36px; height: 36px; background: none; border: none; color: var(--text-muted);
    cursor: pointer; border-radius: var(--radius); display: flex; align-items: center;
    justify-content: center; font-size: 17px; transition: var(--transition); position: relative;
}
.tb-btn:hover { background: var(--navy-700); color: var(--white); }
.badge-dot {
    position: absolute; top: 6px; right: 6px; width: 7px; height: 7px;
    background: var(--amber); border-radius: 50%; border: 1.5px solid var(--navy-900);
}
.user-avatar {
    width: 34px; height: 34px; background: linear-gradient(135deg, var(--accent-blue), var(--navy-400));
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: var(--white); font-weight: 600; font-size: 12px; cursor: pointer; margin-left: 8px;
    border: 2px solid var(--navy-600);
}

/* ============ APP BODY ============ */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--navy-800);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition);
    border-right: 1px solid var(--navy-700);
}
.sidebar.collapsed { width: 56px; }

.sidebar-section { padding: 16px 8px 8px; }
.sidebar-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); padding: 0 8px; margin-bottom: 4px;
    white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-label { opacity: 0; }

.sidebar-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    color: var(--text-light); text-decoration: none; border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500; transition: var(--transition);
    white-space: nowrap; overflow: hidden;
}
.sidebar-item i { font-size: 16px; flex-shrink: 0; }
.sidebar-item:hover { background: var(--navy-700); color: var(--white); }
.sidebar-item.active { background: var(--amber); color: var(--navy-900) !important; }
.sidebar-item.active i { color: var(--navy-900); }
.sidebar.collapsed .sidebar-item span { opacity: 0; width: 0; }

.sidebar-divider { height: 1px; background: var(--navy-700); margin: 8px 16px; }

.sidebar-footer {
    margin-top: auto; padding: 12px; border-top: 1px solid var(--navy-700);
}
.sidebar-version { font-size: 10px; color: var(--text-muted); text-align: center; }

/* ============ MAIN CONTENT ============ */
.main-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }

/* ============ BROWSER PAGE ============ */
.browser-layout { display: flex; height: 100%; overflow: hidden; }

/* Folder Tree Panel */
.folder-tree-panel {
    width: 280px;
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-1);
    flex-shrink: 0;
}
.panel-title { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-secondary); }

.folder-tree { flex: 1; overflow-y: auto; padding: 8px; }

/* Tree Node */
.tree-node { user-select: none; }
.tree-node-row {
    display: flex; align-items: center; gap: 4px; padding: 6px 8px;
    border-radius: var(--radius); cursor: pointer; transition: var(--transition);
    position: relative;
}
.tree-node-row:hover { background: var(--surface-2); }
.tree-node-row.selected { background: rgba(245, 158, 11, 0.12); }
.tree-node-row.selected .tree-node-name { color: var(--amber-dark); font-weight: 600; }

.tree-toggle {
    width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: var(--text-muted); flex-shrink: 0; transition: var(--transition);
}
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { opacity: 0; }

.tree-node-icon { font-size: 15px; flex-shrink: 0; }
.tree-node-name { font-size: 13px; font-weight: 500; flex: 1; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-node-count {
    font-size: 10px; color: var(--text-muted); background: var(--surface-2);
    padding: 1px 6px; border-radius: 10px; flex-shrink: 0;
}

.tree-children { padding-left: 16px; }

/* ============ DOCUMENT AREA ============ */
.document-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Toolbar */
.doc-toolbar {
    padding: 10px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.breadcrumb-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.breadcrumb-item {
    font-size: 13px; color: var(--text-secondary); cursor: pointer;
    padding: 2px 4px; border-radius: var(--radius-sm); transition: var(--transition);
}
.breadcrumb-item:hover { background: var(--surface-2); color: var(--text-primary); }
.breadcrumb-item.active { color: var(--text-primary); font-weight: 500; cursor: default; }
.breadcrumb-item.active:hover { background: none; }
.breadcrumb-sep { color: var(--text-muted); font-size: 12px; }

.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.btn-tool {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--white); color: var(--text-primary); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn-tool:hover { background: var(--surface-2); border-color: var(--navy-500); }
.btn-tool.primary { background: var(--navy-700); color: var(--white); border-color: var(--navy-700); }
.btn-tool.primary:hover { background: var(--navy-600); }
.btn-tool.amber { background: var(--amber); color: var(--navy-900); border-color: var(--amber); font-weight: 600; }
.btn-tool.amber:hover { background: var(--amber-dark); }
.btn-tool i { font-size: 14px; }
.btn-tool:disabled { opacity: 0.5; cursor: not-allowed; }

/* View Mode Toggle */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-btn {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    transition: var(--transition); font-size: 14px;
}
.view-btn.active { background: var(--navy-700); color: var(--white); }
.view-btn:hover:not(.active) { background: var(--surface-2); }

/* ============ DOCUMENT LIST ============ */
.doc-content { flex: 1; overflow-y: auto; padding: 16px 20px; }

/* Empty state */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 60px 20px; text-align: center; color: var(--text-muted);
}
.empty-state i { font-size: 56px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 300px; }

/* Document Table */
.doc-table { width: 100%; border-collapse: collapse; }
.doc-table th {
    text-align: left; padding: 8px 12px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600;
    border-bottom: 2px solid var(--border-light); white-space: nowrap;
}
.doc-table th.sortable { cursor: pointer; }
.doc-table th.sortable:hover { color: var(--text-secondary); }
.doc-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.doc-row { transition: var(--transition); cursor: pointer; }
.doc-row:hover td { background: var(--surface-1); }
.doc-row.selected td { background: rgba(245, 158, 11, 0.07); }
.doc-row:last-child td { border-bottom: none; }

.doc-name-cell { display: flex; align-items: center; gap: 10px; }
.doc-icon { font-size: 20px; flex-shrink: 0; }
.doc-name-info {}
.doc-name { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.doc-original { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.doc-meta-pill {
    font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 500;
    display: inline-block; margin-left: 6px;
}
.pill-checkedout { background: rgba(239, 68, 68, 0.12); color: #DC2626; }
.pill-template { background: rgba(59, 130, 246, 0.12); color: #2563EB; }

.doc-table td.muted { font-size: 12px; color: var(--text-muted); }
.doc-table td.version { font-size: 12px; color: var(--text-secondary); font-family: monospace; }

/* Grid View */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.doc-card {
    background: var(--white); border: 1px solid var(--border-light); border-radius: var(--radius-md);
    padding: 16px; cursor: pointer; transition: var(--transition); position: relative;
}
.doc-card:hover { border-color: var(--navy-400); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.doc-card.selected { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.doc-card-icon { font-size: 36px; text-align: center; margin-bottom: 10px; }
.doc-card-name { font-size: 12.5px; font-weight: 500; text-align: center; word-break: break-word; color: var(--text-primary); }
.doc-card-meta { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 4px; }
.doc-card-checkout {
    position: absolute; top: 6px; right: 6px;
    background: rgba(239, 68, 68, 0.12); color: #DC2626; border-radius: var(--radius-sm);
    font-size: 10px; padding: 2px 5px; font-weight: 600;
}

/* ============ DETAIL PANEL ============ */
.detail-panel {
    width: 360px;
    flex-shrink: 0;
    background: var(--white);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition);
}
.detail-panel.hidden { width: 0; border: none; }

.detail-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--surface-1);
    flex-shrink: 0;
}
.detail-doc-icon { font-size: 28px; margin-bottom: 8px; }
.detail-doc-name { font-size: 15px; font-weight: 600; color: var(--text-primary); word-break: break-word; }
.detail-doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.detail-actions {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}
.detail-action-btn {
    display: flex; align-items: center; gap: 5px; padding: 6px 10px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--white); color: var(--text-primary); font-size: 12px; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.detail-action-btn:hover { background: var(--surface-2); }
.detail-action-btn.danger { color: var(--accent-red); border-color: rgba(239,68,68,.3); }
.detail-action-btn.danger:hover { background: rgba(239,68,68,.06); }
.detail-action-btn.success { color: var(--accent-green); border-color: rgba(16,185,129,.3); }
.detail-action-btn.success:hover { background: rgba(16,185,129,.06); }
.detail-action-btn i { font-size: 13px; }

.detail-tabs { display: flex; border-bottom: 1px solid var(--border-light); }
.detail-tab {
    flex: 1; padding: 10px; text-align: center; font-size: 12px; font-weight: 500;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent;
    transition: var(--transition);
}
.detail-tab.active { color: var(--navy-600); border-bottom-color: var(--navy-600); }
.detail-tab:hover:not(.active) { color: var(--text-secondary); }

.detail-body { flex: 1; overflow-y: auto; padding: 16px; }

/* Field display */
.field-group { margin-bottom: 14px; }
.field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.field-value { font-size: 13.5px; color: var(--text-primary); }
.field-value.empty { color: var(--text-muted); font-style: italic; }

/* Field editing */
.field-edit input,
.field-edit textarea,
.field-edit select {
    width: 100%; padding: 6px 10px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13px; outline: none; transition: var(--transition);
    font-family: inherit; color: var(--text-primary); background: var(--white);
}
.field-edit input:focus,
.field-edit textarea:focus,
.field-edit select:focus { border-color: var(--navy-500); box-shadow: 0 0 0 3px rgba(30,68,114,0.08); }
.field-edit textarea { resize: vertical; min-height: 72px; }

.detail-save-bar {
    padding: 10px 16px; border-top: 1px solid var(--border-light);
    display: flex; gap: 8px; background: var(--surface-1); flex-shrink: 0;
}

/* Checkout badge in detail */
.checkout-badge {
    display: flex; align-items: center; gap: 8px; padding: 10px 12px;
    background: rgba(239, 68, 68, 0.07); border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius); margin-bottom: 12px; font-size: 12px;
}
.checkout-badge i { color: var(--accent-red); }
.checkout-badge strong { color: var(--accent-red); }

/* Audit entries */
.audit-entry {
    display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-light);
    font-size: 12px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-icon {
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; font-size: 12px;
}
.audit-icon.upload { background: rgba(16,185,129,.12); color: var(--accent-green); }
.audit-icon.download { background: rgba(59,130,246,.12); color: var(--accent-blue); }
.audit-icon.checkout { background: rgba(239,68,68,.12); color: var(--accent-red); }
.audit-icon.checkin { background: rgba(16,185,129,.12); color: var(--accent-green); }
.audit-icon.update { background: rgba(245,158,11,.12); color: var(--amber-dark); }
.audit-icon.delete { background: rgba(239,68,68,.12); color: var(--accent-red); }
.audit-icon.default { background: var(--surface-2); color: var(--text-muted); }
.audit-content { flex: 1; }
.audit-action { font-weight: 600; color: var(--text-primary); }
.audit-by { color: var(--text-muted); }
.audit-time { color: var(--text-muted); font-size: 11px; margin-top: 1px; }

/* ============ MODALS ============ */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; backdrop-filter: blur(3px);
}
.modal-box {
    background: var(--white); border-radius: var(--radius-xl); width: 520px;
    max-width: 95vw; max-height: 90vh; overflow: hidden;
    box-shadow: var(--shadow-xl); display: flex; flex-direction: column;
    animation: modalIn 200ms ease;
}
.modal-box.wide { width: 720px; }
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; border-bottom: 1px solid var(--border-light);
    background: var(--surface-1);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }
.modal-title i { color: var(--navy-600); }
.modal-close {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer; border-radius: var(--radius);
    color: var(--text-muted); transition: var(--transition); font-size: 18px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 24px; border-top: 1px solid var(--border-light);
    display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-1);
}

/* ============ FORM CONTROLS ============ */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-label.required::after { content: " *"; color: var(--accent-red); }
.form-control {
    width: 100%; padding: 8px 12px; border: 1.5px solid var(--border);
    border-radius: var(--radius-md); font-size: 13.5px; outline: none;
    transition: var(--transition); font-family: inherit; color: var(--text-primary);
    background: var(--white);
}
.form-control:focus { border-color: var(--navy-500); box-shadow: 0 0 0 3px rgba(30,68,114,0.08); }
.form-control.is-invalid { border-color: var(--accent-red); }
.form-text { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy-600); cursor: pointer; }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
    border-radius: var(--radius-md); border: 1.5px solid transparent;
    font-size: 13.5px; font-weight: 600; cursor: pointer; transition: var(--transition);
    font-family: inherit; white-space: nowrap;
}
.btn-primary { background: var(--navy-700); color: var(--white); border-color: var(--navy-700); }
.btn-primary:hover { background: var(--navy-600); }
.btn-secondary { background: var(--white); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--accent-red); color: var(--white); border-color: var(--accent-red); }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--accent-green); color: var(--white); border-color: var(--accent-green); }
.btn-success:hover { background: #059669; }
.btn-amber { background: var(--amber); color: var(--navy-900); border-color: var(--amber); }
.btn-amber:hover { background: var(--amber-dark); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ BADGES / STATUS ============ */
.badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 600;
}
.badge-active { background: rgba(16,185,129,.12); color: #047857; }
.badge-inactive { background: var(--surface-2); color: var(--text-muted); }
.badge-pending { background: rgba(245,158,11,.12); color: #B45309; }
.badge-error { background: rgba(239,68,68,.12); color: #B91C1C; }

/* ============ TEMPLATES PAGE ============ */
.page-container { padding: 24px; max-width: 1400px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 10px; }
.page-title i { color: var(--navy-600); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card {
    background: var(--white); border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg); overflow: hidden; transition: var(--transition);
}
.template-card:hover { border-color: var(--navy-400); box-shadow: var(--shadow-md); }

.template-card-header {
    padding: 16px; display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border-light);
}
.template-card-icon {
    width: 42px; height: 42px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--white);
}
.template-card-name { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.template-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.template-card-body { padding: 14px 16px; }
.template-field-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.field-chip {
    font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 500;
    background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border-light);
}
.template-card-footer {
    padding: 10px 16px; border-top: 1px solid var(--border-light);
    background: var(--surface-1); display: flex; justify-content: flex-end; gap: 6px;
}

/* ============ FIELDS PAGE ============ */
.fields-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.fields-table th {
    padding: 12px 16px; text-align: left; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600;
    background: var(--surface-1); border-bottom: 1.5px solid var(--border-light);
}
.fields-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); font-size: 13.5px; vertical-align: middle; }
.fields-table tr:last-child td { border-bottom: none; }
.fields-table tr:hover td { background: var(--surface-1); }

.field-type-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 10px; font-size: 11px; font-weight: 600;
}

/* ============ AUDIT PAGE ============ */
.audit-table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.audit-table th { padding: 12px 16px; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; background: var(--surface-1); border-bottom: 1.5px solid var(--border-light); }
.audit-table td { padding: 11px 16px; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: middle; }
.audit-table tr:last-child td { border-bottom: none; }
.audit-table tr:hover td { background: var(--surface-1); }

/* ============ UPLOAD DROPZONE ============ */
.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 32px;
    text-align: center; cursor: pointer; transition: var(--transition); background: var(--surface-1);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--navy-500); background: rgba(30,68,114,0.04); }
.upload-zone i { font-size: 36px; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone h4 { font-size: 15px; color: var(--text-secondary); font-weight: 600; }
.upload-zone p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============ ALERTS / TOASTS ============ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    border-left: 4px solid; animation: toastIn 300ms ease; min-width: 280px; max-width: 400px;
    font-size: 13.5px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }
.toast.info { border-color: var(--accent-blue); }
.toast.warning { border-color: var(--amber); }
.toast i.success { color: var(--accent-green); }
.toast i.error { color: var(--accent-red); }
.toast i.info { color: var(--accent-blue); }
.toast i.warning { color: var(--amber-dark); }

/* ============ STATS / OVERVIEW ============ */
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
    flex: 1; min-width: 150px; background: var(--white);
    border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    padding: 16px; display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 42px; height: 42px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ============ SCROLL ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ UTILITIES ============ */
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 12px; }
.fw-600 { font-weight: 600; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.not-found-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; text-align: center; }

/* Folder action btns */
.icon-btn {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: none; background: none; cursor: pointer; border-radius: var(--radius);
    color: var(--text-muted); transition: var(--transition); font-size: 13px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn.danger:hover { background: rgba(239,68,68,.1); color: var(--accent-red); }

/* Loading */
.spinner {
    display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--border);
    border-top-color: var(--navy-600); border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
    display: flex; align-items: center; justify-content: center; padding: 40px;
    flex-direction: column; gap: 12px; color: var(--text-muted);
}

/* Separator */
.separator { height: 1px; background: var(--border-light); margin: 12px 0; }

/* Move doc dialog */
.folder-select-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.folder-select-item {
    padding: 9px 14px; display: flex; align-items: center; gap: 10px;
    cursor: pointer; transition: var(--transition); font-size: 13.5px;
    border-bottom: 1px solid var(--border-light);
}
.folder-select-item:last-child { border-bottom: none; }
.folder-select-item:hover { background: var(--surface-1); }
.folder-select-item.active { background: rgba(245,158,11,.1); }

/* Info rows in detail */
.info-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: 12.5px; }
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); font-weight: 500; }
.info-row-value { color: var(--text-primary); font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

/* ============ DRAG & DROP ============ */
.doc-drop-area {
    position: relative;
}
.doc-drop-overlay {
    display: none;
    position: absolute;
    inset: 12px;
    border: 2.5px dashed var(--navy-400);
    border-radius: var(--radius-lg);
    background: rgba(30, 68, 114, 0.06);
    z-index: 10;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: var(--navy-600);
    font-weight: 600;
    font-size: 15px;
}
.doc-drop-area.drag-over .doc-drop-overlay { display: flex; }
.doc-drop-area.drag-over .doc-content { opacity: 0.3; pointer-events: none; }

/* Upload modal drop zone */
.upload-drop-zone {
    position: relative;
    border: 2.5px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 20px;
    text-align: center;
    background: var(--surface-1);
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
}
.upload-drop-zone.drag-active,
.upload-drop-zone:hover {
    border-color: var(--navy-500);
    background: rgba(30, 68, 114, 0.04);
}
.upload-drop-zone .drop-label { pointer-events: none; }
.upload-drop-zone .drop-label i { font-size: 38px; color: var(--text-muted); display: block; margin-bottom: 10px; }
.upload-drop-zone .drop-label h4 { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin: 0; }
.upload-drop-zone .drop-label p  { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 0; }
/* Invisible InputFile stretched over entire zone */
.upload-drop-zone input[type=file],
.upload-drop-zone > input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    font-size: 0;
}
.file-selected-info {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); padding: 10px 14px; margin-top: 12px;
}
.file-selected-info i { font-size: 22px; }
.file-selected-info .file-info-name { font-size: 13.5px; font-weight: 500; }
.file-selected-info .file-info-size { font-size: 12px; color: var(--text-muted); }
