/* ============================================================
   SomFree — Panel de Control · Hoja de estilos
   Tema: negro metálico + verde neón + dorado (mis gastos)
   Copiado fielmente de los mockups de referencia.
   ============================================================ */

/* ── Variables (tokens CSS) ───────────────────────────── */
:root {
    --bg: #070a08;
    --panel: #0e1310;
    --panel2: #141c17;
    --panel3: #18211b;
    --line: #202a24;
    --line2: #2a3830;
    --green: #3ee019;
    --green2: #22c55e;
    --green-dk: #0c8f2e;
    --green-glow: rgba(62, 224, 25, .30);
    --silver: #c3cec8;
    --text: #e9f2ec;
    --muted: #6c7f75;
    --muted2: #8c9d93;
    --gold: #d4af37;
    --gold-bg: rgba(212, 175, 55, .12);
    --gold-line: rgba(212, 175, 55, .32);
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, .13);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, .13);
    --grn-bg: rgba(62, 224, 25, .12);
    --mono: "SF Mono", "Cascadia Code", ui-monospace, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--sans);
    background:
        radial-gradient(1100px 500px at 80% -10%, rgba(62, 224, 25, .08), transparent 60%),
        radial-gradient(900px 600px at -10% 110%, rgba(34, 197, 94, .06), transparent 55%),
        var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 16px 60px;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Utilidades ───────────────────────────────────────── */
.spacer { margin-left: auto; }

/* ── Botones premium ──────────────────────────────────── */
.btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--line2);
    background: linear-gradient(180deg, var(--panel3), var(--panel));
    color: var(--text);
    padding: 10px 16px;
    border-radius: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: .18s;
    position: relative;
    text-decoration: none;
}
.btn:hover {
    border-color: #3a4d42;
    transform: translateY(-1px);
}
.btn svg { width: 16px; height: 16px; }

.btn.green {
    background: linear-gradient(180deg, #3ee019, #20a80f);
    color: #05230a;
    border: none;
    box-shadow: 0 6px 20px -6px var(--green-glow), inset 0 1px 0 rgba(255, 255, 255, .35);
    font-weight: 700;
}
.btn.green:hover {
    filter: brightness(1.07);
    box-shadow: 0 10px 26px -6px var(--green-glow);
}
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 12px; border-radius: 9px; }
.btn.danger {
    background: transparent;
    border-color: #4a2a2a;
    color: #f4a3a3;
}
.btn.danger:hover { background: rgba(239, 68, 68, .1); }

/* ── Icon button ──────────────────────────────────────── */
.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line2);
    background: var(--panel3);
    border-radius: 11px;
    cursor: pointer;
    color: var(--muted2);
}
.icon-btn:hover { color: var(--green); border-color: #3a4d42; }
.icon-btn svg { width: 17px; height: 17px; }

/* ════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════ */
#login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}

.loginbox {
    width: 100%;
    max-width: 380px;
    background: linear-gradient(180deg, rgba(20, 28, 23, .9), rgba(14, 19, 16, .95));
    border: 1px solid var(--line2);
    border-radius: 22px;
    padding: 34px 30px;
    box-shadow:
        0 30px 80px -30px #000,
        0 0 0 1px rgba(62, 224, 25, .06),
        0 0 60px -20px var(--green-glow);
    text-align: center;
    backdrop-filter: blur(6px);
}
.loginbox img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 6px 18px var(--green-glow));
}
.loginbox h1 {
    font-size: 19px;
    font-weight: 800;
    margin-top: 6px;
    letter-spacing: -.2px;
}
.loginbox .tag {
    font-size: 12px;
    color: var(--muted2);
    margin-top: 3px;
    margin-bottom: 22px;
}

/* ── Inputs del login ─────────────────────────────────── */
.inp {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(180deg, #0c1210, #080c0a);
    border: 1px solid var(--line2);
    border-radius: 14px;
    padding: 13px 15px;
    margin-bottom: 14px;
    text-align: left;
    transition: border-color .2s, box-shadow .25s;
    position: relative;
}
.inp:focus-within {
    border-color: var(--green2);
    box-shadow: inset 0 0 18px -6px var(--green-glow);
}
.inp svg { width: 17px; height: 17px; color: var(--green); flex: none; }
.inp input {
    background: none !important;
    border: 0 !important;
    outline: 0 !important;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    padding: 2px 0;
    box-shadow: none !important;
}
.inp input:focus,
.inp input:focus-visible,
.inp input:focus-within {
    outline: 0 !important;
    outline-offset: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
}
.inp input::placeholder { color: #586a60; }

/* Eliminar recuadro blanco del autofill del navegador */
.inp input:-webkit-autofill,
.inp input:-webkit-autofill:hover,
.inp input:-webkit-autofill:focus,
.inp input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0c1210 inset !important;
    -webkit-text-fill-color: var(--text) !important;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: var(--text);
}

/* Botón del ojito (mostrar/ocultar contraseña) */
.inp .toggle-pw {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--muted2);
    transition: .15s;
    flex: none;
    padding: 0;
}
.inp .toggle-pw:hover {
    color: var(--green);
    background: rgba(62, 224, 25, .08);
}
.inp .toggle-pw svg {
    width: 18px;
    height: 18px;
    color: inherit;
}
.loginbox .btn.green {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
    padding: 12px;
}

.secnote {
    margin-top: 16px;
    font-size: 10.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}
.secnote svg { width: 13px; height: 13px; color: var(--green2); }

/* ── Flash messages ───────────────────────────────────── */
.flash-msg {
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
}
.flash-msg.error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, .25);
}
.flash-msg.success {
    background: var(--grn-bg);
    color: var(--green);
    border: 1px solid rgba(62, 224, 25, .25);
}
.flash-msg.warning {
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, .25);
}
.flash-msg.info {
    background: rgba(62, 224, 25, .08);
    color: var(--muted2);
    border: 1px solid var(--line2);
}

/* ════════════════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════════════════ */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 16px;
}
.topbar img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: drop-shadow(0 3px 8px var(--green-glow));
}
.topbar .bt { font-weight: 800; font-size: 16px; letter-spacing: -.2px; }
.topbar .bt span { color: var(--green); }
.topbar .bt small {
    display: block;
    font-weight: 500;
    font-size: 10.5px;
    color: var(--muted2);
    letter-spacing: .2px;
}
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--green);
    background: var(--grn-bg);
    border: 1px solid rgba(62, 224, 25, .3);
    padding: 5px 11px;
    border-radius: 30px;
}
.admin-badge svg { width: 13px; height: 13px; }

/* ════════════════════════════════════════════════════════
   KPIs
   ════════════════════════════════════════════════════════ */
.kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.card {
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 15px 16px;
    position: relative;
    overflow: hidden;
}
.card .ic {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--grn-bg);
    color: var(--green);
    margin-bottom: 10px;
}
.card .ic svg { width: 18px; height: 18px; }
.card .lab {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted2);
    font-weight: 600;
}
.card .val {
    font-size: 23px;
    font-weight: 800;
    margin-top: 4px;
    letter-spacing: -.5px;
}
.card .val.mn { font-family: var(--mono); font-size: 19px; }
.card .foot { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.card .val.pos { color: var(--green); }
.card .val.neg { color: var(--red); }

.bar {
    height: 6px;
    background: #0a0f0c;
    border-radius: 6px;
    margin-top: 9px;
    overflow: hidden;
    border: 1px solid var(--line);
}
.bar > i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green-dk), var(--green));
    border-radius: 6px;
    box-shadow: 0 0 10px var(--green-glow);
}

.card.net {
    border-color: rgba(62, 224, 25, .35);
    box-shadow: 0 0 40px -22px var(--green-glow);
}

/* ════════════════════════════════════════════════════════
   MIS GASTOS (tarjetas doradas)
   ════════════════════════════════════════════════════════ */
.myrow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.card.mine {
    border-color: var(--line2);
    border-left: 3px solid var(--gold);
}
.card.mine .ic {
    background: rgba(212, 175, 55, .13);
    color: var(--gold);
}
.card.mine .tophead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}
.card.mine .val.mn { color: #fff; }

.datechips {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    background: #0a0f0c;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 6px 9px;
    color: var(--muted2);
}
.chip svg { width: 13px; height: 13px; color: var(--gold); }
.chip b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.chip.renew svg { color: var(--amber); }

.cyclepill {
    font-size: 10px;
    font-weight: 700;
    color: var(--gold);
    background: rgba(212, 175, 55, .12);
    border: 1px solid rgba(212, 175, 55, .3);
    padding: 3px 9px;
    border-radius: 20px;
}

/* ── Sección título + botones ─────────────────────────── */
.secbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 12px;
}
.secbar h2 { font-size: 15px; font-weight: 700; }
.secbar h2 small {
    display: block;
    font-weight: 500;
    color: var(--muted2);
    font-size: 11px;
}

/* ════════════════════════════════════════════════════════
   TABLA DE CLIENTES
   ════════════════════════════════════════════════════════ */
.panel-c {
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    background: #0a0f0c;
    color: var(--muted2);
    text-align: left;
    padding: 12px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
}
tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(62, 224, 25, .03); }

.slot {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--muted2);
    text-align: center;
}
.addr {
    font-family: var(--mono);
    color: var(--green);
    font-weight: 600;
    font-size: 12.5px;
}
.cname { font-weight: 600; }
.money { font-family: var(--mono); text-align: right; }
.muted { color: #4f6157; font-style: italic; }
.text-muted { color: var(--muted2); }

.pill {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 30px;
    font-size: 11px;
    font-weight: 700;
}
.p-active { background: var(--grn-bg); color: var(--green); }
.p-pend { background: var(--amber-bg); color: var(--amber); }
.p-soon { background: var(--red-bg); color: var(--red); }
.p-free { background: #141c17; color: #4f6157; }

.rowact .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.rowact .icon-btn svg { width: 14px; height: 14px; }

/* ── Grid de resumen ──────────────────────────────────── */
.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 16px;
}
.sumcard {
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 17px 19px;
}
.sumcard h3 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sumcard h3 svg { width: 15px; height: 15px; color: var(--green); }

.srow {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
    font-size: 13px;
    color: var(--muted2);
}
.srow:last-child { border-bottom: none; }
.srow .rv { font-family: var(--mono); font-weight: 700; color: var(--text); }
.srow.total {
    border-top: 1px solid var(--line2);
    border-bottom: none;
    margin-top: 5px;
    padding-top: 11px;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
}
.rv.pos { color: var(--green); }
.rv.neg { color: var(--red); }

/* ════════════════════════════════════════════════════════
   MODALES (overlay + contenido)
   ════════════════════════════════════════════════════════ */

/* Overlay oscuro detrás del modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .7);
    z-index: 1000;
    align-items: flex-start;
    justify-content: center;
    padding: 30px 16px;
    overflow-y: auto;
}
.modal-overlay.active { display: flex; }

.modal {
    background: linear-gradient(180deg, rgba(20, 28, 23, .96), rgba(14, 19, 16, .98));
    border: 1px solid var(--line2);
    border-radius: 20px;
    box-shadow:
        0 30px 80px -30px #000,
        0 0 60px -26px var(--green-glow);
    overflow: hidden;
    width: 100%;
    max-width: 520px;
    margin: auto;
}
.modal.wide { max-width: 660px; }

/* Cabecera del modal */
.mhead {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 20px 22px 14px;
}
.mhead .hic {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--grn-bg);
    color: var(--green);
    flex: none;
}
.mhead .hic.gold { background: var(--gold-bg); color: var(--gold); }
.mhead .hic svg { width: 21px; height: 21px; }
.mhead h2 { font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.mhead p { font-size: 12px; color: var(--muted2); margin-top: 2px; }

.mhead .x {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: 1px solid var(--line2);
    background: var(--panel3);
    color: var(--muted2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
}
.mhead .x:hover { color: var(--red); border-color: #4a2a2a; }
.mhead .x svg { width: 15px; height: 15px; }

/* Cuerpo del modal */
.mbody { padding: 6px 22px 4px; }

/* Pie del modal */
.mfoot {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 16px 22px 20px;
    margin-top: 6px;
    border-top: 1px solid var(--line);
}

/* ── Campos de formulario ─────────────────────────────── */
.field { margin-bottom: 14px; }
.field > label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #0a0f0c;
    border: 1px solid var(--line2);
    border-radius: 11px;
    padding: 11px 13px;
    transition: .15s;
}
.control:focus-within {
    border-color: var(--green2);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .12);
}
.control svg { width: 16px; height: 16px; color: var(--green); flex: none; }
.control.gold svg { color: var(--gold); }
.control input,
.control select {
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
}
.control input.mono { font-family: var(--mono); }
.control select { cursor: pointer; appearance: none; }
.control input::placeholder { color: #4f6157; }

.two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.hint {
    font-size: 10.5px;
    color: var(--muted);
    margin-top: 6px;
}
.suffix {
    font-size: 11px;
    color: var(--muted2);
    font-family: var(--mono);
    flex: none;
}

/* ── Toggle switch ────────────────────────────────────── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0a0f0c;
    border: 1px solid var(--line2);
    border-radius: 11px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.toggle-row .tl { font-size: 13px; font-weight: 600; }
.toggle-row .ts { font-size: 11px; color: var(--muted); font-weight: 400; }

.sw {
    width: 44px;
    height: 25px;
    border-radius: 20px;
    background: var(--green-dk);
    position: relative;
    cursor: pointer;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, .4);
    flex: none;
    border: none;
}
.sw::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 22px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #eafff0;
    transition: .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.sw.off { background: #1e2823; }
.sw.off::after { left: 3px; }

/* ── Sub-secciones dentro del modal ───────────────────── */
.subsec {
    margin: 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 9px;
}
.subsec .sic {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold-bg);
    color: var(--gold);
}
.subsec .sic.grn { background: var(--grn-bg); color: var(--green); }
.subsec .sic svg { width: 15px; height: 15px; }
.subsec h3 { font-size: 13.5px; font-weight: 700; }
.subsec .tag {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    background: var(--gold-bg);
    color: var(--gold);
    border: 1px solid var(--gold-line);
}

.card-in {
    background: rgba(10, 15, 12, .5);
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
    margin-bottom: 14px;
}
.card-in.gold { border-left: 3px solid var(--gold); }

/* ════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════ */
@media (max-width: 920px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .hide-sm { display: none; }
}

@media (max-width: 640px) {
    .myrow { grid-template-columns: 1fr; }
    .grid2 { grid-template-columns: 1fr; }
    .topbar .bt small { display: none; }
    .modal { margin: 10px; }
    .modal-overlay { padding: 16px 8px; }
}

@media (max-width: 560px) {
    .two { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .kpis { grid-template-columns: 1fr 1fr; }
    .card .val { font-size: 20px; }
}

/* Hidden utility */
.hidden { display: none !important; }
