/* ==========================================================================
   Gritz desk — the gym's back office.
   Dark shell, warm light pages, one orange accent. Mobile first-class: under
   900px the sidebar becomes a drawer and a tab bar sits at the bottom.
   ========================================================================== */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Inter-Medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Inter-Bold.woff2") format("woff2"); }

:root {
    /* Surfaces */
    --bg: #f4f4f2;
    --surface: #ffffff;
    --surface-2: #f7f7f5;
    --surface-3: #efefec;
    --border: #e6e6e3;
    --border-strong: #d6d6d2;

    /* Shell */
    --shell: #141414;
    --shell-2: #1d1d1d;
    --shell-text: #a3a3a8;
    --shell-text-strong: #ffffff;
    --shell-line: rgba(255, 255, 255, .08);

    /* Type */
    --text: #141414;
    --text-soft: #3f3f43;
    --muted: #74747a;

    /* Brand. Orange marks and fills use --orange; anything white sits on
       --accent, which is dark enough for white text to read. */
    --orange: #de6645;
    --orange-wash: #fbe9e3;
    --accent: #c24f30;
    --accent-hover: #a9431f;
    --accent-text: #b0461f;

    /* Status: always paired with a word, never colour alone. */
    --grant: #15803d;
    --grant-wash: #e3f4e8;
    --deny: #c53030;
    --deny-wash: #fde8e8;
    --warn: #b45309;
    --warn-wash: #fdf0dc;
    --info: #2f5fb3;
    --info-wash: #e6eefb;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 6px 20px rgba(20, 20, 20, .04);
    --shadow-lg: 0 18px 50px rgba(20, 20, 20, .18);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    --sidebar-w: 248px;
    --tabbar-h: 64px;
}

* { box-sizing: border-box; }

/* The pages hide and show things with the `hidden` attribute. Any component
   that sets its own display (buttons, flex rows) would otherwise override it. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-soft);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 20px 14px 16px;
    background: var(--shell);
    color: var(--shell-text);
    z-index: 40;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 2px 10px 22px;
}
.sidebar__brand strong { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: -.2px; display: block; line-height: 1.25; }
.sidebar__brand small { display: block; color: var(--shell-text); font-size: 12.5px; }

.sidebar__logo {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: var(--shell-2);
    border: 1px solid var(--shell-line);
    color: var(--orange);
    border-radius: 11px;
    flex-shrink: 0;
}
.sidebar__logo svg { width: 22px; height: 22px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.nav-group {
    margin: 16px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #6e6e74;
}
.nav-group:first-child { margin-top: 0; }

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 11px;
    color: var(--shell-text);
    font-weight: 500;
    font-size: 14.5px;
    transition: background .15s ease, color .15s ease;
}
.nav-link svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-link.is-active { background: rgba(222, 102, 69, .14); color: #fff; font-weight: 600; }
.nav-link.is-active svg { color: var(--orange); }

.sidebar__foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--shell-line);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar__user { flex: 1; min-width: 0; padding-left: 4px; }
.sidebar__user strong { display: block; color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user small { display: block; color: var(--shell-text); font-size: 12px; text-transform: capitalize; }

.btn--signout {
    padding: 8px 12px;
    background: var(--shell-2);
    border: 1px solid var(--shell-line);
    border-radius: 10px;
    color: #e8e8ea;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.btn--signout:hover { background: #262626; }

.sidebar__made { margin: 12px 4px 0; font-size: 11.5px; color: #5d5d63; }

.app__main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

/* ---------- Page header ---------- */
.pagebar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 32px;
    background: rgba(244, 244, 242, .92);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.pagebar > div:nth-child(2) { flex: 1; min-width: 0; }
.pagebar__title { margin: 0; font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.5px; line-height: 1.2; }
.pagebar__sub { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.pagebar__user { display: none; }

.sidebar-toggle {
    display: none;
    width: 40px; height: 40px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar { display: none; }

/* ---------- Layout ---------- */
.container { max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; width: 100%; }

.desk-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 20px;
    align-items: start;
}

@media (max-width: 1100px) {
    .desk-grid { grid-template-columns: 1fr; }
}

.desk-grid > *, .split > *, .ov-grid > *, .stat-row > *, .stat-grid > * { min-width: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}

.card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 18px 22px 12px;
}

.card__head h2 {
    margin: 0;
    font-size: 16.5px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card__sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
/* The title block takes the room; a link or badge beside it stays top-right. */
.card__head > div:first-child { flex: 1; min-width: min(100%, 220px); }
.card__action { color: var(--accent-text); font-size: 14px; font-weight: 600; white-space: nowrap; }
.card__action:hover { text-decoration: underline; }

.card__body { padding: 4px 22px 20px; }
/* Tables scroll sideways inside their card on narrow screens instead of
   squashing every column. */
.card__body--flush { padding: 0 0 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Stats ---------- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    min-width: 0;
}
.stat__label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat__value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
    margin-top: 6px;
    letter-spacing: -.8px;
}
.stat__sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat--alert { border-color: #f2c9c9; }
.stat--alert .stat__value { color: var(--deny); }
.stat--warn .stat__value { color: var(--warn); }

.meter { height: 6px; background: var(--surface-3); border-radius: 3px; margin-top: 14px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--grant); border-radius: 3px; transition: width .4s ease; }
.meter__fill.is-high { background: #d97706; }
.meter__fill.is-full { background: var(--deny); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; max-height: 480px; overflow-y: auto; }

.list__item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 22px;
    border-bottom: 1px solid var(--border);
}
.list__item:last-child { border-bottom: 0; }
.list__item--clickable, .list__item[role="button"] { cursor: pointer; }
.list__item--clickable:hover, .list__item[role="button"]:hover { background: var(--surface-2); }

.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__meta { text-align: right; color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--surface-3);
    display: grid; place-items: center;
    font-size: 13px; font-weight: 600;
    color: var(--text-soft);
    flex-shrink: 0;
    object-fit: cover;
}

.empty { padding: 36px 22px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- Badges / decisions ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge--grant { background: var(--grant-wash); color: var(--grant); }
.badge--deny { background: var(--deny-wash); color: var(--deny); }
.badge--manual { background: var(--info-wash); color: var(--info); }
.badge--warn { background: var(--warn-wash); color: var(--warn); }
.badge--muted { background: var(--surface-3); color: var(--muted); }
.badge--accent { background: var(--orange-wash); color: var(--accent-text); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.dot--online { background: var(--grant); }
.dot--offline { background: var(--deny); }
.dot--unknown { background: #c4c4c0; }

.event-row { border-left: 3px solid transparent; }
.event-row--grant { border-left-color: #8fd3a5; }
.event-row--deny { border-left-color: #eba4a4; }
.event-row--review { border-left-color: #e8a04a; }
.event-row.is-new { animation: flash 1.4s ease; }

@keyframes flash {
    0% { background: var(--orange-wash); }
    100% { background: transparent; }
}

/* ---------- Forms & buttons ---------- */
.input, .select, .textarea {
    width: 100%;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder, .textarea::placeholder { color: #a2a2a6; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(222, 102, 69, .16);
}
.textarea { resize: vertical; min-height: 84px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field__error { color: var(--deny); font-size: 13px; margin-top: 6px; }
.field__error ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 17px;
    border-radius: 11px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: #c6c6c1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-active { background: var(--text); border-color: var(--text); color: #fff; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: #fff; border-color: #efc4c4; color: var(--deny); }
.btn--danger:hover { background: #fef4f4; border-color: #e7a8a8; }
.btn--danger-solid { background: var(--deny); border-color: var(--deny); color: #fff; }
.btn--danger-solid:hover { background: #a82727; border-color: #a82727; }
.btn--danger-solid:disabled:hover { background: var(--deny); border-color: var(--deny); }

/* Trigger for a row's actions menu. */
.icon-btn {
    width: 34px; height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--sm { min-height: 32px; padding: 5px 12px; font-size: 13px; border-radius: 9px; }
.btn--block { width: 100%; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Busy button: the label stays in place (so the width does not jump) and a
   spinner sits on top of it. */
.btn.is-loading { position: relative; color: transparent !important; cursor: progress; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 16px; height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    border: 2px solid rgba(20, 20, 20, .2);
    border-top-color: var(--text);
    animation: spin .6s linear infinite;
}
.btn--primary.is-loading::after, .btn--danger-solid.is-loading::after {
    border-color: rgba(255, 255, 255, .4);
    border-top-color: #fff;
}
.btn--danger.is-loading::after { border-color: rgba(197, 48, 48, .3); border-top-color: var(--deny); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .btn.is-loading::after { animation-duration: 1.8s; }
}

/* ---------- Checkbox options ---------- */
.check {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    cursor: pointer;
    margin-bottom: 10px;
}
.check:hover { border-color: var(--border-strong); }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.check__label { font-size: 14px; font-weight: 600; color: var(--text); display: block; }
.check__hint { font-size: 12.5px; color: var(--muted); display: block; margin-top: 1px; }
.check.is-disabled { opacity: .55; cursor: not-allowed; }
.check.is-disabled input { cursor: not-allowed; }

/* ---------- Search ---------- */
.search-wrap { position: relative; }
.search-results {
    list-style: none; margin: 10px 0 0; padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 320px; overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.search-results:empty { display: none; }

/* ---------- Table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 14px 22px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
    color: var(--muted);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 600;
    padding-top: 10px;
    padding-bottom: 10px;
    white-space: nowrap;
    background: var(--surface-2);
}
.table td { color: var(--text-soft); }
.table td strong, .table td b { color: var(--text); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-inactive td { opacity: .55; }
.table__actions { width: 1%; text-align: right; white-space: nowrap; }
.table .num, .table td:last-child { font-variant-numeric: tabular-nums; }

/* ---------- Actions menu ---------- */
/* Positioned from JS against its trigger and appended to the body, so it is
   never clipped by the card it was opened from. */
.menu {
    position: fixed;
    z-index: 60;
    min-width: 194px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    animation: menu-in .12s ease;
}

.menu__item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-2); outline: none; }
.menu__item--danger { color: var(--deny); }
.menu__item--danger:hover, .menu__item--danger:focus-visible { background: #fef4f4; }

@keyframes menu-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Profile ---------- */
.profile__head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}
.profile__avatar {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--shell);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
}
.profile__identity { flex: 1; min-width: 0; }
.profile__identity h3 { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.profile__badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 2px 20px;
    margin: 0;
}
.detail { padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail dt { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.detail dd { margin: 3px 0 0; font-size: 14.5px; color: var(--text); font-weight: 500; word-break: break-word; }

/* ---------- Notices ---------- */
.notice {
    margin: 0 0 18px;
    padding: 13px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.55;
}
.notice--danger { background: var(--deny-wash); border: 1px solid #f3cccc; color: #8f2020; }
.notice--warn { background: var(--warn-wash); border: 1px solid #f3dcb3; color: #7c3d06; }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20, 20, 20, .5);
    display: grid; place-items: center;
    padding: 20px;
    z-index: 50;
}
.modal-backdrop[hidden] { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal__head { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal__head h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); }
.modal__body { padding: 20px 22px; }
.modal__foot { position: sticky; bottom: 0; padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: var(--surface-2); }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
    padding: 13px 18px;
    border-radius: 12px;
    background: var(--shell);
    color: #fff;
    border-left: 3px solid var(--orange);
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    animation: slide-in .22s ease;
    font-size: 14px;
}
.toast--success { border-left-color: #4ade80; }
.toast--error { border-left-color: #f87171; }
.toast--warn { border-left-color: #fbbf24; }
.toast.is-leaving { opacity: 0; transition: opacity .3s ease; }

@keyframes slide-in {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* ---------- Login ---------- */
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--shell);
    background-image: radial-gradient(circle at 85% 10%, rgba(222, 102, 69, .22), transparent 45%);
}
.auth-card {
    width: min(410px, 100%);
    background: var(--surface);
    border-radius: 20px;
    padding: 34px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
}
.auth-card__logo {
    width: 48px; height: 48px;
    display: grid; place-items: center;
    background: var(--shell);
    color: var(--orange);
    border-radius: 13px;
    margin-bottom: 18px;
    font-weight: 700;
}
.auth-card__logo svg { width: 28px; height: 28px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.auth-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.auth-card__foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--grant); margin-right: 7px; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* Only ever visible while the off-canvas menu is open; `hidden` keeps it out of
   the way of clicks on wide screens. */
.nav-scrim { display: none; }
.nav-scrim[hidden] { display: none; }

/* ---------- Tablets and phones ---------- */
@media (max-width: 900px) {
    .sidebar {
        width: min(300px, 86vw);
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 60px rgba(0, 0, 0, .4);
    }
    body.nav-open .sidebar { transform: none; }
    .app__main { margin-left: 0; }

    .sidebar-toggle { display: grid; }
    .pagebar { padding: 12px 16px; gap: 12px; }
    .pagebar__title { font-size: 19px; letter-spacing: -.3px; }
    .pagebar__sub { font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .container { padding: 16px 16px calc(var(--tabbar-h) + 28px); }
    .card { border-radius: 14px; margin-bottom: 16px; }
    .card__head, .card__body, .list__item, .table th, .table td { padding-left: 16px; padding-right: 16px; }
    .card__head { padding-top: 16px; }

    .stat-row, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .stat { padding: 14px 15px; }
    .stat__value { font-size: 24px; }
    .stat__label, .stat__sub { font-size: 12.5px; }

    /* A wide table keeps its columns and scrolls inside the card. */
    .card__body--flush > .table { min-width: 620px; }

    /* Modals rise from the bottom as a sheet. */
    .modal-backdrop { place-items: end center; padding: 0; }
    .modal, .modal--wide { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet-up .2s ease; }
    .modal__foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
    .modal__foot .btn { flex: 1; }

    .toast-stack { left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom)); }
    .toast { max-width: none; }

    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(20, 20, 20, .5);
        z-index: 39;
    }
    .nav-scrim[hidden] { display: none; }

    .tabbar {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 35;
        display: flex;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding: 0 6px env(safe-area-inset-bottom);
        background: var(--shell);
        border-top: 1px solid var(--shell-line);
    }
    .tabbar__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 0;
        border: 0;
        background: none;
        color: var(--shell-text);
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        min-width: 0;
    }
    .tabbar__item svg { width: 22px; height: 22px; }
    .tabbar__item.is-active { color: #fff; }
    .tabbar__item.is-active svg { color: var(--orange); }
}

@keyframes sheet-up {
    from { transform: translateY(24px); opacity: .6; }
    to { transform: none; opacity: 1; }
}

@media (max-width: 380px) {
    .stat-row, .stat-grid { grid-template-columns: 1fr; }
}
/* ==========================================================================
   Members & billing
   ========================================================================== */

/* ---------- Forms ---------- */
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 16px;
}
.field--wide { grid-column: 1 / -1; }

.field__hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; min-height: 1em; }
.field__hint--warn { color: var(--warn); }
.field__hint--ok { color: var(--grant); }

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
}
.check input { margin-top: 3px; flex-shrink: 0; }

.modal--wide { width: min(760px, 100%); }

/* ---------- Stepper ---------- */
.stepper {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.stepper__step {
    font-size: 12.5px;
    color: var(--muted);
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    white-space: nowrap;
}
.stepper__step.is-active { background: var(--accent); color: #fff; font-weight: 600; }
.stepper__step.is-done { color: var(--grant); }

/* ---------- PAR-Q ---------- */
.parq { margin-bottom: 18px; }
.parq__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.parq__row:last-child { border-bottom: 0; }
.parq__toggle { display: flex; gap: 14px; flex-shrink: 0; color: var(--muted); font-size: 13px; }
.parq__toggle label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* ---------- Signature pad ---------- */
.signature {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px;
    background: var(--surface-2);
}
.signature canvas {
    display: block;
    width: 100%;
    height: 160px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .18);
    touch-action: none;
    cursor: crosshair;
}
.signature .btn { margin-top: 10px; }

/* ---------- Totals ---------- */
.totals {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 14px 0;
}
.totals__row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
.totals__row--credit { color: var(--grant); }
.totals__row--total {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 650;
    font-size: 16px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.tab {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 550;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
/* The Gritz console has many tabs: every one stays in sight, wrapping rather than scrolling. */
#console-tabs { flex-wrap: wrap; overflow-x: visible; gap: 0 2px; }
#console-tabs .tab { padding: 10px 12px; }

/* ---------- Key/value panels ---------- */
.kv {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.kv:last-child { border-bottom: 0; }
.kv > span { color: var(--muted); font-size: 12.5px; }
.kv--stack { display: block; }
.kv--stack > div { margin-top: 4px; }

.is-warn { color: var(--warn); }

.notice {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--muted);
}
.notice--warn { border-left-color: var(--warn); color: var(--text); margin: 12px 0; }

/* ---------- Member profile ---------- */
.profile-head {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}
.profile-head__main { flex: 1; min-width: 220px; }
.profile-head__main h2 {
    margin: 0 0 4px;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-head__stats { display: flex; gap: 24px; }
.profile-head__stats span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.profile-head__stats strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.avatar--lg { width: 64px; height: 64px; font-size: 20px; }

/* ---------- Table extras ---------- */
.row--clickable { cursor: pointer; }
.row--clickable:hover { background: var(--surface-2); }

.cell-with-avatar { display: flex; align-items: center; gap: 12px; }

@media (max-width: 640px) {
    .parq__row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .profile-head__stats { width: 100%; justify-content: space-between; }
}

/* ---------- Dialogs (replaces window.confirm / prompt / alert) ---------- */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, .6);
    display: grid;
    place-items: center;
    padding: 20px;
    /* Above page modals — a dialog is always raised from one. */
    z-index: 200;
    animation: dialog-fade .12s ease;
}

.dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: min(460px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
    animation: dialog-rise .16s ease;
}
.dialog__head { padding: 18px 20px 0; }
.dialog__head h3 { margin: 0; font-size: 16.5px; }
.dialog__body { padding: 14px 20px 4px; }
.dialog__message { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dialog__body .field:last-of-type { margin-bottom: 4px; }
.dialog__foot {
    padding: 14px 20px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@keyframes dialog-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-rise {
    from { transform: translateY(8px) scale(.99); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* ---------- Gate console ---------- */
.check {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.check:last-child { border-bottom: 0; }
.check .badge { flex-shrink: 0; min-width: 62px; text-align: center; }
.check .muted { font-size: 13.5px; margin-top: 2px; }
.check__hint {
    margin-top: 6px;
    font-size: 13px;
    padding: 7px 10px;
    border-radius: 6px;
    background: var(--surface-2);
    border-left: 2px solid var(--accent);
}

.test-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}
.test-row:last-child { border-bottom: 0; }
.test-row .muted { font-size: 13px; margin-top: 3px; max-width: 52ch; }
.test-row .btn { flex-shrink: 0; }

.steps { margin: 0 0 12px; padding-left: 20px; font-size: 14px; line-height: 1.65; }
.steps li { margin-bottom: 7px; }

@media (max-width: 640px) {
    .test-row { flex-direction: column; align-items: stretch; }
    .test-row .btn { width: 100%; }
}


/* Pager — only rendered when there is more than one page of results. */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
}

.pager__count { font-size: 13px; }

.pager__controls { display: flex; align-items: center; gap: 12px; }

.pager__page { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.pager .btn[disabled] { opacity: .45; cursor: not-allowed; }

@media (max-width: 640px) {
    .pager { justify-content: center; }
}


/* ---- Financials ------------------------------------------------------- */

.date-range {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.date-range .field { margin: 0; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* The tone stripe carries the meaning, so the number itself stays readable. */
    border-left: 3px solid var(--border-strong);
}

.stat-tile--good { border-left-color: var(--grant); }
.stat-tile--warn { border-left-color: var(--warn); }
.stat-tile--bad  { border-left-color: var(--deny); }

.stat-tile__label {
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-tile__value {
    font-size: 26px;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat-tile__note { font-size: 12.5px; color: var(--muted); }

.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 22px;
    align-items: start;
}

.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
    .date-range { flex-direction: column; align-items: stretch; }
    .date-range .btn { width: 100%; }
}

/* ---- Community ----------------------------------------------------------- */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.hours-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.hours-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 8px; align-items: center; }
@media (max-width: 560px) { .hours-row { grid-template-columns: 1fr 1fr; } }
.people-list { list-style: none; margin: 0; padding: 0; }
.people-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.people-list li:last-child { border-bottom: 0; }
.trainer-cell { display: flex; align-items: center; gap: 10px; }
.trainer-cell img, .trainer-cell .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.trainer-cell .avatar { display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); font-weight: 600; font-size: 13px; }
tr.is-cancelled td { color: var(--muted); }

/* ---- Phones: page-specific ---------------------------------------------- */
@media (max-width: 900px) {
    .split { grid-template-columns: 1fr; gap: 0; }
    .stat-tile { padding: 14px 15px; }
    .stat-tile__value { font-size: 21px; }
    .pager { padding: 12px 16px; }
    .card__head .btn-row { width: 100%; }
    .card__head .btn-row > .input { flex: 1 1 100%; }
    .card__head .btn-row > .select { flex: 1 1 auto; width: auto; }
    .card__head .btn-row > .btn--primary { flex: 1 1 auto; }
    /* Wide tables scroll sideways; cells stay on one line so rows read across. */
    .card__body--flush > .table td, .card__body--flush > .table th { white-space: nowrap; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .stat-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    .modal__foot { flex-wrap: wrap; }
    .profile-head__stats { gap: 16px; }
    .dialog-backdrop { place-items: end center; padding: 0; }
    .dialog { width: 100%; border-radius: 20px 20px 0 0; }
    .dialog__foot { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
    .dialog__foot .btn { flex: 1; }
}

/* ==========================================================================
   Overview
   ========================================================================== */
.ov-updated { font-size: 13px; }

.ov-actions { list-style: none; margin: 0; padding: 0 0 6px; }
.ov-action { border-top: 1px solid var(--border); }
.ov-action__head {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 22px;
    background: none;
    border: 0;
    text-align: left;
    color: inherit;
    font: inherit;
}
button.ov-action__head { cursor: pointer; }
button.ov-action__head:hover { background: var(--surface-2); }
.ov-action__count {
    min-width: 44px; height: 44px;
    padding: 0 8px;
    display: grid; place-items: center;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 700;
    flex-shrink: 0;
}
.ov-action--warn .ov-action__count { background: var(--warn-wash); color: var(--warn); }
.ov-action--bad .ov-action__count { background: var(--deny-wash); color: var(--deny); }
.ov-action--done .ov-action__count { background: var(--grant-wash); color: var(--grant); font-size: 18px; }
.ov-action__text { flex: 1; min-width: 0; }
.ov-action__text strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.35; }
.ov-action__text small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.ov-action--done .ov-action__text strong { color: var(--text-soft); font-weight: 500; }
.ov-action__chev { color: var(--muted); font-size: 22px; line-height: 1; transition: transform .15s ease; }
button[aria-expanded="true"] .ov-action__chev { transform: rotate(90deg); }
.ov-action__body { padding: 0 22px 12px 80px; }

.ov-people { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.ov-person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ov-person:last-child { border-bottom: 0; }
.ov-person__main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; }
.ov-person__main:hover strong { text-decoration: underline; }
.ov-person .avatar { width: 34px; height: 34px; font-size: 12px; }
.ov-person__text { min-width: 0; }
.ov-person__text strong { display: block; color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-person__text small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-person__contact { display: flex; gap: 6px; flex-shrink: 0; }
.ov-more { margin: 8px 2px 0; font-size: 13px; }

.ov-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.ov-kpi .stat__value { font-size: 28px; }
.ov-kpi__foot { margin-top: 6px; min-height: 20px; }
.ov-delta { font-size: 13px; font-weight: 600; color: var(--muted); }
.ov-delta.is-up { color: var(--grant); }
.ov-delta.is-down { color: var(--deny); }

.ov-grid { display: grid; gap: 20px; align-items: start; }
.ov-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ov-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.chart { width: 100%; min-height: 190px; }
.chart svg { display: block; overflow: visible; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__axis { stroke: var(--border-strong); stroke-width: 1; }
.chart__tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart__value { font-size: 11.5px; font-weight: 600; fill: var(--text); }
.chart__hit { fill: transparent; }
.chart__bar.is-hover .chart__hit { fill: rgba(20, 20, 20, .04); }
.chart__bar path { transition: opacity .12s ease; }

.chart-tip {
    position: fixed;
    z-index: 70;
    pointer-events: none;
    padding: 8px 11px;
    background: var(--shell);
    color: #fff;
    border-radius: 9px;
    font-size: 12.5px;
    line-height: 1.35;
    box-shadow: var(--shadow-lg);
}
.chart-tip strong { display: block; font-size: 14px; }
.chart-tip span { color: #c6c6ca; }

.mix__total { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.mix__total strong { color: var(--text); font-size: 24px; font-weight: 700; letter-spacing: -.5px; margin-right: 4px; }
.mix__bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface); }
.mix__seg { display: block; min-width: 3px; }
.mix__legend { list-style: none; margin: 16px 0 0; padding: 0; }
.mix__legend li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mix__legend li:last-child { border-bottom: 0; }
.mix__key { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.mix__label { flex: 1; color: var(--text-soft); }
.mix__count { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.mix__pct { width: 40px; text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.hbars { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "track track"; gap: 5px 10px; align-items: center; }
.hbars__name { grid-area: name; color: var(--text-soft); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbars__value { grid-area: value; color: var(--text); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.hbars__track { grid-area: track; height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbars__fill { display: block; height: 100%; background: var(--orange); border-radius: 0 5px 5px 0; min-width: 3px; }

.ov-gate { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ov-gate__cell { padding: 14px 16px; border-radius: 12px; background: var(--surface-2); }
.ov-gate__cell strong { display: block; font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.ov-gate__cell span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.ov-gate__cell.is-bad { background: var(--deny-wash); }
.ov-gate__cell.is-bad strong { color: var(--deny); }

@media (max-width: 1240px) {
    .ov-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ov-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ov-grid--3 > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
    .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .ov-kpis > :last-child { grid-column: 1 / -1; }
    .ov-kpi .stat__value { font-size: 23px; }
    .ov-grid, .ov-grid--2, .ov-grid--3 { grid-template-columns: 1fr; gap: 0; }
    .ov-action__head { padding: 13px 16px; gap: 12px; }
    .ov-action__count { min-width: 40px; height: 40px; font-size: 16px; }
    .ov-action__body { padding: 0 16px 12px; }
    .ov-person { flex-wrap: wrap; }
    .ov-person__contact { width: 100%; padding-left: 45px; }
    .ov-person__contact .btn { flex: 1; }
    .ov-gate { grid-template-columns: 1fr; }
    .ov-gate__cell { display: flex; align-items: center; gap: 14px; }
    .ov-gate__cell strong { font-size: 22px; min-width: 40px; }
}

/* ==========================================================================
   Members list
   ========================================================================== */
.member-tiles {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.member-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 14px 15px;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    text-align: left;
    color: inherit;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.member-tile:hover { border-color: var(--border-strong); }
.member-tile.is-active { border-color: var(--orange); background: var(--orange-wash); }
.member-tile__value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.5px; line-height: 1.2; }
.member-tile__label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.member-tile__note { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.member-tile.is-warn .member-tile__value { color: var(--warn); }

.member-tags { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 2px; font-size: 12.5px; }
.member-tags .badge { padding: 1px 8px; font-size: 11.5px; }

@media (max-width: 1240px) { .member-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 900px) {
    .member-tiles { display: flex; overflow-x: auto; gap: 10px; margin: 0 -16px 16px; padding: 2px 16px 4px; scroll-snap-type: x proximity; }
    .member-tile { flex: 0 0 150px; scroll-snap-align: start; }
}

/* ==========================================================================
   Member profile
   ========================================================================== */
.profile-hero__body { display: flex; align-items: flex-start; gap: 20px; padding: 22px; flex-wrap: wrap; }
.profile-hero__photo {
    width: 88px; height: 88px;
    border-radius: 22px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-3);
}
.profile-hero__photo--initials { display: grid; place-items: center; background: var(--shell); color: #fff; font-size: 28px; font-weight: 700; }
.profile-hero__main { flex: 1; min-width: 240px; }
.profile-hero__name { margin: 0; font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.4px; line-height: 1.2; }
.profile-hero__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile-hero__plan {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 600;
}
.profile-hero__plan::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.profile-hero__plan.is-good { background: var(--grant-wash); color: var(--grant); }
.profile-hero__plan.is-warn { background: var(--warn-wash); color: var(--warn); }
.profile-hero__plan.is-bad { background: var(--deny-wash); color: var(--deny); }
.profile-hero__plan.is-info { background: var(--info-wash); color: var(--info); }
.profile-hero__plan.is-muted { background: var(--surface-3); color: var(--muted); }
.profile-hero__meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; color: var(--muted); font-size: 13.5px; }
.profile-hero__meta strong { color: var(--text); }
.profile-hero__contact { display: flex; gap: 8px; margin-top: 12px; }
.profile-hero__actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: center; }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.profile-stat { padding: 15px 16px; }
.profile-stat .stat__value { font-size: 22px; letter-spacing: -.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-stat .stat__sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.profile-facts > div { padding: 10px 12px; border-radius: 11px; background: var(--surface-2); min-width: 0; }
.profile-facts span { display: block; color: var(--muted); font-size: 12.5px; }
.profile-facts strong { display: block; color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-plan { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.profile-plan strong { font-size: 17px; color: var(--text); }
.profile-plan__dates { display: flex; justify-content: space-between; margin: 6px 0 10px; color: var(--muted); font-size: 12.5px; }
.profile-history { margin-top: 14px; }
.profile-history__title { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 2px; }
.kv strong { color: var(--text); text-align: right; font-weight: 600; }

@media (max-width: 1240px) { .profile-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
    .profile-hero__body { padding: 16px; gap: 14px; }
    .profile-hero__photo { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
    .profile-hero__main { min-width: 0; flex-basis: calc(100% - 80px); }
    .profile-hero__name { font-size: 20px; }
    .profile-hero__actions { width: 100%; }
    .profile-hero__actions .btn { flex: 1 1 auto; }
    .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
    .profile-facts { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Front desk
   ========================================================================== */
.desk-top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; align-items: stretch; }
.desk-top > .card { margin-bottom: 20px; overflow: visible; }
.desk-find .card__body { padding: 20px 22px; }
.desk-find__label { display: block; font-size: 16.5px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.desk-find__input { font-size: 17px; padding: 14px 16px 14px 44px; border-radius: 14px;
    background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2374747a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 15px center / 19px; }
.desk-find__input:focus { background-color: var(--surface); }
.desk-find .search-results { position: absolute; left: 0; right: 0; z-index: 20; }

.desk-doors .card__body { padding: 20px 22px; }
.desk-doors__title { margin: 0; font-size: 16.5px; font-weight: 700; color: var(--text); }
.desk-doors__buttons { margin-top: 12px; }
.desk-doors__walkin {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%; margin-top: 10px; padding: 10px 14px; height: auto;
    border-style: dashed; text-align: left;
}
.desk-doors__hint { font-size: 12px; font-weight: 500; color: var(--muted); }

.stat__value.is-bad { color: var(--deny); }
.desk-live { font-size: 13px; white-space: nowrap; }

.chart-legend { list-style: none; margin: 4px 0 0; padding: 0; display: flex; gap: 14px; font-size: 12.5px; color: var(--text-soft); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-legend__key { width: 10px; height: 10px; border-radius: 3px; }

@media (max-width: 1100px) { .desk-top { grid-template-columns: 1fr; gap: 0; } }
@media (max-width: 900px) {
    .desk-top > .card { margin-bottom: 16px; }
    .desk-find .card__body, .desk-doors .card__body { padding: 16px; }
    .desk-doors__buttons .btn { flex: 1 1 auto; }
}
.desk-find__tip { margin: 12px 2px 0; color: var(--muted); font-size: 13px; }
.desk-find__tip kbd { display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 12px var(--font); text-align: center; color: var(--text); }
@media (max-width: 900px) { .desk-find__tip { display: none; } }
.table td.mono, .table .mono { white-space: nowrap; }
.btn--primary.desk-doors__walkin { border-style: solid; margin-top: 14px; padding: 12px 16px; font-size: 15px; }
.btn--primary .desk-doors__hint { color: rgba(255, 255, 255, .82); }

/* Members: status tabs under the card head. */
.state-tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.state-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 12px; margin-bottom: -1px;
    border: 0; border-bottom: 2px solid transparent; background: none;
    color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.state-tab:hover { color: var(--text); }
.state-tab.is-active { color: var(--text); border-bottom-color: var(--orange); }
.state-tab__count { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-soft); font-size: 12px; text-align: center; }
.state-tab.is-active .state-tab__count { background: var(--orange-wash); color: var(--accent-text); }
@media (max-width: 900px) { .state-tabs { padding: 0 12px; } }
.desk-top:has(> .card:only-child) { grid-template-columns: 1fr; }

/* Settings → Your gym: the gym's own logo and cover photo. */
.gym-photos { display: grid; gap: 16px; border-bottom: 1px solid var(--border); }
.gym-photos__cover {
    aspect-ratio: 3 / 1; max-height: 200px; border-radius: 14px; overflow: hidden;
    display: grid; place-items: center; text-align: center;
    background: repeating-linear-gradient(135deg, var(--orange-wash) 0 14px, #fff 14px 28px);
    border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.gym-photos__cover span { padding: 0 16px; }
.gym-photos__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gym-photos__row { display: flex; gap: 16px; align-items: flex-start; }
.gym-photos__logo {
    width: 76px; height: 76px; flex: none; border-radius: 18px; overflow: hidden;
    display: grid; place-items: center; background: var(--orange-wash); color: var(--accent-text);
    font-weight: 700; font-size: 24px; border: 1px solid var(--border);
}
.gym-photos__logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gym-photos__text { display: grid; gap: 6px; min-width: 0; font-size: 13.5px; }
.gym-photos__text .btn-row { margin-top: 6px; flex-wrap: wrap; }

/* ---------- A challenge's Manage panel (desk and console) ---------- */
.mg-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mg-winner { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mg-winner:last-child { border-bottom: 0; }
.mg-winner__medal { font-size: 22px; width: 32px; text-align: center; }
.mg-section { margin-top: 22px; }
.mg-section h3 { margin: 0 0 6px; }
