:root {
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --bg4: #252d40;
  --border: #2a3347;
  --border2: #3a4560;
  --accent: #3b7ddd;
  --accent2: #5b9bd5;
  --accent-glow: rgba(59,125,221,0.2);
  --green: #2ec27e;
  --green-bg: rgba(46,194,126,0.12);
  --orange: #e8a730;
  --orange-bg: rgba(232,167,48,0.12);
  --red: #e05c5c;
  --red-bg: rgba(224,92,92,0.12);
  --purple: #9b59b6;
  --purple-bg: rgba(155,89,182,0.12);
  --text: #e8eaf0;
  --text2: #9aa3b8;
  --text3: #5c6478;
  --radius: 10px;
  --radius2: 6px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

/* ====== TEMA CLARO ====== */
body.theme-light {
  --bg:          #f0f4f8;
  --bg2:         #ffffff;
  --bg3:         #f8fafc;
  --bg4:         #edf2f7;
  --border:      #dde3ec;
  --border2:     #c8d3e0;
  --accent:      #2563eb;
  --accent2:     #1d4ed8;
  --accent-glow: rgba(37,99,235,0.12);
  --green:       #16a34a;
  --green-bg:    rgba(22,163,74,0.10);
  --orange:      #d97706;
  --orange-bg:   rgba(217,119,6,0.10);
  --red:         #dc2626;
  --red-bg:      rgba(220,38,38,0.10);
  --purple:      #7c3aed;
  --purple-bg:   rgba(124,58,237,0.10);
  --text:        #1e293b;
  --text2:       #475569;
  --text3:       #94a3b8;
  --shadow:      0 4px 20px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  min-height: 80px;
  display: flex;
  align-items: center;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #6ea8fe);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.logo-text { font-size: 18px; font-weight: 700; color: var(--text); }
.logo-sub { font-size: 10px; color: var(--text3); letter-spacing: 1.5px; text-transform: uppercase; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-label {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius2);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent2); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-text { font-size: 13px; font-weight: 500; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.nav-badge.green { background: var(--green); }
.nav-badge.orange { background: var(--orange); }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius2);
  cursor: pointer; transition: var(--transition);
}
.user-card:hover { background: var(--bg3); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text3); }

/* MAIN */
.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: 58px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 90;
}

.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-sub { font-size: 12px; color: var(--text3); margin-left: 6px; }
.topbar-spacer { flex: 1; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 6px 12px;
  width: 220px;
}

.search-box input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: 13px; width: 100%;
}

.search-box input::placeholder { color: var(--text3); }
.search-icon { color: var(--text3); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius2);
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none;
  transition: var(--transition);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4d8ee0; box-shadow: 0 0 16px var(--accent-glow); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* CONTENT */
.content { flex: 1; padding: 24px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.kpi-card:hover { border-color: var(--border2); transform: translateY(-1px); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.kpi-card.blue::before { background: linear-gradient(90deg, var(--accent), #6ea8fe); }
.kpi-card.green::before { background: linear-gradient(90deg, var(--green), #5dd9a0); }
.kpi-card.orange::before { background: linear-gradient(90deg, var(--orange), #f0c060); }
.kpi-card.purple::before { background: linear-gradient(90deg, var(--purple), #c07de8); }

.kpi-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.kpi-label { font-size: 12px; color: var(--text3); font-weight: 500; letter-spacing: 0.5px; text-transform: uppercase; }

.kpi-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.kpi-icon-wrap.blue { background: var(--accent-glow); }
.kpi-icon-wrap.green { background: var(--green-bg); }
.kpi-icon-wrap.orange { background: var(--orange-bg); }
.kpi-icon-wrap.purple { background: var(--purple-bg); }

.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; }
.kpi-change { font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.card-body { padding: 20px; }

canvas { max-width: 100%; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 13px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--accent-glow); color: var(--accent2); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text3); }

/* PROGRESS */
.progress-bar {
  height: 5px;
  background: var(--bg4);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #6ea8fe);
  transition: width 0.5s ease;
}
.progress-fill.green { background: linear-gradient(90deg, var(--green), #5dd9a0); }
.progress-fill.orange { background: linear-gradient(90deg, var(--orange), #f0c060); }
.progress-fill.red { background: linear-gradient(90deg, var(--red), #f07070); }

/* AVATAR GROUP */
.avatar-group { display: flex; }
.avatar-sm {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--bg2);
  margin-left: -6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  background: var(--accent);
}
.avatar-sm:first-child { margin-left: 0; }

/* KANBAN */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  min-height: 500px;
}

.kanban-col {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}

.kanban-dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban-col-title { font-size: 13px; font-weight: 600; }
.kanban-count {
  margin-left: auto;
  background: var(--bg4);
  color: var(--text3);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.kanban-cards { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 10px; }

.kanban-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 13px;
  cursor: grab;
  transition: var(--transition);
}
.kanban-card:hover { border-color: var(--border2); box-shadow: var(--shadow); transform: translateY(-1px); }
.kanban-card.dragging { opacity: 0.4; cursor: grabbing; }

.kanban-col.drag-over { background: var(--bg3); border-color: var(--accent); }

.kanban-card-title { font-size: 13px; font-weight: 500; margin-bottom: 8px; line-height: 1.4; }
.kanban-card-client { font-size: 11px; color: var(--text3); margin-bottom: 10px; }
.kanban-card-footer { display: flex; align-items: center; justify-content: space-between; }
.kanban-value { font-size: 12px; font-weight: 600; color: var(--green); }

.kanban-add {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  color: var(--text3);
  font-size: 12px;
  margin-top: 4px;
  transition: var(--transition);
}
.kanban-add:hover { border-color: var(--accent); color: var(--accent2); }

/* CLIENTS */
.client-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}

.client-info { display: flex; align-items: center; gap: 10px; }
.client-name { font-size: 13px; font-weight: 500; }

/* ACTIVITIES */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

.activity-icon-wrap {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.activity-body { flex: 1; }
.activity-text { font-size: 13px; line-height: 1.5; }
.activity-text strong { color: var(--text); }
.activity-time { font-size: 11px; color: var(--text3); margin-top: 3px; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalIn 0.2s ease;
}
.modal.modal-wide { width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg4); color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* FORM */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text2); }
.form-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input option { background: var(--bg3); }

textarea.form-input { resize: vertical; min-height: 80px; }

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* STAT MINI */
.stat-mini { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-mini:last-child { border-bottom: none; }
.stat-mini-label { font-size: 13px; color: var(--text2); }
.stat-mini-val { font-size: 13px; font-weight: 600; }

/* TOAST */
.toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius2);
  padding: 12px 16px;
  min-width: 280px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  display: flex; align-items: center; gap: 10px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.error { border-left-color: var(--red); }
.toast-text { font-size: 13px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* SECTION HEADER */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 18px; font-weight: 700; }
.section-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* FILTER BAR */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  transition: var(--transition);
}
.filter-btn:hover { border-color: var(--border2); color: var(--text); }
.filter-btn.active { background: var(--accent-glow); color: var(--accent2); border-color: var(--accent); }

/* LEGEND */
.legend-list { display: flex; flex-direction: column; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 10px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-label { font-size: 12px; color: var(--text2); flex: 1; }
.legend-value { font-size: 12px; font-weight: 600; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  margin-bottom: -1px;
}
.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent2); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* RESPONSIVE */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ====== MOBILE NAV — oculto por padrão ====== */
.mobile-nav        { display: none; }
.mobile-menu-overlay { display: none; }

/* Impede que o scroll horizontal expanda além da tela */
@media (max-width: 768px) {
  html { overflow-x: hidden; }
  body { overflow-x: hidden; max-width: 100vw; }
}

/* Bottom sheet do menu mobile — display controlado por JS */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  z-index: 300;
  background: rgba(0,0,0,0);
  transition: background 0.25s;
}
.mobile-menu-overlay.open {
  background: rgba(0,0,0,0.55);
}

.mobile-menu-sheet {
  width: 100%;
  background: var(--bg2);
  border-radius: 18px 18px 0 0;
  padding: 8px 0 20px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.4);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
}
.mobile-menu-overlay.open .mobile-menu-sheet { transform: translateY(0); }

.mobile-menu-handle {
  width: 36px; height: 4px;
  background: var(--border2);
  border-radius: 2px;
  margin: 8px auto 14px;
}
.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 24px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.mobile-menu-item:active { background: var(--bg3); }
.mobile-menu-item .mmi-icon { font-size: 20px; width: 28px; text-align: center; }
.mobile-menu-divider { border: none; border-top: 1px solid var(--border); margin: 6px 0; }
.mobile-menu-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

/* ====== MOBILE LAYOUT ====== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: 76px; }

  /* Topbar */
  .topbar { padding: 12px 16px; gap: 10px; position: sticky; top: 0; z-index: 100; }
  .topbar-title { font-size: 16px; }
  .topbar-sub, .topbar-spacer, .search-box { display: none; }
  #btn-new { padding: 7px 14px; font-size: 13px; }

  /* Content */
  .content { padding: 12px; }

  /* Grids */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-change { font-size: 11px; }

  /* Section header */
  .section-header { flex-wrap: wrap; gap: 10px; }

  /* Tables */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 540px; }

  /* Filter bar */
  .filter-bar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; gap: 6px; }
  .filter-btn { white-space: nowrap; flex-shrink: 0; }

  /* Kanban coluna única */
  .kanban-board { grid-template-columns: 1fr; }

  /* Calendar empilhado */
  .cal-wrap { flex-direction: column; height: auto; }
  .cal-day-panel { min-height: 300px; }
  .cal-cell { min-height: 52px; }

  /* Modal como bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-overlay .modal,
  .modal-overlay .modal.modal-wide {
    border-radius: 18px 18px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    width: 100%;
    margin: 0;
  }

  /* Cards */
  .card { border-radius: 10px; }
  .card-header { padding: 14px 16px 10px; }
  .card-body { padding: 12px 16px; }

  /* Bottom nav */
  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 10px 4px 8px;
    cursor: pointer;
    color: var(--text3);
    transition: 0.15s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item.active { color: var(--accent); }
  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0; left: 25%; right: 25%;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
  }
  .mobile-nav-icon { font-size: 21px; line-height: 1; }
  .mobile-nav-label { font-size: 10px; font-weight: 500; }
}

/* ====== TABELAS MOBILE — CARDS ====== */
@media (max-width: 768px) {
  /* Remove min-width das tabelas */
  table { min-width: unset; width: 100%; }

  /* Clientes: vira cards */
  #clientes-tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  #clientes-tbody td { display: none; border: none; padding: 0; }
  /* Mostra: Empresa (1), Contato (2), Status (6), Ações (7) */
  #clientes-tbody td:nth-child(1) {
    display: block; flex: 1; font-weight: 600; font-size: 14px;
  }
  #clientes-tbody td:nth-child(2) {
    display: block; width: 100%; font-size: 12px; color: var(--text3);
  }
  #clientes-tbody td:nth-child(6) {
    display: block; margin-left: auto;
  }
  #clientes-tbody td:nth-child(7) {
    display: block;
  }
  /* Esconde cabeçalho das tabelas que viraram cards */
  #page-clientes thead { display: none; }
  #page-clientes .card { padding: 0; }
  #page-clientes .table-wrap { overflow-x: unset; }

  /* Serviços: esconde colunas menos importantes */
  #page-projetos table { min-width: unset; }
  #page-projetos thead th:nth-child(3),
  #page-projetos thead th:nth-child(4),
  #page-projetos tbody td:nth-child(3),
  #page-projetos tbody td:nth-child(4) { display: none; }

  /* Orçamentos: esconde colunas menos importantes */
  #page-orcamentos thead th:nth-child(3),
  #page-orcamentos thead th:nth-child(5),
  #page-orcamentos tbody td:nth-child(3),
  #page-orcamentos tbody td:nth-child(5) { display: none; }
}

/* ====== CALENDÁRIO DE ATIVIDADES ====== */
.cal-wrap {
  display: flex;
  gap: 20px;
  height: calc(100vh - 118px);
}

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

.cal-nav {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.cal-month-label {
  font-size: 17px; font-weight: 700;
  text-transform: capitalize; flex: 1; text-align: center;
}

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}
.cal-weekday {
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--text3); padding: 4px 0;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; flex: 1;
}

.cal-cell {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius2); padding: 8px 6px 6px;
  cursor: pointer; transition: var(--transition);
  display: flex; flex-direction: column; align-items: center;
  min-height: 72px; position: relative;
}
.cal-cell:hover { border-color: var(--accent); background: var(--bg3); }
.cal-cell-empty { background: transparent; border-color: transparent; cursor: default; }
.cal-cell-empty:hover { background: transparent; border-color: transparent; }

.cal-cell.cal-today { border-color: var(--accent); }
.cal-cell.cal-today .cal-day-num {
  background: var(--accent); color: #fff;
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cal-cell.cal-selected { background: rgba(59,125,221,0.12); border-color: var(--accent); }

.cal-day-num {
  font-size: 13px; font-weight: 600;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}

.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
}
.cal-dot.dot-2 { background: var(--green); }
.cal-dot.dot-3 { background: var(--orange); }

/* Painel lateral do dia */
.cal-day-panel {
  width: 320px; flex-shrink: 0;
  display: flex; flex-direction: column;
}
.cal-day-panel .card { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.cal-panel-list { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cal-panel-form {
  padding: 14px 16px; border-top: 1px solid var(--border);
  background: var(--bg3); border-radius: 0 0 var(--radius) var(--radius);
}

.cal-act-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cal-act-item:last-child { border-bottom: none; }
.cal-act-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.cal-act-body { flex: 1; min-width: 0; }
.cal-act-text { font-size: 13px; font-weight: 500; line-height: 1.4; }
.cal-act-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.cal-act-del {
  background: none; border: none; cursor: pointer;
  color: var(--text3); font-size: 14px; padding: 2px 4px;
  border-radius: 4px; transition: var(--transition); flex-shrink: 0;
}
.cal-act-del:hover { color: var(--red); }
