/* ============================================================
   Gomos — Design Tokens & Shared Components
   Tangerina MCA · 2026
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #FEF6EC;
  --surface: #FFFFFF;
  --surface-alt: #FFF7ED;

  /* Ink */
  --ink: #2A1810;
  --ink-soft: #7A5A3F;
  --ink-muted: #A8896C;

  --line: rgba(42, 24, 16, 0.10);
  --line-strong: rgba(42, 24, 16, 0.18);

  /* Tangerine */
  --tang: #EA580C;
  --tang-deep: #C2410C;
  --tang-light: #FB923C;
  --tang-pale: #FED7AA;
  --tang-cream: #FFF1E0;

  /* Semantic */
  --leaf: #65A30D;
  --leaf-pale: #ECFCCB;
  --amber: #D97706;
  --amber-pale: #FEF3C7;
  --rose: #E11D48;
  --rose-pale: #FFE4E6;

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(42, 24, 16, 0.04);
  --shadow: 0 2px 8px rgba(42, 24, 16, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}

/* ============================================================
   Typography
   ============================================================ */

.font-display {
  font-family: 'Fraunces', 'Cormorant Garamond', serif;
  font-feature-settings: 'ss01';
}

.tabular { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { margin: 0; font-weight: 500; }

.h-page {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.h-page em {
  font-style: italic;
  font-weight: 500;
}

.h-section {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ============================================================
   Layout shell (sidebar + main)
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 8px 0;
}

.brand-name {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tang);
  display: inline-block;
  margin-left: 2px;
  transform: translateY(-2px);
}

.brand-sub {
  font-size: 11px;
  color: var(--ink-muted);
  padding: 0 8px;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  /* a lista de itens cresceu: rola por conta própria em telas baixas/zoom,
     mantendo a marca fixa em cima e o card de usuário fixo embaixo */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  margin-right: -8px;
  padding-right: 8px;
}

.nav-section {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 12px 12px 6px;
  font-weight: 500;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.nav a:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.nav a.active {
  background: var(--tang-cream);
  color: var(--tang-deep);
}

.nav a .icon {
  width: 17px;
  height: 17px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--tang);
  color: white;
  padding: 1px 7px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.nav a.active .nav-badge { background: var(--tang-deep); }

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 8px 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-card:hover { background: var(--surface-alt); }

/* Menu do usuário (logout) — abre pra cima */
.user-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(42, 24, 16, 0.12);
  padding: 6px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}
.user-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--rose);
  cursor: pointer;
  text-align: left;
}
.user-menu-item:hover { background: var(--rose-pale); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--tang-pale);
  color: var(--tang-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 13px; }

.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.user-role { font-size: 11px; color: var(--ink-muted); }

/* ============================================================
   Main content
   ============================================================ */

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

.page-header {
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  background: var(--bg);
}

.page-header-left { display: flex; flex-direction: column; gap: 4px; }

.page-header-actions { display: flex; gap: 8px; align-items: center; }

.page-body { padding: 28px 32px; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
  line-height: 1.2;
}

.btn .icon { width: 15px; height: 15px; stroke-width: 1.75; }

.btn-primary {
  background: var(--tang);
  color: white;
  border-color: var(--tang);
}
.btn-primary:hover { background: var(--tang-deep); border-color: var(--tang-deep); }
.btn-primary:disabled { background: var(--tang-pale); border-color: var(--tang-pale); color: white; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-alt); border-color: var(--ink-muted); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }

.btn-danger {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--rose);
}
.btn-danger:hover { background: var(--rose-pale); border-color: var(--rose); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 18px; font-size: 14px; }

.btn-icon { padding: 7px; }
.btn-icon .icon { width: 16px; height: 16px; }

/* ============================================================
   Inputs
   ============================================================ */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.field-hint { font-size: 12px; color: var(--ink-muted); }
.field-error { font-size: 12px; color: var(--rose); }

.input, .textarea, .select {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1.4;
}

.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--tang);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

.input::placeholder, .textarea::placeholder { color: var(--ink-muted); }

.input:disabled { background: var(--surface-alt); color: var(--ink-muted); cursor: not-allowed; }

.textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.search {
  position: relative;
}
.search .icon-search {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-muted);
  pointer-events: none;
}
.search .input { padding-left: 32px; }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
}
.checkbox input, .radio input {
  width: 16px; height: 16px; accent-color: var(--tang); cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}
.switch input { display: none; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--ink-muted);
  opacity: 0.35;
  border-radius: 20px;
  transition: 0.2s;
  cursor: pointer;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-slider { background: var(--tang); opacity: 1; }
.switch input:checked + .switch-slider::before { transform: translateX(14px); }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.card-tight { padding: 14px 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

/* ============================================================
   Badges & pills
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
}

.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
}

.badge-success { background: var(--leaf-pale); color: #4d7c0f; }
.badge-success .dot { background: var(--leaf); }
.badge-warn { background: var(--amber-pale); color: #92400e; }
.badge-warn .dot { background: var(--amber); }
.badge-danger { background: var(--rose-pale); color: #9f1239; }
.badge-danger .dot { background: var(--rose); }
.badge-info { background: var(--tang-cream); color: var(--tang-deep); }
.badge-info .dot { background: var(--tang); }
.badge-neutral { background: rgba(42, 24, 16, 0.06); color: var(--ink-soft); }
.badge-neutral .dot { background: var(--ink-muted); }

/* Confidence badge with score */
.conf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.conf-bar {
  width: 24px;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.25;
  position: relative;
  overflow: hidden;
}
.conf-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: var(--conf, 50%);
  background: currentColor;
  opacity: 4;
  border-radius: 2px;
}
.conf-high { background: var(--leaf-pale); color: #4d7c0f; }
.conf-mid  { background: var(--amber-pale); color: #92400e; }
.conf-low  { background: var(--rose-pale); color: #9f1239; }

/* Account chip */
.acct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: rgba(42, 24, 16, 0.04);
}
.acct .dot { width: 7px; height: 7px; border-radius: 50%; }
.acct-1 .dot { background: #EA580C; }
.acct-2 .dot { background: #65A30D; }
.acct-3 .dot { background: #0891B2; }
.acct-4 .dot { background: #7C3AED; }

/* ============================================================
   Tables
   ============================================================ */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--surface-alt); cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }

.table.in-card { margin: -20px; width: calc(100% + 40px); }
.table.in-card thead th:first-child,
.table.in-card tbody td:first-child { padding-left: 20px; }
.table.in-card thead th:last-child,
.table.in-card tbody td:last-child { padding-right: 20px; }

/* ============================================================
   Question card (used in pendentes, ensinar, dashboard)
   ============================================================ */

.qcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.qcard:hover { border-color: var(--line-strong); }

.qcard.attention {
  border-left: 3px solid var(--rose);
}

.qcard-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.qcard-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.qcard-product {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.qcard-product img,
.qcard-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--tang-cream);
  flex-shrink: 0;
}

.qcard-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--ink-muted);
}

.question-text {
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.5;
}

.ai-suggestion {
  background: var(--tang-cream);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border-left: 3px solid var(--tang);
  position: relative;
}
.ai-suggestion-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tang-deep);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-suggestion-text {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.55;
}

.qcard-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--surface-alt);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.qcard-actions .spacer { flex: 1; }

.reasoning {
  background: var(--surface-alt);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.reasoning strong { color: var(--ink); font-weight: 500; }

/* ============================================================
   KPI tiles
   ============================================================ */

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}

.kpi-value {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-split {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}
.kpi-split span { display: inline-flex; align-items: center; gap: 4px; }
.kpi-split .dot { width: 6px; height: 6px; border-radius: 50%; }

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}
.kpi-trend.up { color: var(--leaf); }
.kpi-trend.down { color: var(--rose); }

.kpi-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--tang-light);
  opacity: 0.35;
}

/* ============================================================
   Misc
   ============================================================ */

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

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px;
  color: var(--ink-muted);
  text-align: center;
}

.muted { color: var(--ink-muted); }
.soft  { color: var(--ink-soft); }
.tang  { color: var(--tang); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }

.scroll-y { overflow-y: auto; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--tang);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Lucide icon sizing */
[data-lucide] { width: 16px; height: 16px; stroke-width: 1.75; }

/* Subtle fade-in for content */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.25s ease both; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(42, 24, 16, 0.35);
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(42, 24, 16, 0.4);
  z-index: 40; display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 480px; max-width: 90vw;
  border: 1px solid var(--line);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(42, 24, 16, 0.18);
}
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

/* ============================================================
   Barra de impersonation ("entrar como")
   ============================================================ */
.impersonation-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--amber);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(42, 24, 16, 0.18);
}
.impersonation-bar .imp-back {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.impersonation-bar .imp-back:hover { background: rgba(255,255,255,0.3); }
.app.with-imp-bar { padding-top: 38px; }
.app.with-imp-bar .sidebar { top: 38px; height: calc(100vh - 38px); }

/* ============================================================
   Aviso de nova pergunta (toast fixo)
   ============================================================ */
.gomos-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--tang);
  border-left: 4px solid var(--tang);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(42, 24, 16, 0.22);
  padding: 14px 16px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.gomos-toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.gomos-toast .gt-emoji { font-size: 22px; line-height: 1; }
.gomos-toast .gt-text { font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.gomos-toast .gt-text strong { color: var(--ink); font-weight: 600; }
.gomos-toast .gt-close {
  background: transparent; border: 0; color: var(--ink-muted);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px;
  margin-left: auto; flex-shrink: 0;
}
.gomos-toast .gt-close:hover { color: var(--ink); }
@media (max-width: 640px) {
  .gomos-toast { left: 16px; right: 16px; max-width: none; }
}

/* ============================================================
   Responsividade
   ============================================================ */

/* Barra superior mobile (hambúrguer) — escondida no desktop */
.mobile-topbar { display: none; }
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(42, 24, 16, 0.45);
  z-index: 55; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}

/* a página inteira nunca deve estourar a largura */
.main { max-width: 100%; overflow-x: hidden; }
.page-header { flex-wrap: wrap; }
.page-header-actions { flex-wrap: wrap; }

/* tabelas largas rolam na horizontal em vez de empurrar o layout */
.u-table, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Telas médias: KPIs em 2 colunas */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet / sidebar vira gaveta */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 268px; max-width: 84vw;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 0 0 50px rgba(42, 24, 16, 0.22);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
  }
  .mobile-topbar .brand-name { font-family: 'Fraunces', serif; font-style: italic; }
  .sidebar-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink); cursor: pointer;
  }
  .sidebar-toggle:hover { background: var(--surface-alt); }

  .page-header { padding: 18px 16px 14px; }
  .page-body { padding: 18px 16px; }

  /* drawer lateral (histórico) ocupa a tela toda */
  .drawer { width: 100%; max-width: 100%; }

  /* modais com margem nas bordas */
  .modal { width: calc(100vw - 32px); }
}

/* Celular: tudo em 1 coluna */
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
  .qcard-actions { flex-wrap: wrap; }
  .qcard-actions .spacer { display: none; }
  .kpi-value { font-size: 26px; }
}
