/* ==========================================================================
   ERP LECE Group — sistema de diseño base
   Sin frameworks externos (Tailwind/Bootstrap): CSS propio, siguiendo el
   lenguaje visual de referencia (sidebar oscuro + acento índigo + cards
   blancas redondeadas).
   ========================================================================== */

:root {
    --sidebar-bg: #12141f;
    --sidebar-bg-elevated: #1a1d2b;
    --sidebar-text: #9295ab;
    --sidebar-text-active: #ffffff;
    --sidebar-border: #23273a;

    --accent: #2f6fed;
    --accent-hover: #2557c7;
    --accent-light: #e8f0fe;

    --bg-page: #f5f6fb;
    --card-bg: #ffffff;
    --border: #e6e7f0;

    --text-primary: #1c1e2b;
    --text-secondary: #6b6f85;
    --text-muted: #9598ab;

    --blue: #2563eb;
    --blue-bg: #e8f0fe;
    --amber: #b45309;
    --amber-bg: #fef3e2;
    --green: #16a34a;
    --green-bg: #e6f7ec;
    --red: #dc2626;
    --red-bg: #fdeaea;
    --purple: #7c3aed;
    --purple-bg: #f1ebfe;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --shadow-card: 0 1px 2px rgba(20, 21, 40, 0.04), 0 1px 6px rgba(20, 21, 40, 0.05);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select {
    font-family: inherit;
    font-size: inherit;
}

h1, h2, h3, h4, p {
    margin: 0;
}

/* ---------- Shell autenticado (sidebar + contenido) ---------- */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: margin-left 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar {
    margin-left: -264px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
}

.sidebar-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-brand-title {
    color: var(--sidebar-text-active);
    font-weight: 600;
    font-size: 14px;
}

.sidebar-brand-subtitle {
    font-size: 11px;
    color: var(--sidebar-text);
}

.sidebar-empresa {
    margin: 0 18px 12px;
    padding: 8px 10px;
    background: var(--sidebar-bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--sidebar-border);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item:hover {
    background: var(--sidebar-bg-elevated);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--accent);
    color: #fff;
}

.nav-item.active svg {
    opacity: 1;
}

.nav-section-label {
    margin: 16px 12px 4px;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    flex-shrink: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
}

.topbar-menu-toggle,
.topbar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.topbar-menu-toggle:hover,
.topbar-icon-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
    user-select: none;
}

.user-menu-trigger::-webkit-details-marker {
    display: none;
}

.user-menu-trigger:hover {
    background: var(--bg-page);
}

.user-menu-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-menu-name {
    font-size: 13.5px;
    font-weight: 600;
}

.user-menu[open] .user-menu-trigger {
    background: var(--bg-page);
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 12px 14px;
    z-index: 30;
}

.user-menu-fullname {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-role {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.user-menu-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--red);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
    cursor: pointer;
}

.user-menu-logout:hover {
    text-decoration: underline;
}

.notif-menu {
    position: relative;
}

.notif-menu-trigger {
    position: relative;
    list-style: none;
    cursor: pointer;
}

.notif-menu-trigger::-webkit-details-marker {
    display: none;
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
}

.notif-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    max-width: 90vw;
    max-height: 420px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 10px;
    z-index: 30;
}

.notif-menu-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: 4px 8px 8px;
}

.notif-item,
.notif-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
}

.notif-item:hover,
.notif-row:hover {
    background: var(--bg-page);
}

.notif-row {
    border-bottom: 1px solid var(--border);
}

.notif-row:last-child {
    border-bottom: none;
}

.notif-item-body,
.notif-row-body {
    flex: 1;
    min-width: 0;
}

.notif-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}

.notif-dot--danger { background: var(--red); }
.notif-dot--warning { background: var(--amber); }
.notif-dot--info { background: var(--accent); }

.notif-item-title,
.notif-row-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-item-desc,
.notif-row-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.notif-menu-viewall {
    display: block;
    text-align: center;
    padding: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.text-danger {
    color: var(--red);
    font-weight: 600;
}

.data-table tfoot td {
    border-top: 2px solid var(--border);
    font-weight: 600;
    background: var(--bg-page);
}

.empresa-switcher select {
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-page);
    color: var(--text-primary);
}

.content {
    padding: 28px;
    width: 100%;
}

/* ---------- Encabezados de página ---------- */

.page-header {
    margin-bottom: 22px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 13.5px;
}

.page-header--with-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

/* ---------- KPI cards ---------- */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 20px;
}

.kpi-card--blue { border-left-color: var(--blue); }
.kpi-card--amber { border-left-color: var(--amber); }
.kpi-card--green { border-left-color: var(--green); }
.kpi-card--purple { border-left-color: var(--purple); }

.kpi-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon--blue { background: var(--blue-bg); color: var(--blue); }
.kpi-icon--amber { background: var(--amber-bg); color: var(--amber); }
.kpi-icon--green { background: var(--green-bg); color: var(--green); }
.kpi-icon--purple { background: var(--purple-bg); color: var(--purple); }

.kpi-link {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
}

.kpi-link:hover {
    text-decoration: underline;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 6px;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ---------- Paginación ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 4px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 12.5px;
    color: var(--text-muted);
}

.pagination-links {
    display: flex;
    gap: 8px;
}

/* ---------- Modales ---------- */

dialog.modal {
    border: none;
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: var(--shadow-card);
    max-width: 480px;
    width: 92vw;
    color: var(--text-primary);
    background: var(--card-bg);
}

dialog.modal::backdrop {
    background: rgba(15, 18, 32, 0.55);
}

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

.modal-header h3 {
    font-size: 15px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 20px;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 18px 20px;
}

.modal-actions {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.doc-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ---------- Documento tipo factura (AR / AP) ---------- */

.invoice-doc {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 26px 28px;
    margin-bottom: 20px;
}

.invoice-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.invoice-doc-emisor-nombre {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
}

.invoice-doc-emisor-detalle {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.invoice-doc-tipo {
    border: 2px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    text-align: center;
    min-width: 230px;
    flex-shrink: 0;
}

.invoice-doc-tipo-rut {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--red);
}

.invoice-doc-tipo-nombre {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--red);
    text-transform: uppercase;
    margin: 5px 0;
}

.invoice-doc-tipo-folio {
    font-size: 13px;
    font-weight: 700;
    color: var(--red);
}

/* Variante no-fiscal (OC y otros documentos internos que no son DTE del SII) */
.invoice-doc-tipo--accent {
    border-color: var(--accent);
}

.invoice-doc-tipo--accent .invoice-doc-tipo-rut,
.invoice-doc-tipo--accent .invoice-doc-tipo-nombre,
.invoice-doc-tipo--accent .invoice-doc-tipo-folio {
    color: var(--accent);
}

.invoice-doc-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 18px;
}

.invoice-doc-meta-row {
    display: flex;
    gap: 8px;
    padding: 3px 0;
    font-size: 12.5px;
}

.invoice-doc-meta-row dt {
    color: var(--text-muted);
    min-width: 100px;
    flex-shrink: 0;
}

.invoice-doc-meta-row dd {
    margin: 0;
    color: var(--text-primary);
    font-weight: 500;
}

.invoice-doc-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 8px;
}

.invoice-doc-referencia {
    margin-bottom: 18px;
}

.invoice-doc-table-wrap {
    overflow-x: auto;
}

.invoice-doc-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.invoice-doc-words {
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary);
    text-transform: uppercase;
    max-width: 60%;
}

.invoice-doc-totales {
    min-width: 220px;
    margin-left: auto;
}

.invoice-doc-totales-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    gap: 20px;
}

.invoice-doc-totales-row.total {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 8px;
    font-weight: 700;
    font-size: 15px;
}

/* ---------- Panels genéricos ---------- */

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.panel h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-weight: 500;
    font-size: 13.5px;
}

.quick-action:hover {
    background: var(--bg-page);
}

/* ---------- Alertas ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    margin-bottom: 16px;
}

.alert-info {
    background: var(--blue-bg);
    color: #1d4ed8;
}

.alert-error {
    background: var(--red-bg);
    color: var(--red);
}

.alert-success {
    background: var(--green-bg);
    color: var(--green);
}

/* ---------- Filtros / buscador ---------- */

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.filter-bar input[type="text"] {
    flex: 1;
    max-width: 360px;
}

.filter-bar input,
.filter-bar select {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
}

/* ---------- Tablas ---------- */

.table-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.data-table th {
    text-align: left;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 32px !important;
}

.cell-empresa {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.avatar-letter {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12.5px;
    flex-shrink: 0;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.row-actions form {
    display: inline-flex;
}

.sync-form {
    align-items: center;
    gap: 6px !important;
}

.sync-form input[type="date"] {
    padding: 8px 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 13px;
}

.sync-form-sep {
    color: var(--text-muted);
    font-size: 12.5px;
}

/* ---------- Badges / pills ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-neutral { background: var(--bg-page); color: var(--text-secondary); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

.pill {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-gray { background: var(--bg-page); color: var(--text-muted); }
.pill-red { background: var(--red-bg); color: var(--red); }

.text-muted {
    color: var(--text-muted);
}

.field-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 14px;
}

/* ---------- Detail list (vistas de detalle tipo cliente) ---------- */

.detail-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 0;
}

.detail-list > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-list dt {
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.detail-list dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
}

/* ---------- Cards de integración ---------- */

.integration-card {
    display: block;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.integration-card:hover {
    border-color: var(--accent);
}

.integration-card h3 {
    font-size: 14.5px;
    margin: 4px 0;
}

.integration-card--disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---------- Botones ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
}

.btn-sm {
    padding: 6px 11px;
    font-size: 12.5px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-page);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg-page);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--red);
    border-color: var(--red-bg);
}

.btn-danger-ghost:hover {
    background: var(--red-bg);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-danger:hover {
    background: var(--red-hover, var(--red));
}

/* ---------- Formularios ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field span {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.field input,
.field select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
}

.field input,
.field select,
.field textarea,
.data-table input,
.data-table select {
    width: 100%;
}

.field textarea {
    resize: vertical;
    font-family: inherit;
}

.field input:focus,
.field select:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.field--wide {
    grid-column: 1 / -1;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}

/* ---------- Login / auth shell ---------- */

.auth-shell {
    display: flex;
    min-height: 100vh;
}

.auth-panel-left {
    flex: 1.1;
    background: linear-gradient(135deg, #2b3fd6 0%, #6a5cf5 100%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
}

.auth-brand {
    font-weight: 700;
    font-size: 14px;
    opacity: 0.9;
    letter-spacing: 0.02em;
}

.auth-panel-left h1 {
    font-size: 34px;
    font-weight: 700;
    line-height: 1.2;
    max-width: 480px;
}

.auth-panel-left p {
    max-width: 460px;
    opacity: 0.85;
    font-size: 14.5px;
}

.auth-feature-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 12px;
    max-width: 480px;
}

.auth-feature {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-feature strong {
    font-size: 13.5px;
}

.auth-feature span {
    font-size: 12px;
    opacity: 0.85;
}

.auth-panel-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 40px;
}

.auth-card {
    width: 100%;
    max-width: 360px;
}

.auth-card h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 13.5px;
    margin-bottom: 18px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-footer {
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- Error shell (404 / 500) ---------- */

.error-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
}

.error-card {
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 48px 56px;
}

.error-card h1 {
    font-size: 48px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 8px;
}

.error-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

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

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        margin-left: -264px;
    }

    .app-shell:not(.sidebar-collapsed) .sidebar {
        margin-left: 0;
        box-shadow: var(--shadow-card);
    }

    .app-shell.sidebar-collapsed .sidebar {
        margin-left: -264px;
    }

    .auth-panel-left {
        display: none;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}
