:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--tg-theme-secondary-bg-color, #f8f4f1);
  color: var(--tg-theme-text-color, #231f20);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--tg-theme-secondary-bg-color, #f8f4f1);
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

button:disabled {
  opacity: 0.55;
}

.app-shell {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 24px 18px 104px;
}

.page-header {
  margin-bottom: 18px;
}

.eyebrow,
.summary-label {
  margin: 0 0 4px;
  color: var(--tg-theme-hint-color, #766f70);
  font-size: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 9vw, 44px);
  line-height: 1.05;
}

h2 {
  margin: 28px 2px 12px;
  font-size: 20px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary > div,
.appointment-card,
.state-message {
  border-radius: 20px;
  background: var(--tg-theme-bg-color, #ffffff);
  box-shadow: 0 8px 24px rgb(61 42 47 / 7%);
}

.health-card {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border-radius: 18px;
  background: #e8dfe1;
}

.frontend-diagnostic {
  border: 1px solid #d99898;
  color: #8a3030;
}

.health-card div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--tg-theme-bg-color, #ffffff);
}

.health-card span {
  color: var(--tg-theme-hint-color, #766f70);
}

.summary > div {
  padding: 18px;
}

.summary strong {
  display: block;
  font-size: 22px;
}

.new-appointment-button {
  width: 100%;
  min-height: 60px;
  margin-top: 14px;
  border: 0;
  border-radius: 18px;
  background: #7d3f4c;
  color: #ffffff;
  font-size: 19px;
  font-weight: 750;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 8px;
  margin: 0 -18px 20px;
  padding: 0 18px 8px;
  overflow-x: auto;
}

.calendar-day {
  min-height: 92px;
  padding: 12px 8px;
  border: 0;
  border-radius: 18px;
  background: var(--tg-theme-bg-color, #ffffff);
  color: #51494a;
  box-shadow: 0 6px 18px rgb(61 42 47 / 6%);
  text-align: center;
}

.calendar-day strong,
.calendar-day span {
  display: block;
}

.calendar-day strong {
  margin: 5px 0;
  font-size: 24px;
}

.calendar-day span {
  color: var(--tg-theme-hint-color, #766f70);
  font-size: 13px;
}

.calendar-day.active {
  background: #7d3f4c;
  color: #ffffff;
}

.calendar-day.active span {
  color: #f4e8eb;
}

.calendar-selection {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.calendar-title {
  margin: 0;
}

.calendar-count {
  min-width: 48px;
  padding: 10px 14px;
  border-radius: 16px;
  background: #f2e4e7;
  color: #653943;
  font-size: 20px;
  text-align: center;
}

#calendar-appointments {
  margin-top: 14px;
}

.clients-search {
  margin-bottom: 8px;
}

.archive-toggle {
  min-height: 44px;
  margin: 0 0 14px;
  padding: 0 14px;
  border: 0;
  border-radius: 13px;
  background: #f2e4e7;
  color: #653943;
  font-weight: 700;
}

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

.client-card {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 86px;
  padding: 16px 18px;
  border: 0;
  border-radius: 18px;
  background: var(--tg-theme-bg-color, #ffffff);
  color: var(--tg-theme-text-color, #231f20);
  box-shadow: 0 8px 24px rgb(61 42 47 / 7%);
  text-align: left;
}

.client-card strong {
  font-size: 22px;
  line-height: 1.2;
}

.client-contact,
.client-stats {
  overflow-wrap: anywhere;
  color: var(--tg-theme-hint-color, #766f70);
  line-height: 1.4;
}

.client-full-contact {
  overflow-wrap: anywhere;
}

.client-note {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f8f4f1;
  white-space: pre-wrap;
}

.client-visit,
.more-card {
  border: 1px solid rgb(255 244 222 / 22%);
  background: rgb(91 62 49 / 96%);
  color: #fff8eb;
}

.client-visit span { color: #e8d8c7; }

.client-history-title {
  display: block;
  margin-bottom: 8px;
}

.client-history {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.client-visit {
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 14px;
  background: #f8f4f1;
}

.client-visit span {
  color: var(--tg-theme-hint-color, #766f70);
}

.client-main-action {
  margin-top: 8px;
}

.danger-outline-button {
  min-height: 48px;
  border: 1px solid #e8c5c5;
  border-radius: 14px;
  background: transparent;
  color: #8a3030;
  font-weight: 700;
}

.more-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.more-card {
  display: grid;
  gap: 10px;
  min-height: 130px;
  place-content: center;
  border: 0;
  border-radius: 22px;
  background: var(--tg-theme-bg-color, #fff);
  color: var(--tg-theme-text-color, #231f20);
  box-shadow: 0 8px 24px rgb(61 42 47 / 7%);
  font-size: 34px;
}

.more-card strong {
  font-size: 18px;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-header h2 {
  margin: 0;
  font-size: 28px;
}

.admin-back {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: #f2e4e7;
  color: #653943;
  font-weight: 700;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-card,
.finance-row,
.timezone-card {
  display: grid;
  gap: 5px;
  padding: 16px;
  border-radius: 18px;
  background: var(--tg-theme-bg-color, #fff);
  box-shadow: 0 8px 24px rgb(61 42 47 / 7%);
  white-space: pre-line;
}

.admin-card > strong {
  font-size: 20px;
}

.admin-card small {
  color: var(--tg-theme-hint-color, #766f70);
}

.admin-card-button {
  width: 100%;
  border: 0;
  color: inherit;
  font: inherit;
  line-height: 1.5;
  text-align: left;
}

.low-stock {
  border-left: 5px solid #d78a3d;
}

.compact-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 8px;
}

.compact-actions .action-button:last-child {
  grid-column: 1 / -1;
}

.finance-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.finance-summary > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  background: var(--tg-theme-bg-color, #fff);
}

.finance-summary span {
  color: var(--tg-theme-hint-color, #766f70);
  font-size: 13px;
}

.finance-row {
  line-height: 1.5;
}

.timezone-card {
  margin: 8px 0 14px;
}

.appointment-list {
  display: grid;
  gap: 12px;
}

.appointment-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  padding: 18px;
}

.appointment-time {
  font-size: 24px;
  font-weight: 750;
}

.appointment-client {
  margin: 0 0 6px;
  font-size: 21px;
  line-height: 1.2;
}

.appointment-details,
.appointment-price {
  margin: 0;
}

.appointment-details {
  color: var(--tg-theme-hint-color, #766f70);
  line-height: 1.45;
}

.appointment-price {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
}

.appointment-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.action-button,
.primary-button,
.secondary-button,
.slot-button,
.choice-button {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  font-weight: 700;
}

.action-button {
  background: #f5eef0;
  color: #653943;
}

.action-button.complete {
  grid-column: 1 / -1;
  background: #e8f3eb;
  color: #265f3b;
}

.action-button.cancel,
.danger-button {
  background: #fbeaea;
  color: #8a3030;
}

.action-sheet {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  align-items: end;
  padding: 18px;
  background: rgb(35 31 32 / 38%);
}

.action-sheet[hidden] {
  display: none;
}

.sheet-card {
  position: relative;
  width: min(100%, 560px);
  max-height: calc(100vh - 36px);
  margin: 0 auto;
  padding: 24px;
  overflow-y: auto;
  border-radius: 24px;
  background: var(--tg-theme-bg-color, #ffffff);
  box-shadow: 0 20px 60px rgb(35 31 32 / 24%);
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #f4eff0;
  color: #51494a;
  font-size: 28px;
}

.sheet-title {
  margin: 0 48px 10px 0;
  font-size: 27px;
}

.sheet-lead,
.sheet-details {
  margin: 0 0 18px;
  line-height: 1.5;
}

.sheet-details {
  color: var(--tg-theme-hint-color, #766f70);
}

.sheet-actions {
  display: grid;
  gap: 10px;
}

.primary-button {
  background: #7d3f4c;
  color: #ffffff;
}

.secondary-button {
  background: #f4eff0;
  color: #51494a;
}

.date-input {
  width: 100%;
  min-height: 54px;
  margin: 4px 0 16px;
  padding: 0 16px;
  border: 1px solid #ded4d6;
  border-radius: 14px;
  background: #ffffff;
  color: #231f20;
  font: inherit;
  font-size: 18px;
}

.text-input {
  width: 100%;
  min-height: 54px;
  margin: 4px 0 12px;
  padding: 0 16px;
  border: 1px solid #ded4d6;
  border-radius: 14px;
  background: #ffffff;
  color: #231f20;
  font: inherit;
  font-size: 18px;
}

.field-label {
  display: block;
  margin-top: 12px;
  color: var(--tg-theme-hint-color, #766f70);
  font-size: 14px;
}

.choice-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.choice-button {
  padding: 0 16px;
  background: #f4eff0;
  color: #51494a;
  text-align: left;
}

.confirmation-card {
  margin: 6px 0 20px;
  padding: 16px;
  border-radius: 16px;
  background: #f8f4f1;
  line-height: 1.65;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slot-button {
  background: #f2e4e7;
  color: #653943;
  font-size: 17px;
}

.material-list {
  margin: 8px 0 20px;
  padding-left: 20px;
  color: var(--tg-theme-hint-color, #766f70);
}

.visit-items {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.visit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 12px 10px 16px;
  border-radius: 14px;
  background: #f8f4f1;
}

.small-danger-button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: #fbeaea;
  color: #8a3030;
  font-weight: 700;
}

.visit-total {
  width: 100%;
  min-height: 56px;
  margin: 0 0 14px;
  padding: 0 16px;
  border: 0;
  border-radius: 16px;
  background: #e8f3eb;
  color: #265f3b;
  font-size: 18px;
  font-weight: 750;
  text-align: left;
}

.visit-summary {
  white-space: pre-line;
}

.sheet-error {
  color: #8a3030;
}

.state-message {
  margin: 0;
  padding: 24px 18px;
  color: var(--tg-theme-hint-color, #766f70);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px max(10px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  border-top: 1px solid rgb(61 42 47 / 8%);
  background: color-mix(in srgb, var(--tg-theme-bg-color, #ffffff) 94%, transparent);
  backdrop-filter: blur(16px);
}

.nav-item {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--tg-theme-hint-color, #766f70);
  font-size: 13px;
}

.nav-item.active {
  background: #f2e4e7;
  color: #7d3f4c;
  font-weight: 700;
}

.nav-item:disabled {
  opacity: 0.48;
}

@media (max-width: 420px) {
  .appointment-card {
    grid-template-columns: 62px 1fr;
    padding: 16px;
  }

  .action-sheet {
    padding: 10px;
  }
}

/* Warm coffee-and-cream theme with a lightweight CSS marble texture. */
:root {
  background: #4b352c;
  color: #fff8eb;
}

body {
  color: #fff8eb;
  background:
    radial-gradient(ellipse at 12% 18%, rgb(255 244 222 / 9%) 0 1px, transparent 2px),
    radial-gradient(ellipse at 82% 68%, rgb(255 255 255 / 6%) 0 2px, transparent 3px),
    linear-gradient(125deg, #3f2c25 0%, #6b4b3c 48%, #4a332a 100%);
  background-attachment: fixed;
}

.summary > div,
.appointment-card,
.client-card,
.admin-card,
.finance-row,
.timezone-card,
.state-message,
.sheet-card,
.confirmation-card,
.health-card div,
.calendar-day {
  border: 1px solid rgb(255 244 222 / 22%);
  background: rgb(91 62 49 / 82%);
  color: #fff8eb;
  box-shadow: 0 10px 28px rgb(28 17 13 / 18%);
}

.eyebrow,
.summary-label,
.appointment-details,
.client-contact,
.client-stats,
.sheet-details,
.field-label,
.health-card span {
  color: #e8d8c7;
}

.primary-button,
.new-appointment-button,
.calendar-day.active {
  background: #d8b58d;
  color: #35241e;
}

.secondary-button,
.choice-button,
.action-button,
.slot-button,
.archive-toggle,
.nav-item.active,
.visit-item,
.visit-total {
  border: 1px solid rgb(255 244 222 / 18%);
  background: rgb(111 77 61 / 88%);
  color: #fff8eb;
}

.text-input,
.date-input {
  border-color: rgb(255 244 222 / 35%);
  background: #fffaf1;
  color: #35241e;
}

.bottom-nav {
  border-color: rgb(255 244 222 / 16%);
  background: rgb(55 37 30 / 94%);
}

.nav-item { color: #ddcbbb; }
.slot-grid { width: 100%; justify-items: stretch; }
.slot-button { width: 100%; text-align: center; }
.note-input { min-height: 92px; padding-top: 14px; resize: vertical; }
.appointment-note { margin: 8px 0 0; color: #f1dfcd; white-space: pre-wrap; }

/* UI polish: lighter canvas, solid coffee sheets, and explicit note controls. */
body {
  color: #3d2a22;
  background:
    radial-gradient(ellipse at 12% 18%, rgb(255 250 236 / 36%) 0 1px, transparent 2px),
    radial-gradient(ellipse at 82% 68%, rgb(255 255 255 / 24%) 0 2px, transparent 3px),
    linear-gradient(125deg, #c7aa8c 0%, #ead9bd 48%, #ccb092 100%);
}

.page-header .eyebrow,
.calendar-selection,
#clients-view > .eyebrow,
#more-view > .eyebrow {
  color: #654a3d;
}

.action-sheet {
  background: rgb(43 28 22 / 74%);
  -webkit-backdrop-filter: blur(12px) saturate(80%);
  backdrop-filter: blur(12px) saturate(80%);
}

.sheet-card {
  max-height: calc(100dvh - 36px);
  border-color: rgb(255 244 222 / 30%);
  background: rgb(67 44 35 / 98%);
  color: #fff8eb;
  box-shadow: 0 24px 72px rgb(27 16 12 / 50%);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-close {
  background: #d8b58d;
  color: #35241e;
}

.client-note {
  display: grid;
  gap: 9px;
  padding: 16px;
  background: rgb(91 62 49 / 98%);
  color: #fff8eb;
}

.client-note-text {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.client-note-empty { color: #ddcbbb; }

.client-note-edit {
  justify-self: start;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgb(255 244 222 / 25%);
  border-radius: 12px;
  background: #d8b58d;
  color: #35241e;
  font-weight: 750;
}

.client-next-appointment {
  display: grid;
  gap: 7px;
  white-space: normal;
}

.client-visit .history-note,
.client-next-appointment .history-note {
  color: #f7e8d7;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.inline-note-button { margin-top: 5px; }
.appointment-note-action { grid-column: 1 / -1; }

@media (max-width: 420px) {
  .action-sheet {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .sheet-card {
    max-height: calc(100dvh - 16px);
    padding: 22px 18px 26px;
    border-radius: 22px;
  }

  .sheet-title {
    padding-right: 8px;
    font-size: 25px;
    overflow-wrap: anywhere;
  }

  .sheet-actions { grid-template-columns: 1fr; }

  .client-full-contact,
  .client-visit,
  .confirmation-card {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
