:root {
  --bg: #ececef;
  --panel: #ffffff;
  --ink: #1f1f23;
  --muted: #6b6b73;
  --line: #e6e7eb;
  --accent: #e2734a;
  --accent-soft: #f3c2ad;
  --cta: #0dc9c9;
  --cta-soft: #8bd6d6;
  --warn: #b25f30;
  --focus-ring: rgba(13, 201, 201, 0.25);
  --heading-font: "Cormorant Garamond", Georgia, serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #dceeee, var(--bg) 46%);
  color: var(--ink);
}

.admin-login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.35rem;
  padding: 1rem;
}

.admin-login-view[hidden],
#admin-app-view[hidden] {
  display: none !important;
}

.admin-login-card {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
}

.admin-login-card h2 {
  margin: 0 0 0.45rem;
}

.admin-login-brand {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  text-align: center;
}

.stack {
  display: grid;
  gap: 0.65rem;
}

.admin-login-error {
  color: #b23d18;
  margin: 0.55rem 0 0;
}

h1,
h2,
h3 {
  font-family: var(--heading-font);
  font-weight: 600;
  letter-spacing: 0.005em;
  line-height: 1.12;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.top-nav-menu-btn {
  display: none !important;
}

.top-nav-link {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  line-height: 1;
}

.top-nav-link.active {
  color: var(--ink);
}

.brand-lockup {
  position: relative;
  padding-left: 0;
}

.brand-title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-main {
  color: var(--ink);
}

.brand-pilates {
  color: #8a8a8a;
  margin-left: 0.25rem;
}

.icon-button {
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--ink);
}

.app-header h1 {
  margin: 0;
}

#new-client-btn {
  padding-left: calc(0.8rem + 15px);
  padding-right: calc(0.8rem + 15px);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

#global-settings-btn {
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  line-height: 1;
  font-size: 2rem;
  color: var(--ink);
}

main {
  padding: 1rem;
}

.system-status-banner {
  margin: 0 0 0.8rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #e8b8a4;
  background: #fff4ef;
  color: #8a3f1f;
  border-radius: 12px;
  font-size: 0.95rem;
}

.app-page {
  display: none;
}

.app-page.active {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  padding: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  min-width: 0;
}

.app-footer {
  margin: 0;
  padding: 2.6rem 1rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.app-footer p {
  margin: 0;
}

.app-footer a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}

.app-footer a:hover {
  text-decoration: underline;
}

.panel-title-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 2rem;
}

.tab-row {
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.tab {
  border: none;
  border-bottom: 3px solid transparent;
  background: transparent;
  border-radius: 0;
  padding: 0.45rem 0.8rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: -1px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tab.active {
  border-bottom-color: var(--cta);
  color: var(--ink);
}

.tab:focus,
.tab:focus-visible {
  outline: none;
  box-shadow: none;
  border-radius: 0;
}

.mobile-tab-header {
  display: none;
}

.mobile-active-tab-label {
  font-weight: 500;
  color: var(--ink);
  font-size: 1.35rem;
  font-family: var(--heading-font);
}

.tab-menu-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--cta);
  border-radius: 50%;
  background: #fff;
  line-height: 0;
}

.hamburger-glyph {
  position: relative;
  display: block;
  width: 18px;
  height: 12px;
  margin: 0 auto;
  flex: 0 0 auto;
}

.hamburger-glyph::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--cta);
  box-shadow: 0 -5px 0 var(--cta), 0 5px 0 var(--cta);
}

.client-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

.client-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem;
  background: #fff;
  cursor: pointer;
  min-width: 0;
  overflow: hidden;
}

.client-item strong {
  font-weight: 400;
}

.client-item.active {
  background: #f4fdfd;
  border: 2px solid var(--cta);
  color: var(--ink);
}

.client-item.active strong {
  font-weight: 600;
  color: var(--ink);
}

.client-item small {
  color: var(--muted);
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

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

.grid-form > * {
  min-width: 0;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.inline-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
  margin-bottom: 0.55rem;
}

.inline-checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}

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

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fff;
}

input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--cta);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

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

.button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.52rem 0.8rem;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  text-align: center;
}

.button.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.92;
}

.button.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  margin-left: 0.5rem;
  animation: button-spin 0.8s linear infinite;
}

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

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

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

.button:hover {
  background: #f3f4f6;
}

.button.primary:hover {
  background: #d9683f;
}

.fit-content-row-cta {
  justify-self: start;
  width: auto;
  min-width: 0;
}

.text-link {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

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

.client-actions-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.25rem;
}

.client-actions-row .text-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.text-link.subdued {
  color: #9a9a9a;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.text-link-icon {
  font-size: 0.82rem;
  line-height: 1;
  color: inherit;
}

.text-link-icon-svg {
  width: 14px;
  height: 14px;
  display: block;
  color: inherit;
}

.icon-only {
  padding: 0;
  min-width: 0;
}

.package-delete-btn {
  margin-left: auto;
  color: #9a9a9a;
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  touch-action: manipulation;
}

.package-delete-btn .text-link-icon-svg {
  width: 15px;
  height: 15px;
}

.square-payment-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.square-payment-remove {
  color: #9a9a9a;
  margin-top: 0.1rem;
}

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

.alerts {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
  margin-bottom: 0.7rem;
}

.alert {
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #cf6f48 !important;
  font-weight: 500;
}

.stack-list {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.5rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #fff;
}

.card .meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.file-meta-row {
  margin: 0 0 0.35rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.file-name-inline {
  font-weight: 600;
  color: var(--ink);
}

.file-detail-inline {
  color: var(--muted);
}

.card textarea {
  width: 100%;
}

.resources-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.resources-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.session-notes-table {
  min-width: 620px;
}

.resources-table th,
.resources-table td {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.92rem;
}

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

.resource-title-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.table-link {
  color: #128b8b;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.session-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.homework-video {
  width: 100%;
  margin-top: 0.55rem;
  border-radius: 10px;
  background: #000;
  max-height: 360px;
}

.homework-video-row {
  justify-content: space-between;
  align-items: center;
  margin-top: 0.2rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 1.2fr) auto;
  align-items: end;
}

.filter-row > * {
  min-width: 0;
}

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

.integration-bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.square-connection {
  margin-bottom: 0.85rem;
  padding: 0.7rem;
  border: 1px solid var(--cta-soft);
  border-radius: 10px;
  background: #f3fcfc;
}

#client-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
}

.dialog-form {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
  min-width: 320px;
}

.settings-dialog-form {
  min-width: min(860px, 96vw);
}

.file-viewer-form {
  min-width: min(980px, 96vw);
  max-width: 96vw;
}

.file-viewer-content {
  min-height: 420px;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem;
}

.file-viewer-content iframe,
.file-viewer-content img,
.file-viewer-content video,
.file-viewer-content audio {
  width: 100%;
}

.file-viewer-content iframe {
  min-height: 62vh;
  border: 0;
}

.file-viewer-content img {
  max-height: 65vh;
  object-fit: contain;
}

.file-viewer-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0;
  margin: 0.3rem 0 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

@media (max-width: 980px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    background: var(--bg);
  }

  .app-header {
    padding: 0.75rem 0.85rem;
    position: sticky;
  }

  .header-actions {
    display: none;
    position: absolute;
    right: 0.75rem;
    top: calc(100% + 0.4rem);
    width: min(320px, calc(100vw - 1.5rem));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem;
    box-shadow: 0 12px 28px rgba(45, 42, 39, 0.12);
    z-index: 20;
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .header-actions.mobile-open {
    display: flex;
  }

  .top-nav-menu-btn {
    display: inline-grid !important;
    margin-left: auto;
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    border: 1px solid var(--cta);
    border-radius: 50%;
    background: #fff;
    line-height: 1;
    padding: 0;
    place-items: center;
  }

  .top-nav-link {
    text-align: left;
    font-size: 1rem;
    padding: 0.2rem 0;
  }

  #new-client-btn {
    width: 100%;
    justify-content: center;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .app-footer {
    margin: 0;
    padding: 2.2rem 0.75rem;
  }

  .panel {
    padding: 0.7rem;
    min-width: 0;
    max-width: 100%;
  }

  .panel-title-row h2 {
    font-size: 1.55rem;
  }

  .mobile-tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.45rem;
  }

  .tab-row {
    display: none;
    flex-direction: column;
    gap: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .tab-row.mobile-open {
    display: flex;
  }

  .tab {
    width: 100%;
    text-align: left;
    padding: 0.6rem 0;
    margin-bottom: 0;
    border-bottom-width: 2px;
  }

  .client-list {
    max-height: 260px;
  }

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

  .tab-panel {
    margin-top: 0.5rem;
    min-width: 0;
    max-width: 100%;
  }

  .stack-list {
    gap: 0.75rem;
  }

  .card {
    padding: 0.65rem;
    min-width: 0;
    max-width: 100%;
  }

  .integration-bar {
    align-items: stretch;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  textarea {
    min-height: 120px;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .filter-row input[type="date"],
  .filter-row input[type="search"],
  .filter-row button,
  .card-actions input[type="file"],
  .card-actions .button,
  .card-actions a.button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

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

  #homework-list .card,
  #files-list .card,
  #resources-list .card {
    width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #homework-list textarea,
  #homework-form input,
  #homework-form textarea,
  #visit-form label,
  #visit-form input,
  #visit-form textarea,
  #visit-form select,
  #files-form input,
  #files-form textarea,
  #files-form select,
  #files-form,
  #resources-form {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #visit-form,
  #visit-history {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  #visit-form .filter-row,
  #visit-form .filter-row > *,
  #visit-form input[type="date"],
  #visit-form input[type="search"],
  #visit-form textarea,
  #visit-form select,
  #visit-form label {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-inline-size: 0;
  }

  #visit-form .card-actions.filter-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
  }

  #visit-form .card-actions.filter-row > * {
    flex: 0 1 auto;
  }

  #visit-form .filter-row input[type="date"],
  #visit-form .filter-row input[type="search"],
  #visit-form .filter-row button {
    min-height: 46px;
    line-height: 1.2;
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
  }

  #visit-form input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    text-align: left;
    padding-right: 0.75rem;
  }

  #visit-form input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
  }

  #visit-form input[type="date"]::-webkit-calendar-picker-indicator {
    margin-left: 0;
  }

  .resources-table {
    min-width: 700px;
  }

  .session-notes-table {
    min-width: 640px;
    table-layout: auto;
  }

  .session-notes-table th,
  .session-notes-table td {
    padding: 0.45rem;
    font-size: 0.86rem;
    overflow-wrap: normal;
    word-break: normal;
  }

  .session-notes-table th:nth-child(1),
  .session-notes-table td:nth-child(1) {
    width: 104px;
    white-space: nowrap;
  }

  .session-notes-table th:nth-child(3),
  .session-notes-table td:nth-child(3) {
    width: 104px;
    white-space: nowrap;
  }

  .session-notes-table th:nth-child(4),
  .session-notes-table td:nth-child(4) {
    width: 72px;
    white-space: nowrap;
    text-align: right;
  }

  .session-notes-table th:nth-child(5),
  .session-notes-table td:nth-child(5) {
    width: 72px;
    white-space: nowrap;
    text-align: right;
  }

  .session-notes-table th:nth-child(2),
  .session-notes-table td:nth-child(2) {
    width: auto;
    min-width: 240px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 761px) and (max-width: 980px) {
  .top-nav-menu-btn {
    display: none !important;
  }

  .header-actions {
    display: flex;
    position: static;
    width: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
  }

  .mobile-tab-header {
    display: none;
  }

  .tab-row {
    display: flex;
    flex-direction: row;
    gap: 0.45rem;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .tab-row.mobile-open {
    display: flex;
  }

  .tab {
    width: auto;
    text-align: left;
    padding: 0.45rem 0.8rem 0.5rem;
    margin-bottom: -1px;
    border-bottom-width: 3px;
  }
}
