:root {
  color-scheme: light;
  --ink: #171a20;
  --ink-soft: #343a46;
  --muted: #687386;
  --line: #dce1e8;
  --line-strong: #c8d0db;
  --surface: #ffffff;
  --canvas: #f3f5f7;
  --dark: #111318;
  --dark-2: #20242c;
  --red: #e52535;
  --red-dark: #bd1423;
  --red-soft: #fff0f1;
  --green: #16835f;
  --green-soft: #e8f6f0;
  --blue: #1674ca;
  --blue-soft: #eaf4fd;
  --amber: #b76b00;
  --amber-soft: #fff5df;
  --shadow: 0 14px 32px rgba(23, 26, 32, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

button {
  color: inherit;
}

svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  color: #fff;
  background: var(--dark);
  border-right: 1px solid #2b3039;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  min-height: 62px;
  padding: 0 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand > span:last-child,
.login-brand > span:last-child,
.trainer-chip > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand strong,
.login-brand strong {
  font-size: 16px;
  line-height: 1.15;
}

.brand small,
.login-brand small,
.trainer-chip small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.brand-mark {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--red);
  font-size: 14px;
  font-weight: 900;
}

.brand-mark.large {
  flex-basis: 52px;
  width: 52px;
  height: 52px;
  font-size: 18px;
}

.main-nav {
  display: grid;
  gap: 5px;
  padding-top: 22px;
}

.main-nav a,
.nav-logout {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.68);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.main-nav a:hover,
.main-nav a.active,
.nav-logout:hover {
  color: #fff;
  background: var(--dark-2);
}

.main-nav a.active {
  box-shadow: inset 3px 0 0 var(--red);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.trainer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px;
}

.trainer-chip strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.avatar.neutral {
  color: var(--ink);
  background: #e9edf1;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 78px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.heading {
  min-width: 0;
}

.heading p,
.heading h1,
.panel-heading p,
.panel-heading h2,
.login-form h2,
.login-form p,
.login-summary h1,
.login-summary p {
  margin: 0;
}

.heading p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.heading h1 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.25;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px 28px 46px;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 13px;
}

.flash.success {
  color: #0c6244;
  background: var(--green-soft);
  border-color: #b7e1d1;
}

.flash.error {
  color: #9f1d28;
  background: var(--red-soft);
  border-color: #f5bdc3;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  min-height: 142px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--dark);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card.accent-red { border-top-color: var(--red); }
.stat-card.accent-green { border-top-color: var(--green); }
.stat-card.accent-blue { border-top-color: var(--blue); }

.stat-card > div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.stat-card span,
.stat-card small {
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  overflow-wrap: anywhere;
  font-size: 25px;
  line-height: 1.18;
}

.stat-card > svg {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: 7px;
  color: var(--ink);
  background: #edf0f3;
}

.accent-red > svg { color: var(--red-dark); background: var(--red-soft); }
.accent-green > svg { color: var(--green); background: var(--green-soft); }
.accent-blue > svg { color: var(--blue); background: var(--blue-soft); }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.span-2 {
  grid-column: span 2;
}

.full-width {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(23, 26, 32, 0.045);
}

.panel-heading {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin-top: 2px;
  font-size: 16px;
  line-height: 1.3;
}

.eyebrow {
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
}

.text-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--red-dark);
  font-size: 12px;
  font-weight: 800;
}

.text-link svg {
  width: 16px;
  height: 16px;
}

.compact-list {
  display: grid;
}

.compact-row {
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 17px;
  border-bottom: 1px solid var(--line);
}

.compact-row:last-child {
  border-bottom: 0;
}

.grow {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}

.grow strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grow small,
td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.time-chip,
.date-badge {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status.success,
.status.active { color: #0c6244; background: var(--green-soft); }
.status.danger { color: #a31c29; background: var(--red-soft); }
.status.warn { color: #875000; background: var(--amber-soft); }
.status.info { color: #0e5c9f; background: var(--blue-soft); }
.status.muted { color: #596273; background: #edf0f3; }

.empty-state {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.empty-state.small {
  min-height: 185px;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 5px;
  color: var(--red);
}

.empty-state strong {
  color: var(--ink);
  font-size: 14px;
}

.empty-state span {
  font-size: 12px;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8f9fa;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: var(--ink-soft);
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fcfcfd;
}

.row-muted td {
  color: #7c8492;
  background: #fafafa;
}

.align-right {
  text-align: right;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell form,
.actions-cell .icon-button {
  display: inline-grid;
  vertical-align: middle;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.person-cell > span:last-child {
  min-width: 0;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-field,
.input-with-icon {
  position: relative;
  display: block;
}

.search-field svg,
.input-with-icon svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-field input,
.input-with-icon input {
  padding-left: 40px;
}

.select-field {
  display: grid;
  gap: 5px;
}

.select-field > span,
.field > span:first-child,
.date-filter span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22, 116, 202, 0.12);
}

input:disabled,
select option:disabled {
  color: #8b93a0;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 800;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button.primary {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.button.primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.button.secondary {
  color: var(--ink-soft);
  background: #fff;
  border-color: var(--line-strong);
}

.button.secondary:hover,
.icon-button:hover {
  background: #f3f5f7;
  border-color: #aeb7c4;
}

.button.danger {
  color: #fff;
  background: var(--red-dark);
}

.button.wide {
  width: 100%;
}

.icon-button {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--ink-soft);
  background: #fff;
  border-color: var(--line);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.danger-button {
  color: var(--red-dark);
}

.menu-button {
  display: none;
}

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

.form-panel {
  padding-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
}

.money-input b {
  min-width: 48px;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  color: var(--muted);
  background: #f5f7f8;
  font-size: 12px;
}

.money-input input {
  border-radius: 0 6px 6px 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 2px 0;
}

.payment-layout {
  grid-template-columns: minmax(0, 2fr) minmax(260px, 0.8fr);
}

.payment-summary {
  align-self: start;
  padding: 18px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.summary-line span {
  color: var(--muted);
}

.summary-line strong {
  text-align: right;
}

.summary-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 6px;
  color: #31536f;
  background: var(--blue-soft);
  font-size: 11px;
  line-height: 1.5;
}

.summary-note svg {
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.attendance-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.4fr);
  gap: 18px;
}

.checkin-panel {
  align-self: start;
}

.checkin-form {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.7fr);
  gap: 13px;
  padding: 18px;
}

.attendance-history {
  min-width: 0;
}

.attendance-list {
  max-height: 580px;
  overflow-y: auto;
}

.date-filter label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-filter input {
  width: 148px;
  min-height: 36px;
}

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

.export-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.export-actions .summary-note {
  max-width: 500px;
  margin: 0;
}

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.modal::backdrop {
  background: rgba(10, 12, 16, 0.68);
}

.modal form {
  display: grid;
  gap: 15px;
  padding: 24px;
}

.modal h2,
.modal p {
  margin: 0;
}

.modal h2 {
  font-size: 19px;
}

.modal p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
}

.modal-icon.danger {
  color: var(--red-dark);
  background: var(--red-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.muted-text {
  color: var(--muted);
  font-size: 11px;
}

.login-page {
  color: #fff;
  background: var(--dark);
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 1.15fr) minmax(420px, 0.85fr);
}

.login-brand-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  background: var(--dark);
  border-right: 1px solid #2b3039;
}

.login-summary {
  max-width: 620px;
}

.login-summary h1 {
  max-width: 560px;
  margin-top: 13px;
  font-size: 48px;
  line-height: 1.08;
}

.login-points {
  display: grid;
  gap: 13px;
  margin-top: 34px;
}

.login-points span {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 14px;
}

.login-points svg {
  color: var(--red);
}

.powered {
  color: rgba(255, 255, 255, 0.48);
}

.login-form-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 34px;
  color: var(--ink);
  background: #fff;
}

.login-form {
  width: min(390px, 100%);
  display: grid;
  gap: 20px;
}

.login-form h2 {
  margin-top: 5px;
  font-size: 27px;
}

.login-form > div:first-child > p:last-child {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-backdrop {
  display: none;
}

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

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

  .dashboard-grid .span-2,
  .dashboard-grid .panel:not(.span-2) {
    grid-column: 1 / -1;
  }

  .payment-layout,
  .attendance-grid {
    grid-template-columns: 1fr;
  }

  .payment-layout .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 840px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    width: min(292px, 86vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(10, 12, 16, 0.58);
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
  }

  .topbar {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding: 12px 16px;
  }

  .menu-button {
    display: grid;
  }

  .content {
    padding: 18px 16px 36px;
  }

  .form-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .form-layout .span-2,
  .settings-grid .full-width {
    grid-column: auto;
  }

  .filter-bar {
    grid-template-columns: 1fr 160px auto;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-brand-panel {
    display: none;
  }

  .login-form-panel {
    min-height: 100vh;
    padding: 24px;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 70px;
  }

  .heading h1 {
    font-size: 18px;
  }

  .heading p {
    display: none;
  }

  .top-actions .button span,
  .desktop-only {
    display: none;
  }

  .top-actions .button {
    width: 40px;
    padding: 0;
  }

  .stat-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    min-height: 116px;
  }

  .dashboard-grid .span-2,
  .dashboard-grid .panel:not(.span-2) {
    grid-column: auto;
  }

  .filter-bar,
  .form-grid.two-columns,
  .checkin-form {
    grid-template-columns: 1fr;
  }

  .filter-bar .button {
    width: 100%;
  }

  .form-grid .span-2,
  .checkin-form .span-2 {
    grid-column: auto;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .compact-row {
    padding-inline: 12px;
  }

  .compact-row .status {
    max-width: 92px;
    white-space: normal;
    text-align: center;
  }

  .date-filter label {
    display: grid;
    gap: 4px;
  }

  .date-filter input {
    width: 132px;
  }

  .export-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
  }

  .form-actions .button {
    flex: 1;
  }
}
