/* ── Design tokens ─────────────────────────────────── */
:root {
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --ink: #0f172a;
    --ink-muted: #475569;
    --surface: #ffffff;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-soft: rgba(13, 148, 136, 0.12);
    --warn-from: #c2410c;
    --warn-to: #ea580c;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 10px 40px -12px rgba(15, 23, 42, 0.12);
    --radius: 14px;
    --radius-sm: 10px;
    --layout-max: 1680px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(13, 148, 136, 0.09), transparent 55%),
        radial-gradient(900px 400px at 100% 0%, rgba(234, 88, 12, 0.06), transparent 50%),
        linear-gradient(180deg, #f1f5f9 0%, #f8fafc 35%, #f1f5f9 100%);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    width: min(100%, var(--layout-max));
    margin: 0 auto;
    padding: 20px clamp(16px, 2.5vw, 40px);
}

.main-content {
    padding-bottom: 48px;
}

/* ── Top bar ───────────────────────────────────────── */
.topbar {
    background: linear-gradient(105deg, var(--warn-from) 0%, var(--warn-to) 48%, #f97316 100%);
    color: #fff;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding-top: 14px;
    padding-bottom: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-text {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-logout {
    display: inline;
    margin: 0;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    text-decoration: none;
    color: var(--ink);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
}

.btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    box-shadow: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fff;
}

.btn-outline-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
    color: #fff;
    box-shadow: none;
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
    color: #fff;
}

.btn-secondary {
    background: #f1f5f9;
    border-color: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* ── Cards & forms ─────────────────────────────────── */
.card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
}

.card h2 {
    margin-top: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

label {
    display: block;
    margin-top: 12px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--ink);
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    font-family: inherit;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.grid2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.table th,
.table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
}

.offers-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin: 12px 0;
}

.offers-toolbar__search {
    flex: 1 1 200px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

.offers-toolbar__filter-label {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-muted);
    white-space: nowrap;
}

.offers-toolbar__filter {
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    min-width: 10rem;
    background: #fff;
}

.offers-toolbar__new {
    margin-left: auto;
}

@media (max-width: 640px) {
    .offers-toolbar__new {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}

/* Fila coloreada por comercial (supervisor / admin en vista equipo) */
.offers-table tbody tr.offer-row--by-user td:first-child {
    box-shadow: inset 3px 0 0 var(--offer-accent, transparent);
}

.offers-table tbody tr.offer-row--by-user:nth-child(even) {
    background: rgba(248, 250, 252, 0.85);
}

.offers-table tbody tr.offer-row--by-user:hover {
    background: #f1f5f9;
}

.offer-user-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
}

.offer-user-tag__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.offer-user-tag__name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.offers-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
}

.offers-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    background: var(--surface);
    table-layout: auto;
}

.offers-table th,
.offers-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.offers-table thead th {
    background: #f8fafc;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    font-weight: 700;
}

.offers-table tbody tr:hover {
    background: #f8fafc;
}

.offers-col-date,
.offers-col-tariff,
.offers-col-total,
.offers-col-user {
    white-space: nowrap;
}

.offers-col-actions {
    white-space: nowrap;
}

.offers-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    border: 1px solid transparent;
    font-size: 0.9375rem;
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert.success {
    background: #e9f8ee;
    border-color: #bfe9c9;
    color: #0f5132;
}

.ok {
    background: #e8ffea;
    border: 1px solid #b6f2be;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin: 10px 0;
}

.muted {
    color: var(--ink-muted);
    margin: 8px 0;
}

hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid var(--line);
}

.sort-indicator {
    margin-left: 6px;
    font-size: 12px;
}

th[data-sort] {
    user-select: none;
}

.alert-success {
    background: #e9f8ee;
    border-color: #bfe9c9;
    color: #0f5132;
}

.alert-error {
    background: #fdecec;
    border-color: #f5bcbc;
    color: #842029;
}

/* ── Estadísticas ────────────────────────────────── */
.stats-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stats-header h2 {
    margin: 0;
    font-size: 1.4em;
}

.stats-badge {
    font-size: 0.75em;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent-hover);
}

.stats-filters form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sff-dates {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.sff-dates--three {
    gap: 14px 18px;
}

.sff-date-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sff-date-group > label {
    display: block;
    margin: 0;
    font-size: 0.82em;
    font-weight: 600;
    color: var(--ink-muted);
}

.sff-date-group input {
    width: 168px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 8px 10px !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 0.88em !important;
    background: #fff !important;
    cursor: pointer;
}

.stats-checkbox-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 8px;
}

.stats-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    font-weight: 400;
}

.stats-checkbox input[type="checkbox"] {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: pointer;
    accent-color: var(--accent);
}

.stats-checkbox > span {
    font-size: 0.88em;
    color: #333;
    line-height: 1;
}

.sff-btns {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sff-btns .btn {
    margin: 0;
}

.stats-export-btn {
    white-space: nowrap;
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.stats-export-btn:hover {
    background: #dcfce7;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stats-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    border-top: 3px solid var(--line-strong);
}

.stats-card--green {
    border-top-color: #22c55e;
}

.stats-card-label {
    font-size: 0.85em;
    color: var(--ink-muted);
    margin-bottom: 6px;
}

.stats-card-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #111;
}

.stats-card--green .stats-card-value {
    color: #16a34a;
}

.stats-card--blue {
    border-top-color: #2563eb;
}
.stats-card--blue .stats-card-value {
    color: #1d4ed8;
}

.stats-card--violet {
    border-top-color: #7c3aed;
}
.stats-card--violet .stats-card-value {
    color: #6d28d9;
}

.stats-card--amber {
    border-top-color: #d97706;
}
.stats-card--amber .stats-card-value {
    color: #b45309;
}

.stats-card--rose {
    border-top-color: #e11d48;
}
.stats-card--rose .stats-card-value {
    color: #be123c;
}

.stats-card--slate {
    border-top-color: #64748b;
}
.stats-card--slate .stats-card-value {
    color: #475569;
}

.stats-card--teal {
    border-top-color: #0d9488;
}
.stats-card--teal .stats-card-value {
    color: #0f766e;
}

.stats-card--brown {
    border-top-color: #92400e;
}
.stats-card--brown .stats-card-value {
    color: #78350f;
}

/* Dashboard email: 8 KPI en 2 filas de 4 (sin “eventos totales”) */
.stats-summary--brevo {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .stats-summary--brevo {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.email-dashboard__intro {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ink-muted);
    line-height: 1.45;
}

.email-dashboard__intro code {
    font-size: 0.82em;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

.email-dashboard__hint {
    font-size: 0.85rem;
    color: var(--ink-muted);
    margin: 0;
}

.email-dash-code {
    font-size: 0.78rem;
    word-break: break-word;
}

.email-dash-msgid {
    font-size: 0.72rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-dash-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0 8px;
}

.email-dash-bar-row {
    display: grid;
    grid-template-columns: 6.5rem 1fr 2.5rem;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}

.email-dash-bar-label {
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.email-dash-bar-track {
    height: 10px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.email-dash-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--accent), #14b8a6);
    min-width: 2px;
}

.email-dash-bar-count {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.email-dash-day {
    font-weight: 600;
    color: var(--accent-hover);
    font-size: 0.95em;
}

.email-activity-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 0 0 14px;
    font-size: 0.78rem;
    color: var(--ink-muted);
}

.email-activity-legend__title {
    font-weight: 700;
    color: var(--ink);
    width: 100%;
}

@media (min-width: 720px) {
    .email-activity-legend__title {
        width: auto;
    }
}

.email-activity-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.email-activity-legend__item--out {
    color: #b91c1c;
    font-weight: 600;
}

.interest-unsub-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

.interest-ladder {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.interest-sq {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 2px solid #cbd5e1;
    background: #f8fafc;
    box-sizing: border-box;
}

.interest-sq--on.interest-sq--1 {
    border-color: #64748b;
    background: #94a3b8;
}

.interest-sq--on.interest-sq--2 {
    border-color: #d97706;
    background: #fbbf24;
}

.interest-sq--on.interest-sq--3 {
    border-color: #0f766e;
    background: #2dd4bf;
}

.interest-sq--on.interest-sq--4 {
    border-color: #5b21b6;
    background: #a78bfa;
}

.interest-unsub-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: #dc2626;
    box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.35);
}

.email-activity-row--unsub td {
    background: #fef2f2;
}

.email-activity-row--unsub .email-activity-types {
    color: #991b1b;
}

.email-activity-types {
    max-width: 36rem;
}

.email-activity-footnote {
    margin: 12px 0 0;
    font-size: 0.75rem;
    color: var(--ink-muted);
}

/* ---- Interés + contacto en listado de ofertas (supervisor) ---- */

.offers-col-correos {
    white-space: nowrap;
    text-align: center;
}

.correos-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.correos-badge--0 { color: var(--ink-muted); }
.correos-badge--1 { background: #dbeafe; color: #1d4ed8; }
.correos-badge--2 { background: #fef9c3; color: #92400e; }
.correos-badge--3 { background: #dcfce7; color: #166534; }

.offers-col-interest {
    width: 1%;
    white-space: nowrap;
}

.offers-interest-none {
    color: var(--ink-muted);
    font-size: 0.85rem;
}

.offers-interest-legend {
    margin: 10px 0 6px;
}

/* ---- fin interés ofertas ---- */

.email-activity-interest-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.email-manual-contestado-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #4c1d95;
    background: #ede9fe;
    border: 1px solid #c4b5fd;
    white-space: nowrap;
}

.email-activity-actions-th {
    width: 1%;
    white-space: nowrap;
}

.email-activity-actions {
    vertical-align: middle;
}

.email-manual-status-form {
    margin: 0;
}

.email-manual-status-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
    white-space: nowrap;
}

.stats-table-title {
    margin: 0 0 12px;
    font-size: 1.1em;
}

.stats-table-wrap {
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.stats-table thead th {
    background: #f8fafc;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-muted);
    padding: 12px 10px;
    border-bottom: 2px solid var(--line);
}

.stats-table tbody td {
    padding: 12px 10px;
}

.stats-table tbody tr:hover {
    background: #f9fafb;
}

.stats-user-name {
    font-weight: 600;
}

.stats-empty {
    text-align: center;
    padding: 30px 10px !important;
    color: #999;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.stats-info-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
}

@media (max-width: 1024px) {
    .wrap {
        padding: 16px 18px;
    }
}

@media (max-width: 640px) {
    .grid2 {
        grid-template-columns: 1fr;
    }

    .offers-actions {
        gap: 6px;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .sff-dates {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-nav {
        width: 100%;
        justify-content: flex-start;
    }
}
