/* =====================================================================
   PAINEL DE REVENDA — estilos
   Papel de livro-caixa: fundo verde-acinzentado, tinta escura, verde de
   razão contábil como destaque. O único elemento ousado é o "ticket" da
   key gerada; todo o resto é quieto e alinhado.
   ===================================================================== */

@font-face {
  font-family: 'Bricolage';
  src: url('fonts/bricolage-grotesque.woff2') format('woff2-variations'),
       url('fonts/bricolage-grotesque.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Martian';
  src: url('fonts/martian-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Martian';
  src: url('fonts/martian-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #EEF1EE;
  --surface: #FFFFFF;
  --surface-2: #F5F7F5;
  --ink: #18201C;
  --muted: #5B6660;
  --line: #D5DBD6;
  --line-strong: #B5BFB8;
  --accent: #1F5C45;
  --accent-ink: #FFFFFF;
  --accent-wash: #E1ECE5;
  --amber: #9A5712;
  --amber-wash: #F5EADB;
  --danger: #B23A2E;
  --danger-strong: #B23A2E;
  --danger-wash: #F7E3E0;
  --whats: #0E7A6E;
  --series-1: #178A5A;
  --chart-grid: #E3E8E4;
  --chart-axis: #C3CBC5;
  --focus: #1F5C45;
  --backdrop: rgba(14, 22, 18, .55);
  --shadow-pop: 0 14px 34px rgba(16, 28, 22, .16);
  --radius: 12px;
  --radius-lg: 18px;
  --font: 'Bricolage', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Martian', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #101714;
    --surface: #17201C;
    --surface-2: #1C2722;
    --ink: #E6ECE8;
    --muted: #9AA7A0;
    --line: #2A3530;
    --line-strong: #3C4A43;
    --accent: #6FCF9F;
    --accent-ink: #0B1A12;
    --accent-wash: #1D3328;
    --amber: #E3A04F;
    --amber-wash: #33281A;
    --danger: #F07A6C;
    --danger-strong: #B23A2E;
    --danger-wash: #3B2321;
    --whats: #0E7A6E;
    --series-1: #38A673;
    --chart-grid: #222E28;
    --chart-axis: #34433B;
    --focus: #6FCF9F;
    --backdrop: rgba(0, 0, 0, .62);
    --shadow-pop: 0 14px 34px rgba(0, 0, 0, .45);
  }
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { line-height: 1.15; font-weight: 650; margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.015em; }
h2 { font-size: 19px; letter-spacing: -0.005em; }
h3 { font-size: 17px; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
strong { font-weight: 650; }
code, .mono { font-family: var(--mono); font-weight: 500; }

/* itens de grade não podem esticar a página no celular */
.col-side > *, .col-main > *, .view > *, .stack > *, .section > *, .tabpanel > * { min-width: 0; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- topo */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
@supports (backdrop-filter: blur(8px)) {
  .topbar { background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(10px); }
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 28px; height: 28px; flex: none; color: var(--accent); }
.brand-mark .mark-bg { fill: currentColor; }
.brand-mark .mark-cut { fill: var(--paper); }

.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-name { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

/* menu de conta */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  display: grid; min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop);
}
.menu-pop .btn { justify-content: flex-start; }

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

.btn {
  font: inherit; font-weight: 650; font-size: 16px; line-height: 1.1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid transparent;
  background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, filter .15s;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-line { border-color: var(--line-strong); background: var(--surface); }
.btn-line:hover { background: var(--surface-2); }
.btn-ghost { color: var(--accent); padding: 0 10px; }
.btn-ghost:hover { background: var(--accent-wash); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--surface); }
.btn-danger:hover { background: var(--danger-wash); }
.btn-danger-solid { background: var(--danger-strong); color: #fff; }
.btn-whats { background: var(--whats); color: #fff; }
.btn-whats:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14.5px; border-radius: 10px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.btn.is-busy { cursor: progress; }
.btn.is-busy::before {
  content: ''; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  font: inherit; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------------------------------------------------------------- formulários */

.field { display: grid; gap: 6px; margin-top: 16px; }
.field:first-child { margin-top: 0; }
.field > label, .field > .label { font-weight: 600; font-size: 15px; }
.opt { font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.field-error { color: var(--danger); font-size: 14px; font-weight: 550; }

.input, .select, .textarea {
  font: inherit; color: var(--ink);
  width: 100%; min-height: 48px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.textarea { padding: 12px 14px; min-height: 128px; resize: vertical; line-height: 1.45; }
.select { padding-right: 8px; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-mono { font-family: var(--mono); font-weight: 500; letter-spacing: .02em; }
.input-code { font-family: var(--mono); font-size: 24px; letter-spacing: .32em; text-align: center; padding-left: calc(14px + .32em); }

.with-action { display: flex; gap: 8px; }
.with-action .input { flex: 1; min-width: 0; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.check.is-disabled { color: var(--muted); cursor: default; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; display: inline-flex; }
.choice input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 650;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.radio-list { display: grid; gap: 10px; }
.radio-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.radio-item input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.radio-item:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.radio-item b { display: block; }

.notice { border-radius: var(--radius); padding: 12px 14px; font-size: 15px; background: var(--amber-wash); }
.notice-error { background: var(--danger-wash); }
.notice-ok { background: var(--accent-wash); }
.notice b { font-weight: 650; }

/* ---------------------------------------------------------------- blocos */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 20px;
}
.panel-title { font-size: 17px; font-weight: 650; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head .panel-title { margin: 0; }

.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.boot { color: var(--muted); padding: 48px 16px; text-align: center; }

.pill {
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px;
  border-radius: 999px; background: var(--accent-wash); color: var(--accent);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}

/* status: ponto + texto (nunca só a cor) */
.st { display: inline-flex; align-items: center; gap: 7px; font-size: 14.5px; font-weight: 600; white-space: nowrap; }
.st i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.st-pending { color: var(--amber); }
.st-used, .st-paid, .st-ok { color: var(--accent); }
.st-banned, .st-fail { color: var(--danger); }
.st-missing, .st-off { color: var(--muted); }
.st-missing i, .st-off i { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.st-open { color: var(--amber); }

/* abas */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit; font-weight: 650; font-size: 15.5px; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 12px 12px 10px; min-height: 46px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 6px; }
.tab .count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); margin-left: 4px; }
.tabpanel { padding-top: 16px; }
@media (max-width: 599px) {
  .tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border-bottom: 0; overflow: visible; }
  .tab {
    border: 1px solid var(--line-strong); border-radius: 10px; margin: 0;
    padding: 10px 8px; background: var(--surface); text-align: center;
  }
  .tab[aria-selected="true"] { background: var(--accent-wash); border-color: var(--accent); }
  .tab:focus-visible { outline-offset: 2px; border-radius: 10px; }
}

/* seletor de período */
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.seg button {
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--muted);
  border: 0; background: transparent; border-radius: 9px; padding: 7px 12px; min-height: 36px; cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field > label { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.filters .input, .filters .select { min-height: 42px; }

/* faixa de números (um painel dividido por linhas finas) */
.kpis {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { padding: 16px 18px 15px; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-label { color: var(--muted); font-size: 14px; }
.kpi-value { font-size: 34px; font-weight: 650; line-height: 1.08; margin-top: 4px; letter-spacing: -0.02em; }
.kpi-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
@media (max-width: 760px) {
  .kpis, .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi-value { font-size: 28px; }
}

/* lista de atenção */
.attn { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.attn li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.attn li:last-child { border-bottom: 0; }
.attn .ic {
  width: 22px; height: 22px; flex: none; margin-top: 1px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--amber-wash); color: var(--amber);
}
.attn .ic-danger { background: var(--danger-wash); color: var(--danger); }
.attn .ic-ok { background: var(--accent-wash); color: var(--accent); }
.attn li > div { flex: 1; min-width: 0; }
.attn .btn { margin-left: auto; }

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

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  text-align: left; font-weight: 600; font-size: 13.5px; color: var(--muted);
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .mono { font-size: 13.5px; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 6px; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.cell-strong { font-weight: 650; }
.cell-sub { display: block; color: var(--muted); font-size: 13.5px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 2px 0; color: var(--muted); font-size: 14px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- diálogos */

dialog.dlg {
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--ink);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
}
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg-wide { width: min(900px, calc(100vw - 32px)); }
dialog::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 4px 20px; }
.dlg-head h2 { font-size: 20px; padding-top: 6px; }
.dlg-body { padding: 8px 20px 20px; overflow: auto; }
.dlg-body > p + p { margin-top: 10px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.dlg-error { margin-top: 14px; }
@media (max-width: 560px) {
  dialog.dlg, dialog.dlg-wide {
    width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92dvh;
    border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  .dlg-foot .btn { flex: 1 1 auto; }
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- avisos */

.toasts {
  position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid; gap: 8px; width: min(460px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: 12px; font-weight: 550; font-size: 15px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-pop);
}
.toast-error { background: var(--danger-strong); color: #fff; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; font: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .8; }

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

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 28px 24px 26px; }
.auth-card .brand-mark { width: 44px; height: 44px; }
.auth-card h1 { margin: 16px 0 6px; font-size: 27px; }
.auth-lead { color: var(--muted); margin-bottom: 18px; }
.auth-card form { margin-top: 4px; }
.auth-card .btn-primary { margin-top: 20px; }
.auth-foot { margin-top: 16px; text-align: center; }
.steps { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 8px; }
.qr { width: 208px; height: 208px; margin: 14px auto 6px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.qr img { display: block; width: 100%; height: 100%; }
.secret { font-family: var(--mono); font-weight: 500; font-size: 14px; letter-spacing: .04em; word-break: break-all; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 10px; }

/* ---------------------------------------------------------------- painel do revendedor */

.reseller { max-width: 1160px; margin: 0 auto; padding: 16px 16px 56px; display: grid; gap: 16px; }
.col-side, .col-main { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 920px) {
  .reseller { grid-template-columns: 384px minmax(0, 1fr); gap: 24px; padding-top: 24px; align-items: start; }
  .col-side { position: sticky; top: 76px; }
}

.stock-label { color: var(--muted); font-size: 15px; font-weight: 600; }
.stock-figure {
  font-size: clamp(68px, 20vw, 92px); line-height: .88; font-weight: 720;
  letter-spacing: -0.035em; margin: 8px 0 2px;
}
.stock-unit { font-size: 17px; font-weight: 600; }
.meter { height: 8px; border-radius: 999px; background: var(--accent-wash); overflow: hidden; margin: 16px 0 10px; }
.meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .5s ease; }
.meter.is-low { background: var(--amber-wash); }
.meter.is-low > span { background: var(--amber); }
.meter.is-empty { background: var(--danger-wash); }
.stock-note { color: var(--muted); font-size: 14.5px; }
.stock-alert { margin-top: 12px; }
.week-line { display: grid; gap: 2px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.week-line.is-plain { margin-top: 0; padding-top: 0; border-top: 0; }
.week-line strong { font-size: 22px; letter-spacing: -0.01em; }
.week-close { color: var(--muted); font-size: 14px; }
.nobr { white-space: nowrap; }

.gen-form .btn-lg { margin-top: 20px; }

/* lista de keys */
.klist { list-style: none; margin: 0; padding: 0; }
.krow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.krow:last-child { border-bottom: 0; }
.kcode { font-family: var(--mono); font-weight: 500; font-size: 14.5px; letter-spacing: .02em; overflow-wrap: anywhere; }
.kmeta { color: var(--muted); font-size: 14px; }
.kmeta .st { font-size: 14px; }
.kmeta-warn { color: var(--amber); font-weight: 600; }
.kactions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
@media (max-width: 520px) {
  .krow { grid-template-columns: minmax(0, 1fr); }
  .kactions { grid-column: 1; grid-row: auto; margin-top: 6px; }
  .kactions .btn { flex: 1; }
}
.more { display: flex; justify-content: center; padding-top: 14px; }

.weeks { list-style: none; margin: 0; padding: 0; }
.week { padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.week:last-child { border-bottom: 0; }
.week-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.week-top strong { font-size: 22px; }
.week-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------------------------------------------------------------- ticket (key gerada) */

dialog.ticket-dlg {
  padding: 0; border: 0; background: transparent; overflow: visible;
  width: min(440px, calc(100vw - 24px)); max-height: none;
}
dialog.ticket-dlg::backdrop { background: var(--backdrop); }
.ticket { filter: drop-shadow(0 18px 38px rgba(0, 0, 0, .3)); }
.ticket-top, .ticket-stub { background: var(--surface); padding: 22px 22px 20px; position: relative; }
.ticket-top {
  border-radius: 20px 20px 0 0;
  -webkit-mask: radial-gradient(circle 13px at 0 100%, #0000 12.5px, #000 13px) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 100%, #0000 12.5px, #000 13px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 13px at 0 100%, #0000 12.5px, #000 13px) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 100%, #0000 12.5px, #000 13px) right / 51% 100% no-repeat;
}
.ticket-stub {
  border-radius: 0 0 20px 20px; padding-top: 20px;
  -webkit-mask: radial-gradient(circle 13px at 0 0, #0000 12.5px, #000 13px) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 0, #0000 12.5px, #000 13px) right / 51% 100% no-repeat;
          mask: radial-gradient(circle 13px at 0 0, #0000 12.5px, #000 13px) left / 51% 100% no-repeat,
                radial-gradient(circle 13px at 100% 0, #0000 12.5px, #000 13px) right / 51% 100% no-repeat;
}
.ticket-stub::before {
  content: ''; position: absolute; left: 20px; right: 20px; top: 0;
  border-top: 2px dashed var(--line-strong);
}
.ticket-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ticket-when { color: var(--muted); font-size: 14px; }
.ticket-key {
  font-family: var(--mono); font-weight: 600; font-size: clamp(17px, 5.3vw, 23px);
  line-height: 1.35; letter-spacing: .03em; margin: 22px 0 10px; overflow-wrap: anywhere;
}
.ticket-count { color: var(--muted); font-size: 14.5px; }
.ticket .facts { font-size: 15px; }
.ticket-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.ticket-actions .btn-ghost { grid-column: 1 / -1; }
@media (max-width: 420px) { .ticket-actions { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: no-preference) {
  .ticket-dlg[open] .ticket { animation: ticket-in .44s cubic-bezier(.2, .8, .2, 1) both; }
  .ticket-dlg[open] .ticket-key { animation: key-print .75s steps(26, end) .2s both; }
  .toast { animation: toast-in .22s ease-out both; }
}
@keyframes ticket-in { from { transform: translateY(32px) rotate(-1.4deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes key-print { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------------------------------------------------------------- admin */

.admin { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 14px;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--paper); overflow-y: auto;
}
.side .brand { padding: 4px 8px 6px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 560; font-size: 15.5px;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-wash); color: var(--ink); font-weight: 680; }
.nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--danger-strong); color: #fff;
}
.side-foot { margin-top: auto; display: grid; gap: 4px; padding: 0 4px; }
.side-foot .who-name { max-width: none; padding: 0 8px 6px; font-size: 14px; }
.side-foot .btn { justify-content: flex-start; }

.main { min-width: 0; padding: 22px 28px 64px; }
.main-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.sync { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync .st { font-size: 14px; font-weight: 550; }
.view { display: grid; gap: 22px; min-width: 0; }
.view.is-loading { opacity: .55; transition: opacity .2s; }
.section { display: grid; gap: 12px; min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 12px; flex-wrap: wrap; }
.lead { color: var(--muted); max-width: 72ch; }

.rblock { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.rblock-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 16px 18px; flex-wrap: wrap; }
.rblock-head h3 { font-size: 18px; }
.rblock-head .cell-sub { margin-top: 2px; }
.owed { text-align: right; }
.owed b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.1; }
.owed span { color: var(--muted); font-size: 14px; }
.rblock .table-wrap { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.rblock-foot { display: flex; gap: 8px 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); }
.rblock-foot .muted { font-size: 14.5px; }

.settings-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.preview { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 15px; }

@media (max-width: 960px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: sticky; top: 0; z-index: 25; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .side::-webkit-scrollbar { display: none; }
  .side > * { flex: none; }
  .side .brand { padding: 0 6px 0 2px; }
  .side .brand-name { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; padding: 8px 11px; font-size: 15px; }
  .side-foot { margin: 0; display: flex; align-items: center; padding: 0; }
  .side-foot .who-name { display: none; }
  .main { padding: 16px 16px 56px; }
}

/* ---------------------------------------------------------------- gráfico */

.chart { margin: 0; padding: 16px 18px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 12px; flex-wrap: wrap; }
.chart-title { font-size: 17px; font-weight: 650; }
.chart-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.chart-plot { position: relative; margin-top: 12px; border-radius: 8px; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-plot:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.chart.is-loading .chart-plot { opacity: .45; transition: opacity .2s; }
.chart .tick { fill: var(--muted); font-family: var(--font); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .bar { fill: var(--series-1); }
.chart .bar.is-active { fill: color-mix(in srgb, var(--series-1) 72%, var(--ink)); }
.chart .bar-future { fill: none; }
.chart .cap { fill: var(--ink); font-family: var(--font); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 11px; font-size: 13.5px; box-shadow: var(--shadow-pop); white-space: nowrap;
}
.chart-tip .tip-day { color: var(--muted); }
.chart-tip .tip-main { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.chart-tip .tip-main b { font-size: 16px; font-weight: 700; }
.chart-tip .tip-key { width: 12px; height: 2px; border-radius: 1px; background: var(--series-1); }
.chart-tip .tip-sub { color: var(--muted); margin-top: 1px; }
.chart-table { margin-top: 12px; }
.chart-table .table-wrap { max-height: 320px; overflow: auto; }

/* ---------------------------------------------------------------- impressão (PDF) */

#print-area { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  #print-area h1 { font-size: 18pt; margin: 0 0 2pt; }
  #print-area h2 { font-size: 12.5pt; margin: 14pt 0 6pt; }
  #print-area .print-sub { color: #444; margin-bottom: 10pt; }
  #print-area table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
  #print-area th, #print-area td { text-align: left; padding: 4pt 6pt; border-bottom: .5pt solid #bbb; }
  #print-area th { color: #444; font-weight: 600; }
  #print-area .num { text-align: right; font-variant-numeric: tabular-nums; }
  #print-area .mono { font-family: var(--mono); }
  #print-area .print-kpis { display: flex; gap: 18pt; margin: 6pt 0 4pt; }
  #print-area .print-kpis div b { display: block; font-size: 16pt; }
  #print-area .print-foot { margin-top: 14pt; color: #555; font-size: 9pt; }
}
