:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #1e40af;
    --accent: #10b981;
    --bg: #f8fafc;
    --bg-soft: #eef4ff;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --border: #dbe4f0;
    --border-strong: #c6d4ea;
    --text: #0f172a;
    --muted: #475569;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --success-soft: #ecfdf5;
    --warning-soft: #fff7ed;
    --shadow-lg: 0 30px 80px rgba(15, 23, 42, 0.10);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

* { box-sizing: border-box; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}
body {
    margin: 0;
    min-width: 320px;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 32%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.10), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, #f6f8fc 100%);
    color: var(--text);
    overflow-x: hidden;
}

a { color: inherit; }
img, svg, canvas, video { max-width: 100%; }
button, input, select, textarea { font: inherit; }

.app-shell { position: relative; min-height: 100vh; overflow-x: clip; }
.app-backdrop {
    position: fixed;
    inset: auto;
    width: min(28rem, 62vw);
    height: min(28rem, 62vw);
    border-radius: 999px;
    filter: blur(70px);
    opacity: .45;
    pointer-events: none;
    z-index: 0;
}
.app-backdrop-a { top: -8rem; right: -7rem; background: rgba(37, 99, 235, 0.25); }
.app-backdrop-b { bottom: -10rem; left: -8rem; background: rgba(16, 185, 129, 0.18); }
.app-content { position: relative; z-index: 1; }
.wrap {
    width: min(1240px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.app-header,
.surface-card,
.auth-card,
.metric-card,
.action-card,
.hero-panel,
.card {
    backdrop-filter: blur(12px);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    margin-bottom: 28px;
    border: 1px solid rgba(255,255,255,.7);
    background: rgba(255,255,255,.74);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.brand-block {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    text-decoration: none;
}
.brand-mark {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-weight: 800;
    letter-spacing: .03em;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.28);
}
.brand-block strong { display: block; font-size: 1rem; }
.brand-block small { display: block; color: var(--muted); margin-top: 2px; }

.nav-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.page-shell,
.centered-shell,
.stack-lg,
.stack-md,
.stack-sm {
    display: grid;
}
.page-shell { gap: 22px; }
.centered-shell { place-items: center; min-height: calc(100vh - 220px); }
.stack-lg { gap: 16px; }
.stack-md { gap: 12px; }
.stack-sm { gap: 8px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    flex-wrap: wrap;
}
.page-header h1, .section-heading h2, .hero-copy h1, .auth-card h1, .card h1, .card h2, .card h3 { margin: 0; }
.page-header p, .section-heading p, .hero-copy p { color: var(--muted); margin: 8px 0 0; max-width: 70ch; }

.section-kicker,
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    max-width: 100%;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
    color: var(--secondary);
    font-weight: 700;
    font-size: .78rem;
    letter-spacing: .02em;
    margin-bottom: 14px;
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: clamp(18px, 3vw, 30px);
    align-items: center;
    padding: clamp(18px, 3vw, 34px);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255,255,255,.75);
    background: linear-gradient(145deg, rgba(255,255,255,.80), rgba(239,246,255,.92));
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
    min-width: 0;
}
.hero-copy h1 {
    font-size: clamp(2rem, 4.8vw, 3.5rem);
    line-height: 1.02;
    letter-spacing: -0.045em;
    text-wrap: balance;
    max-width: 9.5ch;
}
.hero-copy p {
    font-size: clamp(1rem, 1.35vw, 1.08rem);
    line-height: 1.58;
    max-width: 58ch;
}
.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.surface-card,
.auth-card,
.card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 24px;
    min-width: 0;
}
.auth-card-highlight {
    align-self: stretch;
    width: 100%;
    max-width: 430px;
    justify-self: end;
    background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,250,252,.94));
    border-color: rgba(198,212,234,.8);
}
.auth-card-narrow { width: min(100%, 520px); }
.section-heading.compact h2,
.section-heading.compact h1 { font-size: 1.6rem; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 18px;
}
.metric-card {
    padding: 22px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(244,247,252,.92));
    border: 1px solid rgba(198,212,234,.75);
    box-shadow: var(--shadow-md);
    min-height: 145px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.metric-card-accent {
    background: linear-gradient(135deg, rgba(37,99,235,.96), rgba(30,64,175,.94));
    color: #fff;
}
.metric-card-accent .metric-label { color: rgba(255,255,255,.82); }
.metric-label { font-size: .92rem; color: var(--muted); }
.metric-value {
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
    word-break: break-word;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.action-card {
    text-decoration: none;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(245,247,251,.92));
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
    display: grid;
    gap: 8px;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.action-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: rgba(37,99,235,.32); }
.action-card span { color: var(--muted); }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}
.filter-grid-compact { grid-template-columns: 2fr 1fr 1fr auto; }
.filter-actions,
.inline-secret-actions,
.footer-actions,
.toolbar-row,
.inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.col { min-width: 0; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.table-wrap {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.78);
}
.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}
.table-modern thead th {
    position: sticky;
    top: 0;
    background: rgba(248, 250, 252, .96);
    z-index: 1;
}
.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e6edf6;
    font-size: .94rem;
    vertical-align: middle;
}
.table tbody tr:hover { background: rgba(37, 99, 235, 0.03); }
.text-right { text-align: right; }
.table-payments { min-width: 1200px; }

label,
.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
}
input,
select,
textarea,
.form-control,
.form-select {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border-strong);
    background: var(--surface-strong);
    color: var(--text);
    padding: 13px 14px;
    border-radius: 14px;
    outline: none;
    transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
    border-color: rgba(37, 99, 235, .65);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}
textarea { resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-block { width: 100%; }
.btn-xs { min-height: 34px; padding: 0 12px; font-size: .82rem; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: .88rem; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.20);
}
.btn-soft,
.btn-secondary {
    background: rgba(37, 99, 235, 0.09);
    color: var(--secondary);
    border-color: rgba(37, 99, 235, 0.14);
}
.btn-ghost,
.btn-outline-secondary {
    background: rgba(255,255,255,.82);
    color: var(--text);
    border-color: var(--border);
}
.btn.disabled,
button:disabled {
    opacity: .52;
    cursor: not-allowed;
    pointer-events: none;
}

.alert,
.err,
.ok {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid transparent;
    font-weight: 600;
}
.alert-danger,
.err,
.alert-error {
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, .20);
    color: #991b1b;
}
.alert-success,
.ok {
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, .20);
    color: #065f46;
}
.soft-note,
.muted,
.form-text { color: var(--muted); font-size: .93rem; }

.status-chip,
.pill,
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}
.status-paid,
.pill-ok,
.badge.ok {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, .24);
}
.status-waiting,
.pill,
.badge.muted {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
    border: 1px solid rgba(245, 158, 11, .24);
}
.status-danger {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, .22);
}
.status-info {
    background: rgba(37, 99, 235, 0.12);
    color: var(--secondary);
    border: 1px solid rgba(37, 99, 235, .24);
}
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pager-row,
.footer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reveal-card { gap: 10px; }
.reveal-value {
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px dashed rgba(15, 23, 42, 0.14);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: .02em;
    word-break: break-all;
}

.stat {
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(245,247,251,.92));
    border: 1px solid var(--border);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}
.stat-label {
    color: var(--muted);
    font-size: .85rem;
    margin-bottom: 8px;
}
.stat-value {
    font-weight: 800;
    line-height: 1.35;
    word-break: break-word;
}

.app-footer {
    margin-top: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 20px 8px 0;
    color: var(--muted);
    font-size: .92rem;
}
.footer-link { text-decoration: none; }
.footer-link:hover { text-decoration: underline; }
.footer-dot { margin: 0 6px; }
.wa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: linear-gradient(135deg, #25d366, #16a34a);
    color: #fff;
    box-shadow: 0 16px 34px rgba(34,197,94,.22);
}
.wa-icon svg { width: 18px; height: 18px; fill: currentColor; }

.panel-form,
.section-block {
    display: grid;
    gap: 16px;
}
.panel-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.table-cell-truncate {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mono-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-grid-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
    .hero-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
    .auth-card-highlight {
        justify-self: stretch;
        max-width: none;
    }
    .hero-copy h1 { max-width: none; }
}

@media (max-width: 860px) {
    .wrap {
        width: min(100% - 28px, 1240px);
        padding-top: 18px;
        padding-bottom: 32px;
    }
    .app-header {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    .nav-pills {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
    }
    .nav-pills .btn,
    .nav-pills .status-chip { width: 100%; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid,
    .filter-grid-compact,
    .action-grid,
    .row { grid-template-columns: 1fr; }
    .table,
    .table-payments { min-width: 760px; }
    .app-footer { padding-top: 12px; }
}

@media (max-width: 640px) {
    .wrap { width: min(100% - 20px, 1240px); }
    .app-header,
    .hero-panel,
    .surface-card,
    .auth-card,
    .card,
    .metric-card,
    .action-card,
    .stat {
        border-radius: 20px;
    }
    .app-backdrop {
        width: 16rem;
        height: 16rem;
        filter: blur(58px);
    }
    .hero-panel { padding: 18px; gap: 18px; }
    .hero-copy h1 {
        font-size: clamp(1.85rem, 11vw, 2.8rem);
        line-height: 1.04;
        letter-spacing: -0.045em;
    }
    .hero-copy p {
        font-size: 1rem;
        line-height: 1.55;
        max-width: none;
    }
    .section-kicker,
    .eyebrow {
        font-size: .74rem;
        padding: 7px 10px;
        margin-bottom: 12px;
    }
    .metric-grid { grid-template-columns: 1fr; }
    .btn, .btn-block { width: 100%; }
    .hero-actions,
    .filter-actions,
    .pager-row,
    .panel-form-actions,
    .toolbar-row,
    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .page-header,
    .toolbar-between,
    .app-footer,
    .footer-actions {
        align-items: stretch;
    }
    .nav-pills { grid-template-columns: 1fr; }
    .app-footer {
        gap: 10px;
        font-size: .88rem;
    }
    .footer-dot { display: none; }
    .footer-actions { justify-content: flex-start; }
    .table,
    .table-payments { min-width: 640px; }
    .table th,
    .table td { padding: 12px 14px; }
}


/* ===== PATCH RESPONSIVO CIRÚRGICO: HOME MOBILE/TABLET ===== */
.landing-hero {
    grid-template-columns: minmax(0, 1.08fr) minmax(320px, 420px);
    align-items: center;
}
.landing-copy {
    min-width: 0;
}
.landing-copy h1 {
    max-width: 8.6ch;
}
.landing-auth {
    width: 100%;
    max-width: 420px;
    justify-self: end;
}

@media screen and (max-width: 920px) {
    .landing-hero,
    main > .landing-hero,
    section.landing-hero {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 18px !important;
    }

    .landing-hero > *,
    .landing-auth,
    .landing-copy {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    .landing-auth {
        order: 2;
        margin: 0 !important;
        justify-self: stretch !important;
        align-self: stretch !important;
    }

    .landing-copy {
        order: 1;
    }

    .landing-copy h1 {
        max-width: none !important;
        font-size: clamp(2rem, 7vw, 3rem) !important;
        line-height: 1.04 !important;
    }

    .landing-copy p {
        max-width: none !important;
    }
}

@media screen and (max-width: 700px) {
    .app-header {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
    }

    .brand-block {
        width: 100%;
    }

    .nav-pills {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        width: 100% !important;
    }

    .nav-pills > * {
        width: 100% !important;
    }
}

@media screen and (max-width: 560px) {
    .wrap {
        width: calc(100% - 24px) !important;
    }

    .app-header {
        padding: 14px !important;
        gap: 14px !important;
    }

    .brand-block {
        gap: 12px;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .brand-block strong {
        font-size: 0.98rem;
    }

    .brand-block small {
        font-size: 0.92rem;
        line-height: 1.35;
    }

    .nav-pills {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .landing-hero {
        padding: 18px !important;
    }

    .landing-copy h1 {
        font-size: clamp(1.9rem, 10.2vw, 2.7rem) !important;
        letter-spacing: -0.05em !important;
    }

    .landing-copy p {
        font-size: 1rem !important;
        line-height: 1.55 !important;
    }

    .landing-auth {
        padding: 20px !important;
    }

    .landing-auth .section-heading.compact h2 {
        font-size: 1.9rem;
        line-height: 1.06;
    }
}

@media screen and (max-width: 430px) {
    .landing-hero {
        gap: 16px !important;
    }

    .landing-copy h1 {
        font-size: clamp(1.75rem, 11vw, 2.35rem) !important;
    }

    .hero-actions {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }
}

@media screen and (max-width: 920px) and (orientation: landscape) {
    .landing-hero {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 360px) !important;
        align-items: start !important;
    }

    .landing-auth {
        order: initial;
    }
}
