:root {
  --c-primary: #5C1A2A;
  --c-primary-dark: #3D0F1B;
  --c-primary-light: #7A2E3F;
  --c-accent: #C9A96E;
  --c-accent-dark: #B8924A;
  --c-bg: #FAF7F5;
  --c-bg-card: #FFFFFF;
  --c-text: #1F1F1F;
  --c-muted: #5A5A5A;
  --c-border: #E8E2DB;
  --c-success: #3A7D52;
  --c-danger: #A33E3E;
  --c-hot: #D4502A;
  --c-warm: #C9A96E;
  --c-cold: #7B8FA1;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-accent-dark); }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--c-primary);
  letter-spacing: -0.01em;
}

h1 { font-size: 28px; margin-bottom: 8px; }
h2 { font-size: 22px; margin-bottom: 12px; }
h3 { font-size: 18px; margin-bottom: 10px; font-weight: 700; }

/* === LAYOUT === */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--c-primary);
  color: #fff;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}

.sidebar-logo-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
}

.sidebar-logo-tagline {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-top: 4px;
  font-weight: 500;
}

.sidebar-nav { flex: 1; padding: 0 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.75);
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 14px;
  transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: rgba(201,169,110,0.15); color: var(--c-accent); }
.sidebar-nav .icon { font-size: 16px; opacity: .8; }

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}
.sidebar-user .name { color: #fff; font-weight: 500; margin-bottom: 2px; }
.sidebar-user a { color: var(--c-accent); font-size: 11px; }

.main { padding: 32px 40px; overflow-x: hidden; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-border);
}
.page-header .subtitle { font-size: 13px; color: var(--c-muted); }

/* === CARDS === */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 20px;
}

.card h3 {
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--c-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.card .value {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 600;
  color: var(--c-primary);
  line-height: 1.1;
}

.card .sub { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.card .delta { font-size: 12px; margin-top: 4px; font-weight: 500; }
.card .delta.up { color: var(--c-success); }
.card .delta.down { color: var(--c-danger); }

/* === TABLES === */
.table-wrap {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 24px;
}

.table-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-border);
}

.table-header h2 { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 12px 20px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg);
}
td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  font-size: 14px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(92,26,42,0.02); cursor: pointer; }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.badge-hot { background: rgba(212,80,42,0.12); color: var(--c-hot); }
.badge-warm { background: rgba(201,169,110,0.18); color: var(--c-accent-dark); }
.badge-cold { background: rgba(123,143,161,0.15); color: var(--c-cold); }
.badge-status { background: rgba(92,26,42,0.08); color: var(--c-primary); }
.badge-success { background: rgba(58,125,82,0.12); color: var(--c-success); }
.badge-danger { background: rgba(163,62,62,0.12); color: var(--c-danger); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--c-primary);
  color: #fff;
  border: 1px solid var(--c-primary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.btn:hover { background: var(--c-primary-light); color: #fff; }
.btn-secondary { background: #fff; color: var(--c-primary); }
.btn-secondary:hover { background: var(--c-bg); }
.btn-accent { background: var(--c-accent); border-color: var(--c-accent); }
.btn-accent:hover { background: var(--c-accent-dark); border-color: var(--c-accent-dark); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--c-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--c-primary); background: var(--c-bg); }

/* === FORMS === */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--c-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--c-primary);
}
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* === MODAL === */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  padding: 28px 32px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; color: var(--c-muted); line-height: 1;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* === CHART === */
.chart-wrap {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}
.chart-bars {
  display: flex; align-items: flex-end; gap: 12px;
  height: 200px;
  margin-top: 24px;
  padding: 0 8px;
  border-bottom: 1px solid var(--c-border);
}
.chart-bar {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  position: relative;
}
.chart-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--c-accent) 0%, var(--c-primary) 100%);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: all .3s;
  cursor: pointer;
}
.chart-bar-fill:hover { opacity: 0.85; }
.chart-bar-label {
  font-size: 10px;
  color: var(--c-muted);
  margin-top: 8px;
  letter-spacing: 0.3px;
}
.chart-bar-value {
  font-size: 11px;
  color: var(--c-primary);
  font-weight: 600;
  margin-bottom: 4px;
}

/* === FOOTER === */
.app-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
  font-size: 11px;
  color: var(--c-muted);
  text-align: center;
  letter-spacing: 0.5px;
}
.app-footer a { color: var(--c-accent-dark); font-weight: 500; }

/* === LOGIN === */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--c-bg) 0%, var(--c-border) 100%);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(92,26,42,0.08);
  border: 1px solid var(--c-border);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--c-border);
}
.login-logo .name {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 600;
  color: var(--c-primary);
}
.login-logo .tagline {
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-top: 6px;
}
.login-error {
  background: rgba(163,62,62,0.08);
  color: var(--c-danger);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.login-error.show { display: block; }
.login-page .app-footer {
  position: fixed; bottom: 16px; left: 0; right: 0;
  margin: 0; border: none;
}

/* === EMPTY === */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--c-muted);
  font-size: 13px;
}
.empty .icon { font-size: 32px; margin-bottom: 12px; opacity: .4; }

/* === TOGGLE SENHA === */
.pwd-wrap { position: relative; display: flex; align-items: center; }
.pwd-wrap input { padding-right: 44px; }
.pwd-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-muted); border-radius: 6px;
  transition: all .2s;
}
.pwd-toggle:hover { color: var(--c-primary); background: var(--c-bg); }

/* === FAB (mobile floating action button) === */
.fab {
  display: none;
  position: fixed;
  bottom: 76px; right: 16px;
  z-index: 90;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  border: none;
  font-size: 26px;
  font-weight: 300;
  box-shadow: 0 6px 20px rgba(92,26,42,0.35);
  cursor: pointer;
  align-items: center; justify-content: center;
  line-height: 1;
  padding: 0 0 4px 0;
}
.fab:active { transform: scale(0.94); }

/* === phone/whatsapp links nas listas === */
.phone-cell { display: inline-flex; align-items: center; gap: 6px; }
.phone-link {
  color: var(--c-primary);
  text-decoration: none;
  font-weight: 500;
}
.phone-link:hover { color: var(--c-accent-dark); text-decoration: underline; }
.wa-link {
  display: inline-flex; align-items: center; gap: 4px;
  background: #25D366; color: #fff !important;
  padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-decoration: none !important;
  transition: background .15s;
}
.wa-link:hover { background: #128C7E; color: #fff !important; }
.wa-link::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M17.5 14.4c-.3-.1-1.8-.9-2-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.2-.2.2-.3.2-.6.1-.3-.1-1.3-.5-2.4-1.5-.9-.8-1.5-1.8-1.7-2-.2-.3 0-.5.1-.6.1-.1.3-.3.4-.5.1-.2.2-.3.3-.5.1-.2 0-.4 0-.5l-.9-2.2c-.2-.6-.5-.5-.7-.5h-.6c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.5s1.1 2.9 1.2 3.1c.1.2 2.1 3.2 5.1 4.5.7.3 1.3.5 1.7.6.7.2 1.4.2 1.9.1.6-.1 1.8-.7 2-1.4.2-.7.2-1.3.2-1.4-.1-.1-.3-.2-.6-.3M12 2C6.5 2 2 6.5 2 12c0 2.1.6 4.1 1.5 5.8L2 22l4.4-1.5c1.7.9 3.6 1.4 5.6 1.4 5.5 0 10-4.5 10-10S17.5 2 12 2z'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M17.5 14.4c-.3-.1-1.8-.9-2-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.2-.2.2-.3.2-.6.1-.3-.1-1.3-.5-2.4-1.5-.9-.8-1.5-1.8-1.7-2-.2-.3 0-.5.1-.6.1-.1.3-.3.4-.5.1-.2.2-.3.3-.5.1-.2 0-.4 0-.5l-.9-2.2c-.2-.6-.5-.5-.7-.5h-.6c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.5s1.1 2.9 1.2 3.1c.1.2 2.1 3.2 5.1 4.5.7.3 1.3.5 1.7.6.7.2 1.4.2 1.9.1.6-.1 1.8-.7 2-1.4.2-.7.2-1.3.2-1.4-.1-.1-.3-.2-.6-.3M12 2C6.5 2 2 6.5 2 12c0 2.1.6 4.1 1.5 5.8L2 22l4.4-1.5c1.7.9 3.6 1.4 5.6 1.4 5.5 0 10-4.5 10-10S17.5 2 12 2z'/></svg>") center/contain no-repeat;
}

/* === STALE indicator (dias sem contato) === */
.stale {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.stale-fresh { background: rgba(58,125,82,0.12); color: var(--c-success); }
.stale-warn { background: rgba(201,169,110,0.20); color: var(--c-accent-dark); }
.stale-cold { background: rgba(163,62,62,0.13); color: var(--c-danger); }
.stale-none { background: rgba(123,143,161,0.13); color: var(--c-cold); font-style: italic; }

/* === Nav badge === */
.sidebar-nav a { position: relative; }
.nav-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  background: var(--c-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 6px;
  height: 16px;
  min-width: 16px;
  border-radius: 8px;
  margin-left: 6px;
}
.badge-overdue { background: #D4502A; }

/* === Global search === */
.global-search-bar {
  margin: -8px 0 18px;
  position: relative;
}
.global-search-wrap {
  position: relative;
  max-width: 480px;
}
.global-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: var(--c-muted); pointer-events: none;
}
#globalSearch {
  width: 100%;
  padding: 10px 14px 10px 36px;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--c-text);
}
#globalSearch:focus { outline: none; border-color: var(--c-primary); }
.global-search-results {
  display: none;
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  margin-top: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  z-index: 50;
  max-height: 360px;
  overflow-y: auto;
}
.global-search-results.open { display: block; }
.search-item {
  display: block;
  padding: 10px 14px;
  color: var(--c-text) !important;
  border-bottom: 1px solid var(--c-border);
  text-decoration: none !important;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--c-bg); }
.search-item strong { display: block; font-size: 14px; font-weight: 500; }
.search-item span { font-size: 11px; color: var(--c-muted); }
.search-empty { padding: 14px; color: var(--c-muted); font-size: 13px; text-align: center; }

/* === Drawer lateral === */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  z-index: 110;
}
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%; max-width: 520px;
  background: var(--c-bg);
  z-index: 111;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 30px rgba(0,0,0,0.18);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-bg-card);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.drawer-header h2 { margin: 0; font-size: 22px; }
.drawer-close {
  background: none; border: none; cursor: pointer;
  font-size: 26px; color: var(--c-muted); line-height: 1; padding: 0;
}
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 22px 26px;
}
.drawer-footer {
  padding: 14px 26px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg-card);
  display: flex; gap: 8px; justify-content: flex-end;
}
.drawer-tabs {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--c-border);
}
.drawer-tab {
  padding: 8px 14px;
  background: none; border: none; cursor: pointer;
  color: var(--c-muted); font-family: inherit; font-size: 13px;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.drawer-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.drawer-section { margin-bottom: 18px; }
.drawer-section h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--c-muted); margin-bottom: 8px; font-family: var(--font-body); font-weight: 600; }

/* === Timeline histórico === */
.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ''; position: absolute; top: 6px; bottom: 6px; left: 5px;
  width: 1px; background: var(--c-border);
}
.timeline-item { position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: -16px; top: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c-accent); border: 2px solid var(--c-bg-card);
}
.timeline-meta { font-size: 11px; color: var(--c-muted); }
.timeline-text { font-size: 13px; margin-top: 2px; }
.timeline-text strong { color: var(--c-primary); }

/* === KANBAN === */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(240px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  display: flex; flex-direction: column;
  min-height: 400px;
  transition: background .15s, border-color .15s;
}
.kanban-col.drag-over { background: rgba(201,169,110,0.08); border-color: var(--c-accent); }
.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--c-muted);
  font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.kanban-col-count { background: var(--c-bg); color: var(--c-primary); padding: 1px 8px; border-radius: 10px; font-weight: 700; font-size: 11px; letter-spacing: 0; }
.kanban-col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.kanban-card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(92,26,42,0.08); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-name { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.kanban-card-meta { font-size: 11px; color: var(--c-muted); }
.kanban-card-foot { margin-top: 8px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; }
  .kanban-col { min-height: auto; }
  .drawer { max-width: 100%; }
  .drawer-header { padding: 16px 18px 12px; }
  .drawer-body { padding: 16px 18px; }
  .global-search-bar { margin-top: -4px; }
}

/* === RESPONSIVE — mobile-first === */
@media (max-width: 768px) {
  /* layout sidebar -> bottom nav */
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  body { padding-bottom: 0; }
  .main { padding: 16px 14px calc(80px + env(safe-area-inset-bottom, 0px)); overflow-x: hidden; }

  /* SIDEBAR vira BOTTOM NAV */
  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    width: 100%;
    padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 6px);
    background: var(--c-primary);
    border-top: 1px solid rgba(255,255,255,0.08);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
  }
  .sidebar-logo, .sidebar-user { display: none; }
  .sidebar-nav {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
  }
  .sidebar-nav a {
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    font-size: 10px;
    margin-bottom: 0;
    border-radius: 8px;
    min-width: 0;
    text-align: center;
    letter-spacing: 0.01em;
    line-height: 1.1;
  }
  .sidebar-nav a .icon { font-size: 20px; opacity: 0.95; }
  .sidebar-nav a.active { background: rgba(201,169,110,0.18); color: var(--c-accent); }

  /* HEADER compacto */
  .page-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    gap: 12px;
  }
  .page-header h1 { font-size: 22px; margin-bottom: 2px; line-height: 1.1; }
  .page-header .subtitle { font-size: 11px; }
  .page-header > div:first-child { flex: 1; min-width: 0; }
  .page-header > button, .page-header > div:last-child > button { display: none; }
  .fab { display: flex; }

  /* CARDS em 2 colunas */
  .cards-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .card { padding: 14px; }
  .card h3 { font-size: 10px; letter-spacing: 1px; margin-bottom: 6px; }
  .card .value { font-size: 22px; }
  .card .sub, .card .delta { font-size: 10.5px; }

  /* TABELAS scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 560px; font-size: 12.5px; }
  .table-wrap th { padding: 10px 12px; font-size: 9.5px; letter-spacing: 1px; }
  .table-wrap td { padding: 11px 12px; }
  .table-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .table-header h2 { font-size: 16px; }
  .table-header > div { width: 100%; flex-wrap: wrap; }
  .table-header input, .table-header select {
    flex: 1 1 auto;
    min-width: 0 !important;
    width: 100% !important;
  }

  /* CHARTS */
  .chart-wrap { padding: 16px; }
  .chart-bars { height: 160px; gap: 6px; }
  .chart-bar-label { font-size: 9px; }
  .chart-bar-value { font-size: 9.5px; }

  /* FORMS */
  .field-row { grid-template-columns: 1fr; gap: 10px; }
  .field input, .field select, .field textarea { font-size: 16px; } /* evita zoom iOS */
  .field label { font-size: 10px; }

  /* MODAL */
  .modal-overlay { padding: 12px; align-items: flex-start; padding-top: 24px; }
  .modal {
    padding: 20px 18px;
    max-height: calc(100vh - 48px);
    border-radius: 12px;
  }
  .modal-header h2 { font-size: 18px; }
  .modal-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
    margin-top: 18px;
  }
  .modal-footer .btn {
    flex: 1 1 auto;
    min-width: 100px;
    justify-content: center;
  }
  .modal-footer .btn-ghost { flex: 0 0 auto; min-width: 0; }

  /* BTNs touch-friendly */
  .btn { padding: 10px 14px; font-size: 13px; min-height: 40px; }
  .btn-sm { padding: 6px 10px; font-size: 11.5px; min-height: 32px; }

  /* twocol das pages -> 1 coluna */
  .twocol { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* APP FOOTER fica longe do bottom nav */
  .app-footer { display: none; }
}

@media (max-width: 380px) {
  .main { padding: 12px 10px calc(76px + env(safe-area-inset-bottom, 0px)); }
  .sidebar-nav a { font-size: 9px; padding: 6px 1px; }
  .sidebar-nav a .icon { font-size: 18px; }
  .card { padding: 12px; }
  .card .value { font-size: 19px; }
  .page-header h1 { font-size: 19px; }
  .cards-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
