/* ==========================================================
   iSoftControl - Phones
   Tema: Modo Nocturno de Cobranza
   Un solo acento configurable en /ajustes.php (--accent).
   Los colores de estado (pagado/pendiente/al corriente/cancelado)
   son independientes del acento y no cambian con él.
========================================================== */

:root {
    --bg: #0B0B0C;
    --surface: #17171A;
    --surface-2: #1D1D21;
    --ink: #EDEAE2;
    --ink-soft: #8B8D91;
    --line: rgba(237, 234, 226, 0.12);

    --accent: #1769FF;
    --accent-ink: #FFFFFF;

    --pos: #34B27B;
    --neg: #E5484D;
    --warn: #D98A00;
    --cancel: #8B8D91;

    --radius: 16px;
    --radius-sm: 12px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* tema claro, activado con data-theme="light" en <html> desde ajustes.php */
:root[data-theme="light"] {
    --bg: #F6F5F1;
    --surface: #FFFFFF;
    --surface-2: #EFEDE7;
    --ink: #201C14;
    --ink-soft: #6B6559;
    --line: rgba(32, 28, 20, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font);
}

body {
    background: var(--bg);
    color: var(--ink);
    padding: 20px;
}

a {
    color: var(--accent);
}

/* ---------- titulares ---------- */

.titulo {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--ink);
}

.subtitulo {
    font-size: 18px;
    font-weight: bold;
    margin: 25px 0 15px;
    color: var(--ink);
}

.subtitulo.alerta {
    color: var(--neg);
    text-align: center;
}

.total {
    text-align: center;
    margin-bottom: 20px;
    color: var(--ink-soft);
}

/* ---------- tarjetas ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 15px;
}

.card-grande {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 35px;
    text-align: center;
    margin-bottom: 25px;
}

.card-grande h1 {
    font-size: 40px;
    color: var(--ink);
}

.card-grande span {
    font-size: 18px;
    color: var(--ink-soft);
}

.card-pequena {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 25px 10px;
    text-align: center;
}

.card-pequena h2 {
    font-size: 20px;
    color: var(--ink);
}

.card-pequena span {
    display: block;
    margin-top: 10px;
    color: var(--ink-soft);
    font-size: 16px;
}

.fila {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.rojo { color: var(--neg) !important; }
.gris { color: var(--ink-soft) !important; }

.grid {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.grid .card {
    flex: 1;
    margin-bottom: 0;
}

/* ---------- botones ---------- */

.boton {
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    border: none;
    padding: 18px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--accent-ink);
    margin-bottom: 15px;
    margin-top: 0;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.boton:hover { opacity: .92; }

.boton.volver,
.boton.salir {
    background: var(--neg);
    color: #fff;
}

.boton.whatsapp {
    background: #25D366;
    color: #06210F;
}

.icono { vertical-align: -4px; margin-right: 6px; }
.quick-actions a .icono { vertical-align: 0; margin-right: 0; }
.header-actions { display: flex; gap: 8px; }

.ver {
    display: block;
    text-decoration: none;
    text-align: center;
    background: var(--accent);
    color: var(--accent-ink);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    font-weight: 700;
}

/* ---------- texto informativo ---------- */

.info {
    margin-bottom: 8px;
    color: var(--ink-soft);
}

.nombre,
.cliente,
.concepto {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--ink);
}

.hoy {
    color: var(--pos);
    font-weight: bold;
}

.ganancia {
    color: var(--pos);
    font-weight: bold;
}

/* ---------- estados ---------- */

.activo,
.pagado {
    color: var(--pos);
    font-weight: bold;
}

.liquidado,
.pendiente {
    color: var(--neg);
    font-weight: bold;
}

.cancelado {
    color: var(--cancel);
    font-weight: bold;
}

/* ---------- resumen / dashboard ---------- */

.resumen {
    text-align: center;
}

.resumen h2 {
    color: var(--accent);
    margin-bottom: 10px;
}

.resumen span {
    display: block;
    margin-bottom: 8px;
    color: var(--ink-soft);
}

.resumen-card {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.resumen-card h2 {
    font-size: 28px;
    color: var(--ink);
}

.resumen-card span {
    display: block;
    margin-top: 8px;
    color: var(--ink-soft);
}

/* caja de cálculo en línea (p.ej. registrar abono) */
.calculo {
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
}

.calculo div {
    margin-bottom: 8px;
    color: var(--ink-soft);
}

/* ---------- buscador / formularios ---------- */

.buscador {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius);
    font-size: 16px;
    margin-bottom: 15px;
}

.buscador::placeholder { color: var(--ink-soft); }

/* ---------- buscador general en menú principal ---------- */

.global-search-container {
    position: relative;
    margin-bottom: 20px;
    z-index: 100;
}

.global-search-box {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.global-search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.15);
}

.global-search-icon {
    display: flex;
    align-items: center;
    color: var(--ink-soft);
    margin-right: 12px;
    flex-shrink: 0;
}

.global-search-input {
    width: 100%;
    background: transparent;
    border: none;
    padding: 14px 0;
    font-size: 15px;
    color: var(--ink);
    outline: none;
}

.global-search-input::placeholder {
    color: var(--ink-soft);
}

.global-search-clear {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}

.global-search-clear:hover {
    color: var(--ink);
}

/* Resultados desplegables */
.global-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    max-height: 420px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    padding: 8px 0;
}

.global-search-results.active {
    display: block;
}

.search-category-title {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--line);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--ink);
    border-bottom: 1px solid rgba(237, 234, 226, 0.05);
    transition: background 0.15s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
    background: var(--surface-2);
}

.search-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.search-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-sub {
    font-size: 13px;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-item-badge {
    margin-left: 12px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
}

.search-empty-state {
    padding: 24px 16px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 14px;
}

label {
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--ink);
}

input,
select,
textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius-sm);
    font-size: 16px;
}

input::placeholder { color: var(--ink-soft); }

h1 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--ink);
}

/* login: campos y título en formato "hero" */

.label {
    display: block;
    color: var(--ink);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
}

.input {
    width: 100%;
    height: 70px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    padding: 0 20px;
    font-size: 20px;
    margin-bottom: 25px;
}

.input::placeholder { color: var(--ink-soft); }

.hero-titulo {
    color: var(--ink);
    font-size: 44px;
    font-weight: bold;
    line-height: 1.08;
    margin-bottom: 40px;
    text-align: center;
}

.boton.hero {
    height: 72px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 22px;
    font-weight: bold;
}

.contenedor {
    width: 100%;
    max-width: 500px;
    text-align: center;
    margin: 0 auto;
}

.logo {
    width: 60% !important;
    margin: 0 auto 10px;
}

.footer {
    margin-top: 30px;
    color: var(--ink-soft);
    font-size: 16px;
    text-align: center;
}

/* ---------- alertas ---------- */

.error {
    background: rgba(229, 72, 77, 0.15);
    color: #FF9DA1;
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

.exito {
    background: rgba(52, 178, 123, 0.15);
    color: #7BE0B3;
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 15px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

/* ---------- reportes ---------- */

.modulo {
    margin-top: 35px;
    margin-bottom: 20px;
    background: var(--accent);
    color: var(--accent-ink);
    text-align: center;
    padding: 15px;
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: bold;
}

.seccion {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    margin: 30px 0 15px;
    color: var(--accent);
}

.destacado {
    background: var(--accent);
    color: var(--accent-ink);
}

.destacado h2 { color: var(--accent-ink); font-size: 42px; }

/* ---------- acordeón (cobranza de hoy) ---------- */

.grupo { margin-bottom: 20px; }

.grupo summary {
    list-style: none;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 18px;
    font-weight: bold;
    padding: 16px 20px;
    border-radius: var(--radius);
}

.grupo summary::-webkit-details-marker { display: none; }
.grupo summary::after { content: "▼"; float: right; }
.grupo[open] summary::after { content: "▲"; }
.grupo .contenido { padding-top: 15px; }

/* ---------- ajustes ---------- */

.paleta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.swatch-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--line);
    cursor: pointer;
    padding: 0;
}

.swatch-btn.activo {
    border-color: var(--ink);
}

.modo-btn {
    flex: 1;
    background: var(--surface);
    border: 2px solid var(--line);
    color: var(--ink);
    text-align: center;
    padding: 18px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
}

.modo-btn.activo {
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- rediseño: dashboard, detalle y apariencia ---------- */

.app-body { padding: 0; min-height: 100vh; }
.app-shell { width: min(100%, 760px); margin: 0 auto; padding: 24px 18px 112px; }
.app-header, .detail-header, .section-heading, .insight-heading, .preview-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.app-header { margin: 4px 0 24px; }
.app-header h1, .detail-header h1 { margin: 0; text-align: left; font-size: clamp(23px, 5vw, 30px); letter-spacing: -.7px; }
.app-header h1 span { color: var(--accent); }
.eyebrow { margin: 0 0 5px; color: var(--ink-soft); font-size: 12px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.icon-button, .back-link { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); text-decoration: none; font-size: 22px; background: var(--surface); }
.detail-header { margin-bottom: 22px; }
.detail-header h1 { flex: 1; text-align: center; font-size: 18px; }
.detail-header > span { width: 40px; }

.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric-card, .insight-card, .status-card, .loan-summary-grid, .loan-balance-card, .progress-card, .loan-detail-grid, .settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.metric-card { padding: 17px; min-height: 130px; }
.metric-card p, .metric-card span { margin: 0; color: var(--ink-soft); font-size: 13px; }
.metric-card strong { display: block; margin: 9px 0 5px; color: var(--accent); font-size: clamp(22px, 5.4vw, 30px); letter-spacing: -.8px; }
.metric-card-wide { grid-column: span 1; }
.dashboard-insights { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; margin: 12px 0 30px; }
.insight-card, .status-card { padding: 16px; }
.insight-heading span, .status-card p, .status-card div { color: var(--ink-soft); font-size: 12px; }
.insight-heading strong { color: var(--ink); font-size: 14px; }
.insight-card small { color: var(--ink-soft); font-size: 11px; }
.progress-track { height: 8px; margin: 14px 0 9px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.status-card p { margin: 0 0 10px; font-weight: 800; }
.status-card div { display: flex; align-items: center; gap: 6px; margin: 7px 0; }
.status-card strong { margin-left: auto; color: var(--ink); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }.positive { background: var(--pos); }.warning { background: var(--warn); }.muted { background: var(--cancel); }
.section-heading { margin: 26px 0 12px; }.section-heading.compact { margin: 0; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.3px; }.section-heading a { font-size: 13px; font-weight: 800; text-decoration: none; }
.collection-list { display: grid; gap: 9px; }
.collection-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto 10px; align-items: center; gap: 10px; padding: 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 15px; text-decoration: none; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.collection-copy, .collection-amount { min-width: 0; }.collection-copy strong, .collection-copy small, .collection-amount strong, .collection-amount em { display: block; }.collection-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }.collection-copy small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.collection-amount { text-align: right; }.collection-amount strong { font-size: 13px; }.chevron { color: var(--ink-soft); font-size: 23px; }
.chip { display: inline-flex; align-items: center; width: fit-content; margin-top: 4px; padding: 3px 7px; border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 800; }.chip-danger { color: #C93A3F; background: rgba(229, 72, 77, .12); }.chip-success { color: var(--pos); background: rgba(52, 178, 123, .13); }.chip-muted { color: var(--ink-soft); background: var(--surface-2); }
.empty-state { display: grid; gap: 5px; padding: 20px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: 15px; }.empty-state span { color: var(--ink-soft); font-size: 13px; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 28px; }.quick-actions a { display: grid; gap: 5px; place-items: center; min-height: 65px; padding: 8px 4px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 13px; font-size: 17px; text-decoration: none; }.quick-actions span { font-size: 10px; font-weight: 700; color: var(--ink-soft); }

.loan-client-card { display: flex; align-items: center; gap: 12px; padding: 17px; color: #fff; background: linear-gradient(135deg, #172238, #25334f); border-radius: 18px; }.avatar-large { width: 52px; height: 52px; background: #e7efff; color: #24355a; }.loan-client-card h2 { margin: 0 0 3px; font-size: 18px; }.loan-client-card p, .loan-client-card small { display: block; margin: 0; color: rgba(255,255,255,.72); font-size: 12px; }.loan-client-card .chip { margin-left: auto; white-space: nowrap; }
.loan-summary-grid, .loan-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; }.loan-summary-grid div, .loan-detail-grid div { min-width: 0; padding: 14px 10px; text-align: center; border-right: 1px solid var(--line); }.loan-summary-grid div:last-child, .loan-detail-grid div:last-child { border-right: 0; }.loan-summary-grid span, .loan-detail-grid span, .loan-balance-card span { display: block; color: var(--ink-soft); font-size: 11px; }.loan-summary-grid strong, .loan-detail-grid strong { display: block; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.loan-balance-card { display: grid; grid-template-columns: 1fr 1fr; margin-top: 12px; padding: 18px; }.loan-balance-card > div + div { padding-left: 18px; border-left: 1px solid var(--line); }.loan-balance-card strong { display: block; margin-top: 7px; color: var(--accent); font-size: 23px; letter-spacing: -.6px; }.loan-balance-card small { color: var(--ink-soft); font-size: 11px; }.progress-card { margin-top: 12px; padding: 17px; }.progress-card .section-heading strong { color: var(--accent); }.progress-large { height: 10px; margin-top: 16px; }.progress-labels { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 11px; }.loan-detail-grid { grid-template-columns: repeat(2, 1fr); }.loan-detail-grid div:nth-child(2n) { border-right: 0; }.loan-detail-grid div:nth-child(n+3) { border-top: 1px solid var(--line); }
.payment-history { display: grid; gap: 8px; }.payment-item { display: flex; align-items: center; gap: 11px; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }.payment-check { display: grid; place-items: center; width: 21px; height: 21px; color: var(--accent-ink); background: var(--accent); border-radius: 50%; font-size: 12px; font-weight: 800; }.payment-item div:nth-child(2) { min-width: 0; }.payment-item strong, .payment-item small { display: block; }.payment-item small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }.payment-value { margin-left: auto; text-align: right; white-space: nowrap; }.financial-details { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }.financial-details summary { padding: 15px; cursor: pointer; font-weight: 800; }.financial-details div { padding: 0 15px 10px; }.financial-details p { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 13px; }.financial-details strong { color: var(--ink); }.loan-actions { display: grid; gap: 8px; margin-top: 18px; }.loan-actions a, .loan-actions button { width: 100%; padding: 12px; border: 0; color: var(--ink-soft); background: transparent; font: inherit; font-size: 13px; text-align: center; text-decoration: none; cursor: pointer; }.fixed-payment-button { position: fixed; z-index: 4; right: max(18px, calc((100vw - 760px) / 2 + 18px)); bottom: 18px; left: max(18px, calc((100vw - 760px) / 2 + 18px)); display: flex; align-items: center; justify-content: center; gap: 8px; padding: 17px; color: var(--accent-ink); background: var(--accent); border-radius: 14px; box-shadow: 0 12px 28px rgba(0,0,0,.22); font-weight: 800; text-decoration: none; }

.settings-card { padding: 19px; margin-bottom: 13px; }.settings-card h2 { margin: 0; font-size: 19px; }.settings-description { margin: 9px 0 17px; color: var(--ink-soft); font-size: 13px; line-height: 1.45; }.theme-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }.modo-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; }.modo-btn span { font-size: 20px; }.paleta { gap: 14px; margin: 19px 0; }.swatch-btn { width: 45px; height: 45px; border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }.swatch-btn.activo { box-shadow: 0 0 0 3px var(--accent), 0 0 0 4px var(--surface); }.color-input { height: 46px; padding: 4px; cursor: pointer; }.preview-card { overflow: hidden; }.preview-header { margin-bottom: 13px; }.preview-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }.preview-metrics div { padding: 12px; background: var(--surface-2); border-radius: 11px; }.preview-metrics span, .preview-metrics strong { display: block; }.preview-metrics span { color: var(--ink-soft); font-size: 10px; }.preview-metrics strong { margin-top: 5px; color: var(--accent); font-size: 17px; }.preview-button, .save-appearance, .reset-appearance { display: block; width: 100%; margin-top: 13px; padding: 16px; border: 0; border-radius: 13px; font: inherit; font-weight: 800; text-align: center; text-decoration: none; cursor: pointer; }.preview-button, .save-appearance { color: var(--accent-ink); background: var(--accent); }.reset-appearance { color: var(--ink-soft); background: transparent; }

@media (min-width: 620px) { .app-shell { padding: 34px 28px 112px; }.metric-grid { grid-template-columns: 1.25fr .75fr; }.dashboard-insights { grid-template-columns: 1.25fr .75fr; }.quick-actions { grid-template-columns: repeat(7, 1fr); }.fixed-payment-button { left: calc(50% - 340px); right: calc(50% - 340px); } }
