:root {
    --ink: #17231e;
    --ink-soft: #536159;
    --forest: #10231c;
    --forest-2: #18362a;
    --mint: #dff36b;
    --mint-soft: #f1f8cb;
    --canvas: #f4f5ef;
    --surface: #ffffff;
    --line: #dde2d9;
    --line-strong: #cbd2c7;
    --danger: #a63d3d;
    --danger-soft: #f9e4e0;
    --warning: #8a6415;
    --warning-soft: #fff2ca;
    --success: #256445;
    --success-soft: #dff2e5;
    --shadow: 0 18px 50px rgba(24, 40, 32, .08);
    --radius: 18px;
    --radius-sm: 11px;
    --sidebar-width: 248px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(133, 163, 35, .25); outline-offset: 2px; }
[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.08; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); margin-bottom: .65rem; }
h2 { font-size: 1.65rem; margin-bottom: .55rem; }
h3 { font-size: 1.05rem; margin-bottom: .35rem; }

.muted { color: var(--ink-soft); }
.eyebrow { margin-bottom: .55rem; color: #75826c; font-size: .72rem; font-weight: 800; letter-spacing: .15em; }

.brand-lockup { display: flex; align-items: center; gap: .7rem; font-size: 1.06rem; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; color: var(--forest); background: var(--mint); font-weight: 900; }
.brand-lockup--light { color: white; }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; background: var(--surface); }
.login-story { position: relative; min-height: 100vh; padding: clamp(2rem, 5vw, 4.5rem); overflow: hidden; display: flex; flex-direction: column; color: white; background: var(--forest); }
.login-story::before, .login-story::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.login-story::before { width: 480px; height: 480px; right: -210px; top: -140px; border: 1px solid rgba(223, 243, 107, .18); box-shadow: 0 0 0 75px rgba(223, 243, 107, .025), 0 0 0 150px rgba(223, 243, 107, .02); }
.login-story::after { width: 280px; height: 280px; left: -145px; bottom: -90px; background: rgba(223, 243, 107, .06); }
.story-copy { position: relative; z-index: 1; margin: auto 0; max-width: 580px; }
.story-copy .eyebrow { color: var(--mint); }
.story-copy h1 { max-width: 550px; font-size: clamp(3.8rem, 7vw, 7.2rem); letter-spacing: -.065em; }
.story-copy > p:last-child { max-width: 480px; color: rgba(255,255,255,.68); font-size: 1.12rem; }
.story-status { position: relative; z-index: 1; display: flex; align-items: center; gap: .65rem; color: rgba(255,255,255,.7); font-size: .85rem; }
.pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(223, 243, 107, .12); }

.login-panel { display: grid; place-items: center; padding: clamp(1.5rem, 6vw, 6rem); background: #fbfcf8; }
.login-card { width: min(100%, 430px); }
.login-card h2 { font-size: 2.3rem; }
.login-card > .muted { margin-bottom: 2rem; }
.mobile-brand { display: none; margin-bottom: 2.5rem; }
.login-help { margin: 1.2rem 0 0; text-align: center; color: #7b857e; font-size: .79rem; }

.field { display: grid; gap: .45rem; margin-bottom: 1.05rem; color: #39463f; font-size: .82rem; font-weight: 700; }
.field small { color: #89928c; font-weight: 500; }
.field input, .field select, .field textarea, .input {
    width: 100%; min-height: 47px; padding: .76rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); background: var(--surface); font-weight: 500; transition: border .15s, box-shadow .15s;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: #8ba02e; box-shadow: 0 0 0 3px rgba(139,160,46,.12); outline: 0; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 4rem; }
.password-field .icon-button { position: absolute; right: .45rem; top: 50%; transform: translateY(-50%); }
.icon-button { padding: .45rem .55rem; border: 0; border-radius: 8px; color: #5f6c64; background: transparent; cursor: pointer; font-size: .78rem; font-weight: 800; }
.icon-button:hover { background: #f0f2ec; }
.check-row { display: flex; align-items: center; gap: .6rem; margin: .85rem 0 1.25rem; color: #5e6962; font-size: .83rem; cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--forest-2); }
.form-error { margin: .75rem 0; padding: .75rem .85rem; border-radius: 10px; color: var(--danger); background: var(--danger-soft); font-size: .83rem; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: .7rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 750; font-size: .85rem; transition: transform .15s, background .15s, border-color .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.button--primary { color: white; background: var(--forest); }
.button--primary:hover { background: var(--forest-2); }
.button--soft { color: var(--forest); background: var(--mint-soft); border-color: #dce9a5; }
.button--ghost { background: white; border-color: var(--line); }
.button--danger { color: var(--danger); background: var(--danger-soft); }
.button--large { width: 100%; min-height: 51px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 1.4rem 1rem; color: #dbe5de; background: var(--forest); }
.sidebar-brand { padding: .25rem .6rem 1.5rem; color: white; }
.primary-nav { flex: 1; overflow-y: auto; }
.nav-label { margin: 1.25rem .65rem .5rem; color: #71847a; font-size: .63rem; font-weight: 800; letter-spacing: .16em; }
.nav-item { width: 100%; display: flex; align-items: center; gap: .8rem; padding: .72rem .7rem; border: 0; border-radius: 10px; color: #aebdb4; background: transparent; cursor: pointer; text-align: left; font-size: .86rem; font-weight: 650; }
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.is-active { color: var(--forest); background: var(--mint); }
.nav-icon { width: 24px; color: currentColor; opacity: .75; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .67rem; font-weight: 800; }
.sidebar-footer { padding: 1rem .55rem .25rem; border-top: 1px solid rgba(255,255,255,.08); }
.server-chip { display: flex; align-items: center; gap: .55rem; margin-bottom: .85rem; color: #91a198; font-size: .72rem; }
.logout-button { width: 100%; padding: .55rem; border: 0; border-radius: 8px; color: #b7c2bc; background: transparent; cursor: pointer; text-align: left; font-size: .8rem; }
.logout-button:hover { color: white; background: rgba(255,255,255,.055); }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1.2rem, 3vw, 2.8rem); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.gym-name { margin: 0; font-size: .88rem; font-weight: 800; }
.today-label { margin: .08rem 0 0; color: #7c8780; font-size: .7rem; text-transform: capitalize; }
.topbar-actions, .user-menu { display: flex; align-items: center; gap: .8rem; }
.user-menu { padding-left: .9rem; border-left: 1px solid var(--line); }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: var(--forest); background: var(--mint); font-size: .72rem; font-weight: 900; }
.user-copy { display: grid; }
.user-copy strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.user-copy small { color: #7c8780; font-size: .65rem; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: white; cursor: pointer; }

.page-frame { padding: clamp(1.4rem, 3vw, 2.8rem); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.page-heading h1 { margin-bottom: .25rem; font-size: clamp(2rem, 4vw, 3.4rem); }
.page-heading .muted { margin: 0; }
.page-actions { display: flex; gap: .65rem; }

.view { min-height: 360px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.metric-card { position: relative; min-height: 155px; padding: 1.25rem; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 20px rgba(25,44,34,.03); }
.metric-card--feature { color: white; background: var(--forest); border-color: var(--forest); }
.metric-card--feature::after { content: ""; position: absolute; width: 130px; height: 130px; right: -65px; bottom: -65px; border: 24px solid rgba(223,243,107,.12); border-radius: 50%; }
.metric-label { margin: 0 0 1.35rem; color: #748078; font-size: .72rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.metric-card--feature .metric-label { color: rgba(255,255,255,.57); }
.metric-value { position: relative; z-index: 1; margin: 0; font-size: clamp(2rem, 4vw, 3rem); font-weight: 850; letter-spacing: -.055em; line-height: 1; }
.metric-note { position: relative; z-index: 1; margin: .55rem 0 0; color: #839087; font-size: .72rem; }
.metric-card--feature .metric-note { color: var(--mint); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 1rem; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; box-shadow: 0 3px 20px rgba(25,44,34,.025); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid #e8ebe5; }
.panel-header h2 { margin: 0; font-size: 1rem; letter-spacing: -.02em; }
.panel-header p { margin: .2rem 0 0; color: #7b867f; font-size: .73rem; }
.panel-body { padding: 1.2rem; }
.panel-link { padding: .35rem; border: 0; color: var(--success); background: transparent; cursor: pointer; font-size: .75rem; font-weight: 800; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; }
.search-wrap { position: relative; flex: 1; max-width: 420px; }
.search-wrap::before { content: "Buscar"; position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #8b958f; font-size: .7rem; pointer-events: none; }
.search-wrap .input { padding-left: 3.8rem; }
.filter-row { display: flex; gap: .6rem; }
.filter-row select { min-height: 42px; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: white; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th { padding: .8rem 1rem; border-bottom: 1px solid var(--line); color: #7d8881; background: #fafbf8; text-align: left; font-size: .65rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.data-table td { padding: .9rem 1rem; border-bottom: 1px solid #ecefe9; vertical-align: middle; font-size: .8rem; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbf7; }
.table-person { display: flex; align-items: center; gap: .7rem; }
.table-avatar { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--forest); background: #eef3df; font-size: .68rem; font-weight: 900; }
.table-person strong { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; white-space: nowrap; }
.table-person small, .cell-secondary { color: #7d8881; font-size: .7rem; }
.table-action { border: 0; color: var(--success); background: transparent; cursor: pointer; font-size: .73rem; font-weight: 800; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .27rem .55rem; border-radius: 999px; font-size: .65rem; font-weight: 850; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge--active, .badge--granted, .badge--paid { color: var(--success); background: var(--success-soft); }
.badge--inactive, .badge--denied, .badge--void, .badge--revoked { color: var(--danger); background: var(--danger-soft); }
.badge--grace, .badge--waived, .badge--warning, .badge--expired { color: var(--warning); background: var(--warning-soft); }
.badge--neutral { color: #5f6a63; background: #ebeeea; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item { display: grid; grid-template-columns: 10px 1fr auto; gap: .8rem; align-items: center; padding: .86rem 0; border-bottom: 1px solid #edf0eb; }
.activity-item:last-child { border: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.activity-dot--granted { background: #50a474; }
.activity-dot--denied { background: #d2766a; }
.activity-copy strong { display: block; font-size: .78rem; }
.activity-copy small, .activity-time { color: #849088; font-size: .67rem; }

.quick-stack { display: grid; gap: .65rem; }
.quick-action { display: flex; align-items: center; justify-content: space-between; padding: .85rem; border: 1px solid var(--line); border-radius: 12px; background: #fbfcf9; cursor: pointer; text-align: left; }
.quick-action:hover { border-color: #c6d09e; background: #f8faef; }
.quick-action strong { display: block; font-size: .78rem; }
.quick-action small { color: #849088; font-size: .67rem; }
.quick-arrow { color: #7b8d30; font-size: 1rem; }

.empty-state { padding: 3.2rem 1.5rem; text-align: center; }
.empty-mark { display: grid; width: 54px; height: 54px; margin: 0 auto 1rem; place-items: center; border-radius: 18px; color: var(--forest); background: var(--mint-soft); font-size: 1.2rem; font-weight: 900; }
.empty-state h3 { margin-bottom: .4rem; }
.empty-state p { max-width: 430px; margin: 0 auto 1.2rem; color: #77827b; font-size: .8rem; }

.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.skeleton { min-height: 150px; border-radius: var(--radius); background: linear-gradient(90deg, #ecefe9 25%, #f7f8f4 45%, #ecefe9 65%); background-size: 220% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -220% 0; } }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1.2rem; }
.detail-item { padding: .75rem 0; border-bottom: 1px solid #edf0eb; }
.detail-item small { display: block; color: #849088; font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.detail-item strong { font-size: .83rem; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }
.activation-code { margin: 1rem 0; padding: 1.2rem; border: 1px dashed #a8b56d; border-radius: 14px; background: var(--mint-soft); text-align: center; }
.activation-code strong { display: block; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 2rem; letter-spacing: .2em; }

.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tab { padding: .7rem .85rem; border: 0; border-bottom: 2px solid transparent; color: #758078; background: transparent; cursor: pointer; font-size: .78rem; font-weight: 750; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--forest); }

.modal { width: min(620px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 20px; background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(12, 28, 21, .55); backdrop-filter: blur(3px); }
.modal-card { display: flex; max-height: calc(100vh - 2rem); flex-direction: column; margin: 0; background: white; }
.modal-header { display: flex; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.5rem 1rem; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; }
.modal-close { width: 36px; height: 36px; border: 0; border-radius: 10px; color: #667169; background: #f1f3ef; cursor: pointer; font-size: 1.4rem; }
.modal-content { padding: 1.3rem 1.5rem; overflow-y: auto; }
.modal-content .form-error { margin: 0 0 1rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .65rem; padding: 1rem 1.5rem 1.3rem; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .field--full { grid-column: 1 / -1; }

.toast-region { position: fixed; z-index: 100; right: 1rem; top: 1rem; display: grid; gap: .6rem; }
.toast { min-width: 260px; max-width: 360px; padding: .85rem 1rem; border: 1px solid var(--line); border-left: 4px solid var(--success); border-radius: 12px; background: white; box-shadow: var(--shadow); animation: toast-in .2s ease-out; font-size: .8rem; }
.toast--error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-story { display: none; }
    .login-panel { min-height: 100vh; }
    .mobile-brand { display: flex; }
    .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-scrim { position: fixed; z-index: 25; inset: 0; display: block; background: rgba(12,28,21,.42); }
    .workspace { margin-left: 0; }
    .menu-button { display: grid; place-items: center; }
    .topbar { justify-content: flex-start; }
    .topbar-actions { margin-left: auto; }
    .desktop-action, .user-copy { display: none; }
}

@media (max-width: 600px) {
    .page-frame { padding: 1.15rem; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-actions { width: 100%; }
    .page-actions .button { flex: 1; }
    .metric-grid, .skeleton-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 132px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-wrap { max-width: none; }
    .filter-row select { flex: 1; }
    .form-grid, .detail-grid { grid-template-columns: 1fr; }
    .modal-footer .button { flex: 1; }
    .topbar { padding: 0 1rem; }
    .gym-name { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
