/* ============================================================
   Barbearia · Gestão — folha de estilo única
   Tema: carvão profundo + dourado, tipografia do sistema.
   ============================================================ */

:root {
  color-scheme: dark;

  --bg: #0b0b0b;
  --bg-soft: #121212;
  --panel: #171717;
  --panel-2: #1d1d1d;
  --panel-3: #262626;
  --line: #2a2a2a;
  --line-strong: #3d3d3d;

  --accent: #d81f26;
  --accent-soft: #ff6b6b;
  --accent-dim: #8e1a1f;
  --accent-glow: rgba(216, 31, 38, 0.14);

  --text: #f6f3ea;
  --text-2: #d6d6d6;
  --muted: #9a9a9a;

  --danger: #e2564f;
  --danger-bg: rgba(226, 86, 79, 0.12);
  --success: #4caf7d;
  --success-bg: rgba(76, 175, 125, 0.12);
  --warn: #e0a23a;
  --warn-bg: rgba(224, 162, 58, 0.12);
  --info: #8b97a8;
  --info-bg: rgba(139, 151, 168, 0.12);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);

  --sidebar-w: 250px;
  --transition: 160ms ease;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(216, 31, 38, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; }
.hidden { display: none !important; }
/* O atributo hidden precisa vencer declarações de display como grid/flex. */
[hidden] { display: none !important; }

:where(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------ botões ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: var(--accent-dim); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(180deg, #e8343b, #c0171e); border-color: var(--accent-soft); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }

.btn-danger { background: var(--danger-bg); border-color: rgba(226, 86, 79, 0.4); color: #ff9d97; }
.btn-danger:hover { background: rgba(226, 86, 79, 0.22); border-color: var(--danger); }

.btn-sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------ campos ------------------------------ */

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.field > span { font-weight: 550; letter-spacing: 0.01em; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--transition), background var(--transition);
}
input::placeholder, textarea::placeholder { color: #6d675a; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); background: var(--panel); }
textarea { resize: vertical; min-height: 74px; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-error { min-height: 18px; color: #ff9d97; font-size: 13px; }

.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }

/* ------------------------------ login ------------------------------ */

.login-view {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
}
.login-glow {
  position: absolute;
  inset: -30% 20% 40%;
  background: radial-gradient(circle at 50% 40%, var(--accent-glow), transparent 62%);
  pointer-events: none;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 390px;
  padding: 34px 30px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow-lg);
}
.login-form { display: grid; gap: 14px; margin-top: 26px; }
.login-form .btn { margin-top: 6px; }
.login-foot { margin-top: 20px; color: var(--muted); font-size: 12px; text-align: center; }
.login-verse { margin-top: 10px; color: #6f6a60; font-size: 11.5px; font-style: italic; line-height: 1.5; text-align: center; }

/* ------------------------------ marca ------------------------------ */

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  background: linear-gradient(150deg, rgba(216, 31, 38, 0.22), transparent);
  color: var(--accent-soft);
  font-size: 16px;
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.brand-lg .brand-mark { width: 46px; height: 46px; flex-basis: 46px; font-size: 21px; border-radius: 13px; }
.brand-lg h1 { font-size: 22px; }
.brand-lg p { color: var(--muted); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }

/* ------------------------------ layout ------------------------------ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 0 6px; }

.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.nav-item svg {
  width: 18px; height: 18px; flex: 0 0 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; opacity: 0.85;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.selected {
  background: linear-gradient(90deg, rgba(216, 31, 38, 0.16), rgba(216, 31, 38, 0.03));
  border-color: rgba(216, 31, 38, 0.28);
  color: var(--accent-soft);
  font-weight: 600;
}
.nav-item.selected svg { opacity: 1; }

.sidebar-foot { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.user-email { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.3;
}
.status-pill .dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--muted); }
.status-pill[data-state="connected"] { color: #8fd9b4; border-color: rgba(76, 175, 125, 0.35); }
.status-pill[data-state="connected"] .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.status-pill[data-state="reconnecting"] { color: #f0c477; border-color: rgba(224, 162, 58, 0.35); }
.status-pill[data-state="reconnecting"] .dot { background: var(--warn); animation: pulse 1.4s infinite; }
.status-pill[data-state="disconnected"] { color: #f0a49f; border-color: rgba(226, 86, 79, 0.3); }
.status-pill[data-state="disconnected"] .dot { background: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 13, 0.82);
  backdrop-filter: blur(10px);
}
.topbar-title h1 { font-size: 19px; }
.topbar-title p { color: var(--muted); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }
#menu-toggle { display: none; }

.view { padding: 24px 26px 22px; display: grid; gap: 18px; align-content: start; flex: 1; }

/* A visão geral ocupa a altura da tela para não sobrar espaço morto embaixo.
   Flex (e não grid) porque o aviso do topo é opcional: ele fica com a altura
   natural e só o painel abaixo estica. */
#view-root[data-view="overview"] { display: flex; flex-direction: column; }
#view-root[data-view="overview"] > .overview-grid { flex: 1; }

/* ------------------------------ cards ------------------------------ */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; }
.card-head p { color: var(--muted); font-size: 12.5px; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.section-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; }
.section-head p { color: var(--muted); font-size: 13px; }
.section-head .spacer { margin-left: auto; }

/* ------------------------------ placar de fila (tablet) ------------------------------ */

.queue-hero {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(230px, 360px) 1fr;
  align-items: stretch;
}
@media (max-width: 900px) {
  .queue-hero { grid-template-columns: 1fr; }
}

.ticket {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 26px 20px;
  --ticket-cor: var(--danger);
  border: 1px solid color-mix(in srgb, var(--ticket-cor) 45%, transparent);
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--ticket-cor) 20%, transparent),
    color-mix(in srgb, var(--ticket-cor) 4%, transparent)
  );
  text-align: center;
  transition: border-color 220ms ease, background 220ms ease;
}

/* status da fila muda a cor do quadro */
.ticket[data-status="called"] { --ticket-cor: var(--warn); animation: ticket-pulso 1.5s ease-out infinite; }
.ticket[data-status="in_service"] { --ticket-cor: var(--success); }
.ticket[data-status="idle"] { --ticket-cor: var(--line-strong); }

@keyframes ticket-pulso {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--ticket-cor) 16%, transparent); }
}
.ticket-label {
  color: var(--ticket-cor);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.ticket-number {
  color: var(--ticket-cor);
  font-size: clamp(86px, 12vw, 168px);
  line-height: 0.88;
  font-weight: 800;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
.ticket-hint { color: var(--muted); font-size: 14px; }

.hero-current { display: grid; gap: 8px; align-content: center; min-width: 0; }
.hero-current .who {
  font-size: clamp(26px, 3vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.hero-current .what { color: var(--muted); font-size: 15px; }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.hero-actions .btn { min-height: 58px; padding: 0 26px; font-size: 16px; border-radius: 12px; }

.next-list { display: grid; gap: 8px; }
.next-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
}
.next-row .n-ticket {
  min-width: 60px;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-soft);
  font-variant-numeric: tabular-nums;
}

/* Tablet em pé ou deitado: alvos maiores e tipografia mais generosa. */
@media (min-width: 1024px) {
  .hero-actions .btn { min-height: 64px; font-size: 17px; }
  .next-row { padding: 14px 18px; }
}

/* ------------------------------ estatísticas ------------------------------ */

.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.stat-card {
  display: grid;
  gap: 4px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(165deg, var(--panel-2), var(--panel));
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}
.stat-card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.stat-card .stat-label { color: var(--muted); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.stat-card .stat-value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card .stat-note { color: var(--muted); font-size: 12px; }
.stat-card.is-accent .stat-value { color: var(--accent-soft); }

/* Faixa compacta de indicadores do dia, abaixo do placar de fila. */
.stat-grid.compact { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-grid.compact .stat-card { flex: 0 1 210px; padding: 12px 16px; gap: 2px; }
.stat-grid.compact .stat-card .stat-value { font-size: 24px; }
.stat-grid.compact .stat-card .stat-label { font-size: 11px; }

/* ------------------------------ visão geral em duas colunas ------------------------------ */

.overview-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  align-items: stretch;
}
@media (max-width: 1180px) {
  .overview-grid { grid-template-columns: 1fr; }
}
.overview-col { display: grid; gap: 18px; align-content: start; min-width: 0; }

/* Coluna da fila: placar ocupa o espaço todo, indicadores caem no rodapé. */
.overview-col--queue { grid-template-rows: 1fr auto; }
@media (max-width: 1180px) {
  .overview-col--queue { grid-template-rows: auto; }
}

/* Coluna da agenda: o último cartão cresce para a coluna alcançar o rodapé. */
.overview-col--agenda { grid-template-rows: auto 1fr; }
@media (max-width: 1180px) {
  .overview-col--agenda { grid-template-rows: auto; }
}

.card-fill { display: flex; flex-direction: column; }
.card-fill > .card-body { flex: 1; }
.card-fill > .card-body > .empty { height: 100%; align-content: center; }

.hero-body { display: grid; grid-template-rows: 1fr auto; gap: 14px; }
.hero-body .queue-hero { align-items: stretch; }
.hero-body .ticket { align-content: center; }

/* Linha compacta de agendamento (coluna da agenda). */
.agenda-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.agenda-row:hover { background: var(--panel-2); border-color: var(--line-strong); }
.agenda-row .ar-time {
  min-width: 96px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-soft);
  font-variant-numeric: tabular-nums;
}
.agenda-row .ar-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.agenda-row .ar-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-row .ar-meta {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-row[data-status="cancelled"] { opacity: 0.55; }
.agenda-row[data-status="completed"] { border-color: rgba(76, 175, 125, 0.3); }
.agenda-row[data-legacy="true"] { border-color: rgba(224, 162, 58, 0.4); }

/* Fila vazia: o travessão não pode parecer uma barra dourada. */
.ticket-number.is-empty { font-size: 60px; color: var(--muted); opacity: 0.5; }

/* ------------------------------ tabelas ------------------------------ */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  background: var(--bg-soft);
}
.table td { padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.022); }
.table .cell-strong { font-weight: 600; }
.table .cell-muted { color: var(--muted); font-size: 13px; }
.table .cell-actions { display: flex; gap: 7px; justify-content: flex-end; }
.table .num { font-variant-numeric: tabular-nums; }
.table tr.is-inactive td { opacity: 0.55; }

/* ------------------------------ badges ------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge[data-tone="accent"] { color: var(--accent-soft); border-color: rgba(216, 31, 38, 0.38); background: rgba(216, 31, 38, 0.1); }
.badge[data-tone="success"] { color: #8fd9b4; border-color: rgba(76, 175, 125, 0.35); background: var(--success-bg); }
.badge[data-tone="warn"] { color: #f0c477; border-color: rgba(224, 162, 58, 0.35); background: var(--warn-bg); }
.badge[data-tone="danger"] { color: #f0a49f; border-color: rgba(226, 86, 79, 0.35); background: var(--danger-bg); }
.badge[data-tone="info"] { color: #c3cbd6; border-color: rgba(139, 151, 168, 0.35); background: var(--info-bg); }
.badge[data-tone="muted"] { color: var(--muted); }

/* ------------------------------ agenda ------------------------------ */

.agenda-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-soft); }
.segmented button {
  padding: 7px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--panel-3); color: var(--accent-soft); box-shadow: var(--shadow-sm); }

.date-nav { display: inline-flex; align-items: center; gap: 6px; }
.date-nav input[type="date"] { width: auto; padding: 7px 10px; font-size: 13px; }
.date-nav .icon-btn { width: 34px; height: 34px; }
.date-nav .icon-btn svg { width: 16px; height: 16px; }

.agenda-scroll { overflow-x: auto; }
.agenda-week { display: grid; grid-template-columns: repeat(7, minmax(132px, 1fr)); gap: 10px; min-width: 950px; }
.agenda-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.agenda-col.is-today { border-color: var(--accent-dim); background: linear-gradient(180deg, rgba(216, 31, 38, 0.07), var(--bg-soft)); }
.agenda-col-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.agenda-col-head .dow { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.agenda-col-head .dom { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.agenda-col-body { display: grid; gap: 6px; }

.agenda-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.agenda-month .dow-head { padding: 4px 8px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; }
.agenda-cell {
  min-height: 92px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
}
.agenda-cell:hover { border-color: var(--line-strong); background: var(--panel); }
.agenda-cell.is-outside { opacity: 0.35; }
.agenda-cell.is-today { border-color: var(--accent-dim); }
.agenda-cell .day-num { font-size: 12px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.agenda-cell .mini-event {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(216, 31, 38, 0.14);
  color: var(--accent-soft);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agenda-cell .more { color: var(--muted); font-size: 10.5px; }

.event {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent-dim);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
}
.event:hover { background: var(--panel-3); transform: translateX(2px); }
.event .ev-time { font-size: 12px; font-weight: 700; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.event .ev-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event .ev-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event[data-status="cancelled"] { opacity: 0.5; border-left-color: var(--danger); }
.event[data-status="completed"] { border-left-color: var(--success); }
.event[data-status="no_show"] { border-left-color: var(--warn); }
.event[data-legacy="true"] { border-left-color: var(--warn); box-shadow: inset 0 0 0 1px rgba(224, 162, 58, 0.25); }

.day-list { display: grid; gap: 9px; }

/* ------------------------------ horários ------------------------------ */

.slot-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.slot {
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.slot:hover { border-color: var(--accent-dim); color: var(--text); background: var(--panel-2); }
.slot[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  border-color: var(--accent);
  color: #ffffff;
}

/* ------------------------------ fila / espera ------------------------------ */

.queue-list { display: grid; gap: 10px; }
.queue-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.queue-row .q-pos {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  background: rgba(216, 31, 38, 0.12);
  border: 1px solid rgba(216, 31, 38, 0.3);
  color: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.queue-row .q-main { flex: 1; min-width: 0; }
.queue-row .q-title { font-weight: 600; }
.queue-row .q-meta { color: var(--muted); font-size: 12.5px; }
.queue-row .q-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ------------------------------ vazio / aviso ------------------------------ */

.empty {
  display: grid;
  gap: 10px;
  place-items: center;
  padding: 44px 22px;
  color: var(--muted);
  text-align: center;
}
.empty .empty-mark { font-size: 26px; opacity: 0.5; }
.empty h3 { color: var(--text-2); font-size: 15px; }
.empty p { font-size: 13px; max-width: 42ch; }

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border: 1px solid rgba(224, 162, 58, 0.35);
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: #f0c477;
  font-size: 12.5px;
  line-height: 1.35;
}
.banner .banner-actions { margin-left: auto; display: flex; gap: 8px; }
.banner[data-tone="danger"] { border-color: rgba(226, 86, 79, 0.35); background: var(--danger-bg); color: #f0a49f; }

.loading { display: flex; align-items: center; gap: 10px; padding: 34px; color: var(--muted); font-size: 14px; justify-content: center; }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

/* ------------------------------ modal ------------------------------ */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 6, 6, 0.66);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow-lg);
  animation: modal-in 170ms ease-out;
}
.modal.modal-wide { max-width: 720px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-head p { color: var(--muted); font-size: 12.5px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 20px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.16); }

/* ------------------------------ toasts ------------------------------ */

.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 9px; justify-items: end; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-3);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 13.5px;
  animation: toast-in 180ms ease-out;
}
.toast[data-tone="error"] { border-color: rgba(226, 86, 79, 0.45); color: #ffb3ae; }
.toast[data-tone="success"] { border-color: rgba(76, 175, 125, 0.45); color: #a6e6c4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 180ms, transform 180ms; }

/* ------------------------------ diversos ------------------------------ */

.inline-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  font-size: 13px;
}
.chip button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(226, 86, 79, 0.14);
  color: #f0a49f;
  font-size: 12px;
  cursor: pointer;
}
.chip button:hover { background: rgba(226, 86, 79, 0.3); }

.weekday-grid { display: grid; gap: 9px; }
.weekday-row {
  display: grid;
  grid-template-columns: 104px 118px 118px 18px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.weekday-row .wd-name { font-size: 13px; font-weight: 600; color: var(--text-2); }
.weekday-row input[type="time"] { padding: 7px 9px; font-size: 13px; }
.weekday-row.is-off { opacity: 0.55; }
.weekday-row .wd-off { font-size: 12.5px; color: var(--muted); grid-column: 2 / span 2; }

.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }

.qr-box { display: grid; gap: 10px; justify-items: center; text-align: center; }
.qr-image { border-radius: 14px; background: #fff; padding: 12px; box-shadow: var(--shadow-md); }

.mono { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--muted); }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ responsivo ------------------------------ */

.drawer-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
    background: var(--bg-soft);
  }
  .sidebar.is-open { transform: none; }
  #menu-toggle { display: inline-flex; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .topbar-title { min-width: 0; }
  .topbar-actions .btn { padding: 8px 12px; font-size: 13px; }
  .view { padding: 16px 16px 20px; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .card-head .card-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .agenda-toolbar { width: 100%; }
  .weekday-row { grid-template-columns: 1fr 1fr 18px; }
  .weekday-row .wd-name { grid-column: 1 / -1; }
  .weekday-row > .text-muted { display: none; }
}

@media (max-width: 560px) {
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value { font-size: 25px; }
  .queue-row { flex-wrap: wrap; }
  .modal { max-width: 100%; border-radius: 14px; }
  .agenda-month .dow-head { font-size: 10px; }
  .agenda-cell { min-height: 74px; padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------ area de IA ------------------------------ */

.ai-chat { display: grid; gap: 10px; max-height: 400px; overflow-y: auto; padding: 4px; }
.ai-msg {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 82%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-msg[data-role="user"] { justify-self: end; background: rgba(216, 31, 38, 0.13); border: 1px solid rgba(216, 31, 38, 0.3); }
.ai-msg[data-role="assistant"] { justify-self: start; background: var(--panel-2); border: 1px solid var(--line); }
.ai-input-row { display: flex; gap: 10px; }
.ai-input-row input { flex: 1; }
.ai-pending {
  border: 1px solid rgba(224, 162, 58, 0.4);
  background: var(--warn-bg);
  color: #f0c477;
  padding: 12px 14px;
  border-radius: 10px;
  display: grid;
  gap: 10px;
  font-size: 13.5px;
}
.shop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.shop-toggle[data-open="true"] { border-color: rgba(76, 175, 125, 0.45); color: #7fd6a6; background: rgba(76, 175, 125, 0.12); }
.shop-toggle[data-open="false"] { border-color: rgba(216, 31, 38, 0.35); color: #ff8a8a; background: rgba(216, 31, 38, 0.1); }
.shop-toggle:disabled { opacity: 0.6; cursor: progress; }
.shop-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ------------------------------ tema claro ------------------------------ */

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f4ef;
  --bg-soft: #efece6;
  --panel: #ffffff;
  --panel-2: #f8f6f1;
  --panel-3: #efece5;
  --line: #e2ded5;
  --line-strong: #cfc9bd;

  --accent: #c0171e;
  --accent-soft: #a51219;
  --accent-dim: #8e1a1f;
  --accent-glow: rgba(192, 23, 30, 0.1);

  --text: #1b1a17;
  --text-2: #3a3730;
  --muted: #6f6a5f;

  --danger: #b3261e;
  --danger-bg: rgba(179, 38, 30, 0.09);
  --success: #1d7a52;
  --success-bg: rgba(29, 122, 82, 0.1);
  --warn: #8f6206;
  --warn-bg: rgba(143, 98, 6, 0.12);
  --info: #4a5a70;
  --info-bg: rgba(74, 90, 112, 0.1);

  --shadow-sm: 0 1px 2px rgba(27, 26, 23, 0.08);
  --shadow-md: 0 8px 24px rgba(27, 26, 23, 0.1);
  --shadow-lg: 0 24px 64px rgba(27, 26, 23, 0.16);
}

/* textos claros demais para fundo branco */
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: #a49c8d; }
html[data-theme="light"] .login-verse { color: #8a8375; }
html[data-theme="light"] .form-error { color: #b3261e; }

html[data-theme="light"] .status-pill[data-state="connected"] { color: #1d7a52; border-color: rgba(29, 122, 82, 0.3); }
html[data-theme="light"] .status-pill[data-state="reconnecting"] { color: #8f6206; border-color: rgba(143, 98, 6, 0.3); }
html[data-theme="light"] .status-pill[data-state="disconnected"] { color: #b3261e; border-color: rgba(179, 38, 30, 0.3); }

html[data-theme="light"] .badge[data-tone="accent"] { color: #a51219; }
html[data-theme="light"] .badge[data-tone="success"] { color: #1d7a52; }
html[data-theme="light"] .badge[data-tone="warn"] { color: #8f6206; }
html[data-theme="light"] .badge[data-tone="danger"] { color: #b3261e; }

html[data-theme="light"] .table tbody tr:hover { background: rgba(27, 26, 23, 0.035); }
html[data-theme="light"] .toast[data-tone="error"] { color: #8f1d17; }
html[data-theme="light"] .toast[data-tone="success"] { color: #15603f; }
html[data-theme="light"] .btn-danger { color: #b3261e; }
html[data-theme="light"] .shop-toggle[data-open="true"] { color: #1d7a52; }
html[data-theme="light"] .shop-toggle[data-open="false"] { color: #b3261e; }
html[data-theme="light"] .ai-pending { color: #7a5200; }
html[data-theme="light"] .ai-msg[data-role="assistant"] { background: #f4f1ea; border-color: #e2ded5; }
html[data-theme="light"] .ai-chat { scrollbar-color: #cfc9bd transparent; }

/* topo e avisos no tema claro */
html[data-theme="light"] .topbar { background: rgba(246, 244, 239, 0.92); }
html[data-theme="light"] .banner { color: #8f6206; border-color: rgba(143, 98, 6, 0.32); }
html[data-theme="light"] .banner[data-tone="danger"] { color: #b3261e; }
html[data-theme="light"] .badge[data-tone="info"] { color: #4a5a70; }
html[data-theme="light"] .agenda-row[data-legacy="true"] { border-color: rgba(143, 98, 6, 0.35); }

/* --------------------------- formas de pagamento --------------------------- */

.pagamentos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pagamento {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 13px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}
.pagamento:hover { filter: brightness(1.08); }
.pagamento:active { transform: translateY(1px); }
.pagamento[data-metodo="cash"] { background: #1f7a52; }
.pagamento[data-metodo="pix"] { background: #0f766e; }
.pagamento[data-metodo="debit"] { background: #1d4ed8; }
.pagamento[data-metodo="credit"] { background: #6d28d9; }
.pagamento[aria-pressed="true"] { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35) inset; filter: brightness(1.15); }

.resumo-pagamento {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
}
.resumo-pagamento strong { font-size: 20px; color: var(--text); }

.troco { margin: 0; font-size: 14px; font-weight: 700; color: var(--success); }
.troco[data-falta="true"] { color: var(--danger); }
