/* ============================================================
   ROSALINDA - Identidad visual
   Paleta: marfil, vino, terracota, dorado
   ============================================================ */
:root {
    --ivory: #faf6ef;
    --ivory-2: #f3ecdf;
    --wine: #6d1f2c;
    --wine-dark: #4a1420;
    --wine-soft: #8e3446;
    --terra: #c96f4a;
    --terra-soft: #e8a583;
    --gold: #c9a24b;
    --gold-soft: #ecd9a8;
    --ink: #2b2320;
    --ink-soft: #6b5d55;
    --line: #e7dccb;
    --card: #fffdf8;
    --ok: #3e8e5a;
    --warn: #d9932b;
    --danger: #b3372f;
    --info: #3a6ea5;
    --radius: 14px;
    --shadow: 0 4px 18px rgba(74, 20, 32, .08);
    --sidebar-w: 264px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--rl-font-body, "Inter", "Segoe UI", Arial, sans-serif);
    background: var(--ivory);
    color: var(--ink);
    font-size: 15px;
}
h1,h2,h3,h4 { font-family: var(--rl-font-head, Georgia, serif); color: var(--wine-dark); margin: 0 0 .5rem; }
a { color: var(--wine-soft); text-decoration: none; }
a:hover { color: var(--terra); }

/* ---------- AUTH (login) ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1200px 600px at 20% 10%, #f7e8d8 0%, transparent 60%),
                radial-gradient(900px 500px at 85% 90%, #efe0c8 0%, transparent 55%),
                linear-gradient(160deg, var(--ivory) 0%, var(--ivory-2) 100%);
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 420px; background: var(--card);
    border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
    padding: 40px 36px; text-align: center;
}
.auth-card img.logo { height: 84px; margin-bottom: 8px; }
.auth-card h1 { font-size: 1.9rem; letter-spacing: .04em; }
.auth-card .sub { color: var(--ink-soft); font-size: .85rem; margin-bottom: 26px; letter-spacing: .12em; text-transform: uppercase; }
.form-group { text-align: left; margin-bottom: 16px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; }
.form-control {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; font-size: 1rem; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px rgba(201,111,74,.18); }
select.form-control { appearance: auto; }
textarea.form-control { min-height: 90px; resize: vertical; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: .92rem; cursor: pointer; transition: all .15s;
    background: var(--wine); color: #fff;
}
.btn:hover { background: var(--wine-soft); color: #fff; transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: var(--wine-dark); }
.btn-gold:hover { background: #b98f36; color: #fff; }
.btn-outline { background: transparent; color: var(--wine); border-color: var(--wine); }
.btn-outline:hover { background: var(--wine); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 8px; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #93291f; }
.btn-success { background: var(--ok); }
.btn-success:hover { background: #2f7048; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: .9rem; border: 1px solid; }
.alert-error, .alert-danger { background: #fbeae8; border-color: #e5b8b3; color: var(--danger); }
.alert-ok, .alert-success { background: #e8f4ec; border-color: #b7d8c3; color: var(--ok); }
.alert-info { background: #e8eff7; border-color: #b8cde4; color: var(--info); }
.alert-warn { background: #faf0dd; border-color: #ecd3a3; color: #8a5c10; }

/* ---------- APP SHELL ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0;
    background: linear-gradient(180deg, var(--wine-dark) 0%, var(--wine) 55%, #5c1a26 100%);
    color: #f3e4da; display: flex; flex-direction: column; z-index: 50;
    transition: transform .25s;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 12px; padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand img { height: 46px; width: 46px; object-fit: contain; border-radius: 10px; background: rgba(255,255,255,.12); padding: 4px; }
.sidebar .brand .name { font-family: var(--rl-font-head, Georgia, serif); font-size: 1.15rem; font-weight: 700; letter-spacing: .08em; color: #fff; }
.sidebar .brand .tag { font-size: .65rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-soft); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    color: #e8cfc4; border-radius: 10px; margin-bottom: 2px; font-size: .92rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: linear-gradient(90deg, var(--terra), var(--wine-soft)); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.sidebar nav a .ico { width: 22px; text-align: center; font-size: 1rem; }
.sidebar .foot { padding: 14px 18px; font-size: .72rem; color: rgba(255,255,255,.45); border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 14px; padding: 12px 24px;
    background: var(--card); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40;
}
.topbar .burger { display: none; background: none; border: none; font-size: 1.4rem; color: var(--wine); cursor: pointer; }
.topbar .page-title { font-family: var(--rl-font-head, Georgia, serif); font-size: 1.25rem; color: var(--wine-dark); flex: 1; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; }
.topbar .user-chip img, .topbar .user-chip .avatar-fallback {
    width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
    background: linear-gradient(135deg, var(--terra), var(--gold)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem;
}
.topbar .user-chip .uname { font-size: .85rem; font-weight: 600; line-height: 1.1; }
.topbar .user-chip .urole { font-size: .72rem; color: var(--ink-soft); }
.notif-wrap { position: relative; }
.notif-btn { background: none; border: none; font-size: 1.25rem; color: var(--wine); cursor: pointer; position: relative; padding: 4px 8px; }
.notif-badge { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; border-radius: 10px; padding: 1px 6px; }
.notif-panel {
    position: absolute; right: 0; top: 110%; width: 340px; max-height: 420px; overflow-y: auto;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
    display: none; z-index: 60;
}
.notif-panel.open { display: block; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .85rem; cursor: pointer; }
.notif-item:hover { background: var(--ivory-2); }
.notif-item .nt { font-weight: 600; color: var(--ink); }
.notif-item .nm { color: var(--ink-soft); font-size: .78rem; }
.notif-empty { padding: 18px; text-align: center; color: var(--ink-soft); font-size: .85rem; }

.content { padding: 24px; flex: 1; }

/* ---------- COMPONENTES ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card h3 { font-size: 1.05rem; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { color: var(--terra); }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }

.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--terra); }
.kpi.gold::before { background: var(--gold); }
.kpi.wine::before { background: var(--wine); }
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }
.kpi .k-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 600; }
.kpi .k-value { font-family: var(--rl-font-head, Georgia, serif); font-size: 1.7rem; color: var(--wine-dark); margin-top: 6px; }
.kpi .k-sub { font-size: .78rem; color: var(--ink-soft); margin-top: 4px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; background: var(--card); font-size: .9rem; }
.tbl th { background: var(--ivory-2); color: var(--wine-dark); text-align: left; padding: 11px 14px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid #f0e8da; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fbf7ee; }
.alert-wine { background: linear-gradient(90deg, #f7e8e4, #fdf3ec); border-color: #e5b8b3; color: var(--wine-dark); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-ok { background: #e2f2e8; color: var(--ok); }
.badge-warn { background: #faf0dd; color: #8a5c10; }
.badge-danger { background: #fbeae8; color: var(--danger); }
.badge-info { background: #e8eff7; color: var(--info); }
.badge-wine { background: #f3e0e4; color: var(--wine); }
.badge-gray { background: #efece7; color: var(--ink-soft); }

.muted { color: var(--ink-soft); }
.right { text-align: right; }
.center { text-align: center; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.row-flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- MODAL ---------- */
.rl-modal-backdrop { position: fixed; inset: 0; background: rgba(43,20,15,.5); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.rl-modal-backdrop.open { display: flex; }
.rl-modal { background: var(--card); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.rl-modal .m-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.rl-modal .m-head h3 { margin: 0; font-size: 1.1rem; }
.rl-modal .m-body { padding: 22px; }
.rl-modal .m-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.rl-modal .x { background: none; border: none; font-size: 1.3rem; color: var(--ink-soft); cursor: pointer; }

/* ---------- TABS ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 10px 18px; font-size: .92rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.active { color: var(--wine); border-bottom-color: var(--terra); }
.tab-pane { display: none; } .tab-pane.active { display: block; }

/* ---------- PROFILE ---------- */
.profile-head { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.profile-photo-wrap { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.profile-photo-wrap img, .profile-photo-wrap .ph {
    width: 120px; height: 120px; border-radius: 50%; object-fit: cover;
    border: 4px solid var(--card); box-shadow: var(--shadow);
    background: linear-gradient(135deg, var(--terra), var(--gold));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 2.4rem; font-weight: 700; font-family: var(--rl-font-head, Georgia, serif);
}
.photo-overlay {
    position: absolute; inset: 0; border-radius: 50%; background: rgba(74,20,32,.55);
    display: flex; align-items: center; justify-content: center; color: #fff;
    font-size: 1.6rem; cursor: pointer; opacity: 0; transition: opacity .2s;
}
.profile-photo-wrap:hover .photo-overlay { opacity: 1; }
.photo-preview {
    width: 120px; height: 120px; border-radius: 50%; object-fit: cover; display: none;
    border: 4px solid var(--gold); box-shadow: var(--shadow); margin-top: 10px;
}
.photo-preview.show { display: block; }

/* ---------- MODULE TOGGLES ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 12px; }
.mod-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; display: flex; align-items: center; gap: 12px; }
.mod-card .mi { font-size: 1.3rem; }
.mod-card .mt { flex: 1; } .mod-card .mt b { display: block; font-size: .88rem; color: var(--ink); }
.mod-card .mt span { font-size: .74rem; color: var(--ink-soft); }
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #d8cdb8; border-radius: 24px; transition: .2s; cursor: pointer; }
.switch .sl::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .sl { background: var(--ok); }
.switch input:checked + .sl::before { transform: translateX(20px); }

/* ---------- DROPZONE (upload con preview) ---------- */
.dropzone {
    border: 2px dashed var(--line); border-radius: 14px; padding: 22px;
    text-align: center; color: var(--ink-soft); cursor: pointer;
    transition: border-color .2s, background .2s; background: var(--ivory);
}
.dropzone:hover, .dropzone.over { border-color: var(--terra); background: #fdf3ec; }
.dropzone .photo-preview { margin: 0 auto 10px; }

/* ---------- MISC ---------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 2.6rem; margin-bottom: 10px; }
.chart-box { position: relative; height: 280px; }
.chart-box canvas { max-width: 100%; }
.footer-note { text-align: center; color: var(--ink-soft); font-size: .75rem; padding: 14px; }
.perm-matrix td { vertical-align: top; }
.perm-group { background: var(--ivory-2); font-weight: 700; color: var(--wine-dark); }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.3); }
    .main { margin-left: 0; }
    .topbar .burger { display: block; }
    .content { padding: 16px; }
}

/* Contador de denominaciones de caja */
.rl-denom-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(86px,1fr));gap:8px;margin:8px 0}
.rl-denom-cell label{display:block;font-size:.72rem;color:var(--muted);margin-bottom:2px}
.rl-denom-cell input{text-align:center}
.rl-denom-foot{display:flex;align-items:center;gap:10px;margin-top:8px;font-size:.9rem}
.rl-denom-sum{color:var(--wine-dark);font-size:1.05rem}


/* Desglose de conciliacion de caja */
.rl-bd{border:1px solid var(--line);border-radius:10px;padding:12px 14px;margin:10px 0;background:var(--bg-soft,#faf8f6)}
.rl-bd-title{font-size:.78rem;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--muted);margin-bottom:8px}
.rl-bd-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px}
.rl-bd-item{display:flex;flex-direction:column;font-size:.8rem;color:var(--muted)}
.rl-bd-item b{font-size:1rem;color:var(--ink)}
.rl-bd-item.rl-bd-total{border-top:2px solid var(--wine);padding-top:6px;margin-top:2px}
.rl-bd-item.rl-bd-total b{color:var(--wine-dark);font-size:1.15rem}
.rl-pos{color:#1a7f37!important}
.rl-neg{color:#b3261e!important}
.rl-bd-noncash{margin-top:10px;padding-top:8px;border-top:1px dashed var(--line);font-size:.8rem}
.rl-bd-sub{display:block;color:var(--muted);margin-bottom:4px}
.rl-bd-chip{display:inline-block;background:var(--bg-soft,#f1ece8);border:1px solid var(--line);border-radius:20px;padding:2px 10px;margin:2px 4px 2px 0;font-weight:600}
.rl-session{border:1px solid var(--line);border-radius:12px;padding:14px 16px;margin-bottom:14px}
.rl-session-head{display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between}

