/* Gestão Festas — estilo inspirado na planilha de entrada de dados */
:root {
  --primary: #be185d;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #d9d9d6;
  --border-strong: #b9b9b5;
  --text: #1c1c1b;
  --text-2: #52514e;
  --muted: #7a7975;
  --danger: #c0262d;
  --success: #15803d;
  --warning: #b45309;
  --info: #1d4ed8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --sidebar: 280px;
  --primary-soft: color-mix(in srgb, var(--primary) 10%, white);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.neg { color: var(--danger) !important; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  padding: 20px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}
.main { flex: 1; min-width: 0; padding: 20px 28px 40px; display: flex; flex-direction: column; gap: 18px; }

/* Marca */
.brand { display: flex; justify-content: center; }
.brand-logo { max-width: 100%; max-height: 180px; object-fit: contain; }
.brand-circle {
  width: 190px; height: 190px; border-radius: 50%;
  border: 6px solid color-mix(in srgb, var(--primary) 25%, #e6e6e3);
  background: radial-gradient(circle at 30% 25%, #fff, #f1f1ef);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 18px;
}
.brand-name { font-family: "Great Vibes", cursive; font-size: 40px; line-height: 1; color: var(--text); word-break: break-word; }
.brand-slogan { margin-top: 8px; font-size: 12px; color: var(--text-2); }

/* Menu */
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .02em;
  box-shadow: var(--shadow);
  transition: background .15s, border-color .15s;
}
.menu-item:hover { text-decoration: none; background: var(--primary-soft); border-color: var(--primary); }
.menu-item.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.sidebar-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sidebar-user-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info small { color: var(--muted); }

.icon-btn { border: 0; background: none; color: var(--text-2); padding: 6px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* Topo */
.topbar { display: flex; align-items: center; gap: 16px; }
.topbar-title { flex: 1; text-align: center; }
.topbar-title h1 { font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .01em; }
.topbar-title p { margin: 4px 0 0; font-size: 16px; color: var(--text-2); }
.topbar-date { display: flex; align-items: flex-start; gap: 10px; }
.topbar-date div { display: flex; flex-direction: column; }
.topbar-date small { color: var(--text-2); }
.menu-toggle { display: none; }

.impersonate-bar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  padding: 8px 16px; background: #1c1c1b; color: #fff; font-size: 13px;
}

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.link { font-size: 13px; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text); }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-row strong { font-size: clamp(16px, 1.25vw, 20px); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-row .icon { color: var(--text); }
.kpi small { color: var(--text-2); font-size: 12px; }

/* Grade de módulos (como na planilha) */
.modules {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.module { padding: 18px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; }
.module:nth-child(4n) { border-right: 0; }
.module:nth-last-child(-n+4) { border-bottom: 0; }
.module-head { display: flex; align-items: center; gap: 14px; color: var(--text); margin-bottom: 12px; }
.module-head:hover { text-decoration: none; color: var(--primary); }
.module-head h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; }
.module ul { margin: 0 0 12px; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.7; flex: 1; }
.module-action { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; align-self: flex-start; padding: 5px 10px; border-radius: 8px; background: var(--primary-soft); }
.module-action:hover { text-decoration: none; background: var(--primary); color: #fff; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.chart-box { position: relative; height: 280px; }

.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.event-list li { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.event-list li:last-child { border-bottom: 0; }
.event-date { width: 48px; text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 4px 0; display: flex; flex-direction: column; }
.event-date strong { font-size: 18px; }
.event-date small { font-size: 11px; text-transform: uppercase; color: var(--text-2); }
.event-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.event-info a { color: var(--text); }
.event-info small { color: var(--text-2); }

.instructions { display: flex; gap: 20px; align-items: flex-start; }
.instructions h3 { font-size: 14px; text-transform: uppercase; margin-bottom: 10px; }
.instructions ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 32px; color: var(--text-2); }
.instructions li { display: flex; gap: 8px; align-items: center; }

.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.mini-kpis div { display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.mini-kpis small { color: var(--text-2); }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

/* ---------- Seções / filtros / tabelas ---------- */
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-header h2 { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.btn-group { display: flex; gap: 8px; }

.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.filters .field { min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters-summary { margin-left: auto; color: var(--text-2); align-self: center; }

.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 0; }
.card.table-wrap > .card-head { padding: 16px 18px 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; color: var(--text-2); font-weight: 600; background: #fafaf9; white-space: nowrap; }
.table tbody tr:hover { background: #fafaf9; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { background: #fafaf9; color: var(--text); border-top: 1px solid var(--border-strong); }
.table.compact th, .table.compact td { padding: 8px 12px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.actions > * { margin-left: 4px; }

.badge, .tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-agendado, .badge-rascunho { background: #f1f1ef; color: #52514e; border-color: #dededb; }
.badge-confirmado, .badge-enviado { background: #e8f0fe; color: #1d4ed8; }
.badge-realizado, .badge-aprovado, .badge-entrada { background: #e7f6ec; color: #15803d; }
.badge-cancelado, .badge-recusado, .badge-saida { background: #fdecec; color: #b42318; }
.tag-novo { background: #e7f6ec; color: #15803d; }
.tag-bom { background: #e8f0fe; color: #1d4ed8; }
.tag-regular { background: #fef6e7; color: #b45309; }
.tag-danificado { background: #fdecec; color: #b42318; }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; }
.tabs a { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; color: var(--text-2); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--bg); }
.tabs a.active { background: var(--primary); color: #fff; }

.pagination { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; padding: 6px 10px; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Formulários ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text); }
.field small { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text);
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent); border-color: var(--primary); }
input:disabled { background: var(--bg); color: var(--text-2); }
input[type=color] { padding: 3px; height: 40px; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { resize: vertical; }
.w-sm { width: 80px; }
.w-md { width: 130px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }

.segmented { display: flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.segmented label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px; cursor: pointer; font-weight: 600; }
.segmented label + label { border-left: 1px solid var(--border-strong); }
.segmented label:has(input:checked) { background: var(--primary); color: #fff; }
.segmented input { accent-color: #fff; }

.form-section { display: flex; align-items: center; gap: 8px; font-size: 15px; padding-top: 6px; border-top: 1px solid var(--border); padding-top: 16px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
.form-inline-add { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); align-items: end; }
.danger-zone { border-color: #f1c4c4; }
.items-table td { padding: 6px 8px; }
.items-table select { min-width: 180px; }
.items-table input[data-item-desc] { min-width: 220px; }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--bg); }
.totals > div, .totals .field { display: flex; flex-direction: column; gap: 4px; }
.totals small { color: var(--text-2); font-weight: 600; }
.totals strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.logo-upload { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-weight: 400; }
.logo-preview { max-height: 80px; max-width: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; vertical-align: middle; }
.inline-filter select { width: auto; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 85%, black); }
.btn-danger { color: var(--danger); border-color: #ebb6b6; }
.btn-danger:hover { background: #fdecec; }
.btn-light { background: #fff; color: #1c1c1b; border-color: #fff; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- Alertas ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid; }
.alert-success { background: #e7f6ec; border-color: #b7e2c4; color: #14532d; }
.alert-error { background: #fdecec; border-color: #f1c4c4; color: #7f1d1d; }
.alert-info { background: #e8f0fe; border-color: #c3d5fb; color: #1e3a8a; }

/* ---------- Login / instalação ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, #fff, var(--bg)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-card.wide { max-width: 480px; }
.login-card h1 { font-size: 18px; text-align: center; }
.login-card .form-grid { grid-template-columns: 2fr 1fr; }

/* ---------- Orçamento impresso ---------- */
.print-page { background: #e9e9e6; padding: 20px 16px; }
.print-actions { max-width: 800px; margin: 0 auto 14px; display: flex; justify-content: space-between; gap: 10px; }
.print-sheet { max-width: 800px; margin: 0 auto; background: #fff; padding: 40px; border-radius: 6px; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.print-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 3px solid var(--primary); }
.print-logo { max-height: 90px; max-width: 220px; }
.print-company { display: flex; flex-direction: column; text-align: right; color: var(--text-2); font-size: 13px; }
.print-company strong { color: var(--text); font-size: 16px; }
.print-sheet h1 { margin: 24px 0 16px; font-size: 22px; }
.print-sheet h2 { margin: 22px 0 8px; font-size: 15px; text-transform: uppercase; color: var(--text-2); }
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.print-grid div { display: flex; flex-direction: column; }
.print-grid small { color: var(--muted); text-transform: uppercase; font-size: 11px; }
.print-items { margin: 0; padding-left: 20px; line-height: 1.8; }
.print-total { margin-top: 24px; display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: var(--primary-soft); border-radius: 8px; }
.print-total strong { font-size: 24px; color: var(--primary); }
.print-foot { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; text-align: center; }

@media print {
  .no-print { display: none !important; }
  .print-page { background: #fff; padding: 0; }
  .print-sheet { box-shadow: none; padding: 0; max-width: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 1400px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
  .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module:nth-child(4n) { border-right: 1px solid var(--border); }
  .module:nth-child(2n) { border-right: 0; }
  .module:nth-last-child(-n+4) { border-bottom: 1px solid var(--border); }
  .module:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-grid; }
  .main { padding: 16px; }
  .topbar-title { text-align: left; }
  .topbar-title h1 { font-size: 17px; }
  .topbar-title p { font-size: 13px; }
  .grid-2, .instructions ul { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .kpis, .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-row strong { font-size: 16px; }
  .kpi-row .icon { width: 22px; height: 22px; }
  .topbar-date { display: none; }
  .modules { grid-template-columns: 1fr; }
  .module, .module:nth-child(n) { border-right: 0; border-bottom: 1px solid var(--border); }
  .module:last-child { border-bottom: 0; }
  .form-grid, .totals, .mini-kpis { grid-template-columns: 1fr; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
  .filters-summary { margin-left: 0; width: 100%; }
  .instructions-icon { display: none; }
  .print-sheet { padding: 20px; }
  .print-grid { grid-template-columns: 1fr; }
}

/* ======================================================================
   Celular (prioridade da área do dono)
   ====================================================================== */
.bottom-nav { display: none; }

@media (max-width: 960px) {
  .area-dono .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .05);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 4px 0; border: 0; background: none; font: inherit; font-size: 11px; font-weight: 600;
    color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav .active { color: var(--primary); }
  .area-dono .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .area-dono .menu-toggle { display: none; }
  .area-dono .sidebar { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

  /* Botão flutuante "Novo" */
  .area-dono .fab {
    position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 31;
    width: 56px; height: 56px; padding: 0; border-radius: 50%;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  }
  .area-dono .fab span { display: none; }
  .area-dono .fab .icon { width: 24px; height: 24px; }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  /* Evita o zoom automático do iPhone ao focar campos */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
  .btn { padding: 11px 16px; }
  .btn-sm { padding: 8px 11px; }
  .main { gap: 14px; }
  .card { padding: 14px; }
  .section-header h2 { font-size: 17px; }

  /* Tabelas viram cartões */
  .card.table-wrap, .table-wrap { overflow: visible; }
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tfoot, .table.cards tr { display: block; width: 100%; }
  .table.cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.cards tbody tr:last-child { border-bottom: 0; }
  .table.cards tbody tr:hover { background: none; }
  .table.cards td, .table.cards tfoot th {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 3px 0; border: 0; text-align: right; background: none;
  }
  .table.cards td::before, .table.cards tfoot th::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--muted);
  }
  .table.cards td:not([data-label])::before, .table.cards tfoot th:not([data-label])::before { content: none; }
  .table.cards td:first-child { font-size: 15px; }
  .table.cards td.empty { display: block; text-align: center; }
  .table.cards .cell { min-width: 0; text-align: right; }
  .table.cards td.actions { justify-content: flex-end; padding-top: 10px; }
  .table.cards td.actions:empty { display: none; }
  .table.cards td.actions .btn-sm { padding: 9px 13px; }
  .table.cards tfoot tr { background: #fafaf9; font-weight: 700; }
  /* Linhas com campos (itens do orçamento) */
  .table.cards td:has(input, select) { display: block; text-align: left; padding: 4px 0; }
  .table.cards td:has(input, select)::before { display: block; margin-bottom: 4px; }
  .items-table input, .items-table select, .items-table input[data-item-desc] { width: 100%; min-width: 0; }
  .items-table .w-sm, .items-table .w-md { width: 100%; }
  .items-table tr { border: 1px solid var(--border) !important; border-radius: var(--radius); margin-bottom: 10px; }

  .form-actions .btn, .form-actions .inline-form { flex: 1; }
  .form-actions .inline-form .btn { width: 100%; }
  .form-actions .spacer { display: none; }
  .tabs { flex: 1; }
  .tabs a { flex: 1; justify-content: center; }
}

@media (max-width: 600px) {
  /* Dashboard: módulos viram atalhos em grade */
  .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module, .module:nth-child(n) { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); align-items: center; text-align: center; padding: 14px 8px; }
  .module:nth-child(2n) { border-right: 0; }
  .module:nth-last-child(-n+2) { border-bottom: 0; }
  .module ul { display: none; }
  .module-head { flex-direction: column; gap: 8px; margin-bottom: 10px; }
  .module-head h3 { font-size: 12px; }
  .module-action { align-self: center; }
  .instructions { display: none; }
  .chart-box { height: 220px; }
}

/* ---------- PWA: instalação ---------- */
button.menu-item { width: 100%; font-family: inherit; cursor: pointer; text-align: left; }
.menu-install { border-style: dashed; color: var(--primary); }
.install-banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--primary); border-radius: var(--radius);
}
.install-banner[hidden] { display: none; }
.install-banner img { border-radius: 10px; flex-shrink: 0; }
.install-banner div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install-banner small { color: var(--text-2); }
.ios-help { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.ios-help-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 20px; margin-bottom: env(safe-area-inset-bottom); }
.ios-help-card ol { padding-left: 20px; line-height: 1.7; color: var(--text-2); }
@media (min-width: 961px) { .install-banner { display: none !important; } }
/* App instalado: respeita a área da barra de status */
@media (display-mode: standalone) { .main { padding-top: max(16px, env(safe-area-inset-top)); } }

/* Rodapé do menu sempre visível no celular (barra do navegador / gestos) */
.sidebar-user { padding-bottom: env(safe-area-inset-bottom); }
.logout-btn { flex-shrink: 0; }
