/* Riso Facial — Design System tokens & base components.
   Canonical source: DESIGN_SYSTEM.md / design-system.html.
   Rule: only the palette below. No blue, no green, no teal. Positive = wine,
   negative = #b00020. Off-palette color is a design bug. */

:root {
  --wine: #781828;
  --wine-deep: #580015;
  --gold: #C8A848;
  --bg: #F8F0F0;
  --surface: #fff;
  --ink: #231919;
  --muted: #897172;
  --faint: #bfaaaa;
  --wine-tint: #F8E3E3;
  --gold-tint: #FBF1D9;
  --row-alt: #FBF7F7;
  --hairline: #f0e6e6;
  --cool-line: rgba(128, 136, 152, .18);
  --positive: #781828;
  --negative: #b00020;
  --gold-text: #7a5b00;
  --radius: 24px;
  --shadow: 0 4px 32px -10px rgba(120, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; }

.serif { font-family: 'Newsreader', Georgia, serif; }

/* Signature label: uppercase, letter-spaced, muted. */
.label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--cool-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.p-6 { padding: 24px; }
.card.p-7 { padding: 28px; }
.card--gold { border-top: 4px solid var(--gold); }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 9999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--wine); color: #fff; }
.btn-primary:hover { background: var(--wine-deep); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--wine); border-color: var(--cool-line); }
.btn-secondary:hover { background: rgba(120, 24, 40, .06); text-decoration: none; }
.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:hover { filter: brightness(.92); text-decoration: none; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Form fields --- */
.form-group { margin-bottom: 18px; }
.form-group > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.field {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--cool-line);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
}
.field:focus {
  outline: none;
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--wine-tint);
}

/* --- Messages / alerts (semantic, palette-safe) --- */
.alert { padding: 12px 16px; border-radius: 12px; font-size: 13px; margin-bottom: 14px; }
.alert-success { background: var(--wine-tint); color: var(--wine); }
.alert-error { background: #f7dcdf; color: var(--negative); }
.alert-warning { background: var(--gold-tint); color: var(--gold-text); }

.form-errors { color: var(--negative); font-size: 13px; margin-bottom: 14px; }

/* --- Auth screens (login / select clinic): centered card, no shell --- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card { width: 100%; max-width: 400px; padding: 40px 36px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .logo { font-size: 30px; font-weight: 600; color: var(--wine); }
.auth-brand .sub { margin-top: 4px; }

/* --- App shell: fixed header + sidebar + content --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--cool-line);
}
.app-header .brand { font-family: 'Newsreader', serif; font-size: 22px; font-weight: 600; color: var(--wine); }
.header-right { display: flex; align-items: center; gap: 16px; }

.clinic-select {
  padding: 8px 14px;
  border: 1px solid var(--cool-line);
  border-radius: 9999px;
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--wine);
  cursor: pointer;
}
.user-name { font-size: 13px; color: var(--muted); }

.app-shell { display: flex; align-items: flex-start; max-width: 1480px; margin: 0 auto; }
.sidebar { width: 232px; flex: 0 0 232px; padding: 24px 16px; }
.content { flex: 1; min-width: 0; padding: 28px 32px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-link:hover { background: rgba(120, 24, 40, .06); color: var(--wine); text-decoration: none; }
.nav-link.active { background: var(--wine); color: #fff; }
.nav-link .material-symbols-outlined { font-size: 20px; }

.page-title { font-family: 'Newsreader', serif; font-size: 28px; font-weight: 500; margin: 0 0 4px; }
.page-eyebrow { margin-bottom: 20px; }

/* Pills / badges */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.pill-wine { background: var(--wine-tint); color: var(--wine); }
.pill-gold { background: var(--gold-tint); color: var(--gold-text); }

.app-footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 32px 32px;
  color: var(--faint);
  font-size: 11px;
}

/* --- Header left group + sidebar toggle --- */
.header-left { display: flex; align-items: center; gap: 12px; }
.nav-toggle {
  background: none; border: 1px solid var(--cool-line); border-radius: 10px;
  width: 38px; height: 38px; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--wine);
}
.nav-toggle:hover { background: rgba(120, 24, 40, .06); }

/* --- Collapsed sidebar (icon rail); collapsed by default --- */
html.nav-collapsed .sidebar { width: 64px; flex-basis: 64px; padding: 24px 8px; }
html.nav-collapsed .nav-label { display: none; }
html.nav-collapsed .nav-link { justify-content: center; padding: 10px; gap: 0; }
html.nav-collapsed .nav-link .pill { display: none; }

/* --- Mobile-only chrome, hidden on desktop/tablet (see the 820px block) --- */
.brand-short, .header-mobile-only, .drawer-only, .bottom-nav, .nav-backdrop { display: none; }
.btn-compact { padding: 6px 16px; }

/* --- Page head: title + primary actions --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: nowrap; overflow-x: auto; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(35, 25, 25, .5);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 60; padding: 40px 20px; overflow: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px -20px rgba(120, 24, 40, .35);
  width: 100%; max-width: 520px; padding: 28px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-head .page-title { font-size: 22px; margin: 0; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-close:hover { color: var(--wine); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.detail-value { font-size: 14px; margin-top: 3px; }

/* --- Tabs (section navigation, e.g. Configurações) --- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--hairline); margin-bottom: 24px; overflow-x: auto; }
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 18px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; border-radius: 10px 10px 0 0;
  white-space: nowrap; cursor: pointer; transition: background .15s, color .15s;
}
.tab .material-symbols-outlined { font-size: 18px; }
.tab:hover { color: var(--wine); background: var(--wine-tint); text-decoration: none; }
.tab.active { color: var(--wine); border-bottom-color: var(--wine); background: var(--wine-tint); }

/* --- Filter pills (one-click filters, e.g. status on Pedidos) ---
   Links reais (querystring), sem JS. Mesmo raio 9999px e mesmo estado ativo
   vinho cheio do .nav-link.active; inativo segue o .btn-secondary. */
.filter-pills { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 6px 14px; border: 1px solid var(--cool-line); border-radius: 9999px;
  font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface);
  white-space: nowrap; transition: background .15s, color .15s, border-color .15s;
}
.filter-pill:hover { color: var(--wine); background: var(--wine-tint); text-decoration: none; }
.filter-pill.active { background: var(--wine); border-color: var(--wine); color: #fff; }

/* --- Toolbar / search --- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .field { width: auto; min-width: 260px; }
/* Keep every filter on a single line (scrolls horizontally if narrow). */
.toolbar--inline { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
.toolbar--inline .field { min-width: 0; flex-shrink: 0; }
.toolbar--inline > label, .toolbar--inline > button, .toolbar--inline > .btn, .toolbar--inline > .field { flex-shrink: 0; white-space: nowrap; }
/* Filtro com rotulo ("De", "Ate", "Categoria"): o datepicker vira um <div>
   dentro do <label>, que quebraria a linha e desalinharia o campo dos demais
   filtros — inline-flex mantem rotulo e campo lado a lado e centralizados. */
.toolbar label { display: inline-flex; align-items: center; gap: 6px; }
.toolbar .datepicker { flex-shrink: 0; }
.toolbar .datepicker-display.field { width: 148px; min-width: 0; }

/* --- Dense table (.xls) --- */
.xls-wrap { border-radius: 16px; border: 1px solid var(--hairline); overflow: auto; background: var(--surface); }
table.xls { width: 100%; border-collapse: collapse; font-size: 13px; }
.xls th {
  background: var(--wine); color: #fff; font-size: 11px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; text-align: left;
  padding: 11px 14px; position: sticky; top: 0; white-space: nowrap;
}
.xls td { padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
.xls tr:nth-child(even) td { background: var(--row-alt); }
.xls tr:last-child td { border-bottom: none; }
.xls .num { text-align: right; font-variant-numeric: tabular-nums; }
.xls .row-actions { text-align: right; white-space: nowrap; }
.xls .row-actions a, .xls .row-actions button { font-size: 12px; font-weight: 600; }
.xls .row-actions form { display: inline; }
.xls .row-actions > * + * { margin-left: 8px; }
.link-danger { color: var(--negative); background: none; border: none; padding: 0; font: inherit; font-weight: 600; cursor: pointer; }
.link-action { color: var(--wine); background: none; border: none; padding: 0; font: inherit; font-weight: 600; cursor: pointer; }

/* Horizontal scroll hint: app.js flags which edge still hides content and the
   edge fades out, so a clipped table/toolbar reads as "swipe for more". */
.table-scroll { overflow-x: auto; }
.is-scrollable.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}
.is-scrollable.can-scroll-left {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 36px);
          mask-image: linear-gradient(to right, transparent, #000 36px);
}
.is-scrollable.can-scroll-left.can-scroll-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent);
          mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent);
}

/* --- Dashboard KPI grids --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.kpi-grid + .kpi-grid, .kpi-grid + .dash-split { margin-top: 20px; }
.kpi-value { font-family: 'Newsreader', Georgia, serif; font-size: 40px; font-weight: 500; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.kpi-value--md { font-size: 34px; }
.kpi-value--text { font-size: 24px; margin-top: 8px; overflow-wrap: anywhere; }
.kpi-value--wine { color: var(--wine); }
.dash-split { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.dash-split > * { min-width: 0; }

/* --- Offline page (PWA) --- */
.offline-card { text-align: center; }
.offline-icon { display: block; margin: 0 auto 18px; border-radius: 16px; }
.offline-card .page-title { margin: 6px 0 12px; }
.offline-card p { font-size: 14px; line-height: 1.55; margin: 0 0 22px; }

/* --- Badges (palette-safe: no green/blue) --- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 9999px; font-size: 11px; font-weight: 700; }
.badge-neutral { background: var(--wine-tint); color: var(--wine); }
.badge-gold { background: var(--gold-tint); color: var(--gold-text); }
.badge-muted { background: #efe7e7; color: var(--muted); }
.badge-danger { background: #f7dcdf; color: var(--negative); }
.badge-wine-deep { background: #ecd9d9; color: var(--wine-deep); }

/* --- Empty state --- */
.empty-state { padding: 40px; text-align: center; color: var(--muted); }

/* --- Pagination --- */
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 18px; font-size: 13px; }
.pagination a { padding: 6px 12px; border: 1px solid var(--cool-line); border-radius: 9999px; }

/* --- Forms --- */
.form-card { max-width: 720px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.field-check { width: auto; margin-right: 8px; }
.check-row { display: flex; align-items: center; margin-bottom: 18px; font-weight: 600; color: var(--muted); }
.help-text { font-size: 11px; color: var(--faint); margin-top: 4px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--negative); font-size: 12px; }
.section-title { font-family: 'Newsreader', serif; font-size: 18px; margin: 24px 0 12px; }
.formset-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; padding: 12px 0; border-bottom: 1px dashed var(--hairline); }
.formset-row .form-group { margin-bottom: 0; }
.formset-row--error { background: rgba(176,0,32,.04); box-shadow: inset 3px 0 0 var(--negative); padding-left: 10px; }
.formset-row:has([data-add-supplier]) { padding-bottom: 40px; }
.formset-row .form-group:has([data-add-supplier]) { position: relative; }
.formset-row [data-add-supplier] { position: absolute; left: 0; top: 100%; margin-top: 6px; white-space: nowrap; }
.btn-remove-item {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: var(--wine-tint); color: var(--wine); cursor: pointer;
}
.btn-remove-item:hover { background: var(--wine); color: #fff; }
.btn-remove-item .material-symbols-outlined { font-size: 20px; }
[data-supplier-row] input[name$="-DELETE"] { display: none; }
.xls tr.row-best td { background: var(--gold-tint); }

/* --- Unread indicator (pedido novo) --- */
.xls tr.row-unread td { background: var(--gold-tint); font-weight: 600; }
.dot-new {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 6px;
  vertical-align: middle;
}

/* --- Form widgets: quantity stepper --- */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--cool-line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  max-width: 180px;
}
.stepper:focus-within {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px var(--wine-tint);
}
.stepper-btn {
  border: 0;
  background: var(--wine-tint);
  color: var(--wine);
  width: 40px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.stepper-btn:hover { background: var(--wine); color: #fff; }
.stepper-input.field {
  width: 80px;
  border: 0;
  border-radius: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: none;
}
.stepper-input.field:focus { box-shadow: none; }
/* Hide the native number spinners so only our buttons remain. */
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-input { -moz-appearance: textfield; }

/* --- Form widgets: product combobox --- */
.combobox { position: relative; }
.combobox-native { display: none; }
.combobox-list {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--cool-line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 4px;
}
.combobox-option {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
}
.combobox-option:hover,
.combobox-option.active { background: var(--wine-tint); color: var(--wine); }
.combobox-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* --- Form widgets: password visibility toggle --- */
.password-toggle { position: relative; }
.password-toggle .field { padding-right: 44px; }
.password-toggle-btn {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-toggle-btn:hover,
.password-toggle-btn[aria-pressed="true"] { color: var(--wine); }
.password-toggle-btn .material-symbols-outlined { font-size: 20px; }

/* --- Form widgets: date picker --- */
.datepicker { position: relative; }
.datepicker-display.field { padding-right: 44px; }
.datepicker-icon {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 40px;
  border: 0;
  background: transparent;
  color: var(--wine);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.datepicker-icon .material-symbols-outlined { font-size: 20px; }
/* Fixo (nao absoluto): a toolbar de filtros tem overflow-x:auto, que recorta
   qualquer pop-up absoluto dentro dela. O widgets.js calcula top/left a partir
   do campo e reposiciona em scroll/resize. */
.datepicker-pop {
  position: fixed;
  z-index: 70;
  width: 288px;
  background: var(--surface);
  border: 1px solid var(--cool-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.dp-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.dp-nav {
  border: 0; background: var(--wine-tint); color: var(--wine);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.dp-nav:hover { background: var(--wine); color: #fff; }
.dp-select {
  flex: 1; padding: 6px 8px; border: 1px solid var(--cool-line);
  border-radius: 8px; background: var(--surface); color: var(--ink); font-family: inherit; font-size: 13px;
}
.dp-dow, .dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow span {
  text-align: center; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; padding-bottom: 4px;
}
.dp-cell {
  border: 0; background: transparent; color: var(--ink);
  height: 34px; border-radius: 8px; cursor: pointer;
  font-variant-numeric: tabular-nums; font-size: 13px;
}
.dp-cell:hover { background: var(--wine-tint); color: var(--wine); }
.dp-blank { background: transparent; cursor: default; }
.dp-today { box-shadow: inset 0 0 0 1px var(--wine); color: var(--wine); }
.dp-selected { background: var(--wine); color: #fff; }
.dp-selected:hover { background: var(--wine-deep); color: #fff; }

/* --- Form widgets: BRL money mask --- */
.money-field { position: relative; }
.money-prefix {
  position: absolute; left: 14px; top: 0; height: 100%;
  display: flex; align-items: center; color: var(--muted); font-size: 14px; pointer-events: none;
}
.money-display.field { padding-left: 36px; text-align: right; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Mobile (<=820px): header compacto, sidebar vira gaveta modal, navegação
   inferior fixa, coluna única e alvos de toque de 44px. Desktop/tablet acima
   deste ponto mantém a sidebar (trilho recolhível) intacta.
   ========================================================================== */
@media (max-width: 820px) {
  :root { --header-h: 56px; --bottom-nav-h: 64px; }

  /* Header */
  .app-header {
    height: calc(var(--header-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    gap: 10px;
  }
  .header-left { flex: 0 0 auto; gap: 10px; }
  .app-header .brand { font-size: 19px; white-space: nowrap; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .header-right { flex: 1 1 auto; min-width: 0; justify-content: flex-end; gap: 8px; }
  .header-secondary { display: none; }
  .header-mobile-only { display: inline-block; }
  .header-clinic {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 4px 10px; vertical-align: middle;
  }
  .nav-toggle { width: 44px; height: 44px; flex-shrink: 0; }

  /* Sidebar -> gaveta modal (sobrepõe as regras do trilho recolhido) */
  .app-shell { display: block; }
  html .app-shell .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(320px, 86vw); flex: none;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background: var(--bg);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 0 20px 60px -20px rgba(120, 24, 40, .35);
    overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-105%); visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  html.nav-open .app-shell .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  html.nav-open body { overflow: hidden; }
  html .sidebar .nav-label { display: inline; }
  html .sidebar .nav-link { justify-content: flex-start; gap: 12px; padding: 11px 18px; min-height: 44px; margin-bottom: 2px; }
  html .sidebar .nav-link .pill { display: inline-block; }
  .drawer-only { display: block; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px 8px; }
  .drawer-head .brand { font-size: 22px; font-weight: 600; color: var(--wine); }
  .drawer-close {
    width: 44px; height: 44px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--cool-line); border-radius: 12px; color: var(--wine); cursor: pointer;
  }
  .drawer-account { margin-top: 16px; padding: 18px 8px 0; border-top: 1px solid var(--hairline); }
  .drawer-account .label { margin-bottom: 12px; }
  .drawer-account form { margin: 0 0 12px; }
  .drawer-field-label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
  .drawer-account .pill { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
  .drawer-user { margin: 12px 0; font-size: 13px; color: var(--muted); }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(35, 25, 25, .5); }
  .nav-backdrop[hidden] { display: none; }

  /* Navegação inferior fixa */
  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: var(--surface);
    border-top: 1px solid var(--cool-line);
    box-shadow: 0 -4px 24px -12px rgba(120, 24, 40, .18);
  }
  .bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; padding: 0; border: 0; border-radius: 16px; background: none;
    font-family: inherit; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item:hover { color: var(--wine); text-decoration: none; }
  .bottom-nav-item .material-symbols-outlined { font-size: 22px; padding: 2px 16px; border-radius: 9999px; }
  .bottom-nav-item.active, .bottom-nav-item[aria-expanded="true"] { color: var(--wine); }
  .bottom-nav-item.active .material-symbols-outlined,
  .bottom-nav-item[aria-expanded="true"] .material-symbols-outlined { background: var(--wine-tint); }

  .nav-toggle:focus-visible, .drawer-close:focus-visible, .nav-link:focus-visible,
  .bottom-nav-item:focus-visible, .btn:focus-visible, .tab:focus-visible, .filter-pill:focus-visible {
    outline: 2px solid var(--wine); outline-offset: 2px;
  }

  /* Conteúdo: espaço para a navegação inferior + safe areas */
  .content { padding: 18px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left)); }
  .app-footer { padding: 4px 16px calc(var(--bottom-nav-h) + 20px + env(safe-area-inset-bottom)); }

  /* Cabeçalho de página e ações em coluna única */
  .page-title { font-size: 24px; }
  .page-eyebrow { margin-bottom: 10px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; }
  .page-head .actions { flex-direction: column; flex-wrap: nowrap; overflow: visible; gap: 8px; }
  .page-head .actions > *, .page-head .actions form .btn { width: 100%; }

  /* Alvos de toque */
  .btn { min-height: 44px; }
  .field, .clinic-select { min-height: 44px; font-size: 16px; } /* 16px evita zoom do iOS no foco */
  .tab { min-height: 44px; }
  .pagination { flex-wrap: wrap; }
  .pagination a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; }
  .xls .row-actions a, .xls .row-actions button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; }
  .link-action, .link-danger { min-height: 44px; }
  .stepper-btn { width: 44px; }
  .datepicker-icon { width: 44px; }
  .dp-nav { width: 44px; height: 44px; }
  .dp-cell { height: 44px; }
  .datepicker-pop { width: min(320px, calc(100vw - 16px)); }

  /* Formulários em coluna única */
  .form-card { max-width: none; }
  .form-row, .formset-row { grid-template-columns: 1fr; }
  .form-actions { flex-direction: column; }
  .form-actions > * { width: 100%; }
  .card.p-6, .card.p-7 { padding: 20px; }

  /* Toolbars: busca em largura total, filtros em grade de 2 colunas */
  .toolbar, .toolbar--inline { flex-wrap: wrap; overflow-x: visible; padding-bottom: 0; }
  .toolbar .field, .toolbar--inline .field { min-width: 0; }
  .toolbar > .field, .toolbar > .datepicker, .toolbar > label { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .toolbar > input[type="text"], .toolbar > input[type="search"] { flex-basis: 100%; }
  .toolbar > label { font-size: 12px; }
  .toolbar > label > .field, .toolbar > label > .datepicker { flex: 1 1 auto; min-width: 0; }
  .toolbar .datepicker-display.field { width: 100%; }
  .toolbar > .btn { flex: 1 1 100%; }

  /* Tabelas densas: continuam completas, com rolagem horizontal */
  .xls-wrap, .table-scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .xls-wrap > table.xls, .table-scroll > table.xls { min-width: 640px; }

  /* Modais cabem na tela */
  .modal-overlay { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
  .modal { padding: 20px; border-radius: 20px; }
  .modal-head { gap: 12px; }
  .modal-head .page-title, .modal-head h2 { font-size: 20px; margin: 0; }
  .modal-close { width: 44px; height: 44px; flex-shrink: 0; }

  /* Dashboard */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-grid + .kpi-grid, .kpi-grid + .dash-split { margin-top: 12px; }
  .kpi-grid > .card--gold { grid-column: 1 / -1; }
  .kpi-grid > .card.p-7 { padding: 18px; }
  .kpi-value { font-size: 32px; }
  .kpi-value--md { font-size: 28px; }
  .kpi-value--text { font-size: 20px; }
  .dash-split { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 520px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html .app-shell .sidebar, html.nav-open .app-shell .sidebar { transition: none; }
}

/* Impressão (ex.: botão "Imprimir" no detalhe do pedido): só o conteúdo da página,
   sem navegação, botões ou sombras; campos de formulário viram texto. */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .app-header, .sidebar, .nav-backdrop, .bottom-nav, .alert, .modal-overlay,
  .btn, .stepper-btn, .form-actions, .no-print { display: none !important; }
  .app-shell { display: block; max-width: none; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; max-width: none !important; break-inside: avoid; }
  .xls-wrap { overflow: visible; box-shadow: none; }
  .xls tr { break-inside: avoid; }
  .field, input, select, textarea { border: 0 !important; background: none !important; box-shadow: none !important; padding: 0 !important; appearance: none; -moz-appearance: textfield; }
  input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
  a { color: inherit; text-decoration: none; }
}
