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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    font-size: 15px;
}

/* ---- Header ---- */
header {
    background: #1a1a2e;
    color: white;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.nav-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 36px; height: 36px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }

.mes-titulo {
    font-size: 22px;
    font-weight: 700;
    flex: 1;
}

/* ---- Objetivo editable ---- */
.objetivo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgba(255,255,255,0.8);
}
.objetivo-wrap input {
    width: 90px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}
.objetivo-wrap input:focus { outline: none; border-color: #4ecca3; }
.objetivo-wrap button {
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    background: #4ecca3;
    color: #1a1a2e;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
}

/* ---- KPIs ---- */
.kpis {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 16px 24px;
    overflow-x: auto;
}

.kpis .kpi {
    flex: 1 0 0;
    min-width: 120px;
}

.kpi {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
}
.kpi-value.green { color: #1a9e6e; }
.kpi-value.amber { color: #d4870a; }
.kpi-value.red   { color: #c0392b; }
.kpi-value small {
    font-size: 14px;
    font-weight: 400;
    color: #888;
    margin-left: 2px;
}

/* ---- Progress bar ---- */
.progress-wrap {
    padding: 0 24px 8px;
}
.progress-bar-bg {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: #4ecca3;
    border-radius: 4px;
    transition: width 0.4s;
}
.progress-bar-fill.completed { background: #1a9e6e; }
.progress-label {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
    text-align: right;
}

/* ---- Main layout ---- */
main {
    padding: 0 24px 40px;
    max-width: 1100px;
    margin: 0 auto;
}

/* ---- Tabla de días ---- */
.tabla-wrap {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}
thead th {
    background: #1a1a2e;
    color: rgba(255,255,255,0.8);
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}
tbody tr:nth-child(even) { background: #f9fafb; }
tbody tr:hover { background: #eef6f2; }
td {
    padding: 10px 14px;
    font-size: 14px;
    vertical-align: top;
    border-bottom: 1px solid #f0f0f0;
}
td.fecha {
    font-weight: 700;
    white-space: nowrap;
    color: #555;
    font-size: 13px;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.prima-total { font-weight: 700; color: #1a1a2e; }

.polizas-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.poliza-chip {
    background: #eef6f2;
    border: 1px solid #c8e6d8;
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.poliza-chip .del-poliza {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}
.poliza-chip .del-poliza:hover { color: #c0392b; }

.del-dia {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 16px;
    margin-left: 6px;
    padding: 0;
    vertical-align: middle;
}
.del-dia:hover { color: #c0392b; }

.incentivo-badge {
    display: inline-block;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 5px;
    padding: 2px 7px;
    font-size: 12px;
    color: #856404;
}

.ratio-cell { color: #555; font-weight: 600; }

/* ---- Formulario de entrada ---- */
.form-card {
    background: white;
    border-radius: 12px;
    padding: 20px 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.form-card h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    color: #1a1a2e;
}
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-group label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-group input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    width: 150px;
}
.form-group input:focus {
    outline: none;
    border-color: #4ecca3;
    box-shadow: 0 0 0 3px rgba(78,204,163,0.15);
}
.form-group input.wide { width: 200px; }

.btn-add {
    padding: 9px 22px;
    background: #1a1a2e;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-add:hover { background: #2d2d4e; }

.btn-incentivo {
    padding: 9px 18px;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-incentivo:hover { background: #ffe69c; }

.btn-trabajado {
    padding: 9px 18px;
    background: #f0f0f0;
    color: #555;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-trabajado:hover { background: #e0e0e0; }

tr.sin-ventas td { color: #aaa; font-style: italic; }
tr.festivo td { color: #e74c3c; font-style: italic; }

.btn-festivo {
    padding: 9px 18px;
    background: #fdecea;
    color: #c0392b;
    border: 1px solid #e74c3c;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-festivo:hover { background: #f9d0cc; }

/* ── Calendario de citas ── */
.citas-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    align-items: start;
}
.cal-wrap {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 14px;
    position: sticky;
    top: 16px;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-head {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    padding: 4px 0;
}
.cal-day {
    min-height: 34px;
    border-radius: 6px;
    padding: 3px 4px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}
.cal-day:hover    { background: #f0f9f5; }
.cal-blank        { cursor: default; }
.cal-blank:hover  { background: none; }
.cal-hoy          { background: #eef6f2; }
.cal-hoy .cal-num { color: #1a9e6e; font-weight: 800; }
.cal-selected     { background: #1a1a2e !important; }
.cal-selected .cal-num  { color: white; }
.cal-selected .cal-dot  { opacity: 0.8; }
.cal-con-citas .cal-num { font-weight: 700; }
.cal-num {
    font-size: 11px;
    color: #333;
    display: block;
}
.cal-dots {
    display: flex;
    gap: 3px;
    margin-top: 4px;
}
.cal-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ccc;
}
.cal-dot.estado-pendiente    { background: #ccc; }
.cal-dot.estado-no_localizado{ background: #f59e0b; }
.cal-dot.estado-vendido      { background: #16a34a; }
.cal-dot.estado-no_vendido   { background: #dc2626; }
.cal-dot.estado-seguimiento  { background: #7c3aed; }

/* Panel del día */
.citas-panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    padding: 20px 24px;
    margin-bottom: 16px;
    min-height: 320px;
}
@media (max-width: 640px) {
    .citas-layout { grid-template-columns: 1fr; }
    .cal-wrap { position: static; }
}
.citas-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 14px;
}
.cita-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}
.cita-item:last-child { border-bottom: none; }
.cita-hora {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a2e;
    min-width: 48px;
}
.cita-info { flex: 1; }
.cita-cliente {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
}
.cita-desc {
    font-size: 13px;
    color: #888;
    margin-top: 2px;
}
.cita-creado {
    font-size: 11px;
    color: #aaa;
    margin-top: 3px;
}
.cita-aviso {
    font-size: 12px;
    color: #aaa;
    white-space: nowrap;
}
.cita-estado-bar {
    width: 4px;
    align-self: stretch;
    border-radius: 4px;
    min-height: 36px;
    flex-shrink: 0;
}
.cita-btns-estado {
    display: flex;
    gap: 5px;
    align-items: center;
}
.btn-estado {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--col);
    background: none;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
    flex-shrink: 0;
}
.btn-estado:hover  { background: var(--col); opacity: 0.7; }
.btn-estado.activo { background: var(--col); }

/* ── Botón Catastro ── */
.btn-catastro {
    padding: 7px 16px;
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn-catastro:hover { background: #e0e7ff; }

/* ── Modal Catastro ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-box {
    background: white;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 18px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: #aaa;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}
.modal-close:hover { color: #c0392b; }

.cat-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 0;
}
.cat-tab {
    padding: 7px 16px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.cat-tab.active { color: #1a1a2e; border-bottom-color: #4ecca3; }
.cat-tab:hover  { color: #1a1a2e; }

.cat-panel { margin-bottom: 16px; }

.cat-result {
    margin-top: 16px;
    border-top: 1px solid #f0f0f0;
    padding-top: 14px;
}
.cat-loading { color: #888; font-size: 14px; }
.cat-error   { color: #c0392b; font-size: 14px; font-weight: 600; }

.cat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.cat-table th {
    text-align: left;
    color: #666;
    font-weight: 600;
    padding: 6px 10px 6px 0;
    white-space: nowrap;
    width: 170px;
    vertical-align: top;
}
.cat-table td {
    padding: 6px 0;
    color: #1a1a2e;
    border-bottom: 1px solid #f5f5f5;
}
.cat-table thead th {
    background: #f9fafb;
    color: rgba(255,255,255,0.8);
    padding: 8px 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #1a1a2e;
}
.cat-row { cursor: pointer; }
.cat-row:hover td { background: #eef6f2; }
.cat-table code {
    font-size: 12px;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* ---- Vacío ---- */
.empty {
    text-align: center;
    padding: 40px;
    color: #aaa;
    font-size: 15px;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #1a9e6e;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 999;
}
.toast.show { opacity: 1; }
.toast.error { background: #c0392b; }

/* ── Banner de aviso de cita ── */
.cita-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1a1a2e;
    color: white;
    border-left: 5px solid #f59e0b;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 380px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 9999;
    animation: slideIn 0.3s ease;
}
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
.cita-banner-icon { font-size: 24px; flex-shrink: 0; }
.cita-banner-body { flex: 1; }
.cita-banner-body strong { display: block; font-size: 14px; margin-bottom: 3px; }
.cita-banner-body span   { font-size: 12px; color: rgba(255,255,255,0.65); }
.cita-banner button {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    align-self: flex-start;
}
.cita-banner button:hover { color: white; }

/* ── Autocomplete ── */
.ac-wrap { position: relative; }
.ac-list {
    position: absolute;
    top: calc(100% + 2px);
    left: 0; right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 4px 0;
}
.ac-list.visible { display: block; }
.ac-item {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-item:hover, .ac-item.focused { background: #f0f9f5; color: #1a9e6e; }
.ac-loading { padding: 10px 14px; font-size: 13px; color: #aaa; }

@media (max-width: 600px) {
    header { padding: 12px 16px; }
    .kpis { padding: 12px 16px; }
    main { padding: 0 16px 40px; }
    .form-group input { width: 130px; }
    thead th:nth-child(3),
    thead th:nth-child(5),
    td:nth-child(3),
    td:nth-child(5) { display: none; }
}
