/* ========================================
   Caja Ale - Control de Billeteras
   Paleta: Azul marino (#1A3A52) + Ámbar (#D4A017)
   ======================================== */

:root {
    --primary: #1A3A52;
    --primary-dark: #122838;
    --primary-light: #2A5070;
    --accent: #D4A017;
    --accent-dark: #B08612;
    --accent-light: #E5B947;

    --bg: #F7F6F2;
    --bg-soft: #FBFAF7;
    --surface: #FFFFFF;
    --surface-alt: #F1EFE8;

    --text: #1A1A1F;
    --text-muted: #6B6B70;
    --text-soft: #9A9A9F;
    --text-tertiary: #B5B5BA;

    --border: #E8E6DF;
    --border-soft: #F1EFE8;
    --border-strong: #D5D3CB;

    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --danger: #C62828;
    --danger-bg: #FBEAEA;
    --warning: #E65100;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(26,58,82,.05);
    --shadow: 0 4px 12px rgba(26,58,82,.08);
    --shadow-lg: 0 12px 32px rgba(26,58,82,.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

/* ============ LOGIN ============ */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.login-logo {
    font-size: 38px;
    color: var(--accent);
    text-align: center;
    line-height: 1;
    margin-bottom: 6px;
}

.login-brand-name {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    letter-spacing: -0.3px;
}

.login-brand-sub {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 2px;
    margin-bottom: 22px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.login-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 18px;
    text-align: center;
}

.login-error {
    color: var(--danger);
    font-size: 12px;
    min-height: 16px;
    margin-top: 4px;
    margin-bottom: 4px;
}

.password-wrap { position: relative; }
.btn-eye {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    padding: 4px;
    display: flex;
}
.btn-eye:hover { color: var(--primary); }

/* ============ FORM GENERICS ============ */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
    outline: none;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,58,82,.10);
}
.form-input-sm { padding: 7px 10px; font-size: 13px; }
.guarani-input { font-variant-numeric: tabular-nums; }

/* ============ BUTTONS ============ */
.btn-primary {
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    transition: background .15s, transform .05s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
    background: var(--surface-alt);
    color: var(--text);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13px;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
}
.btn-danger:hover { background: #A02020; }

.btn-full { width: 100%; }

.btn-icon-round {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .1s;
}
.btn-icon-round:hover { background: var(--primary-dark); transform: rotate(90deg); }

/* ============ HEADER ============ */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 18px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--primary); letter-spacing: -0.2px; }
.brand-sub { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

.header-center { justify-self: center; }
.header-balance {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface-alt);
    padding: 6px 22px;
    border-radius: 10px;
}
.balance-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.balance-amount {
    font-size: 19px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
}

.header-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-categorias, .btn-arqueo, .btn-admin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    color: var(--primary);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: background .15s;
}
.btn-categorias:hover, .btn-arqueo:hover, .btn-admin:hover { background: var(--border); }
.btn-arqueo { background: var(--accent); color: #fff; }
.btn-arqueo:hover { background: var(--accent-dark); }

.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}
.user-details { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; }
.user-links { font-size: 11px; color: var(--text-muted); }
.user-link { font-size: 11px; color: var(--text-muted); text-decoration: none; transition: color .15s; padding: 0; }
.user-link:hover { color: var(--primary); }
.user-link-sep { padding: 0 4px; color: var(--text-tertiary); }

/* ============ LAYOUT ============ */
.layout {
    max-width: 1400px;
    margin: 0 auto;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 18px;
}

/* ============ SIDEBAR ============ */
.sidebar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    height: fit-content;
    position: sticky;
    top: 80px;
}

.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-title { font-size: 14px; font-weight: 700; color: var(--text); }

.add-wallet-form {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 14px;
    display: none;
}
.add-wallet-form.open { display: block; }

.color-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--c);
    border: 2px solid transparent;
    transition: transform .1s, border-color .15s;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text); }

.wallets-list { display: flex; flex-direction: column; gap: 12px; }

.titular-group { display: flex; flex-direction: column; gap: 4px; }
.titular-header {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 700;
    padding: 4px 2px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.titular-total { font-size: 11px; color: var(--primary); font-weight: 600; font-variant-numeric: tabular-nums; }

.wallet-item {
    border-left: 3px solid var(--c, var(--primary));
    padding: 8px 10px 8px 12px;
    background: var(--surface-alt);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    transition: background .15s;
}
.wallet-item:hover { background: var(--border); }
.wallet-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.wallet-balance {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.wallet-delete {
    color: var(--text-tertiary);
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    opacity: 0;
    transition: opacity .15s, color .15s;
}
.wallet-item:hover .wallet-delete { opacity: 1; }
.wallet-delete:hover { color: var(--danger); }

/* ============ MAIN ============ */
.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header-row .card-title { margin-bottom: 0; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.form-span-full { grid-column: 1 / -1; }

.form-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 12px; flex-wrap: wrap; }

/* Toggle modo histórico */
.toggle-historico {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.toggle-historico input { display: none; }
.toggle-track {
    width: 34px;
    height: 18px;
    background: var(--border);
    border-radius: 18px;
    position: relative;
    transition: background .15s;
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle-historico input:checked + .toggle-track { background: var(--accent); }
.toggle-historico input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-label { font-size: 12px; color: var(--text); font-weight: 500; }
.toggle-hint { color: var(--text-muted); font-weight: 400; }

/* Saldos negativos */
.wallet-balance-neg { color: var(--danger) !important; }
.titular-total-neg { color: var(--danger) !important; }
.balance-amount-neg { color: var(--danger) !important; }

/* Cuenta corriente en sidebar */
.wallet-cuenta {
    font-size: 11px;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.2px;
}
.cuenta-pos { color: var(--success); font-weight: 600; }
.cuenta-neg { color: var(--danger); font-weight: 600; }

/* Toggle cobrar a (igual al de modo histórico) */
.cobrar-a-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.cobrar-a-toggle input { display: none; }
.cobrar-a-toggle input:checked + .toggle-track { background: var(--accent); }
.cobrar-a-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.cobrar-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

/* Chip cobrar a en historial */
.cobrar-chip {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 8px;
    background: #FFF3E0;
    color: var(--warning);
    font-size: 10px;
    font-weight: 600;
    margin-left: 4px;
    border: 1px dashed var(--warning);
}

/* Modal de cuentas */
.modal-cuentas { max-width: 680px; max-height: 85vh; display: flex; flex-direction: column; }
.modal-cuentas #cuentasContent { overflow-y: auto; flex: 1; }
.cuentas-empty { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.cuentas-empty .empty-icon { font-size: 42px; color: var(--success); margin-bottom: 10px; }
.cuentas-empty p { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }

.cuenta-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}
.cuenta-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 10px;
    flex-wrap: wrap;
}
.cuenta-flow {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.cuenta-arrow {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: lowercase;
    font-style: italic;
}
.cuenta-monto {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.cuenta-detalle {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.cuenta-ops {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-bottom: 10px;
}
.cuenta-op-row {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 8px;
    font-size: 12px;
    padding: 3px 0;
    align-items: center;
}
.cuenta-op-fecha { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cuenta-op-motivo { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cuenta-op-monto { font-variant-numeric: tabular-nums; color: var(--danger); font-weight: 600; }
.cuenta-op-more { font-size: 11px; color: var(--text-muted); font-style: italic; padding: 2px 0; }
.cuenta-actions { display: flex; justify-content: flex-end; }
.btn-saldar { font-size: 12px; padding: 7px 14px; }

/* Tag de titular en historial */
.titular-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--c, var(--primary));
    white-space: nowrap;
}

/* Fila de saldos en panel de período */
.periodo-saldos {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.periodo-stat-saldo {
    font-size: 14px !important;
    color: var(--primary);
}

.history-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.history-filters .form-input { min-width: 130px; }
.history-filters .form-input-sm { min-width: 110px; }
.history-filters input[type="date"] { min-width: 140px; padding: 6px 8px; }

.btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--danger);
    color: #fff;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: background .15s;
}
.btn-pdf:hover { background: #A02020; }

/* Panel de resumen del período */
.periodo-resumen {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 14px;
}
.periodo-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.periodo-info {
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}
.periodo-count { color: var(--text-muted); font-weight: 500; font-size: 11px; }
.periodo-totales { display: flex; gap: 18px; flex-wrap: wrap; justify-content: flex-start; }
.periodo-stat { display: flex; flex-direction: column; gap: 1px; min-width: 90px; }
.periodo-stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.periodo-stat-val {
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.2px;
}
.periodo-pos { color: var(--success); }
.periodo-neg { color: var(--danger); }
.periodo-stat-net { margin-left: auto; padding-left: 18px; border-left: 1px solid var(--border); }
.periodo-stat-net .periodo-stat-val { font-size: 16px; }

@media (max-width: 640px) {
    .periodo-totales { gap: 10px; }
    .periodo-stat { min-width: 70px; }
    .periodo-stat-net { margin-left: 0; padding-left: 0; border-left: none; flex-basis: 100%; padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--border-soft); }
}

.table-wrap { overflow-x: auto; }
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.history-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.history-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover { background: var(--bg-soft); }
.text-right { text-align: right; }

.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.type-income { background: var(--success-bg); color: var(--success); }
.type-expense { background: var(--danger-bg); color: var(--danger); }
.type-transfer { background: #FFF3E0; color: var(--warning); }

.wallet-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    background: var(--c, var(--primary));
}

.categoria-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

.amount-pos { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-neg { color: var(--danger); font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-neutral { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.delete-btn {
    color: var(--text-tertiary);
    padding: 4px 6px;
    border-radius: 4px;
    transition: color .15s, background .15s;
}
.delete-btn:hover { color: var(--danger); background: var(--danger-bg); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 36px; color: var(--text-tertiary); margin-bottom: 10px; }
.empty-state p { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state span { font-size: 13px; }

.loading-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ TOAST ============ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 50px));
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    transition: transform .25s;
    max-width: 90%;
    text-align: center;
    pointer-events: none;
    opacity: 0;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ============ MODALS ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26,58,82,.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
/* El modal de confirmación va siempre por encima de los de gestión */
#modalBackdrop { z-index: 300; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.modal-icon { font-size: 32px; color: var(--warning); margin-bottom: 8px; }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.modal-msg { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; }

.modal-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    text-align: left;
}
.btn-close-modal {
    color: var(--text-muted);
    font-size: 22px;
    padding: 0 4px;
    line-height: 1;
}
.btn-close-modal:hover { color: var(--text); }

.modal-gestion { max-width: 640px; text-align: left; }
.gestion-section { margin-bottom: 18px; }
.gestion-section-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.gestion-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
.gestion-table-wrap { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.gestion-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gestion-table th { text-align: left; padding: 8px 10px; background: var(--surface-alt); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.gestion-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.gestion-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.profile-error { color: var(--danger); font-size: 12px; min-height: 14px; }

/* Edición inline de filas */
.edit-btn {
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 4px;
    transition: background .15s;
}
.edit-btn:hover { background: var(--surface-alt); }
.btn-xs { padding: 5px 10px; font-size: 12px; margin-right: 4px; }
.btn-xs:last-child { margin-right: 0; }
.tit-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.edit-colors { display: flex; gap: 4px; margin-top: 6px; }
.color-swatch-sm {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--c);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform .1s, border-color .15s;
    padding: 0;
}
.color-swatch-sm:hover { transform: scale(1.1); }
.color-swatch-sm.active { border-color: var(--text); }
tr[data-mode="edit"] td { vertical-align: top; padding-top: 8px; padding-bottom: 8px; }

.modal-arqueo { max-width: 540px; text-align: left; }
.arqueo-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.arqueo-wallet-bar { margin-bottom: 14px; }
.arqueo-body { max-height: 320px; overflow-y: auto; margin-bottom: 14px; }
.arqueo-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.arqueo-table th { padding: 6px 10px; background: var(--surface-alt); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); border-bottom: 1px solid var(--border); text-align: left; }
.arqueo-table td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); }
.arqueo-table input { width: 60px; text-align: center; padding: 4px; }
.arqueo-summary { background: var(--surface-alt); padding: 14px; border-radius: var(--radius-sm); }
.arqueo-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.arqueo-row-diff { font-weight: 700; font-size: 14px; }
.arqueo-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.arqueo-hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.arqueo-status-wrap { text-align: center; margin-top: 12px; }
.arqueo-badge { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.arqueo-badge.pending { background: var(--surface-alt); color: var(--text-muted); }
.arqueo-badge.ok { background: var(--success-bg); color: var(--success); }
.arqueo-badge.diff { background: var(--danger-bg); color: var(--danger); }
.arqueo-diff.ok { color: var(--success); }
.arqueo-diff.bad { color: var(--danger); }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px) {
    .header-inner {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 8px 12px;
    }
    .brand { grid-column: 1; grid-row: 1; }
    .header-actions { grid-column: 2; grid-row: 1; justify-self: end; }
    .header-center {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
    }
    .header-balance {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 6px 14px;
        width: 100%;
    }
    .header-balance .balance-label::after { content: ":"; }
    .balance-amount { font-size: 16px; }
    .layout { grid-template-columns: 1fr; padding: 12px; }
    .sidebar { position: static; }
}

@media (max-width: 640px) {
    .header-inner { padding: 0 12px; }
    .brand-text { display: none; }
    .header-actions { gap: 6px; }
    .btn-categorias span, .btn-arqueo span { display: none; }
    .user-details { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .card { padding: 14px; }
    .card-header-row { flex-direction: column; align-items: stretch; }
    .history-filters { width: 100%; }
    .history-filters .form-input,
    .history-filters .form-input-sm { min-width: 0; flex: 1 1 130px; }
    .history-table { font-size: 12px; }
    .history-table th, .history-table td { padding: 8px 6px; }
    .balance-amount { font-size: 16px; }
}

@media (max-width: 480px) {
    .login-card { padding: 28px 22px; }
    .btn-categorias, .btn-arqueo { padding: 7px 9px; }
    .btn-categorias svg, .btn-arqueo svg { margin: 0; }
}
