/* =========================================================
   SalãoSmart — base e componentes compartilhados
   ========================================================= */
:root {
  color-scheme: light;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Bodoni Moda', 'Didot', 'Bodoni 72', Georgia, 'Times New Roman', serif;

  --bg: #f3f2f5;
  --surface: #ffffff;
  --surface-2: #f8f7fa;
  --line: #e6e3ea;
  --line-strong: #d6d1dc;
  --ink: #1f1a24;
  --ink-2: #3b3441;
  --muted: #6b6474;
  --faint: #9d97a6;

  --brand: #9c4668;
  --brand-ink: #7e3452;
  --brand-soft: #f6e8ee;
  --side: #2b1d2f;
  --side-2: #3a2a3f;
  --side-ink: #d9cfdc;

  --blue: #3563b8;   --blue-soft: #e8eefa;
  --green: #1f7a5c;  --green-soft: #e3f3ec;
  --amber: #9a6a07;  --amber-soft: #fbf0d9;
  --red: #b43c3c;    --red-soft: #fbe7e7;
  --gray: #6b6474;   --gray-soft: #efedf1;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --shadow-1: 0 1px 2px rgba(31, 26, 36, .06);
  --shadow-2: 0 8px 24px -12px rgba(43, 29, 47, .22);
  --shadow-3: 0 24px 60px -20px rgba(43, 29, 47, .35);
  --focus: 0 0 0 3px rgba(156, 70, 104, .28);

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strike { text-decoration: line-through; color: var(--faint); font-weight: 500; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.stack { display: grid; gap: .8rem; }
.ic { flex-shrink: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 42px; padding: 0 1.05rem; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .94rem; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  background: var(--surface); color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-dark { background: var(--side); color: #fff; }
.btn-dark:hover { background: #1c1220; }
.btn-outline { border-color: var(--line-strong); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #962f2f; }
.btn-success { background: var(--green); color: #fff; }
.btn-whats { background: #1f8f4e; color: #fff; }
.btn-whats:hover { background: #17713d; }
.btn-sm { min-height: 34px; padding: 0 .75rem; font-size: .86rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 0 1.5rem; font-size: 1.02rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-outline.is-busy::after, .btn-ghost.is-busy::after { border-color: var(--line); border-top-color: var(--brand); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--gray-soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Cartões e layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.narrow { max-width: 460px; margin: 0 auto; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.loading { display: grid; place-items: center; padding: 3rem; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid.one { grid-template-columns: 1fr; }
.form-section { grid-column: 1 / -1; margin: .6rem 0 0; padding-top: .6rem; border-top: 1px solid var(--line); font-size: .95rem; color: var(--ink-2); }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.col-full { grid-column: 1 / -1; }
.field > label { font-size: .86rem; font-weight: 600; color: var(--ink-2); }
.req { color: var(--brand); margin-left: 2px; }
.hint { color: var(--muted); font-size: .8rem; }
.error-msg { color: var(--red); font-size: .8rem; min-height: 0; }
.error-msg:empty { display: none; }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=url], select, textarea {
  width: 100%; min-height: 42px; padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; font-size: 16px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--focus); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6474' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
.input-prefix, .input-suffix { position: relative; display: flex; align-items: center; }
.input-prefix span { position: absolute; left: .75rem; color: var(--muted); font-size: .9rem; pointer-events: none; }
.input-prefix input { padding-left: 2.3rem; }
.input-suffix .icon-btn { position: absolute; right: 4px; }
.input-suffix input { padding-right: 2.8rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .4rem; }
.check { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-size: .9rem; background: var(--surface); }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.weekday-picker { display: flex; gap: .35rem; flex-wrap: wrap; }
.wd input { position: absolute; opacity: 0; pointer-events: none; }
.wd span { display: grid; place-items: center; min-width: 46px; height: 38px; border-radius: 9px; border: 1px solid var(--line-strong); font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.wd input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.wd input:focus-visible + span { box-shadow: var(--focus); }
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-ui { box-shadow: var(--focus); }
.switch-text { font-size: .92rem; }
.field-switch { justify-content: flex-end; }
.img-field { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.img-preview { width: 84px; height: 84px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.img-field.wide .img-preview { width: 220px; height: 96px; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.color-input { display: flex; align-items: center; gap: .6rem; }
.color-input input { width: 48px; height: 42px; padding: 3px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff; cursor: pointer; }
.color-input code { font-size: .85rem; color: var(--muted); }

/* ---------- Badges, avatar, estrelas ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--gray-soft); color: var(--gray); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.avatar { --av: var(--brand); display: inline-grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--av) 16%, white); color: var(--av); font-weight: 700; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.stars { display: inline-flex; gap: 1px; color: var(--line-strong); vertical-align: middle; }
.stars .on { color: #d59a21; }
.stars .on svg { fill: currentColor; }

/* ---------- Segmented / tabs ---------- */
.segmented { display: inline-flex; background: var(--gray-soft); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: .42rem .85rem; border-radius: 8px; font-weight: 600; font-size: .86rem; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Tabelas ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .78rem; font-weight: 700; color: var(--muted); padding: .75rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .t-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .t-num { text-align: right; white-space: nowrap; }
.cell-main { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.cell-main strong { display: block; font-weight: 600; }
.cell-main small { color: var(--muted); display: block; }
.thumb { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--faint); flex-shrink: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-muted td { opacity: .6; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.search { position: relative; flex: 1 1 240px; display: flex; align-items: center; }
.search svg { position: absolute; left: .75rem; color: var(--faint); }
.search input { padding-left: 2.4rem; }
.select-sm, input.select-sm[type], select.select-sm { width: auto; min-width: 150px; }

/* ---------- Estados vazios ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto .8rem; background: var(--brand-soft); color: var(--brand); }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 1rem; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(31, 22, 34, .5); display: grid; place-items: center; padding: 1rem; opacity: 0; transition: opacity .18s; }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); width: 100%; max-height: calc(100vh - 2rem); display: flex; flex-direction: column; transform: translateY(12px) scale(.98); transition: transform .18s; }
.modal-backdrop.show .modal { transform: none; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 620px; } .modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem .6rem; }
.modal-head h3 { margin: 0; font-size: 1.12rem; }
.modal-body { padding: .4rem 1.25rem 1.2rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.confirm-text { font-size: 1rem; color: var(--ink-2); }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 90; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .6rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 12px; background: var(--side); color: #fff; box-shadow: var(--shadow-3); font-weight: 500; font-size: .92rem; transform: translateY(10px); opacity: 0; transition: all .22s; }
.toast.show { transform: none; opacity: 1; }
.toast-success svg { color: #7ee0b5; }
.toast-error { background: #7a2020; }
.toast-info svg { color: #b7c8ff; }

/* ---------- KPIs ---------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.kpi-label { font-size: .84rem; color: var(--muted); font-weight: 600; }
.kpi-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--gray-soft); color: var(--ink-2); }
.kpi-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.kpi-hint { font-size: .8rem; color: var(--muted); }
.kpi.accent { background: var(--side); border-color: var(--side); color: #fff; }
.kpi.accent .kpi-label, .kpi.accent .kpi-hint { color: var(--side-ink); }
.kpi.accent .kpi-icon { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- Gráficos ---------- */
.chart-bars { display: flex; align-items: stretch; gap: .5rem; height: 210px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; min-width: 0; }
.bar-track { flex: 1; width: 100%; max-width: 44px; display: flex; align-items: flex-end; }
.bar { width: 100%; background: color-mix(in srgb, var(--brand) 55%, white); border-radius: 7px 7px 3px 3px; min-height: 3px; transition: height .4s; }
.bar-col.is-last .bar, .bar-col:hover .bar { background: var(--brand); }
.bar-val { font-size: .74rem; color: var(--muted); font-weight: 600; min-height: 1em; white-space: nowrap; }
.bar-label { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chart-line { position: relative; height: 210px; padding-bottom: 22px; }
.chart-line svg { width: 100%; height: calc(100% - 4px); display: block; }
.line-points { position: absolute; inset: 0 0 22px 0; pointer-events: none; }
.line-points span { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); pointer-events: auto; }
.line-labels { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); }
.line-max { position: absolute; top: -4px; left: 0; font-size: .72rem; color: var(--faint); }
.chart-hbars { display: grid; gap: .8rem; }
.hbar-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; margin-bottom: .3rem; }
.hbar-track { height: 8px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.hbar-track div { height: 100%; background: var(--brand); border-radius: 99px; }
.chart-donut { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; position: relative; }
.donut span { width: 92px; height: 92px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; align-content: center; font-weight: 800; font-size: 1.4rem; line-height: 1; }
.donut small { font-size: .72rem; font-weight: 600; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; font-size: .88rem; flex: 1; min-width: 160px; }
.legend li { display: flex; align-items: center; gap: .5rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend strong { margin-left: auto; }

/* ---------- Aviso de plano ---------- */
.gate { text-align: center; padding: 3rem 1.5rem; max-width: 560px; margin: 2rem auto; }
.gate-icon { width: 60px; height: 60px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 1rem; }
.gate p { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
[hidden] { display: none !important; }
