:root {
  color-scheme: light;
  --paper: #fffaf7;
  --surface: #ffffff;
  --surface-soft: #fff3ef;
  --ink: #261f1d;
  --muted: #756762;
  --line: rgba(76, 52, 44, 0.14);
  --brand: #b85f4d;
  --brand-dark: #824133;
  --gold: #bd8a4d;
  --sage: #4f7f68;
  --blue: #446c8f;
  --danger: #b43d3d;
  --shadow: 0 18px 48px rgba(77, 47, 37, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--paper);
}

body {
  min-width: 0;
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 248, 246, 0.96), rgba(255, 255, 255, 0.98) 42%, rgba(251, 244, 239, 0.92)),
    var(--paper);
  overflow-x: hidden;
}

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

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

a {
  color: inherit;
}

.manager-body {
  min-height: 100vh;
}

.manager-root {
  min-height: 100vh;
}

.boot-screen,
.manager-noscript {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

.boot-screen img {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 18px 24px rgba(80, 45, 35, 0.16));
}

.boot-screen p,
.manager-noscript p {
  margin: 0;
  color: var(--muted);
}

.manager-auth {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.auth-card,
.setup-card {
  width: min(100%, 520px);
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-media {
  min-height: 156px;
  display: grid;
  align-content: end;
  gap: 10px;
  padding: 24px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(39, 29, 26, 0.38), rgba(184, 95, 77, 0.16)),
    url("../assets/alessia-bernabucci-beauty-studio-roma.jpg") center/cover;
}

.auth-media img {
  width: 58px;
  height: 58px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 6px;
}

.auth-media h1,
.setup-heading h1 {
  margin: 0;
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  line-height: 0.98;
}

.auth-media p,
.setup-heading p {
  margin: 0;
  max-width: 34rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5;
}

.auth-content,
.setup-content {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.setup-heading {
  padding: 24px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(38, 31, 29, 0.88), rgba(130, 65, 51, 0.72)),
    url("../assets/nail-artist-roma-alessia-bernabucci.jpg") center/cover;
}

.setup-heading p {
  color: rgba(255, 255, 255, 0.86);
}

.auth-title,
.section-title,
.view-title {
  display: grid;
  gap: 6px;
}

.eyebrow,
.auth-title small,
.section-title small,
.view-title small {
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-title h2,
.section-title h2,
.view-title h1 {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 2rem);
  line-height: 1.05;
}

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

.hint {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.form-grid,
.compact-form {
  display: grid;
  gap: 12px;
}

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

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

.field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(184, 95, 77, 0.7);
  box-shadow: 0 0 0 4px rgba(184, 95, 77, 0.12);
}

.button,
.icon-button,
.nav-button,
.chip-button,
.wa-link {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 8px;
  padding: 12px 15px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.button svg,
.icon-button svg,
.nav-button svg,
.wa-link svg,
.metric-card svg,
.inline-icon svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

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

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

.button.ghost {
  background: rgba(255, 255, 255, 0.65);
}

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

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.button-row,
.split-row,
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button-row .button,
.toolbar-row .button {
  flex: 1 1 150px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 8px;
  color: var(--brand-dark);
  background: rgba(184, 95, 77, 0.1);
  border: 1px solid rgba(184, 95, 77, 0.18);
}

.notice.success {
  color: #2d6b51;
  background: rgba(79, 127, 104, 0.11);
  border-color: rgba(79, 127, 104, 0.2);
}

.notice.danger {
  color: var(--danger);
  background: rgba(180, 61, 61, 0.08);
  border-color: rgba(180, 61, 61, 0.18);
}

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

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

.setup-list strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
}

.setup-code {
  display: block;
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  color: #fff;
  background: #211b19;
  overflow-x: auto;
  white-space: nowrap;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.manager-sidebar {
  display: none;
}

.manager-main {
  min-width: 0;
  width: 100%;
  padding: max(14px, env(safe-area-inset-top)) 14px 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -14px -14px 16px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: rgba(255, 250, 247, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.topbar-brand {
  min-width: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-brand img,
.sidebar-brand img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px;
}

.topbar-brand span,
.sidebar-brand span {
  display: grid;
  min-width: 0;
}

.topbar-brand strong,
.sidebar-brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-brand small,
.sidebar-brand small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.view-stack {
  display: grid;
  gap: 16px;
}

.view-head {
  display: grid;
  gap: 12px;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.view-actions .button {
  flex: 1 1 150px;
}

.manager-panel,
.metric-card,
.appointment-card,
.client-card,
.service-card,
.report-card,
.empty-state {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(77, 47, 37, 0.08);
}

.manager-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.highlight-panel {
  border-color: rgba(184, 95, 77, 0.28);
  background:
    linear-gradient(135deg, rgba(184, 95, 77, 0.1), rgba(255, 255, 255, 0.94) 42%),
    rgba(255, 255, 255, 0.96);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.panel-head h3,
.metric-card h3,
.appointment-card h3,
.client-card h3,
.service-card h3,
.report-card h3 {
  margin: 0;
}

.panel-head p,
.appointment-card p,
.client-card p,
.service-card p,
.report-card p {
  margin: 0;
  color: var(--muted);
}

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

.metric-card,
.report-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.metric-card::after,
.report-card::after {
  content: "";
  position: absolute;
  inset: auto 12px 10px auto;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(184, 95, 77, 0.08);
}

.metric-card svg {
  color: var(--brand);
}

.metric-card strong,
.report-card strong {
  display: block;
  font-size: clamp(1.55rem, 9vw, 2.35rem);
  line-height: 1;
}

.metric-card span,
.report-card span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.3;
}

.list-stack,
.appointments-list,
.clients-list,
.services-list {
  display: grid;
  gap: 12px;
}

.appointment-card,
.client-card,
.service-card {
  display: grid;
  gap: 13px;
  padding: 14px;
}

.compact-list .appointment-card {
  box-shadow: none;
}

.card-top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
}

.card-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.card-title h3 {
  overflow-wrap: anywhere;
}

.status-badge,
.service-chip,
.client-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--brand-dark);
  background: rgba(184, 95, 77, 0.1);
  border: 1px solid rgba(184, 95, 77, 0.16);
}

.status-badge[data-status="confermato"] {
  color: #2f6752;
  background: rgba(79, 127, 104, 0.12);
  border-color: rgba(79, 127, 104, 0.18);
}

.status-badge[data-status="completato"] {
  color: #345c7f;
  background: rgba(68, 108, 143, 0.12);
  border-color: rgba(68, 108, 143, 0.18);
}

.status-badge[data-status="annullato"],
.status-badge[data-status="no_show"] {
  color: var(--danger);
  background: rgba(180, 61, 61, 0.08);
  border-color: rgba(180, 61, 61, 0.16);
}

.client-chip[data-client-tag="vip"] {
  color: #7a4e12;
  background: rgba(189, 138, 77, 0.14);
  border-color: rgba(189, 138, 77, 0.24);
}

.client-chip[data-client-tag="no-show"] {
  color: var(--danger);
  background: rgba(180, 61, 61, 0.08);
  border-color: rgba(180, 61, 61, 0.16);
}

.client-chip[data-client-tag="abituale"] {
  color: #2f6752;
  background: rgba(79, 127, 104, 0.12);
  border-color: rgba(79, 127, 104, 0.18);
}

.client-chip[data-client-tag="da richiamare"] {
  color: #345c7f;
  background: rgba(68, 108, 143, 0.12);
  border-color: rgba(68, 108, 143, 0.18);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.meta-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-width: 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.meta-item strong {
  color: var(--ink);
}

.meta-item svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--brand);
  margin-top: 1px;
}

.chip-list,
.filters,
.status-actions,
.wa-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  font-weight: 800;
}

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

.chip-button.calendar-chip {
  color: #245f75;
  background: rgba(130, 188, 207, 0.14);
  border-color: rgba(36, 95, 117, 0.18);
}

.chip-button.danger-chip {
  color: var(--danger);
  background: rgba(164, 64, 64, 0.08);
  border-color: rgba(164, 64, 64, 0.18);
}

.status-actions .chip-button {
  flex: 1 1 120px;
  justify-content: center;
}

.appointment-card .status-actions .chip-button:first-child {
  flex-basis: 100%;
}

.wa-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  background: #1f8f5f;
  font-weight: 850;
}

.wa-actions .wa-link {
  flex: 1 1 128px;
}

.search-row {
  display: grid;
  gap: 10px;
}

.checkbox-grid {
  display: grid;
  gap: 8px;
}

.service-check {
  min-width: 0;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.service-check input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.service-check strong,
.service-check span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.service-check span {
  color: var(--muted);
  font-size: 0.88rem;
}

.summary-strip {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(184, 95, 77, 0.08);
  border: 1px solid rgba(184, 95, 77, 0.14);
  position: sticky;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 8;
  backdrop-filter: blur(14px);
}

.summary-strip strong {
  display: block;
}

.summary-strip p {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  padding: 20px;
  display: grid;
  gap: 10px;
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  color: var(--brand);
}

.mobile-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 250, 247, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav-button {
  min-width: 0;
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 3px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 0.74rem;
  font-weight: 800;
}

.nav-button.active {
  color: #fff;
  background: var(--ink);
}

.nav-button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.desktop-nav {
  display: grid;
  gap: 8px;
}

.desktop-nav .nav-button {
  grid-template-columns: 22px 1fr;
  justify-items: start;
  min-height: 44px;
  padding: 10px;
  font-size: 0.92rem;
}

.divider {
  height: 1px;
  background: var(--line);
}

.service-form-actions,
.appointment-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.service-form-actions .button,
.appointment-form-actions .button {
  flex: 1 1 150px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.mini-table th,
.mini-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.mini-table th {
  color: var(--muted);
  font-size: 0.86rem;
}

.toast-area {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 60;
  display: grid;
  pointer-events: none;
}

.toast {
  justify-self: center;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (min-width: 700px) {
  .form-grid.two,
  .meta-grid,
  .search-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-grid,
  .report-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (min-width: 1040px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    padding-bottom: 0;
  }

  .manager-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    align-content: start;
    gap: 22px;
    padding: 22px;
    border-right: 1px solid var(--line);
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 243, 239, 0.84)),
      var(--paper);
  }

  .sidebar-brand {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .manager-main {
    padding: 24px;
  }

  .topbar {
    margin: -24px -24px 22px;
    padding: 18px 24px;
  }

  .mobile-tabbar {
    display: none;
  }

  .view-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .appointments-list,
  .clients-list,
  .services-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manager-panel.wide {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1360px) {
  .appointments-list,
  .clients-list,
  .services-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
