@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --navy: #0d1249;
    --navy-soft: #151b5f;
    --sky: #c5d9e2;
    --gold: #f0a531;
    --gold-soft: #fff5df;
    --danger: #e04f5f;
    --green: #1d6f42;
    --ink: #111827;
    --muted: #667085;
    --line: #dbe3ea;
    --surface: #ffffff;
    --surface-soft: #f7fafc;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
}

.reparto-body {
    min-height: 100svh;
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--surface-soft);
    color: var(--ink);
}

.reparto-header {
    min-height: 64px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.reparto-brand,
.reparto-nav a,
.salary-hook a {
    text-decoration: none;
}

.reparto-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--navy);
    font-weight: 800;
}

.reparto-logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.reparto-logo:hover {
    transform: scale(1.04);
}

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

.reparto-nav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: #eef3f7;
    color: var(--navy);
    font-size: 0.9rem;
    font-weight: 700;
}

.reparto-nav a:first-child {
    background: var(--navy);
    color: #ffffff;
}

/* Global Header unified across all pages */
.global-header {
    background-color: #ffffff;
    padding: 8px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.header-logo {
    height: 72px;
    width: 72px;
    border-radius: 14px;
    object-fit: contain;
}

.header-right {
    display: flex;
    align-items: center;
}

.btn-header-glosario {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #f1f5f9;
    color: #001F3F;
    padding: 8px 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9em;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-header-glosario:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.btn-header-glosario span {
    font-size: 1.2em;
}

@media (max-width: 768px) {
    .global-header {
        padding: 8px 14px;
        gap: 10px;
    }

    .header-center {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }

    .header-logo {
        width: 52px;
        height: 52px;
        border-radius: 10px;
    }

    .header-right {
        width: auto !important;
        gap: 6px !important;
        flex-shrink: 0;
    }

    .btn-header-glosario {
        padding: 8px 9px;
        border-radius: 8px;
        font-size: 0.78em;
    }
}

.reparto-shell {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px;
}

.reparto-app {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(360px, 1.08fr);
    gap: 16px;
    align-items: stretch;
}

.reparto-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 40px rgba(13, 18, 73, 0.08);
}

.reparto-panel-config {
    padding: 18px;
}

.reparto-panel-results {
    padding: 18px;
    display: flex;
    flex-direction: column;
    min-height: 650px;
}

.reparto-heading,
.results-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.reparto-kicker {
    margin: 0 0 7px;
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.reparto-heading h1,
.results-head h2 {
    margin: 0;
    color: var(--navy);
    font-size: clamp(1.55rem, 3vw, 2.2rem);
    line-height: 1.05;
}

.results-head h2 {
    font-size: clamp(1.35rem, 2.4vw, 1.9rem);
}

.reparto-heading p:not(.reparto-kicker) {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.reparto-trust,
.sleep-badge {
    flex-shrink: 0;
    border-radius: 8px;
    border: 1px solid rgba(29, 111, 66, 0.18);
    background: #effaf3;
    color: var(--green);
}

.reparto-trust {
    width: 158px;
    padding: 10px;
}

.reparto-trust span,
.reparto-trust strong,
.sleep-badge {
    display: block;
    font-size: 0.78rem;
}

.reparto-trust strong,
.sleep-badge {
    font-weight: 800;
}

.sleep-badge {
    min-height: 34px;
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
}

.reparto-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reparto-fieldset {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
}

.reparto-fieldset legend {
    padding: 0 6px;
    color: var(--navy);
    font-weight: 800;
}

.time-grid,
.settings-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.time-grid label,
.counter-card,
.relevo-card {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.time-grid span,
.counter-card > span,
.relevo-card > span,
.companion-index {
    color: #344054;
    font-size: 0.84rem;
    font-weight: 700;
}

input,
button {
    font: inherit;
}

.time-grid input,
.companion-name {
    width: 100%;
    min-height: 48px;
    border-radius: 8px;
    border: 1px solid #b8c5d0;
    background: #ffffff;
    color: var(--ink);
    font-size: 1rem;
}

.time-grid input {
    padding: 0 12px;
}

.time-grid input:focus,
.companion-name:focus,
.counter-control button:focus-visible,
.pill-group button:focus-visible,
.terror-button:focus-visible,
.copy-button:focus-visible,
.salary-hook a:focus-visible,
.reparto-nav a:focus-visible {
    outline: 3px solid rgba(240, 165, 49, 0.45);
    outline-offset: 2px;
}

.counter-control,
.pill-group {
    min-height: 48px;
    display: flex;
    align-items: center;
    border-radius: 8px;
}

.counter-control {
    overflow: hidden;
    border: 1px solid #b8c5d0;
    background: #ffffff;
}

.counter-control button,
.counter-control output {
    min-height: 48px;
    border: 0;
}

.counter-control button {
    width: 48px;
    background: var(--navy);
    color: #ffffff;
    cursor: pointer;
    font-size: 1.25rem;
    font-weight: 800;
}

.counter-control output {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    font-weight: 800;
}

.pill-group {
    gap: 6px;
    padding: 4px;
    background: #edf3f7;
}

.pill-group button {
    min-height: 40px;
    flex: 1;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--navy);
    cursor: pointer;
    font-weight: 800;
}

.pill-group button::after {
    content: " min";
    font-weight: 600;
}

.pill-group button.is-active {
    background: var(--gold);
    color: #2f1f00;
}

.companeros-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.companion-row {
    min-height: 48px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 48px;
    gap: 8px;
    align-items: center;
}

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

.companion-name {
    padding: 0 12px;
}

.emoji-button {
    width: 48px;
    height: 48px;
    border: 1px solid #b8c5d0;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    font-size: 1.25rem;
}

.fair-mode {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px;
    border: 1px solid rgba(13, 18, 73, 0.14);
    border-radius: 8px;
    background: #f4f7ff;
    color: var(--muted);
    line-height: 1.4;
    cursor: pointer;
}

.fair-mode input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--navy);
}

.fair-mode strong {
    display: block;
    color: var(--navy);
}

.error-box {
    display: none;
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid rgba(224, 79, 95, 0.35);
    background: #fff0f2;
    color: #9b1c2b;
    font-weight: 700;
}

.error-box.is-visible {
    display: block;
}

.terror-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 10px;
    align-items: stretch;
}

.terror-button,
.copy-button,
.salary-hook a {
    min-height: 52px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    font-weight: 800;
}

.terror-button {
    width: 100%;
    background: var(--navy);
    color: #ffffff;
    border: 2px solid var(--gold);
    text-transform: uppercase;
    box-shadow: 0 10px 22px rgba(13, 18, 73, 0.2);
}

.terror-button:active {
    transform: scale(0.95);
}

.terror-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.terror-help {
    position: relative;
    width: 52px;
    min-height: 52px;
    border: 2px solid var(--gold);
    border-radius: 8px;
    background: #ffffff;
    color: var(--navy);
    cursor: help;
    font-weight: 800;
    font-size: 1.15rem;
}

.terror-tooltip {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: min(310px, calc(100vw - 36px));
    padding: 12px;
    border-radius: 8px;
    background: var(--navy);
    color: #ffffff;
    box-shadow: 0 14px 32px rgba(13, 18, 73, 0.25);
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.45;
    text-align: left;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

.terror-tooltip::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 100%;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: var(--navy) transparent transparent;
}

.terror-help:hover .terror-tooltip,
.terror-help:focus-visible .terror-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.empty-state {
    flex: 1;
    min-height: 280px;
    border: 1px dashed #aebccc;
    border-radius: 8px;
    background: #fbfdff;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 22px;
}

.empty-state strong {
    color: var(--navy);
    font-size: 1.1rem;
}

.results-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.turnos-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 430px;
    padding-right: 4px;
}

.turno-item,
.handoff-item {
    border-radius: 8px;
    padding: 10px 12px;
}

.turno-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    border: 1px solid #dbe7f0;
    background: #ffffff;
}

.turno-item.is-worst {
    border-color: rgba(224, 79, 95, 0.5);
    background: #fff6f7;
}

.turno-main {
    min-width: 0;
}

.turno-time {
    color: var(--navy);
    font-weight: 800;
}

.turno-name {
    color: #344054;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.turno-label {
    padding: 5px 8px;
    border-radius: 8px;
    background: var(--sky);
    color: var(--navy);
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}

.handoff-item {
    background: var(--gold-soft);
    border: 1px solid rgba(240, 165, 49, 0.45);
    color: #7a4b00;
    font-size: 0.9rem;
    font-style: italic;
}

/* Shared notice banner */
.shared-notice {
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #eef8f2;
    border: 1px solid rgba(29, 111, 66, 0.3);
    border-radius: 8px;
    color: var(--green);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* Results action buttons */
.results-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 480px) {
    .results-actions {
        grid-template-columns: 1fr 1fr;
    }
    .action-btn-whatsapp {
        grid-column: 1 / -1;
    }
}

.action-btn {
    min-height: 46px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.action-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn-whatsapp {
    background: #1e7e48;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(30, 126, 72, 0.25);
}

.action-btn-qr {
    background: var(--navy);
    color: #ffffff;
    border: 1px solid rgba(240, 165, 49, 0.4);
    box-shadow: 0 2px 8px rgba(13, 18, 73, 0.2);
}

.action-btn-image {
    background: var(--gold);
    color: #2f1f00;
    box-shadow: 0 2px 8px rgba(240, 165, 49, 0.25);
}

.action-status {
    min-height: 20px;
    margin: -4px 0 0;
    color: var(--green);
    font-weight: 700;
    text-align: center;
    font-size: 0.88rem;
}

/* QR Modal */
.qr-modal {
    border: none;
    border-radius: 16px;
    padding: 0;
    background: transparent;
    box-shadow: 0 24px 60px rgba(13, 18, 73, 0.35);
    max-width: min(92vw, 420px);
    width: 100%;
}

.qr-modal::backdrop {
    background: rgba(13, 18, 73, 0.65);
    backdrop-filter: blur(4px);
}

.qr-modal-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--line);
}

.qr-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.qr-modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--navy);
}

.qr-modal-subtitle {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.qr-modal-close {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.qr-modal-close:hover {
    color: var(--navy);
    background: #edf3f7;
}

.qr-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    background: #edf3f7;
    padding: 4px;
    border-radius: 10px;
}

.qr-tab {
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.qr-tab.is-active {
    background: #ffffff;
    color: var(--navy);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.qr-code-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: #fbfdff;
    border: 2px dashed #d5e0ea;
    border-radius: 12px;
    min-height: 240px;
}

.qrcode-box {
    display: flex;
    justify-content: center;
    align-items: center;
}

.qrcode-box canvas,
.qrcode-box img {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.qr-modal-desc {
    margin: 0;
    font-size: 0.84rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.4;
}

.qr-modal-footer {
    display: flex;
    justify-content: flex-end;
}

.qr-btn-dismiss {
    min-height: 40px;
    padding: 8px 20px;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    background: #ffffff;
    color: var(--navy);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

.qr-btn-dismiss:hover {
    background: #edf3f7;
}

.salary-hook {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 8px;
    background: #fff4dc;
    border: 1px solid rgba(240, 165, 49, 0.48);
}

.salary-hook span {
    color: #5c3900;
    font-weight: 800;
}

.salary-hook a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    background: var(--gold);
    color: #2f1f00;
    text-align: center;
}

@media (max-width: 940px) {
    .reparto-app {
        grid-template-columns: 1fr;
    }

    .reparto-panel-results {
        min-height: auto;
    }
}

@media (max-width: 620px) {
    .reparto-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .reparto-nav,
    .reparto-nav a {
        width: 100%;
    }

    .reparto-shell {
        padding: 10px;
    }

    .reparto-panel-config,
    .reparto-panel-results {
        padding: 12px;
    }

    .reparto-heading,
    .results-head,
    .settings-row {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .reparto-trust,
    .sleep-badge {
        width: 100%;
    }

    .time-grid {
        grid-template-columns: 1fr 1fr;
    }

    .pill-group button::after {
        content: "";
    }

    .turno-item {
        grid-template-columns: 1fr;
    }

    .turno-label {
        justify-self: start;
    }
}
