:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e2a38;
    --sidebar-hover: #2a3a4d;
    --topbar-height: 56px;
}

body { background: #f4f6f9; font-size: .95rem; }

/* Top bar */
.topbar { height: var(--topbar-height); z-index: 1040; }

/* Sidebar */
.sidebar { background: var(--sidebar-bg); color: #fff; }
.sidebar .nav-link {
    color: rgba(255, 255, 255, .75);
    padding: .6rem 1.25rem;
    display: flex; align-items: center; gap: .75rem;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar .nav-link:hover { color: #fff; background: var(--sidebar-hover); }
.sidebar .nav-link.active { color: #fff; background: var(--sidebar-hover); border-left-color: #0d6efd; font-weight: 600; }
.sidebar-heading {
    color: rgba(255, 255, 255, .4); font-size: .7rem; text-transform: uppercase;
    letter-spacing: .08em; padding: 1rem 1.25rem .35rem;
}

@media (min-width: 992px) {
    .sidebar {
        position: fixed; top: var(--topbar-height); bottom: 0; left: 0;
        width: var(--sidebar-width); overflow-y: auto; z-index: 1030;
    }
    .main-content { margin-left: var(--sidebar-width); }
}
@media (max-width: 991.98px) {
    .sidebar.offcanvas-lg { width: var(--sidebar-width); background: var(--sidebar-bg); }
}

.main-content { padding: calc(var(--topbar-height) + 20px) 20px 20px; min-height: 100vh; }
@media (max-width: 575.98px) { .main-content { padding-left: 10px; padding-right: 10px; } }

/* Cards */
.card { border: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04); border-radius: .6rem; }
.card-header { border-bottom: 1px solid #eef0f3; }
.form-card { max-width: 1000px; }
.tab-content.card { border: 1px solid #dee2e6; }
.nav-tabs .nav-link.active { background: #fff; }

/* KPI */
.kpi-card { color: inherit; transition: transform .15s, box-shadow .15s; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .1); }
.kpi-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0; }
.kpi-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; color: #1e2a38; }
.kpi-label { color: #6c757d; font-size: .85rem; }

/* Badges */
.type-badge { font-weight: 500; }
.audit-badge { background: #e9ecef; color: #343a40; }
.audit-action-create, .audit-action-upload { background: #d1e7dd !important; color: #0f5132 !important; }
.audit-action-update, .audit-action-config { background: #cfe2ff !important; color: #084298 !important; }
.audit-action-delete { background: #f8d7da !important; color: #842029 !important; }
.audit-action-login, .audit-action-logout, .audit-action-password { background: #fff3cd !important; color: #664d03 !important; }
.audit-diff th { width: 30%; background: #f8f9fa; }

/* Info grid */
.info-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; }
.info-value { font-weight: 500; word-break: break-word; }
.preserve-lines { white-space: pre-line; }

/* Inline config editing */
.config-field { padding: .55rem .25rem; border-bottom: 1px solid #f0f2f5; }
.config-field:last-child { border-bottom: 0; }
.config-field:hover { background: #fafbfc; }
.config-label { font-weight: 500; color: #495057; }
.config-display { display: flex; align-items: center; min-height: 31px; }
.config-display .config-edit-btn { opacity: .35; padding: 0 .5rem; }
.config-field:hover .config-edit-btn { opacity: 1; }
.config-field.saving .config-input { background-image: linear-gradient(90deg, #f8f9fa, #e9ecef, #f8f9fa); }
.config-field.saved { animation: savedFlash 1.2s ease; }
@keyframes savedFlash { 0% { background: #d1e7dd; } 100% { background: transparent; } }

/* Components */
.component-card { transition: box-shadow .15s; }
.component-card:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .1); }

/* Log */
.log-entry { border-left: 3px solid #0d6efd; background: #fff; padding: .65rem .9rem; margin-bottom: .6rem; border-radius: 0 .4rem .4rem 0; box-shadow: 0 1px 2px rgba(0, 0, 0, .05); }

/* File drop zone */
.drop-zone {
    border: 2px dashed #adb5bd; border-radius: .6rem; padding: 1.5rem; text-align: center;
    color: #6c757d; cursor: pointer; background: #fafbfc; transition: all .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: #0d6efd; background: #eef4ff; color: #0d6efd; }
.drop-zone.has-file { border-color: #198754; background: #eefaf3; color: #198754; }

/* Login */
.login-page { background: linear-gradient(135deg, #1e2a38 0%, #34495e 100%); }
.login-card { width: 100%; max-width: 400px; border-radius: 1rem; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: #0d6efd; color: #fff; font-size: 2rem; display: inline-flex; align-items: center; justify-content: center; }

/* Tables */
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table-sm > :not(caption) > * > * { padding: .4rem .5rem; }

/* Toasts */
.toast { min-width: 280px; }
