/* ==========================================================================
   Postres Balcarce S.A. — Sistema de Diseño UI Air-Gapped (DOC-UI-00)
   App Shell Full-Width (100vw × 100vh) + Sidebar Izquierdo Colapsable + Forms
   ========================================================================== */

@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('../fonts/montserrat-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Open Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/open-sans-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
}

@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    font-weight: 100 700;
    font-display: block;
    src: url('../fonts/material-symbols-outlined.woff2') format('woff2');
}

:root,
[data-theme="light"] {
    /* Tokens oficiales DOC-UI-00 §5 (Light Mode) */
    --bg-canvas: #f7f5f0;
    --bg-surface: #ffffff;
    --bg-elevated: #f4f0e6;
    --bg-hover: #f4f0e6;
    --bg-input: #ffffff;
    --bg-topbar: #231d1a;
    --bg-sidebar: #231d1a;
    --bg-sidebar-hover: rgba(247, 200, 160, 0.09);
    --bg-sidebar-active: rgba(229, 160, 109, 0.20);

    --text-primary: #2b2420;
    --text-main: #2b2420;
    --text-secondary: #4a3f39;
    --text-muted: #786b62;
    --text-on-dark: #f4f0e6;
    --text-on-dark-muted: #b5aaa0;
    --text-topbar: #f4f0e6;
    --text-sidebar: #d8d1c2;
    --text-sidebar-active: #f7c8a0;

    --border-subtle: #e5dfd3;
    --border-strong: #c8beae;
    --border: #e5dfd3;
    --border-color: #e5dfd3;
    --border-input: #c8beae;
    --border-sidebar: #3b332e;

    --paper: #f4f0e6;
    --ink: #3b332e;
    --taupe: #b4a390;
    --linen: #d8d1c2;

    --primary: #754c32;
    --primary-hover: #5c3a24;
    --accent: #754c32;
    --accent-hover: #5c3a24;
    --accent-warm: #e5a06d;
    --accent-peach: #f7c8a0;
    --accent-soft: rgba(229, 160, 109, 0.18);

    /* Semáforo Intocable de Negocio (DOC-UI-00 §3.2) */
    --success: #166534;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-border: #86efac;

    --warning: #92400e;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-border: #fde68a;

    --danger: #991b1b;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --danger-border: #fca5a5;

    --info-bg: rgba(229, 160, 109, 0.18);
    --info-text: #5c3a24;
    --info-border: #e5a06d;

    --shadow-sm: 0 1px 3px 0 rgba(35, 29, 26, 0.06), 0 1px 2px -1px rgba(35, 29, 26, 0.04);
    --shadow-md: 0 4px 10px -2px rgba(35, 29, 26, 0.08), 0 2px 4px -2px rgba(35, 29, 26, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(35, 29, 26, 0.14), 0 8px 10px -6px rgba(35, 29, 26, 0.06);
}

[data-theme="dark"] {
    /* Tokens oficiales DOC-UI-00 §5 (Dark Mode) */
    --bg-canvas: #14110f;
    --bg-surface: #1e1916;
    --bg-elevated: #29221e;
    --bg-hover: #29221e;
    --bg-input: #161210;
    --bg-topbar: #100d0b;
    --bg-sidebar: #100d0b;
    --bg-sidebar-hover: rgba(247, 200, 160, 0.08);
    --bg-sidebar-active: rgba(229, 160, 109, 0.20);

    --text-primary: #f4f0e6;
    --text-main: #f4f0e6;
    --text-secondary: #d8d1c2;
    --text-muted: #a69b90;
    --text-on-dark: #f4f0e6;
    --text-on-dark-muted: #a69b90;
    --text-topbar: #f4f0e6;
    --text-sidebar: #d8d1c2;
    --text-sidebar-active: #f7c8a0;

    --border-subtle: #2e2622;
    --border-strong: #463a34;
    --border: #2e2622;
    --border-color: #2e2622;
    --border-input: #463a34;
    --border-sidebar: #2e2622;

    --paper: #1e1916;
    --ink: #f4f0e6;
    --taupe: #a69b90;
    --linen: #463a34;

    --primary: #e5a06d;
    --primary-hover: #f7c8a0;
    --accent: #e5a06d;
    --accent-hover: #f7c8a0;
    --accent-warm: #e5a06d;
    --accent-peach: #f7c8a0;
    --accent-soft: rgba(229, 160, 109, 0.16);

    --success: #4ade80;
    --success-bg: rgba(22, 101, 52, 0.28);
    --success-text: #86efac;
    --success-border: rgba(134, 239, 172, 0.35);

    --warning: #fbbf24;
    --warning-bg: rgba(146, 64, 14, 0.28);
    --warning-text: #fde68a;
    --warning-border: rgba(253, 230, 138, 0.35);

    --danger: #f87171;
    --danger-bg: rgba(153, 27, 27, 0.28);
    --danger-text: #fca5a5;
    --danger-border: rgba(252, 165, 165, 0.35);

    --info-bg: rgba(229, 160, 109, 0.16);
    --info-text: #f7c8a0;
    --info-border: rgba(229, 160, 109, 0.4);

    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 14px -2px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

:root {
    --font-heading: 'Montserrat', system-ui, -apple-system, Arial, sans-serif;
    --font-sans: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

    --fs-xs: 0.75rem;
    --fs-sm: 0.84rem;
    --fs-base: 0.925rem;
    --fs-md: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.35rem;
    --fs-2xl: 1.65rem;

    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-xl: 12px;

    --topbar-height: 56px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 68px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .page-title, .brand-link, .btn {
    font-family: var(--font-heading);
}

.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: var(--bg-elevated);
    padding: 0.12rem 0.38rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 1.2rem;
    width: 1em;
    height: 1em;
    overflow: hidden;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    user-select: none;
    flex-shrink: 0;
    vertical-align: middle;
}

html[data-icons="fallback"] .material-symbols-outlined {
    font-family: var(--font-sans);
    font-size: 1rem;
    width: 1.15em;
    height: 1.15em;
    overflow: visible;
    font-variation-settings: normal;
}

.icon-sm { font-size: 1.05rem; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 18; }
.icon-md { font-size: 1.25rem; font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20; }
.icon-lg { font-size: 1.5rem;  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.icon-xl { font-size: 2rem;    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 32; }

/* ─── App Shell ───────────────────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; width: 100%; }

.app-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    color: var(--text-topbar);
    border-bottom: 2px solid var(--accent-warm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    z-index: 100;
    gap: var(--sp-4);
}

.topbar-left { display: flex; align-items: center; gap: var(--sp-3); }

.sidebar-toggle-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-md);
    border: 1px solid rgba(244, 240, 230, 0.18);
    background: rgba(244, 240, 230, 0.06);
    color: var(--text-on-dark); cursor: pointer;
}
.sidebar-toggle-btn:hover { background: rgba(229, 160, 109, 0.22); }

.brand-link {
    display: inline-flex; align-items: center; gap: 0.65rem;
    color: var(--text-on-dark); font-weight: 700; font-size: 0.98rem; text-decoration: none;
}
.brand-link:hover { text-decoration: none; opacity: 0.95; }

.brand-logo-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.brand-subtitle { font-weight: 400; color: var(--text-on-dark-muted); font-size: 0.82rem; font-family: var(--font-sans); }

.topbar-right { display: flex; align-items: center; gap: var(--sp-3); }

.topbar-user {
    display: inline-flex; align-items: center; gap: 0.55rem;
    padding: 0.25rem 0.65rem;
    background: rgba(244, 240, 230, 0.07);
    border: 1px solid rgba(244, 240, 230, 0.15);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--text-on-dark);
}

.topbar-user-name { font-weight: 600; color: #ffffff; }

.topbar-user .badge {
    background: rgba(244, 240, 230, 0.14);
    color: #f4f0e6;
    border-color: rgba(244, 240, 230, 0.35);
}
.topbar-user .badge-blue, .topbar-user .badge-info {
    background: rgba(229, 160, 109, 0.24);
    color: #fde4cf;
    border-color: rgba(229, 160, 109, 0.6);
}
.topbar-user .badge-yellow, .topbar-user .badge-amber, .topbar-user .badge-warning {
    background: rgba(245, 158, 11, 0.22);
    color: #fde68a;
    border-color: rgba(251, 191, 36, 0.55);
}
.topbar-user .badge-green, .topbar-user .badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: #bbf7d0;
    border-color: rgba(74, 222, 128, 0.5);
}

.topbar-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 34px; padding: 0 0.65rem; border-radius: var(--radius-md);
    border: 1px solid rgba(244, 240, 230, 0.16);
    background: rgba(244, 240, 230, 0.06);
    color: var(--text-on-dark); font-size: var(--fs-sm); font-weight: 600; gap: 0.4rem; cursor: pointer;
}
.topbar-icon-btn:hover { background: rgba(229, 160, 109, 0.22); color: #ffffff; text-decoration: none; }

.topbar-logout-btn {
    border-color: rgba(252, 165, 165, 0.45);
    background: rgba(153, 27, 27, 0.25);
    color: #fecaca;
}
.topbar-logout-btn:hover { background: #991b1b; border-color: #991b1b; color: #ffffff; }

.app-body { display: flex; flex: 1; padding-top: var(--topbar-height); min-height: 100vh; width: 100%; }

.app-sidebar {
    position: fixed;
    top: var(--topbar-height); left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex; flex-direction: column; justify-content: space-between;
    z-index: 90;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden; overflow-y: auto;
}

.sidebar-nav { list-style: none; margin: 0; padding: var(--sp-3); display: flex; flex-direction: column; gap: 0.22rem; }

.sidebar-section-label {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-on-dark-muted); padding: 0.65rem 0.75rem 0.3rem; white-space: nowrap;
}

.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 0.75rem; border-radius: var(--radius-md);
    color: var(--text-sidebar); font-size: 0.86rem; font-weight: 500;
    text-decoration: none; white-space: nowrap; border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sidebar-link:hover { background: var(--bg-sidebar-hover); color: #ffffff; text-decoration: none; }

/* DOC-UI-00 Regla de Detalle Visual #2: activo #F7C8A0 + ícono #E5A06D + borde 3px #E5A06D */
.sidebar-link.active {
    background: var(--bg-sidebar-active);
    color: #f7c8a0;
    font-weight: 600;
    border-left-color: #e5a06d;
}
.sidebar-link.active .sidebar-icon { color: #e5a06d; }

.sidebar-icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-text { overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { padding: var(--sp-3); border-top: 1px solid var(--border-sidebar); display: flex; flex-direction: column; gap: var(--sp-2); }

.sidebar-collapse-footer-btn {
    display: flex; align-items: center; gap: 0.75rem; width: 100%;
    padding: 0.55rem 0.75rem; border-radius: var(--radius-md);
    border: 1px solid rgba(244, 240, 230, 0.12);
    background: rgba(244, 240, 230, 0.04);
    color: var(--text-on-dark-muted); font-size: 0.82rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.sidebar-collapse-footer-btn:hover { background: rgba(229, 160, 109, 0.14); color: #ffffff; }

.app-main {
    flex: 1; min-width: 0; margin-left: var(--sidebar-width);
    padding: 1.75rem 2.25rem;
    transition: margin-left 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-height));
}

.app-content { flex: 1; width: 100%; }

.app-footer {
    margin-top: var(--sp-8); padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
    color: var(--text-muted); font-size: var(--fs-xs);
}

html[data-sidebar="collapsed"] .app-sidebar { width: var(--sidebar-collapsed-width); }
html[data-sidebar="collapsed"] .app-main { margin-left: var(--sidebar-collapsed-width); }
html[data-sidebar="collapsed"] .sidebar-text,
html[data-sidebar="collapsed"] .sidebar-section-label { display: none; }
html[data-sidebar="collapsed"] .sidebar-link,
html[data-sidebar="collapsed"] .sidebar-collapse-footer-btn { justify-content: center; padding-left: 0; padding-right: 0; }
html[data-sidebar="collapsed"] .sidebar-chevron { transform: rotate(180deg); }

/* ─── Auth Shell (DOC-UI-00: fondo --paper #F4F0E6 y borde superior 3px #E5A06D) ─── */
.auth-shell {
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--topbar-height) + var(--sp-6)) var(--sp-4) var(--sp-6);
}

.auth-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent-warm);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth-logo-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-block;
    margin-bottom: var(--sp-2);
}

/* ─── Page Headers & Cards ────────────────────────────────────────────────── */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
    gap: var(--sp-4); margin-bottom: var(--sp-6); padding-bottom: var(--sp-4); border-bottom: 1px solid var(--border);
}

.page-title { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }
.page-subtitle { margin: 0.25rem 0 0 0; font-size: var(--fs-sm); color: var(--text-secondary); }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.card, .glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-5);
}

.card-featured { border-top: 3px solid var(--accent-warm); }

.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-md { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-6); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-4); }
.grid-4, .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sp-4); }

.kpi-card {
    background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.3rem;
}
.kpi-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--text-main); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* ─── Forms & Controls ────────────────────────────────────────────────────── */
.form-section-title {
    margin: 0 0 var(--sp-3) 0; padding-bottom: var(--sp-2); border-bottom: 1px solid var(--border);
    font-size: 0.95rem; font-weight: 700; color: var(--text-main); display: flex; align-items: center; gap: var(--sp-2);
}

.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-4); }
.form-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--sp-4); }

.form-group, .field { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group > label, .field > label, .form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-main); }

.form-control,
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    min-height: 40px;
    padding: 0.5rem 0.8rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-warm);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-hint, .field small, .form-group small { font-size: 0.76rem; color: var(--text-muted); line-height: 1.4; }

.form-check-row {
    display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.75rem 1rem;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.form-check-row input[type="checkbox"], input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 0.12rem; accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.form-check-row label { font-size: 0.88rem; font-weight: 500; color: var(--text-main); cursor: pointer; margin: 0; }

.validation-summary-valid { display: none !important; }
.field-error, .field-validation-error { font-size: 0.78rem; font-weight: 500; color: var(--danger-text); }
.field-validation-valid { display: none; }
.input-validation-error { border-color: var(--danger) !important; }

/* ─── Buttons (DOC-UI-00 Contraste WCAG AA/AAA) ───────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 38px; padding: 0.45rem 1rem; font-size: 0.84rem; font-weight: 600;
    border-radius: var(--radius-md); border: 1px solid var(--border-input);
    background: var(--bg-surface); color: var(--text-main); cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: all 0.15s ease;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}
[data-theme="dark"] .btn-primary { color: #1e1916; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #ffffff; }
[data-theme="dark"] .btn-primary:hover { color: #1e1916; }

.btn-accent-warm {
    background: #e5a06d;
    border-color: #e5a06d;
    color: #3b332e;
}
.btn-accent-warm:hover { background: #f7c8a0; border-color: #f7c8a0; color: #2b2420; }

.btn-secondary { background: var(--bg-surface); border-color: var(--border-input); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-elevated); }

.btn-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger:hover { background: #991b1b; border-color: #991b1b; color: #ffffff; }

.btn-sm { min-height: 30px; padding: 0.25rem 0.65rem; font-size: 0.78rem; }

/* ─── Badges & Alerts ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.18rem 0.6rem;
    font-size: 0.73rem; font-weight: 700; border-radius: 9999px;
    background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); white-space: nowrap;
}
.badge-green, .badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-yellow, .badge-amber, .badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-red, .badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.badge-blue, .badge-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }

.alert {
    display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md); border: 1px solid var(--border); margin-bottom: var(--sp-4);
    font-size: var(--fs-sm); font-weight: 500;
}
.alert ul { margin: 0; padding-left: 1.2rem; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }

/* ─── Tables & Empty States ───────────────────────────────────────────────── */
.table-container, .table-wrap {
    width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface);
}
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
    background: var(--bg-elevated); color: var(--text-secondary); font-size: 0.73rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; text-align: left; padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 0.72rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-main); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; gap: var(--sp-3); padding: 2.5rem 1.5rem;
    border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--bg-elevated);
}
.empty-state-icon { font-size: 2.5rem; color: var(--taupe); }

/* ─── Pagination ──────────────────────────────────────────────────────────── */
.pagination-container { margin-top: var(--sp-3); display: flex; justify-content: flex-end; }
.pagination { list-style: none; display: flex; gap: 0.35rem; margin: 0; padding: 0; }
.page-link {
    display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
    padding: 0 0.5rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-main); font-size: var(--fs-xs); font-weight: 600;
}
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.page-item.disabled .page-link { opacity: 0.45; pointer-events: none; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-sidebar { transform: translateX(0); }
    html[data-sidebar="collapsed"] .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
    .app-main, html[data-sidebar="collapsed"] .app-main { margin-left: 0; padding: 1.25rem 1rem; }
    .brand-subtitle { display: none; }
}

/* ─── Google OAuth & Legal Pages ──────────────────────────────────────────── */
.btn-google-oauth {
    width: 100%; min-height: 44px; padding: 0.65rem 1rem; display: inline-flex; align-items: center; justify-content: center;
    gap: 0.65rem; border-radius: var(--radius-md); border: 1px solid var(--border-input);
    background-color: var(--bg-surface); color: var(--text-main); font-family: var(--font-heading);
    font-size: 0.9rem; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm);
}
.btn-google-oauth:hover { border-color: var(--accent-warm); background-color: var(--bg-elevated); }

.oauth-divider {
    display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); font-size: 0.76rem; font-weight: 600;
}
.oauth-divider::before, .oauth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.auth-main-wide { align-items: flex-start; padding-top: calc(var(--topbar-height) + var(--sp-6)); }
.public-doc-container { width: 100%; max-width: 880px; margin: 0 auto; }

.legal-tabs {
    display: inline-flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.3rem;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.legal-tab {
    display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.9rem;
    border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
}
.legal-tab.active { background: var(--accent); color: #ffffff; }

.legal-doc { display: flex; flex-direction: column; gap: var(--sp-5); line-height: 1.65; font-size: 15px; border-top: 3px solid var(--accent-warm); }
.legal-section { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.legal-section:first-of-type { padding-top: 0; border-top: none; }
.legal-section h2 { margin: 0; font-size: var(--fs-md); color: var(--text-main); display: flex; align-items: center; gap: 0.5rem; }
.legal-section p, .legal-section li { margin: 0; font-size: 0.9375rem; color: var(--text-secondary); }
.legal-section ul { margin: 0.25rem 0 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.legal-highlight { padding: var(--sp-4); border-radius: var(--radius-md); background: var(--bg-elevated); border-left: 4px solid var(--accent-warm); font-size: var(--fs-sm); color: var(--text-main); }
.legal-links-inline { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.5rem; font-size: var(--fs-xs); color: var(--text-muted); }

/* ─── Step-Up MFA Dialog & Chat Playground ────────────────────────────────── */
.mfa-dialog {
    padding: 0; margin: auto; max-width: 440px; width: calc(100% - 2rem);
    border: 1px solid var(--border); border-top: 3px solid var(--accent-warm);
    border-radius: var(--radius-lg); background: var(--bg-surface); color: var(--text-main); box-shadow: var(--shadow-lg);
}
.mfa-dialog::backdrop { background: rgba(20, 17, 15, 0.72); backdrop-filter: blur(3px); }
.mfa-dialog-body { padding: var(--sp-6); }

.chat-messages { display: flex; flex-direction: column; gap: var(--sp-3); max-height: 520px; overflow-y: auto; padding: var(--sp-3); background: var(--bg-canvas); border: 1px solid var(--border); border-radius: var(--radius-md); }
.chat-bubble { padding: 0.85rem 1rem; border-radius: var(--radius-md); max-width: 85%; font-size: var(--fs-sm); line-height: 1.55; }
.chat-bubble-user { align-self: flex-end; background: var(--accent); color: #ffffff; }
[data-theme="dark"] .chat-bubble-user { color: #1e1916; }
.chat-bubble-model { align-self: flex-start; background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main); }
.copilot-toggles-row { display: flex; flex-wrap: wrap; gap: 0.65rem 1.15rem; align-items: center; }
.copilot-toggle-label { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.copilot-tool-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }
.copilot-source-list { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.55rem; padding-top: 0.45rem; border-top: 1px dashed var(--border); }
.copilot-source-pill { display: inline-flex; align-items: center; padding: 0.14rem 0.5rem; border-radius: 9999px; background: var(--accent-soft); border: 1px solid var(--border-strong); color: var(--accent); font-size: 0.72rem; font-weight: 600; text-decoration: none; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copilot-source-pill:hover { text-decoration: underline; }
.copilot-inspector-card { padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-left: 3px solid var(--accent-warm); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.copilot-inspector-title { font-size: 0.74rem; font-weight: 700; color: var(--text-main); }
.copilot-source-link { display: block; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--accent); font-size: 0.74rem; font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copilot-source-link:hover { border-color: var(--accent-warm); text-decoration: underline; }
.copilot-inline-link { color: var(--accent); font-weight: 600; text-decoration: underline; }

/* ─── Comercial CRM Fase 2A (HTMX Indicator, Split 360, Timeline, Quick Pills) */
.htmx-indicator { opacity: 0; transition: opacity 0.15s ease-in; font-size: var(--fs-xs); color: var(--accent); font-weight: 600; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.split-360 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 1080px) { .split-360 { grid-template-columns: 1fr; } }
.timeline-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.timeline-item { padding: var(--sp-3) var(--sp-4); background: var(--bg-canvas); border: 1px solid var(--border); border-left: 3px solid var(--accent-warm); border-radius: var(--radius-md); }
.quick-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pill-btn { padding: 0.2rem 0.65rem; border-radius: 9999px; border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text-secondary); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.pill-btn:hover { border-color: var(--accent-warm); background: var(--accent-soft); color: var(--text-main); }
.tag-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.12rem 0.48rem; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); font-size: 0.7rem; font-weight: 600; color: var(--text-secondary); }
