/* ===== Firma Digital ===== */
:root {
    --red: #315B91;
    --red-d: #172B4D;
    --yellow: #DCE7F7;
    --yellow-d: #C5D5EE;
    --blue: #1C3C6B;
    --blue-d: #172B4D;
    --white: #ffffff;
    --bg: #F4F6FB;
    --ink: #17243B;
    --muted: #68758A;
    --line: #E1E6EF;
    --card: #ffffff;
    --radius: 18px;
    --shadow: 0 10px 30px -12px rgba(27, 31, 42, .18);
    --sidebar: 264px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Outfit', system-ui, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.logo { width: 46px; height: 31px; stroke: none; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
svg.logo text { stroke: none; }
.muted { color: var(--muted); }

/* Franja de la bandera */
.flag-strip { position: fixed; top: 0; left: 0; right: 0; height: 4px; display: flex; z-index: 50; }
.flag-strip span:nth-child(1) { flex: 1; background: var(--blue); }
.flag-strip span:nth-child(2) { flex: 1; background: var(--yellow); }
.flag-strip span:nth-child(3) { flex: 2; background: var(--red); }

/* ===== Layout ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar); position: fixed; inset: 0 auto 0 0; padding: 26px 18px 18px;
    background: linear-gradient(180deg, #172B4D 0%, #1C3C6B 55%, #254A7F 100%);
    color: #fff; display: flex; flex-direction: column; gap: 26px; z-index: 20;
}
.sidebar::after { display: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.brand strong { display: block; font-size: 1.2rem; letter-spacing: .2px; }
.brand small { opacity: .7; font-size: .8rem; }
.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; color: rgba(255,255,255,.78); font-weight: 500; transition: .2s; position: relative; }
.menu-item:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(3px); }
.menu-item.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 700; box-shadow: inset 3px 0 #8FB1E2; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: rgba(255,255,255,.08); }
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user strong { display: block; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { opacity: .7; font-size: .75rem; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; background: linear-gradient(135deg, #315b91, #1c3c6b); color: #fff; text-transform: uppercase; flex-shrink: 0; }
.avatar.sm { width: 36px; height: 36px; border-radius: 10px; font-size: .85rem; }
.icon-btn { background: none; border: 0; color: #fff; cursor: pointer; padding: 8px; border-radius: 10px; opacity: .8; }
.icon-btn:hover { background: rgba(255,255,255,.12); opacity: 1; }

.main { flex: 1; margin-left: var(--sidebar); padding: 28px 34px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.topbar-title { display: flex; align-items: center; gap: 14px; }
.topbar h1 { margin: 0; font-size: 1.85rem; font-weight: 800; letter-spacing: -.5px; }
.topbar p { margin: 2px 0 0; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mobile-brand { display: none; }
.content { animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ===== Botones ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; font: 600 .95rem 'Outfit', sans-serif; border: 0; cursor: pointer; transition: .2s; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, #1C3C6B, #172B4D); color: #fff; box-shadow: 0 10px 22px -10px rgba(28, 60, 107, .55); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 26px -10px rgba(28, 60, 107, .65); }
.btn-ghost { background: #fff; color: var(--blue); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--blue); background: #F2F5FC; }
.btn-danger { background: #E8EFF9; color: var(--blue-d); }
.btn-danger:hover { background: #315B91; color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .82rem; border-radius: 10px; }
.btn-block { width: 100%; padding: 14px; font-size: 1rem; }

/* ===== Alertas ===== */
.alert { padding: 14px 18px; border-radius: 14px; margin-bottom: 18px; font-weight: 500; animation: rise .35s ease; transition: opacity .4s, transform .4s; }
.alert-ok { background: #E8EFF9; color: var(--blue-d); border-left: 5px solid var(--blue); }
.alert-err { background: #E8EFF9; color: var(--blue-d); border-left: 5px solid var(--blue); }

/* ===== Cards & stats ===== */
.card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid rgba(0,0,0,.03); }
.card.p0 { padding: 0; overflow: hidden; }
.card h2 { margin: 0 0 16px; font-size: 1.05rem; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat { position: relative; overflow: hidden; border-radius: var(--radius); padding: 22px; color: #fff; box-shadow: var(--shadow); transition: transform .25s; }
.stat:hover { transform: translateY(-4px); }
.stat::after { content: '★'; position: absolute; right: -8px; bottom: -34px; font-size: 120px; opacity: .14; line-height: 1; }
.stat-label { font-size: .85rem; font-weight: 600; opacity: .9; text-transform: uppercase; letter-spacing: .8px; }
.stat strong { display: block; font-size: 2.6rem; font-weight: 800; margin: 6px 0 2px; line-height: 1.1; }
.stat small { opacity: .85; }
.stat-red { background: linear-gradient(135deg, var(--red), var(--red-d)); }
.stat-yellow { background: linear-gradient(135deg, var(--yellow), var(--yellow-d)); color: var(--blue-d); }
.stat-blue { background: linear-gradient(135deg, var(--blue), var(--blue-d)); }
.stat-white { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.stat-white::after { color: var(--blue); }

.grid-dash { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card-wide { grid-column: 1 / -1; }
.bars { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.bar-head { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.bar { height: 10px; background: #E8EFF9; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; animation: grow 1s .2s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes grow { to { width: var(--w); } }
.c1 { --c: #315B91; } .c2 { --c: var(--blue); } .c3 { --c: #6D8FBF; } .c4 { --c: var(--red); } .c5 { --c: var(--yellow-d); }
.bar i { background: var(--c); }
.donut { --h: 50; width: 170px; height: 170px; margin: 6px auto 16px; border-radius: 50%; display: grid; place-items: center;
    background: conic-gradient(var(--blue) calc(var(--h) * 1%), var(--red) 0); }
.donut > div { width: 112px; height: 112px; border-radius: 50%; background: #fff; display: grid; place-content: center; text-align: center; }
.donut strong { font-size: 1.8rem; } .donut small { color: var(--muted); }
.legend { display: flex; justify-content: center; gap: 22px; font-size: .9rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.blue { background: var(--blue); } .dot.red { background: var(--red); }
.rank { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.rank:last-child { border: 0; }
.rank b { background: #DCE7F7; color: var(--blue-d); padding: 2px 10px; border-radius: 99px; font-size: .85rem; }
.recent { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recent:last-child { border: 0; }
.recent .grow { flex: 1; min-width: 0; }
.recent strong, .cell-user strong { display: block; }
.recent small, .cell-user small { color: var(--muted); font-size: .8rem; }

/* ===== Tablas ===== */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { flex: 1; min-width: 180px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; padding: 14px 16px; background: #F4F7FC; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: #F4F7FC; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table .empty { text-align: center; color: var(--muted); padding: 40px; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: color-mix(in srgb, var(--c, var(--blue)) 12%, white); color: var(--c, var(--blue)); }
.badge { padding: 4px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.badge.on, .badge.off { background: #E8EFF9; color: var(--blue-d); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.pg { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: 1.2rem; }
.pg.disabled { opacity: .4; } .pg-info { color: var(--muted); font-size: .9rem; }

/* ===== Formularios ===== */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.section-title { margin: 8px 0 0 !important; padding-bottom: 8px; border-bottom: 2px solid var(--yellow); display: inline-block; font-size: 1rem !important; color: var(--blue); }
.req, label b { color: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: .88rem; }
input, select, textarea {
    font: 500 .95rem 'Outfit', sans-serif; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
    transition: border-color .2s, box-shadow .2s; width: 100%; -webkit-appearance: none; appearance: none;
}
select { background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%230B3A8C' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; padding-right: 36px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(11, 58, 140, .12); }
input:disabled { background: #F4F7FC; color: var(--muted); }
.err { color: var(--red); font-size: .8rem; }
.segmented { display: flex; gap: 8px; }
.segmented label { flex: 1; }
.segmented input, .options input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 11px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; transition: .2s; }
.segmented input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.option span { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; transition: .2s; font-weight: 500; }
.option span b { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, white); color: var(--c); flex-shrink: 0; }
.option span:hover { border-color: var(--c); }
.option input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, white); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.option input:checked + span b { background: var(--c); color: #fff; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; -webkit-appearance: checkbox; appearance: auto; accent-color: var(--red); }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.switch input { display: none; }
.switch span { width: 46px; height: 26px; background: #D9D6CE; border-radius: 99px; position: relative; transition: .2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { left: 23px; }
.pw-wrap { position: relative; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; font-size: 1.1rem; opacity: .6; }

/* ===== Login ===== */
.auth-page { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; position: relative; isolation: isolate; }
.auth-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100lvh; z-index: 0; transform: translateZ(0); pointer-events: none; }
.auth-flag { position: absolute; inset: 0; display: grid; grid-template-columns: 45% 55%; grid-template-rows: 1fr 1fr; }
.af-white { background: #fff; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; font-size: clamp(28px, 9vw, 80px); letter-spacing: 8px; line-height: 1; }
.af-white span:first-child { background: linear-gradient(90deg, var(--red) 0 50%, var(--blue) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.af-white span:last-child { color: var(--blue); }
.af-yellow { background: var(--yellow); }
.af-red { grid-column: 1 / -1; background: linear-gradient(160deg, var(--red), var(--red-d)); }
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: rgba(10, 20, 50, .25); }
.auth-card { width: 100%; max-width: 420px; padding: 36px 32px; border-radius: 26px; background: rgba(255,255,255,.95); box-shadow: 0 30px 70px -20px rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.7); animation: rise .6s ease both; }
@media (min-width: 821px) { .auth-card { background: rgba(255,255,255,.88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); } }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head svg.logo { width: 84px; height: 56px; border-radius: 10px; }
.auth-head h1 { margin: 14px 0 4px; font-size: 2rem; font-weight: 800; color: var(--blue-d); letter-spacing: -.5px; }
.auth-head p { margin: 0; color: var(--muted); }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin: 22px 0 0; }

.bottom-nav { display: none; }

/* Pastel de propuestas */
.pie-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 32px; align-items: center; }
.pie { width: 260px; height: 260px; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 14px 30px -14px rgba(0,0,0,.35); animation: spin-in .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes spin-in { from { transform: rotate(-90deg) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.pie-center { width: 130px; height: 130px; border-radius: 50%; background: #fff; display: grid; place-content: center; text-align: center; box-shadow: inset 0 0 0 6px rgba(0,0,0,.03); }
.pie-center strong { font-size: 2rem; font-weight: 800; color: var(--blue-d); }
.pie-center small { color: var(--muted); }
.pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.pie-legend li { display: grid; grid-template-columns: 14px 1fr auto 60px; align-items: center; gap: 4px 10px; }
.pie-legend li > i { width: 14px; height: 14px; border-radius: 4px; }
.pie-legend b { font-size: 1rem; }
.pie-legend em { font-style: normal; font-weight: 800; text-align: right; }
.pie-legend .bar { grid-column: 2 / -1; height: 6px; }

/* Filtro de fechas */
.filter-card { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 20px; padding: 16px 18px; }
.range { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; flex: 1; }
.range label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.range input { padding: 9px 12px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 12px; font: 600 .8rem 'Outfit', sans-serif; color: var(--blue); cursor: pointer; transition: .2s; }
.quick button:hover { background: var(--yellow); border-color: var(--yellow); color: var(--blue-d); }
.toolbar.m0 { margin: 0; width: 100%; }

/* Barras por día */
.cols { display: flex; align-items: flex-end; gap: 4px; height: 180px; overflow-x: auto; padding-top: 18px; }
.col { flex: 1; min-width: 18px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.col i { width: 100%; max-width: 28px; height: var(--h); min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(var(--red), var(--yellow)); animation: up .8s ease both; }
@keyframes up { from { height: 0; } }
.col b { font-size: .7rem; color: var(--blue-d); }
.col small { font-size: .65rem; color: var(--muted); }
.table.compact td, .table.compact th { padding: 10px 12px; }

@media (max-width: 820px) {
    .pie-wrap { grid-template-columns: 1fr; justify-items: center; }
    .pie { width: 220px; height: 220px; }
    .pie-center { width: 110px; height: 110px; }
    .pie-legend { width: 100%; }
    .filter-card .btn { width: 100%; }
}

/* ===== Responsive / móvil (app) ===== */
@media (max-width: 960px) {
    .grid-dash { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
    .mobile-brand { display: block; }
    .topbar h1 { font-size: 1.4rem; }
    .topbar-actions { width: 100%; }
    .topbar-actions .btn { flex: 1; }
    .grid-2 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat { padding: 16px; } .stat strong { font-size: 2rem; }
    .card { padding: 18px; }
    .form-actions .btn { flex: 1; }
    /* Tablas como tarjetas */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 14px 16px; border-bottom: 8px solid var(--bg); }
    .table td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
    .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
    .table td[data-label="Nombre"] { text-align: left; padding-bottom: 10px; }
    .table td[data-label="Nombre"]::before { display: none; }
    .table .actions { justify-content: stretch; padding-top: 10px; }
    .table .actions > * { flex: 1; } .table .actions .btn { width: 100%; }

    .bottom-nav {
        display: flex; position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
        background: var(--blue-d); border-radius: 22px; padding: 8px; box-shadow: 0 16px 40px -10px rgba(7, 39, 95, .6);
    }
    .bottom-nav > a, .bottom-nav > form { flex: 1; display: flex; }
    .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 14px; color: rgba(255,255,255,.7); font: 600 .68rem 'Outfit', sans-serif; background: none; border: 0; cursor: pointer; transition: .2s; }
    .bn-item.active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 2px #8FB1E2; }
    .auth-flag { grid-template-columns: 50% 50%; }
}
