/* ── Design System ─────────────────────────────────────────────────── */
:root {
    --primary: #1a3a5c;
    --primary-light: #2a5a8c;
    --primary-dark: #0f2440;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-content {
    flex: 1;
    padding: 1.5rem 2rem;
    max-width: 100vw;
}

/* ── Barra superior (topbar) ─────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    padding: 0 1.25rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.brand-logo {
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: .85rem;
    padding: .35rem .5rem;
    border-radius: 6px;
    letter-spacing: .5px;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.brand-badge {
    background: var(--accent);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    padding: .15rem .4rem;
    border-radius: 3px;
    letter-spacing: .8px;
}

/* ── Menú horizontal con dropdowns ───────────────────────────────────── */
.topnav {
    display: flex;
    align-items: stretch;
    height: 100%;
    flex: 1;
    min-width: 0;
}

.topnav-item {
    position: relative;
    display: flex;
    align-items: stretch;
}

.topnav-link {
    display: flex;
    align-items: center;
    gap: .3rem;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    background: none;
    border: none;
    font: inherit;
    font-size: .9rem;
    padding: 0 .9rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.topnav-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.topnav-link.active {
    color: #fff;
    border-bottom-color: var(--accent);
}

.caret {
    font-size: .65rem;
    opacity: .7;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: var(--primary-dark);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .4rem 0 .6rem;
    z-index: 950;
}

.dropdown-right { left: auto; right: 0; }

.topnav-item:hover .dropdown,
.topnav-item:focus-within .dropdown {
    display: block;
}

.dropdown-header {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
    padding: .6rem 1rem .3rem;
}

.dropdown a {
    display: block;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .88rem;
    padding: .5rem 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.dropdown a:hover {
    background: var(--accent);
    color: #fff;
}

/* ── Lado derecho: buscador global + usuario + salir ─────────────────── */
.topbar-right {
    display: flex;
    align-items: center;
    gap: .9rem;
    flex-shrink: 0;
    margin-left: auto;
}

.global-search {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search .search-icon {
    position: absolute;
    left: .6rem;
    font-size: .75rem;
    opacity: .6;
    pointer-events: none;
}

.global-search input {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 6px;
    color: #fff;
    font-size: .85rem;
    padding: .42rem .7rem .42rem 2rem;
    width: 220px;
    transition: var(--transition);
}

.global-search input::placeholder { color: rgba(255,255,255,.5); }

.global-search input:focus {
    outline: none;
    background: rgba(255,255,255,.18);
    border-color: var(--accent);
    width: 280px;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--primary-dark);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .3rem 0 .5rem;
    z-index: 960;
}

.search-results a {
    display: block;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: .85rem;
    padding: .45rem 1rem;
    cursor: pointer;
}

.search-results a:hover { background: var(--accent); color: #fff; }

.search-empty {
    color: rgba(255,255,255,.55);
    font-size: .85rem;
    padding: .6rem 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}

.user-name { font-size: .88rem; font-weight: 600; }

.user-badge {
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    font-size: .68rem;
    font-weight: 600;
    padding: .12rem .45rem;
    border-radius: 10px;
}

.btn-salir {
    background: #fff;
    color: var(--primary-dark);
    border: none;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    padding: .4rem .9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-salir:hover { background: var(--danger); color: #fff; }

.link-button {
    background: none;
    border: none;
    color: rgba(255,255,255,.65);
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: .82rem;
    text-align: left;
}

.link-button:hover { color: #fff; }

/* ── Page Header ─────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius);
    border: none;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
    background: #e2e8f0;
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: .88rem;
    padding: .25rem .5rem;
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-link:hover { background: rgba(59,130,246,.1); }

.icon { font-size: 1.1rem; line-height: 1; }

/* ── Action bar (frmPrincipal ribbon style) ──────────────────────────── */
.action-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    box-shadow: var(--shadow-sm);
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.action-group-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    font-weight: 600;
}

.action-buttons {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

/* ── Button variants ──────────────────────────────────────────────── */
.btn-success {
    background: #16a34a;
    color: white;
    border: none;
    padding: .5rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.btn-success:hover { background: #15803d; }

.btn-danger {
    background: #dc2626;
    color: white;
    border: none;
    padding: .5rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.btn-danger:hover { background: #b91c1c; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    gap: .75rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 .75rem;
    flex: 1;
    max-width: 420px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.search-icon { font-size: .9rem; opacity: .5; margin-right: .5rem; }

.search-box input {
    flex: 1;
    border: none;
    padding: .6rem 0;
    font-size: .92rem;
    background: transparent;
    outline: none;
    font-family: var(--font);
}

.result-count {
    font-size: .85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Table ───────────────────────────────────────────────────────────── */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: .7rem .9rem;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: .65rem .9rem;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.data-table tbody tr:hover { background: #f8fafc; }

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.data-table td.mono { font-family: "SF Mono", "Cascadia Code", monospace; font-size: .85rem; }

.data-table .row-inactive { opacity: .6; }

.muted { color: var(--text-secondary); font-size: .88rem; }

.text-warning { color: var(--warning); font-weight: 600; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
}

.badge-active {
    background: rgba(16,185,129,.12);
    color: var(--success);
}

.badge-inactive {
    background: rgba(239,68,68,.1);
    color: var(--danger);
}

/* ── Card ────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Tabs ────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
    overflow-x: auto;
}

.tab {
    padding: .75rem 1.25rem;
    border: none;
    background: none;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font);
}

.tab:hover { color: var(--text); }

.tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content {
    padding: 1.5rem;
}

/* ── Form Grid ───────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}

.field { display: flex; flex-direction: column; gap: .3rem; }

.field-full { grid-column: 1 / -1; }

.field label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.field input, .field select, .field textarea {
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-family: var(--font);
    transition: var(--transition);
    background: #fff;
    color: var(--text);
}

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.field input.input-uppercase { text-transform: uppercase; }

.field input.input-sm { max-width: 140px; }

.field input.input-disabled {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
}

.field textarea { resize: vertical; min-height: 44px; }

/* ── Días de semana (checkboxes) ─────────────────────────────────────── */
.dias-semana {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.dia-check {
    display: flex;
    align-items: center;
    gap: .3rem;
    padding: .4rem .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    font-size: .88rem;
    user-select: none;
}

.dia-check input { display: none; }

.dia-check.checked {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.dia-check:hover:not(.checked) { border-color: var(--accent); }

/* ── Vendedores ──────────────────────────────────────────────────────── */
.vendedores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .4rem;
}

.vnd-check {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    font-size: .88rem;
    user-select: none;
}

.vnd-check input { }
.vnd-check.checked {
    background: rgba(59,130,246,.08);
    border-color: var(--accent);
}

/* ── Form Actions ────────────────────────────────────────────────────── */
.form-actions {
    display: flex;
    gap: .75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* ── Info Grid (Historial tab) ───────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.info-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.info-value {
    font-size: .95rem;
    color: var(--text);
}

/* ── States ──────────────────────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ── Alert ───────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    margin-top: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ── Login ───────────────────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(16,185,129,.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(245,158,11,.06) 0%, transparent 50%),
        linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1e3a5f 100%);
    position: relative;
    overflow: hidden;
}

.login-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(255,255,255,.02) 60px, rgba(255,255,255,.02) 61px),
        repeating-linear-gradient(0deg, transparent, transparent 60px, rgba(255,255,255,.02) 60px, rgba(255,255,255,.02) 61px);
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 2.5rem 2.5rem 2rem;
    width: 380px;
    box-shadow:
        0 4px 6px -1px rgba(0,0,0,.08),
        0 10px 25px -6px rgba(0,0,0,.12),
        0 0 0 1px rgba(255,255,255,.08);
    position: relative;
    z-index: 1;
    animation: loginIn .4s ease-out;
}

@keyframes loginIn {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    border-radius: 14px;
    margin-bottom: .75rem;
    box-shadow: 0 4px 12px rgba(59,130,246,.3);
}

.login-brand h1 {
    margin: 0 0 .25rem;
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -.3px;
}

.login-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: .9rem;
}

.login-alert {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .7rem .85rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #b91c1c;
    font-size: .88rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    animation: shakeIn .35s ease-out;
}

@keyframes shakeIn {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-4px); }
    40%  { transform: translateX(4px); }
    60%  { transform: translateX(-2px); }
    80%  { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

.login-alert-icon {
    flex-shrink: 0;
    opacity: .8;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.login-field label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: .3px;
    text-transform: uppercase;
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: .75rem;
    color: var(--text-secondary);
    opacity: .6;
    pointer-events: none;
    transition: var(--transition);
}

.login-input-wrap input {
    width: 100%;
    padding: .65rem .85rem .65rem 2.5rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: .92rem;
    font-family: var(--font);
    color: var(--text);
    background: #f8fafc;
    transition: all .2s ease;
    box-sizing: border-box;
}

.login-input-wrap input::placeholder {
    color: #94a3b8;
    font-size: .88rem;
}

.login-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(59,130,246,.1);
}

.login-input-wrap:focus-within .login-input-icon {
    color: var(--accent);
    opacity: 1;
}

.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: .15rem;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: .45rem;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text-secondary);
    user-select: none;
}

.login-remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.login-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .7rem 1rem;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all .25s ease;
    margin-top: .35rem;
    box-shadow: 0 4px 14px rgba(59,130,246,.3);
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59,130,246,.4);
}

.login-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59,130,246,.25);
}

.login-btn-arrow {
    transition: transform .2s ease;
}

.login-btn:hover .login-btn-arrow {
    transform: translateX(3px);
}

/* ── Modal genérico ──────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    width: 420px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-box input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: .55rem .7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: .75rem 0;
}

.modal-list { overflow-y: auto; flex: 1; border-top: 1px solid var(--border); }

.modal-list-item {
    padding: .6rem .5rem;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: var(--transition);
}

.modal-list-item:hover { background: #f1f5f9; }

/* ── Dashboard / KPI cards ──────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.kpi-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.kpi-label {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .3rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* ── Row states ─────────────────────────────────────────────────────── */
.row-warning td { background-color: #fffbe6 !important; }
.row-inactive td { opacity: .65; }

.hover-row:hover td { background-color: #f0f7ff !important; }

/* ── Nav buttons (searchControl) ────────────────────────────────────── */
.nav-controls {
    display: flex;
    gap: .35rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn-nav {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .35rem .65rem;
    font-size: .9rem;
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

.btn-nav:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-nav:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ── Icon buttons ─────────────────────────────────────────────────── */
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 4px;
    font-size: .85rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-icon:hover { background: #fee2e2; color: var(--danger); }
.btn-icon:disabled { opacity: .3; cursor: not-allowed; }

/* ── Text colors ─────────────────────────────────────────────────── */
.text-info { color: #2563eb; font-weight: 600; }

/* ── MovimientoForm layout ─────────────────────────────────────────── */
.mov-form-hdr {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    width: 100%;
    margin-bottom: .5rem;
}

.mov-hdr-field {
    flex: 1;
    min-width: 140px;
}

.mov-hdr-field label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .25rem;
}

.mov-hdr-field input,
.mov-hdr-field select {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    background: white;
    font-family: var(--font);
    transition: var(--transition);
    box-sizing: border-box;
}

.mov-hdr-field input:focus,
.mov-hdr-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.mov-line-entry {
    width: 100%;
}

.mov-line-controls {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
}

/* ── Field helper text ───────────────────────────────────────────── */
.field-hint {
    display: block;
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .2rem;
    line-height: 1.3;
}

/* ── Modal overlay (AddArt dialog) ───────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn .2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 1rem; }

.modal-body { padding: 1rem 1.2rem; overflow-y: auto; flex: 1; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding: .75rem 1.2rem;
    border-top: 1px solid var(--border);
}

/* ── Blazor defaults ─────────────────────────────────────────────────── */
h1:focus { outline: none; }

.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }

.invalid { outline: 1px solid var(--danger); }

.validation-message { color: var(--danger); font-size: .82rem; }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after { content: "An error has occurred."; }

.darker-border-checkbox.form-check-input { border-color: #929292; }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

/* ── Facturacion layout ─────────────────────────────────────────── */
.fac-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.fac-main { flex: 1; min-width: 0; }

.fac-sidebar {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 1.5rem;
}

@media (max-width: 900px) {
    .fac-layout { flex-direction: column; }
    .fac-sidebar { width: 100%; position: static; }
}

.fac-hdr {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.fac-hdr:last-child { margin-bottom: 0; }

.fac-hdr-field {
    flex: 1;
    min-width: 130px;
}

.fac-hdr-field label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .25rem;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.fac-hdr-field input,
.fac-hdr-field select {
    width: 100%;
    padding: .45rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    background: white;
    font-family: var(--font);
    transition: var(--transition);
    box-sizing: border-box;
}

.fac-hdr-field input:focus,
.fac-hdr-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.fac-hdr-field input.input-uppercase { text-transform: uppercase; }

.fac-lineas-toolbar {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
}

.fac-totales {
    padding: .75rem 1rem;
}

.fac-total-row {
    display: flex;
    justify-content: space-between;
    padding: .25rem 0;
    font-size: .9rem;
}

.fac-total-val { font-weight: 600; font-variant-numeric: tabular-nums; }

.fac-total-final {
    border-top: 2px solid var(--text);
    margin-top: .5rem;
    padding-top: .5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* ── Facturacion bottom row (Precios left + Totales right) ──── */
.fac-bottom {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.fac-bottom-precios {
    flex: 0 0 280px;
    min-width: 0;
}
.fac-bottom-precios .table-container {
    max-height: 200px;
    overflow-y: auto;
}
.fac-bottom-totales {
    flex: 1;
    min-width: 0;
}
@media (max-width: 800px) {
    .fac-bottom { flex-direction: column; }
    .fac-bottom-precios { flex: 1; }
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

.input-sm {
    padding: .4rem .5rem !important;
    font-size: .85rem !important;
}

.input-disabled {
    background: #f1f5f9 !important;
    color: var(--text-secondary) !important;
    cursor: not-allowed !important;
}

.input-uppercase { text-transform: uppercase; }

.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.mono { font-family: "SF Mono", "Cascadia Code", monospace; }

/* ── Blazor overrides for date input ───────────────────────────── */
input[type="date"] { min-height: 38px; }

/* ── Badge variants for prestamos ──────────────────────────────── */
.badge-pending { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-success { background: rgba(16,185,129,.12); color: var(--success); }

/* ── Filter select (Index) ─────────────────────────────────────── */
.filter-select {
    padding: .45rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    background: var(--bg-card);
    color: var(--text);
    font-family: var(--font);
    min-width: 160px;
}

/* ── Select-with-search (Edit / Pago) ──────────────────────────── */
.select-with-search {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.select-with-search input {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}
.select-with-search select {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
    min-height: 100px;
    font-size: .85rem;
}
.select-with-search select option {
    padding: .25rem .5rem;
}

/* ── Calc summary cards (Edit / Simulador) ─────────────────────── */
.calc-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.calc-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.calc-label {
    display: block;
    font-size: .8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: .35rem;
}
.calc-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

/* ── Fiador rows (Edit) ─────────────────────────────────────────── */
.fiadores-section { padding: 1rem; }
.fiador-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: .75rem;
    align-items: end;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
}
.fiador-row:last-child { border-bottom: none; }

/* ── Row highlight ─────────────────────────────────────────────── */
.data-table .row-success { background: rgba(16,185,129,.05); }

/* ── Input monto ───────────────────────────────────────────────── */
.input-monto { font-weight: 600; font-size: 1.05rem !important; }

/* ── Page header left (for Edit with badge) ────────────────────── */
.page-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ── Prestamo form (WinForms replica) ──────────────────────────── */
.prestamo-form, .winforms-form {
    max-width: 820px;
    margin: 0 auto;
}

/* Search bar (WinForms searchControl) */
.search-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .35rem .5rem;
    background: #e8efe5;
    border: 1px solid #a3c293;
    border-radius: var(--radius-sm);
    margin-bottom: .5rem;
    gap: .5rem;
    flex-wrap: wrap;
}
.search-left, .search-nav {
    display: flex;
    align-items: center;
    gap: .2rem;
}
.search-left .btn-nav, .search-nav .btn-nav {
    padding: .25rem .5rem;
    font-size: .85rem;
    min-width: 32px;
    text-align: center;
    background: #f0f7ed;
    border: 1px solid #b8d4a8;
    border-radius: 3px;
    cursor: pointer;
    color: #2d5016;
}
.search-left .btn-nav:hover, .search-nav .btn-nav:hover {
    background: #d4e8ca;
}
.search-left .btn-nav:disabled, .search-nav .btn-nav:disabled {
    opacity: .4;
    cursor: default;
}
.search-left .btn-danger { color: #c00; }
.nav-pos {
    font-size: .82rem;
    color: #3a5a2a;
    font-weight: 600;
    padding: 0 .35rem;
    min-width: 50px;
    text-align: center;
}

/* Group panel (WinForms GroupPanel) */
.group-panel {
    border: 1px solid #72a45a;
    border-radius: var(--radius);
    margin-bottom: .5rem;
    overflow: hidden;
    background: #fff;
}
.group-header {
    background: linear-gradient(to bottom, #c3d9b9, #9cbf8b);
    color: #3c4a1f;
    font-weight: 600;
    font-size: .88rem;
    padding: .35rem .75rem;
    letter-spacing: .3px;
}
.group-body {
    padding: .5rem .75rem;
}

/* Prestamo grid (WinForms TableLayoutPanel) */
.prestamo-grid {
    display: grid;
    grid-template-columns: 110px 1fr 40px 110px 1fr;
    gap: .4rem .35rem;
    align-items: center;
}
.grid-label {
    font-size: .85rem;
    font-weight: 500;
    color: #333;
    text-align: right;
    padding-right: .25rem;
}
.grid-field input, .grid-field select, .grid-field textarea {
    width: 100%;
    padding: .3rem .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-family: var(--font);
    background: #fff;
    box-sizing: border-box;
    height: 30px;
}
.grid-field select {
    height: 30px;
    padding: .2rem .3rem;
    appearance: auto;
}
.grid-field input:disabled, .grid-field select:disabled, .grid-field textarea:disabled {
    background: #f5f5f5;
    color: #666;
    cursor: default;
}
.grid-field .field-cliente { font-weight: 600; }
.grid-field .field-monto { text-align: right; font-weight: 600; }
.grid-spacer { height: 1px; }
.grid-btn { text-align: left; }
.grid-btn .btn-sm {
    padding: .15rem .5rem;
    font-size: .85rem;
    background: #e8efe5;
    border: 1px solid #b8d4a8;
    border-radius: 3px;
    cursor: pointer;
}
.grid-btn .btn-sm:hover { background: #d4e8ca; }
.grid-field-full {
    grid-column: span 2;
}

/* Gasto fields (two-column grid like WinForms TableLayoutPanel) */
.gasto-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem .75rem;
    align-items: center;
}
.gasto-pair {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.gasto-pair.gasto-full {
    grid-column: 1 / -1;
}
.gasto-label {
    width: 100px;
    font-size: .85rem;
    font-weight: 500;
    color: #333;
    text-align: right;
    flex-shrink: 0;
}
.gasto-pair input, .gasto-pair select {
    flex: 1;
    padding: .3rem .4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-family: var(--font);
    background: #fff;
    box-sizing: border-box;
    height: 30px;
}
.gasto-pair select {
    appearance: auto;
}
.gasto-pair input:disabled, .gasto-pair select:disabled {
    background: #f5f5f5;
    color: #666;
    cursor: default;
}

/* Amortization table */
.amort-table { font-size: .85rem; }
.amort-table th { background: #f0f7ed; }
.amort-table td { padding: .2rem .5rem; }
.amort-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Bottom bar (WinForms absolute buttons area) */
.bottom-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem 0;
    flex-wrap: wrap;
}
.codigo-label {
    margin-left: auto;
    font-weight: 700;
    font-size: .95rem;
    color: #1a3a5c;
}

/* Status bar (WinForms StatusStrip) */
.status-bar {
    background: #e8efe5;
    border: 1px solid #a3c293;
    border-radius: var(--radius-sm);
    padding: .2rem .75rem;
    font-size: .82rem;
    color: #3a5a2a;
    min-height: 24px;
    display: flex;
    align-items: center;
}

/* Modal for client search */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-body {
    padding: .75rem 1rem;
    overflow-y: auto;
    flex: 1;
}
.modal-body input[type="text"] {
    width: 100%;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    margin-bottom: .5rem;
}
.client-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.client-item {
    padding: .5rem .75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.client-item:last-child { border-bottom: none; }
.client-item:hover { background: #f0f7ed; }

/* ── Toast notifications (top-right) ──────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 400px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .9rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toast-in .3s ease;
    cursor: pointer;
    color: #fff;
    font-size: .88rem;
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }

.toast-icon {
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
}
.toast-body { flex: 1; line-height: 1.4; }
.toast-title { font-weight: 600; font-size: .9rem; margin-bottom: .15rem; }
.toast-msg { opacity: .92; }
.toast-close { font-size: .8rem; opacity: .6; flex-shrink: 0; padding-left: .25rem; }

@keyframes toast-in {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Simulador calc grid ──────────────────────────────────────── */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
}
.calc-item {
    text-align: center;
    padding: .5rem;
}
.calc-item .calc-label {
    display: block;
    font-size: .8rem;
    color: var(--text-secondary);
    margin-bottom: .2rem;
}
.calc-item .calc-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a3a5c;
}

/* ── Print document styles ─────────────────────────────────────── */
.print-doc {
    display: none;
}

@media print {
    @page { margin: .5in; size: letter; }
    body { background: #fff !important; }
    .topbar, .page-header, .search-bar, .toolbar, .card, .tabs, .tab-content,
    .form-actions, .form-grid, .footer { display: none !important; }
    .app-content > * { display: none !important; }
    .app-content > *:has(.print-area) { display: block !important; }
    .print-doc {
        display: block !important;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: #fff;
        padding: 0;
        font-size: 12pt;
        color: #000;
        z-index: 99999;
        overflow: auto;
    }
    .print-area { display: block !important; }
    .print-doc .print-header {
        text-align: center;
        border-bottom: 2px solid #000;
        padding-bottom: .75rem;
        margin-bottom: 1rem;
    }
    .print-doc .print-header h2 { margin: 0; font-size: 16pt; }
    .print-doc .print-header p { margin: .25rem 0 0; font-size: 10pt; color: #333; }
    .print-doc .print-section { margin-bottom: .75rem; }
    .print-doc .print-section h3 {
        font-size: 11pt;
        margin: 0 0 .35rem;
        padding-bottom: .25rem;
        border-bottom: 1px solid #999;
        text-transform: uppercase;
        letter-spacing: .3px;
    }
    .print-doc table { width: 100%; border-collapse: collapse; font-size: 10pt; }
    .print-doc table th {
        background: #e5e7eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        text-align: left;
        padding: .35rem .5rem;
        font-size: 9pt;
        text-transform: uppercase;
        letter-spacing: .3px;
    }
    .print-doc table td { padding: .3rem .5rem; border-bottom: 1px solid #d1d5db; }
    .print-doc table th.num, .print-doc table td.num { text-align: right; }
    .print-doc .print-totals { margin-top: .75rem; text-align: right; font-size: 11pt; }
    .print-doc .print-totals strong { font-size: 13pt; }
    .print-doc .print-footer {
        margin-top: 1.5rem;
        padding-top: .5rem;
        border-top: 1px solid #999;
        font-size: 9pt;
        color: #555;
        text-align: center;
    }
    .print-doc .print-info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .25rem .75rem;
        font-size: 10pt;
    }
    .print-doc .print-info-grid .label { color: #555; }
    .print-doc .print-info-grid .value { font-weight: 600; }
    .print-doc .print-badge {
        display: inline-block;
        padding: .1rem .4rem;
        border: 1px solid #000;
        font-size: 8pt;
        text-transform: uppercase;
        letter-spacing: .5px;
    }
}

/* ── Dashboard (moderno) ─────────────────────────────────────────────── */
.dash {
    max-width: 1200px;
    margin: 0 auto;
    animation: dashFadeIn .5s ease-out;
}

@keyframes dashFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 55%, #2b5a8c 100%);
    border-radius: 18px;
    padding: 1.4rem 1.6rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(15,36,64,.25);
}

/* brillos decorativos del banner */
.dash-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 420px 200px at 85% -20%, rgba(59,130,246,.35) 0%, transparent 70%),
        radial-gradient(ellipse 300px 160px at 15% 120%, rgba(16,185,129,.18) 0%, transparent 70%);
    pointer-events: none;
}

.dash-header-content { flex: 1; min-width: 0; position: relative; }

.dash-title {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .5rem;
    letter-spacing: -.3px;
}

.dash-title-icon {
    font-size: 1.2rem;
    opacity: .75;
    color: #7cc4ff;
}

.dash-subtitle {
    margin: .3rem 0 0;
    font-size: .9rem;
    color: rgba(255,255,255,.72);
}

.dash-header-actions {
    flex-shrink: 0;
    position: relative;
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}

.dash-btn-ghost {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
}

.dash-btn-ghost:hover {
    background: rgba(255,255,255,.2);
    transform: translateY(-2px);
    color: #fff;
}

.dash-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1.2rem;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .25s ease;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}

.dash-btn-primary {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

.dash-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,.28);
    color: var(--primary-dark);
}

.dash-btn-primary span {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1;
}

/* KPI grid */
.dash-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: #fff;
    border-radius: 16px;
    padding: 1.15rem 1.2rem 1.15rem 1.1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 14px 0 0 14px;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,.1);
}

.kpi-blue::before { background: linear-gradient(to bottom, #3b82f6, #2563eb); }
.kpi-indigo::before { background: linear-gradient(to bottom, #6366f1, #4f46e5); }
.kpi-green::before { background: linear-gradient(to bottom, #10b981, #059669); }
.kpi-amber::before { background: linear-gradient(to bottom, #f59e0b, #d97706); }
.kpi-purple::before { background: linear-gradient(to bottom, #8b5cf6, #7c3aed); }
.kpi-rose::before { background: linear-gradient(to bottom, #f43f5e, #e11d48); }

.kpi-icon-bg {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.25rem;
}

.kpi-blue .kpi-icon-bg { background: rgba(59,130,246,.12); }
.kpi-indigo .kpi-icon-bg { background: rgba(99,102,241,.12); }
.kpi-green .kpi-icon-bg { background: rgba(16,185,129,.12); }
.kpi-amber .kpi-icon-bg { background: rgba(245,158,11,.12); }
.kpi-purple .kpi-icon-bg { background: rgba(139,92,246,.12); }
.kpi-rose .kpi-icon-bg { background: rgba(244,63,94,.12); }

.kpi-icon { font-size: 1.2rem; line-height: 1; }

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    min-width: 0;
}

.kpi-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    letter-spacing: -.4px;
    /* símbolo y monto nunca se separan en dos líneas */
    white-space: nowrap;
}

/* Símbolo de moneda: pequeño y discreto, pegado al monto */
.kpi-currency {
    font-size: .68em;
    font-weight: 700;
    color: var(--text-secondary);
    margin-right: .22rem;
}

.kpi-meta {
    font-size: .78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Bottom row */
.dash-bottom {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .dash-bottom { grid-template-columns: 1fr; }
}

.dash-panel {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    overflow: hidden;
}

.dash-panel-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border);
}

.dash-panel-title {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .2px;
}

.dash-panel-link {
    font-size: .82rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.dash-panel-link:hover { color: var(--accent-hover); text-decoration: underline; }

.dash-panel-body { padding: .5rem .75rem; }

/* Dashboard table */
.dash-table {
    width: 100%;
    border-collapse: collapse;
}

.dash-table th {
    padding: .5rem .6rem;
    text-align: left;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.dash-table td {
    padding: .45rem .6rem;
    font-size: .85rem;
    border-bottom: 1px solid #f1f5f9;
}

.dash-table tbody tr:last-child td { border-bottom: none; }

.dash-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.dash-table td.mono { font-family: "SF Mono", "Cascadia Code", monospace; font-size: .82rem; }

.dash-table tbody tr { transition: var(--transition); }

.dash-table tbody tr:hover { background: #f8fafc; }

.dash-link {
    text-decoration: none;
    font-size: .85rem;
    opacity: .6;
    transition: var(--transition);
}

.dash-link:hover { opacity: 1; }

/* Quick action grid */
.dash-quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
}

.dash-quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: .85rem .5rem;
    border-radius: 12px;
    text-decoration: none;
    transition: all .2s ease;
    text-align: center;
}

.dash-quick-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}

.dash-q-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.dash-q-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
}

.dash-q-sales { background: rgba(59,130,246,.08); }
.dash-q-sales:hover { background: rgba(59,130,246,.16); }

.dash-q-client { background: rgba(16,185,129,.08); }
.dash-q-client:hover { background: rgba(16,185,129,.16); }

.dash-q-art { background: rgba(245,158,11,.08); }
.dash-q-art:hover { background: rgba(245,158,11,.16); }

.dash-q-loan { background: rgba(139,92,246,.08); }
.dash-q-loan:hover { background: rgba(139,92,246,.16); }

.dash-q-gasto { background: rgba(244,63,94,.08); }
.dash-q-gasto:hover { background: rgba(244,63,94,.16); }

.dash-q-inv { background: rgba(14,165,233,.08); }
.dash-q-inv:hover { background: rgba(14,165,233,.16); }

/* ── Responsive ──────────────────────────────────────────────────── */

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 .25rem;
    line-height: 1;
}

/* Overlay when mobile menu open */
.nav-overlay {
    display: none;
}

@media (max-width: 768px) {

    .hamburger { display: inline-flex; }

    .topbar {
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
        padding: 0 .75rem;
        position: relative;
    }

    .topnav {
        display: none;
        flex: 0 0 100%;
        flex-direction: column;
        height: auto;
        order: 10;
        background: var(--primary-dark);
        border-top: 1px solid rgba(255,255,255,.1);
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .topnav-open { display: flex; }

    .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 800;
    }
    .topbar-open { position: relative; z-index: 850; }

    .topnav-item {
        flex-direction: column;
        border-bottom: 1px solid rgba(255,255,255,.06);
    }

    .topnav-link {
        padding: .7rem 1rem;
        border-bottom: none;
        justify-content: space-between;
    }

    .topnav-link.active { border-bottom: none; background: rgba(255,255,255,.06); }
    .topnav-link .caret { display: none; }

    .dropdown {
        position: static;
        display: block;
        box-shadow: none;
        background: transparent;
        padding: 0 0 .3rem 1rem;
        border-radius: 0;
    }
    .dropdown-header { padding: .5rem 1rem .2rem; }
    .dropdown a { padding: .5rem 1rem; font-size: .85rem; }

    .topbar-right {
        order: 5;
        gap: .5rem;
        margin-left: 0;
        width: 100%;
        padding: .5rem 0;
        border-top: 1px solid rgba(255,255,255,.08);
        flex-wrap: wrap;
    }

    .global-search {
        flex: 1;
        min-width: 0;
    }
    .global-search input {
        width: 100%;
        max-width: none;
    }
    .global-search input:focus { width: 100%; }
    .search-results { width: 100%; right: auto; left: 0; }

    .topbar-user { font-size: .82rem; }
    .user-badge { display: none; }

    .btn-salir { padding: .35rem .7rem; font-size: .8rem; }

    /* Content */
    .app-content { padding: 1rem .75rem; }

    /* Tables: horizontal scroll */
    .table-container { overflow-x: auto; }

    .data-table { min-width: 600px; }
    .data-table th,
    .data-table td { padding: .5rem .6rem; font-size: .82rem; white-space: nowrap; }

    /* Form grid: 1 column on mobile */
    .form-grid { grid-template-columns: 1fr; }

    .toolbar { flex-wrap: wrap; }
    .toolbar .field { width: 100% !important; }
    .search-box { max-width: 100%; }

    /* Dashboard */
    .dash-header { flex-direction: column; align-items: stretch; }
    .dash-title { font-size: 1.25rem; }
    .dash-header-actions { width: 100%; }
    .dash-btn { width: 100%; justify-content: center; }
    .dash-kpis { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
    .kpi-card { padding: .75rem; }
    .kpi-icon-bg { width: 34px; height: 34px; font-size: 1rem; }
    .kpi-value { font-size: 1.1rem; }
    .dash-bottom { grid-template-columns: 1fr; }

    .dash-quick-grid { grid-template-columns: repeat(3, 1fr); }

    /* Action bar */
    .action-bar { flex-direction: column; gap: .75rem; }

    /* Winforms pages */
    .winforms-form { margin: 0; }

    /* Login */
    .login-card { width: 100%; max-width: 360px; padding: 1.5rem; }
}

@media (max-width: 480px) {
    .dash-kpis { grid-template-columns: 1fr; }
    .dash-quick-grid { grid-template-columns: repeat(2, 1fr); }

    .data-table { min-width: 500px; }

    .topbar-right { gap: .35rem; }
    .global-search input { font-size: .8rem; }
}

/* ── Prestamo Index Layout ─────────────────────────────────────────── */
.prestamo-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.25rem;
    align-items: start;
}

.prestamo-table-col {
    min-width: 0;
}

.prestamo-kpi-col {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    position: sticky;
    top: 1rem;
}

.prestamo-kpi-col .kpi-card {
    padding: 1.85rem 1rem;
    gap: .7rem;
}

.prestamo-kpi-col .kpi-card::before {
    width: 3px;
}

.prestamo-kpi-col .kpi-icon-bg {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 1rem;
}

.prestamo-kpi-col .kpi-value {
    font-size: 1.1rem;
}

/* En anchos intermedios (tablet / zoom alto) la columna de KPIs se mantiene
   a la derecha, solo más angosta; únicamente en móvil real pasa abajo. */
@media (max-width: 1080px) {
    .prestamo-layout {
        grid-template-columns: 1fr 225px;
        gap: .75rem;
    }
    .prestamo-kpi-col .kpi-card {
        padding: .65rem .7rem;
        gap: .55rem;
    }
    .prestamo-kpi-col .kpi-value {
        font-size: 1rem;
    }
    .prestamo-kpi-col .kpi-icon-bg {
        width: 30px;
        height: 30px;
        font-size: .85rem;
    }
}

@media (max-width: 640px) {
    .prestamo-layout {
        grid-template-columns: 1fr;
    }
    .prestamo-kpi-col {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: .5rem;
        position: static;
    }
    .prestamo-kpi-col .kpi-card {
        padding: .7rem .75rem;
    }
}

/* ── Factura impresa: aprovechar la hoja carta completa ─────────────── */
@media print {
    /* Con el margen de .5in de @page queda ~1in lateral. La factura se
       estira a lo alto de la hoja: el detalle crece (flex) y el bloque de
       letras/totales + leyenda queda anclado al fondo, como una factura
       fiscal preimpresa, sin el vacío al pie. */
    .print-doc.print-factura {
        padding: 0 !important;
        display: flex !important;
        flex-direction: column;
        min-height: 0; /* carta 11in − márgenes @page − holgura anti salto de página */
    }
    .print-factura .factura-detalle {
        flex: 1 1 auto;
    }
}
