/* ==========================================================================
   Gym Manager — hand-written stylesheet (no build step required)
   ========================================================================== */

:root {
    color-scheme: light;
    --bg: #f4f5f9;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e4e7ec;
    --text: #101828;
    --muted: #667085;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --link: #4f46e5;
    --focus-ring: rgba(79, 70, 229, .18);
    --success: #079455;
    --success-soft: #ecfdf3;
    --success-border: #abefc6;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --warning-strong: #f79009;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --danger-border: #fecdca;
    --danger-dark: #b42318;
    --info: #175cd3;
    --info-soft: #eff8ff;
    --neutral-soft: #f2f4f7;
    --neutral-text: #475467;
    --input-bg: #ffffff;
    --input-border: #d0d5dd;
    --sidebar: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-muted: #64748b;
    --overlay: rgba(15, 23, 42, .4);
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme: follows the system unless the user picked a theme (html[data-theme]). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0d1117;
        --surface: #161b24;
        --surface-2: #1c2230;
        --border: #2a3140;
        --text: #e8ebf1;
        --muted: #98a2b3;
        --primary: #6366f1;
        --primary-dark: #4f46e5;
        --link: #a5b4fc;
        --primary-soft: rgba(129, 140, 248, .16);
        --focus-ring: rgba(129, 140, 248, .3);
        --success: #47cd89;
        --success-soft: rgba(71, 205, 137, .14);
        --success-border: rgba(71, 205, 137, .35);
        --warning: #fdb022;
        --warning-soft: rgba(253, 176, 34, .14);
        --warning-strong: #fdb022;
        --danger: #f97066;
        --danger-soft: rgba(249, 112, 102, .14);
        --danger-border: rgba(249, 112, 102, .35);
        --danger-dark: #f04438;
        --info: #53b1fd;
        --info-soft: rgba(83, 177, 253, .14);
        --neutral-soft: #242b38;
        --neutral-text: #c0c7d4;
        --input-bg: #11161f;
        --input-border: #343c4d;
        --sidebar: #090c12;
        --sidebar-text: #aab4c5;
        --sidebar-muted: #5b6678;
        --overlay: rgba(0, 0, 0, .55);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b24;
    --surface-2: #1c2230;
    --border: #2a3140;
    --text: #e8ebf1;
    --muted: #98a2b3;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --link: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, .16);
    --focus-ring: rgba(129, 140, 248, .3);
    --success: #47cd89;
    --success-soft: rgba(71, 205, 137, .14);
    --success-border: rgba(71, 205, 137, .35);
    --warning: #fdb022;
    --warning-soft: rgba(253, 176, 34, .14);
    --warning-strong: #fdb022;
    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, .14);
    --danger-border: rgba(249, 112, 102, .35);
    --danger-dark: #f04438;
    --info: #53b1fd;
    --info-soft: rgba(83, 177, 253, .14);
    --neutral-soft: #242b38;
    --neutral-text: #c0c7d4;
    --input-bg: #11161f;
    --input-border: #343c4d;
    --sidebar: #090c12;
    --sidebar-text: #aab4c5;
    --sidebar-muted: #5b6678;
    --overlay: rgba(0, 0, 0, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); transition: background-color .15s; font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
[x-cloak] { display: none !important; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px; color: #fff; font-weight: 700; font-size: 16px; }
.sidebar .brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: #fff; }
.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.sidebar .foot { margin-top: auto; padding: 16px 20px; font-size: 12px; color: var(--sidebar-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border); height: 60px;
    display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--link); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.menu-toggle { display: none; background: none; border: 0; padding: 6px; cursor: pointer; }
.content { padding: 24px; max-width: 1440px; width: 100%; }
.overlay { display: none; }

@media (max-width: 1023px) {
    .sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); }
    .overlay.open { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 30; }
    .menu-toggle { display: block; }
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .topbar .user .name { display: none; }
}

/* ---------------------------------------------------------------- page header */

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- cards & grids */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .span-2 { grid-column: auto; } }
.grid > * { min-width: 0; }

/* ---------------------------------------------------------------- KPI tiles */

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; margin: 4px 0 6px; letter-spacing: -.01em; }
.kpi .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.delta { font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 999px; }
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--muted); background: var(--neutral-soft); }
.progress { height: 6px; background: var(--neutral-soft); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.good > span { background: var(--success); }
.progress.bad > span { background: var(--warning-strong); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

dl.details { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; font-weight: 500; }

/* ---------------------------------------------------------------- badges */

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--link); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral-text); }

/* ---------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.4;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-link { border: 0; background: none; color: var(--link); padding: 0; font-weight: 600; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------- forms */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field + .field { margin-top: 12px; }
.form-grid .field + .field { margin-top: 0; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=datetime-local],
input[type=month], input[type=password], input[type=search], select, textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--input-border); border-radius: 8px; background: var(--input-bg);
    font: inherit; color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea { min-height: 88px; resize: vertical; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.inline-form { display: inline; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input[type=search], .filters input[type=text] { width: 260px; }
.filters select, .filters input[type=month] { width: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--link); border-bottom-color: var(--primary); }
.tabs .count { margin-left: 4px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- flash & alerts */

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: 0; }
.alert-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.alert-item.danger .dot { background: var(--danger); }
.alert-item.warning .dot { background: var(--warning-strong); }
.alert-item.info .dot { background: var(--info); }
.alert-item .title { font-weight: 600; }
.alert-item .detail { color: var(--muted); font-size: 13px; }

.empty { padding: 32px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- lead pipeline */

.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.pipeline a { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); }
.pipeline a:hover { border-color: var(--primary); text-decoration: none; }
.pipeline a.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring); }
.pipeline .n { font-size: 20px; font-weight: 700; }
.pipeline .l { font-size: 12px; color: var(--muted); font-weight: 600; }
@media (max-width: 900px) { .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- check-in */

.checkin-box { display: flex; gap: 8px; }
.checkin-box input { font-size: 16px; padding: 12px 14px; }
.result-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.result-row:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- charts */

.chart { position: relative; height: 280px; }
.chart.sm { height: 220px; }

/* ---------------------------------------------------------------- pagination */

.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pagination .pages { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- login */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin-bottom: 20px; }
.auth .brand .logo { width: 36px; height: 36px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: #fff; }

/* ---------------------------------------------------------------- receipt / print */

.receipt { max-width: 560px; }
@media print {
    .sidebar, .topbar, .no-print, .page-header .actions { display: none !important; }
    body { background: #fff; color: #101828; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 0; }
}

/* ---------------------------------------------------------------- theme toggle */

.theme-toggle { width: 36px; height: 36px; padding: 0; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .sun { display: block; }
    :root:not([data-theme]) .theme-toggle .moon { display: none; }
}

/* ---------------------------------------------------------------- period picker */

.period-filter { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period-filter select, .period-filter input[type=date] { width: auto; }
.period-filter .btn { padding: 7px 12px; }

/* ---------------------------------------------------------------- sign-in page */

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr); }
.login-hero {
    position: relative; color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between;
    background: linear-gradient(160deg, rgba(7, 10, 20, .55) 0%, rgba(7, 10, 20, .2) 45%, rgba(7, 10, 20, .8) 100%), var(--login-bg) center / cover no-repeat, #0b1020;
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.login-brand .logo, .login-card .logo { width: 36px; height: 36px; border-radius: 8px; background: var(--primary); display: grid; place-items: center; color: #fff; }
.login-copy { max-width: 460px; }
.login-kicker { display: inline-block; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: #fdba74; margin-bottom: 12px; }
.login-copy h1 { font-size: 44px; line-height: 1.08; letter-spacing: -.02em; margin-bottom: 14px; }
.login-copy p { color: rgba(255, 255, 255, .8); font-size: 16px; margin-bottom: 20px; }
.login-copy ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.login-copy li { display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .9); font-weight: 500; }
.login-copy li svg { color: #fdba74; }
.login-panel { position: relative; display: grid; place-items: center; padding: 32px 24px; background: var(--bg); }
.login-theme { position: absolute; top: 20px; right: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 26px; margin-bottom: 4px; }
.login-card form { margin-top: 24px; }

@media (max-width: 900px) {
    .login { grid-template-columns: 1fr; }
    .login-hero { padding: 24px; min-height: 260px; }
    .login-copy h1 { font-size: 30px; }
    .login-copy p, .login-copy ul { display: none; }
    .login-panel { align-items: start; padding-top: 32px; }
}

/* ---------------------------------------------------------------- VAT disclaimer */

.vat-note { margin: 32px 0 0; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
