/* ════════════════════════════════════════════════════════════════════════════
   BARBEARIA NA RÉGUA — sistema de design (site do cliente + painel + caixa)

   Cor: preto de verdade (o da logo), marfim nos detalhes, latão nos destaques.
   Tipo: Bodoni Moda (títulos e preços — a mesma família didone do N e do R da
   logo) + Instrument Sans (interface).
   Raios por hierarquia: controle 10 · cartão 16 · folha/modal 22 · pílula 999.
   Profundidade por degraus de superfície e linhas finas; sombra só no que flutua.
   Documentação completa: docs/design/design-system.md
   ════════════════════════════════════════════════════════════════════════════ */

@font-face { font-family: 'Bodoni'; src: url(/fonts/bodoni.woff2?v=c032219ef6) format('woff2-variations'); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bodoni'; src: url(/fonts/bodoni-italic.woff2?v=b737328c13) format('woff2-variations'); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Instrument'; src: url(/fonts/instrument.woff2?v=8b74e9bc6e) format('woff2-variations'); font-weight: 400 700; font-stretch: 75% 100%; font-style: normal; font-display: swap; }

/* ── Tokens: escuro (padrão) ─────────────────────────────────────────────── */
:root {
    color-scheme: dark;
    --black: #000000;
    --bg: #000000;
    --bg-raised: #0C0C0C;
    --surface: #141414;
    --surface-2: #1C1C1C;
    --surface-3: #262626;
    --line: #2A2A2A;
    --line-strong: #3A3A3A;
    --text: #F4F1EA;
    --text-2: #C9C4B9;
    --muted: #96918A;
    --ivory: #F4F1EA;

    --brass: #C4A26A;          /* latão: destaque, botão principal */
    --brass-hi: #DCC08C;
    --brass-text: #CFAE74;     /* latão para texto sobre fundo escuro */
    --brass-ink: #15110A;      /* texto em cima do latão */
    --brass-soft: rgba(196, 162, 106, 0.13);
    --brass-line: rgba(196, 162, 106, 0.42);

    --ok: #74C69D;       --ok-soft: rgba(116, 198, 157, 0.14);
    --warn: #E9B45A;     --warn-soft: rgba(233, 180, 90, 0.15);
    --danger: #EE8270;   --danger-soft: rgba(238, 130, 112, 0.15);
    --info: #8FB4F0;     --info-soft: rgba(143, 180, 240, 0.14);
    --plum: #C59BD9;     --plum-soft: rgba(197, 155, 217, 0.15);

    --shadow-float: 0 18px 50px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.66);

    --f-display: 'Bodoni', 'Didot', 'Bodoni 72', Georgia, serif;
    --f-ui: 'Instrument', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

    --r-control: 10px;
    --r-card: 16px;
    --r-sheet: 22px;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 56px; --s10: 72px;

    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

/* ── Tokens: claro ───────────────────────────────────────────────────────── */
:root[data-theme="claro"] {
    color-scheme: light;
    --bg: #F6F3EC;
    --bg-raised: #FBF9F4;
    --surface: #FFFFFF;
    --surface-2: #F1EDE4;
    --surface-3: #E7E2D6;
    --line: #E3DDD1;
    --line-strong: #CFC7B8;
    --text: #111111;
    --text-2: #3B3833;
    --muted: #67625A;
    --brass: #B08D57;
    --brass-hi: #C4A26A;
    --brass-text: #7C5E2A;
    --brass-ink: #FFFFFF;
    --brass-soft: rgba(176, 141, 87, 0.14);
    --brass-line: rgba(176, 141, 87, 0.5);
    --ok: #2F7D55;       --ok-soft: rgba(47, 125, 85, 0.11);
    --warn: #93600F;     --warn-soft: rgba(201, 136, 26, 0.14);
    --danger: #B23A2A;   --danger-soft: rgba(178, 58, 42, 0.1);
    --info: #2C5AA0;     --info-soft: rgba(44, 90, 160, 0.1);
    --plum: #7C4A96;     --plum-soft: rgba(124, 74, 150, 0.1);
    --shadow-float: 0 18px 50px rgba(30, 24, 12, 0.16), 0 2px 8px rgba(30, 24, 12, 0.08);
    --overlay: rgba(20, 16, 10, 0.42);
}
@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] {
        color-scheme: light;
        --bg: #F6F3EC; --bg-raised: #FBF9F4; --surface: #FFFFFF; --surface-2: #F1EDE4; --surface-3: #E7E2D6;
        --line: #E3DDD1; --line-strong: #CFC7B8; --text: #111111; --text-2: #3B3833; --muted: #67625A;
        --brass: #B08D57; --brass-hi: #C4A26A; --brass-text: #7C5E2A; --brass-ink: #FFFFFF;
        --brass-soft: rgba(176, 141, 87, 0.14); --brass-line: rgba(176, 141, 87, 0.5);
        --ok: #2F7D55; --ok-soft: rgba(47, 125, 85, 0.11); --warn: #93600F; --warn-soft: rgba(201, 136, 26, 0.14);
        --danger: #B23A2A; --danger-soft: rgba(178, 58, 42, 0.1); --info: #2C5AA0; --info-soft: rgba(44, 90, 160, 0.1);
        --plum: #7C4A96; --plum-soft: rgba(124, 74, 150, 0.1);
        --shadow-float: 0 18px 50px rgba(30, 24, 12, 0.16), 0 2px 8px rgba(30, 24, 12, 0.08); --overlay: rgba(20, 16, 10, 0.42);
    }
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--f-ui);
    font-size: 15px;
    line-height: 1.5;
    font-variant-numeric: lining-nums;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration-color: var(--brass-line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--brass); }
::selection { background: var(--brass); color: var(--brass-ink); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

h1, h2, h3, .display { font-family: var(--f-display); font-weight: 600; letter-spacing: -0.005em; line-height: 1.08; margin: 0; font-optical-sizing: auto; }
h1 { font-size: clamp(32px, 6vw, 48px); }
h2 { font-size: clamp(24px, 4vw, 30px); }
h3 { font-size: 20px; }
p { margin: 0; }
.muted { color: var(--muted); }
.soft { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.money { font-family: var(--f-display); font-weight: 600; font-variant-numeric: lining-nums; letter-spacing: 0; }
.brass { color: var(--brass-text); }
.nowrap { white-space: nowrap; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ícones (sprite /img/icons.svg, desenho Lucide) */
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 24px; height: 24px; }

/* divisor com losango — a simetria da logo */
.rule { display: flex; align-items: center; gap: 10px; color: var(--line-strong); }
.rule::before, .rule::after { content: ''; flex: 1; height: 1px; background: currentColor; }
.rule > i { width: 6px; height: 6px; transform: rotate(45deg); background: var(--brass); flex: none; }

/* ── Botões ──────────────────────────────────────────────────────────────── */
.btn {
    --b-bg: var(--surface-2); --b-fg: var(--text); --b-line: var(--line);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: var(--r-control);
    border: 1px solid var(--b-line); background: var(--b-bg); color: var(--b-fg);
    font-weight: 600; font-size: 15px; letter-spacing: 0.005em; text-decoration: none;
    cursor: pointer; user-select: none; white-space: nowrap;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { --b-bg: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn.is-busy { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.is-busy::after { content: ''; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
.btn-primary { --b-bg: var(--brass); --b-fg: var(--brass-ink); --b-line: var(--brass); }
.btn-primary:hover { --b-bg: var(--brass-hi); --b-line: var(--brass-hi); }
.btn-ivory { --b-bg: var(--text); --b-fg: var(--bg); --b-line: var(--text); }
.btn-ivory:hover { --b-bg: var(--text-2); }
.btn-ghost { --b-bg: transparent; --b-line: transparent; }
.btn-ghost:hover { --b-bg: var(--surface-2); }
.btn-line { --b-bg: transparent; --b-line: var(--line-strong); }
.btn-line:hover { --b-bg: var(--surface); --b-line: var(--brass-line); }
.btn-danger { --b-bg: transparent; --b-fg: var(--danger); --b-line: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover { --b-bg: var(--danger-soft); }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-block { width: 100%; }

/* ── Formulários ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
    width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--r-control);
    border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--text);
    font-size: 15px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { padding: 12px 14px; min-height: 92px; resize: vertical; line-height: 1.45; }
.select { appearance: none; padding-right: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-money { font-family: var(--f-display); font-size: 22px; font-weight: 600; text-align: right; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; color: var(--text-2); }
.check input { width: 20px; height: 20px; accent-color: var(--brass); margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 560px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; flex: none; transition: background-color 0.18s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text-2); transition: transform 0.18s var(--ease), background-color 0.18s; }
.switch input:checked + .track { background: var(--brass); border-color: var(--brass); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--brass-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--brass); outline-offset: 2px; }

/* controle segmentado */
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 0 14px; min-height: 36px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ── Chips e selos ───────────────────────────────────────────────────────── */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text-2); cursor: pointer; font-weight: 500; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.tag.brass { background: var(--brass-soft); color: var(--brass-text); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.plum { background: var(--plum-soft); color: var(--plum); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }

/* ── Superfícies ─────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s5); }
.card-flat { background: transparent; border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s5); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: var(--s4); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 21px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.grow { flex: 1; min-width: 0; }

/* lista em linhas (troca as tabelas no celular) */
.list { display: flex; flex-direction: column; }
.list > .li { display: flex; align-items: center; gap: 12px; padding: 13px 2px; border-top: 1px solid var(--line); min-height: 56px; }
.list > .li:first-child { border-top: 0; }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.li-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.li, a.li { background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; color: inherit; text-decoration: none; cursor: pointer; }
button.li:hover, a.li:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* tabela */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.r, .t th.r { text-align: right; }
.t tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* avatar com inicial (serifada, como o monograma) */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-3); color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-family: var(--f-display); font-weight: 600; font-size: 17px; flex: none; overflow: hidden; border: 1px solid var(--line-strong); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.lg { width: 56px; height: 56px; font-size: 24px; }

/* indicador (número grande) */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-family: var(--f-display); font-size: 34px; font-weight: 600; line-height: 1; }
.kpi .k-sub { font-size: 13px; color: var(--text-2); }

/* ── Modal e folha ───────────────────────────────────────────────────────── */
dialog.sheet { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--r-sheet); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 900px); box-shadow: var(--shadow-float); overflow: hidden; }
dialog.sheet.wide { width: min(860px, calc(100vw - 24px)); }
dialog.sheet::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.22s var(--ease); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 23px; flex: 1; }
.sheet-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line); flex-wrap: wrap; }
@media (max-width: 640px) {
    dialog.sheet, dialog.sheet.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 92vh; border-bottom: 0; }
    dialog.sheet[open] { animation: sheet-up 0.26s var(--ease); }
    .sheet-foot .btn { flex: 1; }
}

/* ── Aviso flutuante ─────────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toasts[popover] { inset: auto auto calc(24px + var(--safe-b)) 50%; margin: 0; border: 0; padding: 0; background: transparent; overflow: visible; color: inherit; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-float); font-weight: 500; animation: toast-in 0.22s var(--ease); }
.toast.error { background: var(--danger); color: #fff; }
.toast .i { margin-top: 1px; }

/* ── Estados ─────────────────────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 36px 16px; color: var(--muted); }
.empty .mark { width: 34px; height: 54px; opacity: 0.35; background: url(/img/logo-claro.png) center/contain no-repeat; }
:root[data-theme="claro"] .empty .mark { background-image: url(/img/logo-escuro.png); }
.empty strong { color: var(--text); font-family: var(--f-display); font-size: 19px; font-weight: 600; }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: skel 1.3s ease-in-out infinite; border-radius: 8px; min-height: 14px; }
.error-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--danger-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.note-box { display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: 12px; background: var(--brass-soft); border: 1px solid var(--brass-line); color: var(--text); }
.note-box .i, .error-box .i { margin-top: 1px; flex: none; }
.note-box .i { color: var(--brass-text); }
.error-box .i { color: var(--danger); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes skel { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.4; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

@media print {
    body { background: #fff; color: #000; }
    .no-print { display: none !important; }
}
