:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1f2933;
  --ink-soft: #52606d;
  --muted: #7b8794;
  --line: #e4e7eb;
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #d5f0ec;
  --danger: #dc2626;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}

h1 { font-size: 1.6rem; margin: 0 0 0.2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.link { color: var(--primary-dark); font-weight: 500; }
.strong { font-weight: 600; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.inline { display: inline; }

/* ---- Top bar ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.brand-mark-lg { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; margin: 0 auto; }
.brand-name { font-size: 1.02rem; }
.nav { display: flex; gap: 0.35rem; margin-left: 0.5rem; }
.nav a {
  color: var(--ink-soft);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { color: var(--primary-dark); background: var(--primary-soft); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-name { color: var(--ink-soft); font-weight: 500; font-size: 0.9rem; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ---- Panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel.no-pad { padding: 0; overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.panel-head.pad-head { padding: 1.1rem 1.25rem; margin: 0; border-bottom: 1px solid var(--line); }
.form-panel { max-width: 720px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.empty { padding: 0.5rem 0; }
.empty.pad { padding: 1.25rem; }
.pad { padding: 1.25rem; }

/* ---- Stat cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
}
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 0.35rem; letter-spacing: -0.02em; }

/* ---- Balance banner ---- */
.balance-banner {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.balance-item { background: var(--surface); padding: 1.1rem 1.25rem; }
.balance-item.balance-primary { background: #fbfdfc; }
.balance-amount { display: block; font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; letter-spacing: -0.02em; }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.table td { padding: 0.8rem 1.25rem; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f7fafb; }
.amount { font-weight: 600; }

/* ---- Pills ---- */
.pill {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: capitalize;
  border: 1px solid transparent;
}
.pill-scheduled { background: #e0edff; color: #1d4ed8; }
.pill-completed { background: #dcfce7; color: #15803d; }
.pill-cancelled { background: #eef0f2; color: #6b7280; }
.pill-no-show { background: #fde2e1; color: #b91c1c; }
.pill-charge { background: var(--danger-soft); color: var(--danger); }
.pill-payment { background: #dcfce7; color: var(--ok); }

/* ---- Timeline lists ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 0.9rem; align-items: baseline; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline-time { color: var(--muted); font-size: 0.85rem; min-width: 130px; font-variant-numeric: tabular-nums; }
.timeline-main { display: flex; gap: 0.5rem; align-items: center; color: var(--ink); font-weight: 500; }

/* ---- Detail list ---- */
.detail-list { margin: 0; display: grid; gap: 0.85rem; }
.detail-list dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.detail-list dd { margin: 0.15rem 0 0; font-size: 1rem; }
.plain-list { margin: 0.5rem 0 1rem; padding-left: 1.1rem; }

/* ---- Forms ---- */
.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd2d9;
  border-radius: 9px;
  padding: 0.55rem 0.7rem;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; }
.checkbox-field { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; color: var(--ink-soft); }
.checkbox-field input { width: auto; margin-top: 0.2rem; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.4rem; }
.searchbar { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; max-width: 560px; }
.searchbar input { flex: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: #eef1f4;
  color: var(--ink);
  transition: background 0.12s ease, border-color 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: #cbd2d9; color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.3rem;
  border-radius: 6px;
}
.icon-btn:hover { color: var(--danger); background: var(--danger-soft); }

/* ---- Flash ---- */
.flash-stack { margin-bottom: 1.25rem; display: grid; gap: 0.6rem; }
.flash { padding: 0.75rem 1rem; border-radius: 9px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.flash-error { background: var(--danger-soft); color: #991b1b; border-color: #fbd5d0; }
.error-list { margin: 0; padding-left: 1.1rem; }

/* ---- Legend ---- */
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1rem; color: var(--ink-soft); font-size: 0.85rem; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.35rem; vertical-align: middle; }

/* ---- Auth ---- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #e8f1f0, #f4f6f8);
  padding: 1.5rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.3rem; margin: 0.6rem 0 0.1rem; }

/* ---- Error page ---- */
.center-panel { text-align: center; padding: 3rem 1.5rem; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--primary); }

/* ---- FullCalendar theming ---- */
#calendar {
  --fc-border-color: var(--line);
  --fc-today-bg-color: var(--primary-soft);
  --fc-button-bg-color: var(--primary);
  --fc-button-border-color: var(--primary);
  --fc-button-hover-bg-color: var(--primary-dark);
  --fc-button-hover-border-color: var(--primary-dark);
  --fc-button-active-bg-color: var(--primary-dark);
  --fc-button-active-border-color: var(--primary-dark);
  --fc-page-bg-color: var(--surface);
}
.fc .fc-button { font-weight: 600; text-transform: capitalize; }
.fc .fc-toolbar-title { font-size: 1.2rem; }
.fc-event { cursor: pointer; }

/* ---- Admin settings toggle ---- */
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; }
.switch-field { display: flex; align-items: flex-start; gap: 0.7rem; cursor: pointer; }
.switch-field input { margin-top: 0.25rem; width: 1.1rem; height: 1.1rem; }
.switch-field span { display: grid; gap: 0.15rem; }

/* ---- Admin brand tag ---- */
.brand-tag { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #fff; background: var(--primary); padding: 0.08rem 0.4rem; border-radius: 6px; vertical-align: middle; margin-left: 0.15rem; }

/* ---- Multi-user: status pills ---- */
.flash-info { background: #e0edff; color: #1e40af; border-color: #bfdbfe; }
.pill-pending { background: #fef3c7; color: #92400e; }
.pill-active { background: #dcfce7; color: #15803d; }
.pill-suspended { background: #fde2e1; color: #b91c1c; }
.pill-rejected { background: #eef0f2; color: #6b7280; }
.pill-admin { background: #ede9fe; color: #6d28d9; }
.pill-type { background: #e0edff; color: #1d4ed8; text-transform: capitalize; }
.pill-sub-active { background: #dcfce7; color: #15803d; }
.pill-sub-pending { background: #fef3c7; color: #92400e; }
.pill-sub-expired { background: #fde2e1; color: #b91c1c; }
.pill-sub-cancelled, .pill-sub-none { background: #eef0f2; color: #6b7280; }

/* ---- Auth extras (register / account) ---- */
.auth-card-wide { max-width: 560px; }
.auth-alt { text-align: center; margin-top: 1.1rem; color: var(--muted); font-size: 0.9rem; }
.auth-version { text-align: center; margin-top: 0.4rem; font-size: 0.75rem; letter-spacing: 0.03em; }
.auth-actions { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; margin-top: 1.4rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; }
.small { font-size: 0.8rem; }
.text-right { text-align: right; }
.section-title { font-size: 1rem; margin: 0 0 0.2rem; }
textarea, .input, .select-sm, .select-xs {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cbd2d9; border-radius: 9px; padding: 0.5rem 0.6rem; width: 100%;
}
textarea { resize: vertical; }

/* ---- Plan picker ---- */
.plan-picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem; display: grid; gap: 0.6rem; }
.plan-picker legend { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); padding: 0 0.3rem; }
.plan-option { display: flex; gap: 0.7rem; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; cursor: pointer; }
.plan-option:hover { border-color: var(--primary); }
.plan-option input { margin-top: 0.25rem; }
.plan-body { display: grid; gap: 0.15rem; }
.plan-name { font-weight: 600; }
.plan-price { font-weight: 600; color: var(--primary-dark); }
.plan-price small { color: var(--muted); font-weight: 500; }
.plan-desc { font-size: 0.82rem; }

/* ---- Account page ---- */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 0.6rem; }
.account-cell { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; display: grid; gap: 0.3rem; }

/* ---- Admin ---- */
.badge { display: inline-block; min-width: 1.3rem; padding: 0 0.35rem; margin-left: 0.35rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 700; text-align: center; }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tab { padding: 0.35rem 0.8rem; border-radius: 8px; color: var(--ink-soft); font-weight: 600; text-transform: capitalize; font-size: 0.9rem; }
.tab:hover { background: var(--bg); text-decoration: none; }
.tab.active { background: var(--primary-soft); color: var(--primary-dark); }
.toolbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }
.toolbar .input { max-width: 320px; }
.toolbar .select-sm { width: auto; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-users td { vertical-align: top; }
.actions-cell { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.inline-form { display: inline-flex; gap: 0.25rem; align-items: center; margin: 0; }
.select-xs { width: auto; padding: 0.25rem 0.4rem; font-size: 0.8rem; }
.days-input { width: 4.6rem; }
.btn-xs { padding: 0.25rem 0.55rem; font-size: 0.78rem; }
.btn-warn { background: #fef3c7; color: var(--warn); }
.btn-warn:hover { background: var(--warn); color: #fff; }

/* ---- Admin request cards ---- */
.request-list { display: grid; gap: 0.8rem; }
.request-card { display: flex; gap: 1rem; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; }
.request-main { display: grid; gap: 0.35rem; }
.request-plan { font-size: 0.9rem; }
.request-note { margin: 0.3rem 0 0; padding: 0.5rem 0.8rem; border-left: 3px solid var(--line); color: var(--ink-soft); background: var(--bg); border-radius: 6px; font-size: 0.9rem; }
.request-actions { display: grid; gap: 0.6rem; align-content: start; min-width: 160px; }
.stack-sm { display: grid; gap: 0.3rem; margin: 0; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .balance-banner { grid-template-columns: 1fr; }
  .field-row, .account-grid { grid-template-columns: 1fr; }
  .request-card { flex-direction: column; }
  .request-actions { min-width: 0; }
  .nav { display: none; }
}
