:root {
  --page: #f5f5f7;
  --background: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f2f2f7;
  --surface-muted: #e8e8ed;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --soft: #8e8e93;
  --line: #d2d2d7;
  --primary: #007aff;
  --primary-strong: #0057d9;
  --primary-soft: #e8f2ff;
  --sage: #34c759;
  --sage-soft: #ecf9ef;
  --gold: #ff9f0a;
  --gold-soft: #fff4e3;
  --success: #248a3d;
  --success-bg: #ecf9ef;
  --warning: #9a6700;
  --warning-bg: #fff4d6;
  --danger: #d70015;
  --danger-bg: #ffecee;
  --whatsapp: #25d366;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  pointer-events: none;
}

.hidden {
  display: none;
}

.access-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.access-panel {
  width: min(100%, 390px);
  display: grid;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.access-brand {
  min-height: 520px;
  display: grid;
  align-content: space-between;
  gap: 28px;
  padding: 32px;
  border-radius: 8px;
  background: var(--surface);
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.access-brand h1 {
  max-width: 560px;
  margin: 0;
  font-size: clamp(36px, 5vw, 62px);
  line-height: 0.98;
  letter-spacing: 0;
}

.access-preview {
  display: grid;
  gap: 10px;
}

.preview-top,
.preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-top {
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.preview-top span,
.preview-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.preview-top strong {
  font-size: 28px;
}

.preview-card {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview-card strong {
  font-size: 17px;
}

.preview-card small {
  color: var(--muted);
}

.access-form {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 420px;
  padding: 32px;
  border-radius: 8px;
  background: var(--surface);
}

.access-form h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
}

.access-form p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.form-error {
  margin: -4px 0 0;
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.app-shell {
  position: relative;
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--background);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  background: rgba(245, 245, 247, 0.84);
  border-bottom: 1px solid rgba(210, 210, 215, 0.72);
  backdrop-filter: blur(18px);
}

.topbar-copy {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-badge svg {
  width: 15px;
  height: 15px;
}

.sync-badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.sync-badge.agendado {
  background: var(--primary-soft);
  color: var(--primary);
}

.sync-badge.pendente {
  background: var(--warning-bg);
  color: var(--warning);
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.05;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.main {
  padding: 16px 16px 98px;
}

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

.section,
.panel-block {
  display: grid;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.panel-block,
.command-panel,
.appointment-row,
.client-card,
.stock-card,
.service-row,
.priority-item,
.message-panel,
.metric-card,
.insight-card {
  border: 1px solid rgba(210, 210, 215, 0.78);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.command-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.command-copy h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(30px, 9vw, 46px);
  line-height: 0.98;
}

.command-copy p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.42;
}

.command-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 9px;
}

.action-tight {
  min-height: 42px;
}

.action-icon-mobile {
  min-width: 0;
}

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

.insight-card {
  min-width: 0;
  min-height: 112px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 13px;
}

.insight-card > span,
.metric-icon,
.panel-icon,
.priority-icon {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
}

.insight-card strong {
  min-width: 0;
  font-size: 22px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.insight-card small,
.insight-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.25;
}

.insight-card em {
  color: var(--soft);
}

.timeline-list,
.list,
.priority-list,
.slot-list {
  display: grid;
  gap: 10px;
}

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

.appointment-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  overflow: hidden;
}

.client-command .command-copy h2 {
  font-size: clamp(34px, 11vw, 54px);
}

.client-appointment-row .actions {
  display: none;
}

.appointment-time {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 15px 12px;
  border-right: 1px solid var(--line);
  background: #fbfbfd;
}

.appointment-time strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.appointment-time span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.appointment-body,
.client-content,
.stock-card,
.message-panel,
.panel-block {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.client-card {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  padding: 14px;
}

.client-card .client-content {
  padding: 0;
}

.avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}

.stock-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.stock-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.service-row,
.priority-item,
.message-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
}

.message-panel {
  grid-template-columns: auto 1fr;
}

.message-panel .button {
  grid-column: 1 / -1;
}

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

.template-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.template-message {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.priority-icon.ok {
  background: var(--success-bg);
  color: var(--success);
}

.priority-icon.pendente {
  background: var(--warning-bg);
  color: var(--warning);
}

.priority-icon.baixo {
  background: var(--danger-bg);
  color: var(--danger);
}

.priority-item strong {
  display: block;
  font-size: 14px;
}

.priority-item small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

.card-title {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.24;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inline-meta span,
.segment,
.time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
}

.time-pill {
  width: max-content;
  color: var(--primary);
}

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

.metric-card {
  display: grid;
  min-height: 118px;
  align-content: start;
  gap: 8px;
  padding: 14px;
}

.metric-card strong {
  min-width: 0;
  font-size: 22px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.metric-card span:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.segment-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 1px;
}

.segment {
  min-height: 34px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

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

.search,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search {
  background: var(--surface-soft);
}

.search:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(0, 122, 255, 0.54);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

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

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

.field label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.button,
.text-button,
.icon-button,
.slot-button {
  touch-action: manipulation;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}

.button.primary {
  min-height: 48px;
  background: var(--primary);
  color: #fff;
}

.button.secondary {
  border-color: transparent;
  background: var(--surface-soft);
  color: var(--primary);
}

.button.whatsapp {
  background: #effdf5;
  color: #166235;
}

.button.compact {
  min-height: 42px;
  padding-inline: 12px;
  white-space: nowrap;
}

.button.full {
  width: 100%;
}

.button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.slot-button {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 1px solid rgba(210, 210, 215, 0.78);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.slot-button svg {
  color: var(--primary);
}

.text-button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.icon-button {
  position: relative;
  width: 44px;
  height: 44px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.primary-icon {
  background: var(--primary);
  color: #fff;
}

.notification-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 2px solid var(--background);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 0;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.badge.confirmado,
.badge.pago,
.badge.ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge.agendado,
.badge.atendido {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.cancelado,
.badge.baixo {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.pendente,
.badge.noshow,
.badge.nao-compareceu,
.badge.re-agendando {
  background: var(--warning-bg);
  color: var(--warning);
}

.checkout-panel {
  display: grid;
  gap: 12px;
}

.checkout-segments {
  padding-bottom: 2px;
}

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

.behavior-stat {
  display: grid;
  gap: 4px;
  padding: 10px 11px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.behavior-stat strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
}

.behavior-stat span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.behavior-table {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border-radius: 8px;
  background: #fbfbfd;
}

.behavior-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 1.3;
}

.behavior-row span:first-child {
  color: var(--muted);
  font-weight: 700;
}

.behavior-row span:nth-child(2) {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.behavior-row .badge {
  justify-self: end;
}

.behavior-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.empty,
.summary-line {
  padding: 15px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.summary-line {
  text-align: left;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(var(--nav-count, 5), 1fr);
  gap: 4px;
  padding: 8px 10px 12px;
  background: rgba(245, 245, 247, 0.86);
  border-top: 1px solid rgba(210, 210, 215, 0.72);
  backdrop-filter: blur(18px);
}

.nav-item {
  min-width: 0;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--soft);
  display: grid;
  place-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
}

.nav-item.active {
  background: var(--surface);
  color: var(--primary);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
}

.modal {
  width: min(100%, 520px);
  max-height: 88vh;
  overflow: auto;
  background: var(--page);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.18);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.modal-header h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 50;
  width: min(calc(100% - 32px), 440px);
  transform: translateX(-50%);
  border-radius: 8px;
  background: rgba(29, 29, 31, 0.94);
  color: #fff;
  padding: 12px 14px;
  font-size: 14px;
}

@media (min-width: 760px) {
  body {
    padding: 14px 0;
  }

  .app-shell {
    min-height: calc(100vh - 28px);
    border: 1px solid rgba(210, 210, 215, 0.76);
    border-radius: 8px;
    overflow: clip;
    box-shadow: var(--shadow);
  }

  .main {
    padding-inline: 22px;
  }
}

@media (max-width: 760px) {
  .access-shell {
    padding: 0;
    place-items: stretch;
  }

  .access-panel {
    min-height: 100vh;
    align-content: start;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .access-brand {
    min-height: auto;
    padding: 24px 20px;
    border-radius: 0;
    background: var(--surface);
  }

  .access-brand h1 {
    font-size: 40px;
  }

  .access-form {
    min-height: 100vh;
    padding: 24px 20px 32px;
    border-radius: 0;
  }
}

@media (max-width: 520px) {
  .command-actions {
    grid-template-columns: 44px 1fr;
    align-items: start;
  }

  .command-actions .button {
    width: 100%;
  }

  .action-icon-mobile {
    width: 44px;
    min-width: 44px;
    padding: 0;
    justify-content: center;
  }

  .action-icon-mobile span {
    display: none;
  }

  .action-tight {
    min-height: 42px;
    padding-inline: 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .action-tight span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

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

  .appointment-time {
    grid-template-columns: auto 1fr;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .appointment-time span {
    justify-self: end;
  }

  .appointment-time {
    padding: 12px 10px;
  }

  .appointment-body,
  .client-content,
  .stock-card,
  .message-panel,
  .panel-block {
    padding: 12px;
  }

  .appointment-row .actions,
  .client-card .actions {
    gap: 6px;
  }

  .client-behavior {
    grid-template-columns: 1fr;
  }

  .behavior-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .behavior-row .badge {
    grid-column: 1 / -1;
    width: max-content;
    justify-self: start;
  }

  .appointment-row .actions .button,
  .client-card .actions .button {
    min-height: 42px;
    padding-inline: 12px;
  }

  .client-card {
    grid-template-columns: 40px 1fr;
    gap: 10px;
  }

  .avatar {
    width: 40px;
    height: 40px;
  }

  .service-row,
  .priority-item {
    grid-template-columns: auto 1fr;
  }

  .service-row .badge,
  .priority-item .badge {
    grid-column: 1 / -1;
    width: max-content;
  }
}

@media (max-width: 430px) {
  .actions .button {
    flex: 1 1 calc(50% - 8px);
  }

  .appointment-row .actions .button {
    flex: 1 1 100%;
  }
}

@media (max-width: 390px) {
  .two-cols,
  .toolbar,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .client-card {
    grid-template-columns: 1fr;
  }
}
