:root {
    --bg: #f4ede4;
    --panel: #fffaf4;
    --panel-strong: #fff;
    --ink: #261a12;
    --muted: #725d4d;
    --line: #dbcbb8;
    --accent: #af3f2f;
    --accent-dark: #7e2317;
    --accent-soft: #f5d4c8;
    --success-soft: #dfe9d7;
    --shadow: 0 18px 40px rgba(67, 35, 18, 0.08);
    --radius: 22px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(175, 63, 47, 0.15), transparent 26%),
        linear-gradient(180deg, #f8f1e8 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    max-width: 1700px;
    margin: 0 auto;
    padding: 22px;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 24px;
    padding: 14px 22px;
    background: var(--accent-dark);
    color: #fff;
}

.app-nav-brand {
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.85;
    font-size: 13px;
    text-transform: uppercase;
}

.app-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.app-nav-link {
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.app-nav-link.active {
    background: #fff;
    color: var(--accent-dark);
    font-weight: 600;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.eyebrow,
.panel-kicker,
.summary-label {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    color: var(--muted);
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: 38px;
    line-height: 1;
    margin-bottom: 10px;
}

.subtitle {
    max-width: 760px;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    gap: 12px;
}

.primary-button,
.ghost-button {
    border: 0;
    border-radius: 999px;
    padding: 14px 20px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-button {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 12px 24px rgba(175, 63, 47, 0.24);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    border: 1px solid rgba(38, 26, 18, 0.1);
}

.primary-button:hover,
.ghost-button:hover,
.text-button:hover {
    transform: translateY(-1px);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.summary-card,
.panel,
.error-banner {
    background: rgba(255, 250, 244, 0.92);
    border: 1px solid rgba(114, 93, 77, 0.14);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.summary-card {
    padding: 20px 22px;
}

.summary-value {
    font-size: 28px;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 14px;
    align-items: start;
}

.builder-panel {
    grid-column: 1 / -1;
}

.builder-inner {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 20px;
    align-items: start;
}

.builder-form {
    display: flex;
    flex-direction: column;
}

.builder-preview {
    display: flex;
    flex-direction: column;
}

.panel {
    padding: 20px;
}

.panel-title-row,
.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.field span {
    font-size: 13px;
    color: var(--muted);
}

.field input,
.field select,
.field textarea {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--panel-strong);
    color: var(--ink);
}

.inline-toggle {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.stats-stack {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.mini-stat,
.total-card,
.adjustment-row,
.selected-item {
    padding: 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(114, 93, 77, 0.12);
}

.mini-stat span,
.selected-item small,
.soft-pill {
    color: var(--muted);
}

.mini-stat strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.soft-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    font-size: 12px;
}

.table-wrap {
    overflow: auto;
    max-height: 640px;
    border-radius: 16px;
    border: 1px solid rgba(114, 93, 77, 0.14);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

thead th {
    position: sticky;
    top: 0;
    background: #f8f1e8;
    z-index: 1;
}

th,
td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid #efe3d6;
    font-size: 13px;
}

tbody tr:hover {
    background: #fff8ef;
}

tbody tr.is-selected {
    background: #fff0e8;
}

.selected-item,
.adjustment-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.selected-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.selected-item-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.selected-item-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.selected-item-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
}

.selected-item-fields input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--panel-strong);
    color: var(--ink);
}

.selected-item-fields .computed-importe-wrap {
    text-align: right;
}

.computed-importe {
    display: block;
    font-weight: 700;
    margin-top: 18px;
}

.selection-items,
.adjustments-list {
    display: grid;
    gap: 10px;
}

.selection-list,
.adjustments-card,
.preview-card,
.email-card {
    margin-bottom: 16px;
}

.email-card {
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(114, 93, 77, 0.16);
    background: rgba(255, 255, 255, 0.62);
}

.email-card .selection-header small,
.muted-text {
    color: var(--muted);
}

.link-button {
    display: inline-block;
    text-decoration: none;
    white-space: nowrap;
}

.full-button {
    width: 100%;
    margin-bottom: 14px;
}

.schedule-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
}

.schedule-row .field {
    margin-bottom: 0;
}

.schedule-row button {
    margin-bottom: 0;
}

.email-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.scheduled-details {
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
}

.scheduled-details summary {
    cursor: pointer;
}

.scheduled-list {
    display: grid;
    gap: 6px;
    margin-top: 8px;
}

.scheduled-item {
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(114, 93, 77, 0.12);
    overflow-wrap: anywhere;
}

.text-button {
    background: transparent;
    border: 0;
    color: var(--accent-dark);
    cursor: pointer;
    padding: 0;
}

.empty-state {
    color: var(--muted);
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
}

.adjustment-row {
    grid-template-columns: 1fr 110px 40px;
}

.adjustment-row input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
}

.total-card {
    background: linear-gradient(135deg, #251711 0%, #4b2618 100%);
    color: #fff;
}

.total-card span {
    display: block;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 6px;
}

.total-card strong {
    font-size: 32px;
}

#previewFrame {
    width: 100%;
    min-height: 580px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.error-banner {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    color: #7e2317;
    background: #fff1ee;
}

.table-footer,
.pagination,
.rows-control,
.preview-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-footer {
    justify-content: space-between;
    margin-top: 14px;
}

.rows-control label {
    color: var(--muted);
    font-size: 13px;
}

.rows-control select {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
}

.small-button {
    padding: 10px 14px;
}

.ref-agencia-cell {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-style: italic;
    cursor: default;
}

.codigo-link {
    color: var(--accent-dark);
    font-weight: 600;
    text-decoration: none;
}

.codigo-link:hover {
    text-decoration: underline;
}

.pago-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.pago-safetypay {
    background: #e3f0ff;
    color: #1a5aa8;
    border-color: #b8d8ff;
}

.pago-billetera {
    background: #eae2ff;
    color: #5b3ec2;
    border-color: #d5c6ff;
}

.pago-paypal {
    background: #dff0e5;
    color: #1f6f43;
    border-color: #bfe3cc;
}

.pago-mercadopago {
    background: #fff2cf;
    color: #8a6a00;
    border-color: #f5df9c;
}

.pago-otro,
.pago-desconocido {
    background: #f1e9df;
    color: var(--muted);
    border-color: var(--line);
}

.origin-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

.origin-badge--online {
    background: var(--success-soft);
    color: #2f5a1f;
    border: 1px solid #c3d9b6;
}

.pik-add-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.pik-add-row input {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--panel-strong);
    color: var(--ink);
}

.pik-status {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    margin: 0 0 12px;
}

.pik-status--loading {
    background: #f1e9df;
    color: var(--muted);
}

.pik-status--error {
    background: #fff1ee;
    color: #7e2317;
}

.pik-status--success {
    background: var(--success-soft);
    color: #2f5a1f;
}

.pik-status--warning {
    background: #fff2cf;
    color: #8a6a00;
}

@media (max-width: 1280px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .builder-panel {
        grid-column: 1;
    }

    .builder-inner {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .shell {
        padding: 14px;
    }

    h1 {
        font-size: 26px;
    }

    .summary-value {
        font-size: 22px;
    }

    .topbar {
        flex-wrap: wrap;
    }

    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .primary-button,
    .topbar-actions .ghost-button {
        flex: 1;
    }

    .panel {
        padding: 16px;
    }

    .table-footer {
        flex-wrap: wrap;
    }

    .pagination {
        width: 100%;
        justify-content: space-between;
    }

    .rows-control {
        width: 100%;
        justify-content: space-between;
    }
}

.add-reservation-detail { margin-top: 10px; }
.reservation-details:not(:empty) { margin-top: 10px; }
.reservation-details .adjustment-row { grid-template-columns: minmax(0, 1fr) 82px 20px; padding: 8px; }
