:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --ink: #1f2422;
  --muted: #6f766f;
  --line: #ddd8cd;
  --green: #28684d;
  --green-2: #3f8d65;
  --teal: #277a7a;
  --coral: #d86c53;
  --amber: #c98b28;
  --rose: #b4556b;
  --blue: #426a8f;
  --shadow: 0 18px 45px rgba(31, 36, 34, 0.09);
  --radius: 8px;
  --sidebar: 280px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

.is-hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

img,
video {
  display: block;
  max-width: 100%;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  background:
    linear-gradient(90deg, rgba(31, 36, 34, 0.76), rgba(31, 36, 34, 0.28)),
    url("https://images.unsplash.com/photo-1517836357463-d25dfeac3438?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.auth-copy {
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  padding: clamp(24px, 6vw, 72px);
  color: #fff;
}

.auth-copy h1 {
  max-width: 760px;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
}

.auth-copy p {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.05rem;
}

.auth-panel {
  align-self: center;
  width: min(100%, 520px);
  margin: 24px;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px);
}

.auth-panel .brand {
  margin-bottom: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.auth-tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tab.is-active {
  color: #fff;
  background: var(--green);
}

.auth-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: #fcfbf8;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.role-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.role-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.role-button svg,
.nav-link svg,
.primary-button svg,
.secondary-button svg,
.ghost-button svg,
.icon-button svg,
.table-action svg,
.mobile-nav button svg,
.empty-state svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.role-button.is-active {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(40, 104, 77, 0.2);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-link.is-active {
  background: #e7efe9;
  color: var(--green);
  font-weight: 700;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.86rem;
  background: var(--surface);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-2);
  box-shadow: 0 0 0 5px rgba(63, 141, 101, 0.13);
}

.main-area {
  min-width: 0;
  padding: 26px clamp(16px, 3vw, 42px) 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 82px;
  margin: -26px calc(clamp(16px, 3vw, 42px) * -1) 24px;
  padding: 18px clamp(16px, 3vw, 42px);
  background: rgba(246, 244, 239, 0.92);
  border-bottom: 1px solid rgba(221, 216, 205, 0.75);
  backdrop-filter: blur(12px);
}

.eyebrow {
  display: block;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.topbar-actions,
.inline-actions,
.card-actions,
.filter-row,
.form-actions,
.tool-row,
.tab-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.student-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-picker select,
.field select,
.field input,
.field textarea,
.search-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.student-picker select:focus,
.field select:focus,
.field input:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(63, 141, 101, 0.13);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 13px;
  white-space: nowrap;
}

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

.secondary-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button {
  background: transparent;
  color: var(--green);
  border-color: transparent;
}

.danger-button {
  background: #fff2ef;
  color: #a8402e;
  border-color: #efc7bb;
}

.icon-button,
.table-action {
  width: 40px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.icon-button:hover,
.secondary-button:hover,
.table-action:hover,
.nav-link:hover {
  border-color: #cfc7b8;
  background: #f4f0e8;
}

.content-stage {
  display: grid;
  gap: 22px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 760px;
}

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

.metric-card,
.info-card,
.exercise-card,
.student-card,
.class-card,
.finance-tile,
.workout-card,
.profile-strip,
.media-card,
.empty-state,
.report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 10px;
  min-height: 126px;
  padding: 16px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: #fff;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
}

.metric-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

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

.info-card,
.report-card {
  padding: 18px;
}

.info-card-header,
.table-header,
.class-card-header,
.workout-card-header,
.student-card-header,
.exercise-card-body,
.profile-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.list-stack {
  display: grid;
  gap: 10px;
}

.agenda-item,
.payment-item,
.mini-item,
.exercise-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.agenda-item:last-child,
.payment-item:last-child,
.mini-item:last-child,
.exercise-row:last-child {
  border-bottom: 0;
}

.time-pill,
.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.time-pill {
  color: var(--green);
  background: #e7efe9;
}

.tag {
  color: var(--muted);
  background: #f0ece3;
}

.status-pill {
  color: #fff;
  background: var(--green);
}

.status-pill.warning {
  background: var(--amber);
}

.status-pill.danger {
  background: var(--coral);
}

.status-pill.info {
  background: var(--blue);
}

.status-pill.muted {
  background: #77766f;
}

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

.student-card,
.exercise-card,
.class-card,
.workout-card,
.media-card {
  overflow: hidden;
}

.student-card,
.class-card,
.workout-card {
  padding: 16px;
}

.exercise-card img,
.media-card img {
  width: 100%;
  height: 178px;
  object-fit: cover;
  background: #e8e2d6;
}

.exercise-card-body {
  padding: 14px;
}

.exercise-meta,
.tags,
.student-meta,
.workout-meta,
.class-meta {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.exercise-card h3,
.student-card h3,
.class-card h3,
.workout-card h3 {
  margin-bottom: 6px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.86rem;
}

.price,
.positive {
  color: var(--green);
  font-weight: 800;
}

.negative {
  color: var(--coral);
  font-weight: 800;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.table-actions {
  display: flex;
  gap: 7px;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e6efe8;
  color: var(--green);
  font-weight: 800;
}

.student-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe6da;
}

.progress-fill {
  height: 100%;
  width: var(--value, 0%);
  border-radius: inherit;
  background: var(--green);
}

.filter-row {
  justify-content: space-between;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-input {
  max-width: 340px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 7px 12px;
}

.chip.is-active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.modal {
  width: min(900px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(20, 22, 21, 0.55);
  backdrop-filter: blur(5px);
}

.modal-box {
  max-height: inherit;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.25);
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

#modalBody {
  padding: 18px;
}

.video-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
}

.video-box {
  overflow: hidden;
  border-radius: var(--radius);
  background: #111;
}

.video-box video,
.video-box iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #111;
}

.step-list {
  display: grid;
  gap: 10px;
  padding-left: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
}

.step-list b {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e7efe9;
  color: var(--green);
}

.profile-strip {
  padding: 16px;
}

.profile-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-main .avatar {
  width: 54px;
  height: 54px;
  font-size: 1.1rem;
}

.media-card {
  display: grid;
}

.media-card-body {
  padding: 14px;
}

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

.finance-tile {
  padding: 16px;
}

.finance-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 1.4rem;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(76px, 1fr));
  gap: 8px;
}

.day-card {
  min-height: 88px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.day-card strong {
  display: block;
  margin-bottom: 8px;
}

.dot-list {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.dot:nth-child(2n) {
  background: var(--coral);
}

.dot:nth-child(3n) {
  background: var(--amber);
}

.chart-bars {
  display: grid;
  align-items: end;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  height: 170px;
  margin-top: 16px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}

.bar {
  display: grid;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.bar span {
  display: block;
  min-height: 16px;
  border-radius: 6px 6px 0 0;
  background: var(--green);
}

.bar small {
  color: var(--muted);
  text-align: center;
  font-size: 0.75rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 32px;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--green);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.mobile-nav {
  display: none;
}

.print-only {
  display: none;
}

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

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

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .auth-screen {
    display: block;
    min-height: 100vh;
    padding: 14px;
  }

  .auth-copy {
    display: block;
    min-height: 0;
    padding: 28px 10px 10px;
  }

  .auth-copy h1 {
    font-size: 2.35rem;
  }

  .auth-panel {
    width: auto;
    margin: 14px 0 0;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list,
  .sidebar-status {
    display: none;
  }

  .main-area {
    padding-bottom: 92px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .student-picker {
    flex: 1 1 210px;
  }

  .primary-button {
    flex: 1 1 auto;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-cards,
  .three-column,
  .metric-grid,
  .finance-grid {
    grid-template-columns: 1fr;
  }

  .calendar-strip {
    overflow-x: auto;
    grid-template-columns: repeat(7, 112px);
    padding-bottom: 4px;
  }

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

  .mobile-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    overflow-x: auto;
  }

  .mobile-nav button {
    display: grid;
    place-items: center;
    gap: 2px;
    min-width: 74px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    padding: 8px 6px;
    font-size: 0.72rem;
  }

  .mobile-nav button.is-active {
    background: #e7efe9;
    color: var(--green);
    font-weight: 800;
  }
}

@media (max-width: 560px) {
  .sidebar {
    gap: 14px;
  }

  .role-switch {
    grid-template-columns: 1fr;
  }

  .main-area {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .student-card-header,
  .class-card-header,
  .workout-card-header,
  .profile-strip,
  .exercise-card-body,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    max-width: none;
  }

  .card-actions,
  .inline-actions,
  .form-actions {
    width: 100%;
  }

  .card-actions > button,
  .inline-actions > button,
  .form-actions > button {
    flex: 1 1 auto;
  }

  .exercise-card img,
  .media-card img {
    height: 154px;
  }

  .modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
}
