:root {
    --court: #0f7f45;
    --court-dark: #063d2d;
    --lime: #d8ff35;
    --ball: #e6ff45;
    --ink: #102018;
    --muted: #68746d;
    --line: rgba(16, 32, 24, 0.12);
    --surface: #ffffff;
    --soft: #f3f7ee;
    --safe-top: max(env(safe-area-inset-top, 0px), 44px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(160deg, rgba(6, 61, 45, 0.84), rgba(15, 127, 69, 0.34)),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 58px),
        #0c5e3c;
    font-family: Arial, Helvetica, sans-serif;
    position: relative;
}

body,
button,
input,
select,
textarea,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

main,
header,
nav,
section,
article,
form,
label {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
}

button,
input,
select,
textarea {
    font: inherit;
    font-size: 16px;
}

.phone-shell {
    width: 100%;
    max-width: min(430px, 100vw);
    min-height: 100vh;
    margin: 0 auto;
    background: var(--soft);
    overflow-x: hidden;
    position: relative;
    isolation: isolate;
}

.phone-shell > * {
    max-width: 100%;
}

.login-page {
    display: grid;
    place-items: center;
}

.login-shell {
    display: grid;
    align-content: start;
    overflow: hidden;
}

.login-hero,
.top-dashboard {
    position: relative;
    padding: calc(34px + var(--safe-top)) 20px 34px;
    color: #fff;
    background:
        linear-gradient(180deg, rgba(4, 24, 18, 0.18), rgba(4, 24, 18, 0.78)),
        linear-gradient(135deg, #0f7f45, #062b22);
    overflow: hidden;
}

.top-dashboard {
    align-items: flex-start;
}

.login-hero::after,
.top-dashboard::after {
    position: absolute;
    right: 18px;
    top: 22px;
    width: 86px;
    height: 86px;
    border-radius: 50%;
    content: "";
    background:
        radial-gradient(circle at center, transparent 0 48%, rgba(255,255,255,0.88) 49% 51%, transparent 52%),
        var(--ball);
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
}

.top-dashboard::after {
    right: 18px;
    top: calc(22px + var(--safe-top));
    opacity: 0.1;
}

.brand-pill {
    display: grid;
    width: 54px;
    height: 54px;
    margin-bottom: 28px;
    place-items: center;
    border: 2px solid rgba(255,255,255,0.76);
    border-radius: 50%;
    background: var(--ball);
    color: var(--court-dark);
    font-weight: 900;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--ball);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

.login-hero h1,
.top-dashboard h1 {
    position: relative;
    z-index: 1;
    max-width: 100%;
    margin-bottom: 8px;
    font-size: clamp(1.6rem, 10vw, 2.3rem);
    line-height: 1.04;
    overflow-wrap: anywhere;
}

.hero-copy,
.top-dashboard span {
    position: relative;
    z-index: 1;
    color: rgba(255,255,255,0.78);
    display: block;
    max-width: 100%;
    font-size: clamp(0.92rem, 4.8vw, 1.12rem);
    line-height: 1.22;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.login-panel {
    position: relative;
    margin: -22px 18px 28px;
    padding: 24px 18px 20px;
    border: 1px solid rgba(255,255,255,0.88);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 42px rgba(6, 40, 30, 0.16);
}

.ball-badge {
    position: absolute;
    right: 20px;
    top: -26px;
    width: 58px;
    height: 58px;
    border: 3px solid #fff;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, transparent 0 46%, rgba(255,255,255,0.9) 47% 50%, transparent 51%),
        var(--ball);
    box-shadow: 0 10px 22px rgba(6, 61, 45, 0.24);
}

.login-panel h2 {
    margin-bottom: 6px;
    font-size: 1.55rem;
}

.login-panel p {
    color: var(--muted);
    font-size: 0.95rem;
}

.alert {
    margin-bottom: 12px;
    padding: 11px 12px;
    border-radius: 8px;
    background: #ffe6e2;
    color: #8f2418;
    font-weight: 700;
}

form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf6;
    color: var(--ink);
}

select,
textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf6;
    color: var(--ink);
}

textarea {
    resize: vertical;
}

button {
    min-height: 52px;
    border: 0;
    border-radius: 999px;
    background: var(--court);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

.secondary-button {
    min-height: 48px;
    border: 1px solid rgba(15, 127, 69, 0.18);
    background: #ecffd1;
    color: var(--court-dark);
}

.app-shell {
    padding-bottom: calc(34px + var(--safe-bottom));
}

.top-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 16px;
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.top-dashboard > div {
    min-width: 0;
    width: auto;
    max-width: 100%;
}

.logout {
    position: relative;
    z-index: 3;
    align-self: start;
    padding: 9px 8px;
    border: 1px solid rgba(255,255,255,0.34);
    border-radius: 999px;
    color: #fff;
    font-size: 0.84rem;
    font-weight: 800;
    flex: 0 0 auto;
    width: 76px;
    max-width: 76px;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-grid,
.action-grid,
.schedule-panel {
    width: auto;
    margin: 18px;
}

.top-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 18px 22px;
    padding: 8px;
    width: auto;
    max-width: none;
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 18px;
    background: rgba(255,255,255,0.94);
    box-shadow: 0 12px 24px rgba(6, 40, 30, 0.1);
}

.top-nav a {
    padding: 11px 8px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 900;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-nav a.active {
    background: var(--court);
    color: #fff;
}

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

.stat-card {
    min-height: 108px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(6, 40, 30, 0.08);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 12px;
    font-size: clamp(1.35rem, 7vw, 1.8rem);
    overflow-wrap: anywhere;
}

.ball-card {
    background:
        radial-gradient(circle at right -20px top -20px, var(--ball) 0 54px, transparent 56px),
        #fff;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 12px;
}

.action-ball {
    display: grid;
    min-height: 72px;
    aspect-ratio: 1 / 1;
    place-items: center;
    padding: 6px;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, transparent 0 47%, rgba(255,255,255,0.9) 48% 50%, transparent 51%),
        var(--ball);
    color: var(--court-dark);
    font-size: 0.77rem;
    font-weight: 900;
    text-align: center;
    line-height: 1.05;
    overflow-wrap: anywhere;
    box-shadow: 0 9px 18px rgba(6, 40, 30, 0.12);
}

.schedule-panel,
.panel {
    width: auto;
    padding: 18px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(6, 40, 30, 0.08);
}

.panel {
    margin: 18px;
}

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

.section-title h2 {
    margin: 0;
    font-size: 1.2rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.section-title span {
    color: var(--muted);
    font-weight: 800;
    flex: 0 0 auto;
}

.schedule-list {
    display: grid;
    gap: 12px;
}

.form-grid,
.list {
    display: grid;
    gap: 14px;
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

input[type="date"],
input[type="time"],
input[type="number"],
input[type="tel"],
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
    overflow: hidden;
}

input[type="date"],
input[type="time"] {
    min-height: 52px;
    padding: 0 12px;
    line-height: 52px;
    text-align: center;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
    text-align: center;
}

.inline-filter {
    display: grid;
    grid-template-columns: 1fr;
    align-items: end;
    gap: 12px;
    margin-bottom: 14px;
}

.inline-filter button,
.status-row button {
    min-height: 48px;
    width: 100%;
    padding: 0 16px;
}

.schedule-item,
.list-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf6;
    min-width: 0;
}

.schedule-item.stacked {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.schedule-item > div,
.list-item > div {
    min-width: 0;
}

.schedule-item strong,
.list-item strong {
    overflow-wrap: anywhere;
}

.status-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
}

.quick-status-form {
    display: grid;
    gap: 8px;
    width: 100%;
}

.quick-status-form.is-collapsed {
    display: none;
}

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

.edit-status-toggle {
    min-height: 42px;
    width: 100%;
    border: 1px solid rgba(15, 127, 69, 0.18);
    background: #fff;
    color: var(--court);
    font-size: 0.86rem;
}

.status-chip {
    min-height: 42px;
    padding: 8px;
    border: 1px solid rgba(15, 127, 69, 0.18);
    border-radius: 999px;
    background: #fff;
    color: var(--court);
    font-size: 0.82rem;
    font-weight: 900;
}

.status-chip.active {
    background: var(--court);
    color: #fff;
}

.status-chip[data-estado="cancelada"] {
    color: #b42318;
}

.status-chip[data-estado="cancelada"].active {
    background: #b42318;
    color: #fff;
}

.schedule-item span,
.list-item span,
.empty-state span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.schedule-item em,
.list-item em {
    display: block;
    margin-top: 6px;
    color: var(--court);
    font-style: normal;
    font-weight: 900;
    white-space: normal;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reservation-card {
    align-items: stretch;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.reservation-card.saved {
    border-color: var(--court);
    background: #f0ffe9;
}

.reservation-meta {
    line-height: 1.32;
}

.status-badge {
    display: inline-grid;
    width: fit-content;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eef3ed;
    color: var(--court-dark);
    font-size: 0.78rem;
    font-weight: 900;
}

.status-badge.status-pendiente {
    background: #fff3bf;
    color: #7a4f00;
}

.status-badge.status-confirmada,
.status-badge.status-reservada {
    background: #dff8d8;
    color: #0b6b35;
}

.status-badge.status-en_uso {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.status-finalizada {
    background: #eceff3;
    color: #59616c;
}

.status-badge.status-cancelada,
.status-badge.status-no_asistio {
    background: #ffe4e1;
    color: #9f1d16;
}

.status-message {
    min-height: 18px;
    color: var(--court);
    font-size: 0.82rem;
    font-weight: 900;
}

.quick-status-form button:disabled {
    opacity: 0.72;
}

.notice {
    margin: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #ecffd1;
    color: #285812;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(6, 40, 30, 0.08);
}

.code-pill {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    background: var(--court);
    color: #fff;
    font-weight: 900;
}

.public-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: auto;
    margin: 18px;
}

.public-links.compact {
    margin: 16px 0 0;
}

.public-links a {
    display: grid;
    min-height: 48px;
    place-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--court);
    font-size: 0.86rem;
    font-weight: 900;
    text-align: center;
}

.public-hero {
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
}

.court-agenda {
    display: grid;
    gap: 18px;
    width: auto;
    margin: 18px;
}

.court-card {
    padding: 18px;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 24px rgba(6, 40, 30, 0.08);
}

.timeline {
    display: grid;
    gap: 10px;
}

.time-block {
    display: grid;
    gap: 4px;
    padding: 13px;
    border-left: 5px solid var(--court);
    border-radius: 8px;
    background: #f8faf6;
}

.time-block strong,
.time-block span,
.time-block em {
    overflow-wrap: anywhere;
}

.time-block em {
    color: var(--muted);
    font-style: normal;
    font-weight: 800;
}

.status-pendiente {
    border-left-color: #d89b00;
    background: #fff7dc;
}

.status-confirmada,
.status-reservada {
    border-left-color: var(--court);
}

.status-en_uso {
    border-left-color: #1f6feb;
    background: #eaf2ff;
}

.status-finalizada {
    border-left-color: #8a8f98;
}

.danger-button {
    min-height: 44px;
    background: #b42318;
}

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

.slot-button {
    min-height: 46px;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.1;
}

.slot-free {
    background: #138a4d;
    color: #fff;
}

.slot-busy {
    background: #c92a2a;
    color: #fff;
    opacity: 0.78;
}

.slot-button.selected {
    outline: 3px solid var(--ball);
    outline-offset: 2px;
}

.compact-panel {
    padding: 14px 16px;
}

details summary {
    cursor: pointer;
    color: var(--court-dark);
    font-weight: 900;
    list-style: none;
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::after {
    content: "+";
    float: right;
    color: var(--court);
}

details[open] summary::after {
    content: "-";
}

.compact-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.compact-item {
    display: grid;
    gap: 3px;
    padding: 10px;
    border-radius: 8px;
    background: #f8faf6;
}

.compact-item strong,
.compact-item span {
    overflow-wrap: anywhere;
}

.compact-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

.member-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 18px;
}

.member-shortcuts a {
    display: grid;
    min-height: 44px;
    place-items: center;
    padding: 8px;
    border-radius: 999px;
    background: #fff;
    color: var(--court);
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
    box-shadow: 0 8px 18px rgba(6, 40, 30, 0.08);
}

.anchor-target {
    display: block;
    position: relative;
    top: -8px;
    visibility: hidden;
}

.empty-state {
    padding: 18px;
    border: 1px dashed rgba(15, 127, 69, 0.34);
    border-radius: 8px;
    background: #f8faf6;
    text-align: center;
}

@media (min-width: 700px) {
    .phone-shell {
        min-height: min(900px, 100vh);
        margin-top: 18px;
        margin-bottom: 18px;
        border-radius: 28px;
        overflow: hidden;
        box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
    }
}

@media (max-width: 390px) {
    .top-dashboard {
        grid-template-columns: minmax(0, 1fr) 68px;
        gap: 12px;
        padding: calc(34px + var(--safe-top)) 16px 30px;
    }

    .login-hero h1,
    .top-dashboard h1 {
        font-size: clamp(1.45rem, 9vw, 1.95rem);
        max-width: 100%;
    }

    .logout {
        width: 68px;
        max-width: 68px;
        padding-left: 6px;
        padding-right: 6px;
        font-size: 0.78rem;
    }

    .top-dashboard::after {
        width: 68px;
        height: 68px;
        right: 12px;
        top: calc(24px + var(--safe-top));
        opacity: 0.1;
    }

    .stats-grid {
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .action-grid {
        gap: 10px;
    }

    .action-ball {
        min-height: 64px;
        font-size: 0.68rem;
    }

    .schedule-item,
    .list-item {
        align-items: flex-start;
    }
}

@media (max-width: 430px) {
    .two-cols,
    .inline-filter,
    .status-row,
    .public-links {
        grid-template-columns: 1fr;
    }

    .member-shortcuts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-title span {
        max-width: 100%;
        white-space: normal;
    }
}

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

    .action-ball {
        border-radius: 999px;
        aspect-ratio: auto;
    }
}
