/* ============================================================
   Mirantes 360 — Design System
   ============================================================ */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #15213a;
  --muted: #6d7890;
  --line: #e4e9f1;
  --nav: #0b1830;
  --nav-soft: #142542;
  --primary: #176b87;
  --primary-2: #0f536c;
  --accent: #d7a94a;
  --success: #13805b;
  --warning: #bd7620;
  --danger: #c74646;
  --info: #356bc4;
  --border-color: var(--line);
  --text-main: var(--text);
  --text-muted: var(--muted);
  --card-bg: var(--surface);
  --border: var(--line);
  --shadow: 0 10px 30px rgba(20, 42, 71, .08);
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #08111f;
  --surface: #101d30;
  --surface-2: #15243a;
  --text: #eef4ff;
  --muted: #9cacbf;
  --line: #26364d;
  --nav: #050c16;
  --nav-soft: #14233a;
  --primary: #36a0bd;
  --primary-2: #23839e;
  --border-color: var(--line);
  --text-main: var(--text);
  --text-muted: var(--muted);
  --card-bg: var(--surface);
  --border: var(--line);
  --shadow: 0 14px 34px rgba(0, 0, 0, .26);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
  outline-offset: 2px;
}

/* ---------- Estrutura principal ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: var(--nav);
  color: #e8eef8;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 1100;
  transition: transform .25s ease;
}
.workspace {
  flex: 1;
  min-width: 0;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  padding-top: 76px;
}

/* ---------- Sidebar / Navegação ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-logo { width: 64px; height: 64px; object-fit: cover; background: transparent; border-radius: 50%; flex-shrink: 0; max-width: 100%; box-shadow: none; overflow: hidden; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #2a91aa, #17617a);
  font-weight: 900; color: #fff;
  box-shadow: 0 8px 22px rgba(20, 130, 155, .32);
}
.brand-mark span { font-size: 9px; color: #f3cf77; }
.brand strong, .brand small, .sidebar-foot strong, .sidebar-foot small { display: block; }
.brand strong { font-size: 16px; }
.brand small { color: #91a2bc; font-size: 11px; }

/* ---------- Nav Groups (Dropdown Accordion) ---------- */
.nav-group { margin-bottom: 3px; }

.nav-group-toggle {
  width: 100%; border: 0; background: transparent; cursor: pointer;
  color: #adbbce; border-radius: 11px; padding: 9px 11px; margin: 1px 0;
  display: flex; align-items: center; gap: 11px; text-align: left;
  transition: background .18s, color .18s;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group.open .nav-group-toggle { color: #fff; background: rgba(255,255,255,.04); }

.nav-group-label {
  flex: 1; font-size: 12px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-group-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; opacity: .55; flex-shrink: 0;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.nav-group.open .nav-group-arrow { transform: rotate(180deg); opacity: .9; }
.nav-group-arrow svg { width: 14px; height: 14px; }

.nav-group-items {
  display: none; padding-left: 14px; overflow: hidden;
  border-left: 1px solid rgba(255,255,255,.07); margin-left: 22px; margin-bottom: 4px;
}
.nav-group.open .nav-group-items { display: block; }

/* Animated open */
.nav-group-items.animating {
  display: block;
  animation: navGroupOpen .22s cubic-bezier(.4,0,.2,1) both;
}
@keyframes navGroupOpen {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-item {
  width: 100%; border: 0; background: transparent; color: #9aadbe;
  border-radius: 8px; padding: 7px 10px; margin: 1px 0;
  display: flex; align-items: center; gap: 9px; text-align: left;
  text-decoration: none; font-size: 12.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(35,135,161,.25); color: #7dd3e8; font-weight: 700; }
.nav-item.active .nav-item-dot { background: #7dd3e8; box-shadow: 0 0 0 3px rgba(125,211,232,.2); }

.nav-item-dot {
  width: 5px; height: 5px; border-radius: 50%; background: rgba(255,255,255,.25); flex-shrink: 0;
  transition: background .2s, box-shadow .2s;
}
.nav-item:hover .nav-item-dot { background: rgba(255,255,255,.6); }

.nav-item-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-icon {
  width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255,255,255,.08);
  display: grid; place-items: center; flex-shrink: 0;
}
.nav-icon svg { width: 14px; height: 14px; }
.nav-group.open .nav-group-toggle .nav-icon { background: rgba(35,135,161,.35); color: #7dd3e8; }

.nav-count {
  margin-left: auto; background: #d9a844; color: #102039;
  font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 20px; flex-shrink: 0;
}
.sidebar nav { overflow-y: auto; padding-right: 3px; scrollbar-width: thin; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .08); }
.system-status { display: flex; align-items: center; gap: 10px; padding: 9px; }
.system-status i { width: 8px; height: 8px; border-radius: 50%; background: #48ce91; box-shadow: 0 0 0 5px rgba(72, 206, 145, .12); }
.system-status strong { font-size: 11px; }
.system-status small { font-size: 9px; color: #7f91aa; }
.profile-mini {
  width: 100%; border: 0; background: rgba(255, 255, 255, .06); color: #fff;
  border-radius: 12px; padding: 9px; display: flex; gap: 9px; align-items: center; text-align: left;
}
.profile-mini span:nth-child(2) { min-width: 0; flex: 1; }
.profile-mini strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; display: block; }
.profile-mini small { font-size: 9px; color: #7f91aa; display: block; }
.profile-mini b { color: #7f91aa; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2a91aa 0%, #17617a 100%);
  color: #ffffff;
  display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: .03em;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .35), 0 2px 6px rgba(0, 0, 0, .12);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: transform .2s ease, box-shadow .2s ease;
}
.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px; padding: 10px 12px; border-radius: 11px;
  color: #e8eef8; background: rgba(255, 255, 255, .06);
  font-size: 13px; font-weight: 700; text-decoration: none; transition: .2s;
}
.logout-btn:hover { background: rgba(199, 70, 70, .28); color: #fff; }

/* ---------- Topbar ---------- */
.topbar {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
  min-height: 76px;
  position: fixed;
  top: 0;
  left: 260px;
  right: 0;
  z-index: 999;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.3px; }
.topbar-sub { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.topbar .greet { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 2px; font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.avatar-btn {
  width: 42px; height: 42px; border-radius: 50%; padding: 2px;
  border: 2px solid color-mix(in srgb, var(--primary) 35%, var(--line));
  background: var(--surface); display: grid; place-items: center; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 15%, transparent);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.avatar-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px) scale(1.06);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 35%, transparent);
}
.avatar-btn .avatar { width: 100%; height: 100%; font-size: 13px; }
.icon-btn {
  width: 40px; height: 40px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  border-radius: 12px; display: grid; place-items: center; font-size: 17px;
  transition: .2s;
}
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }
.menu-btn { display: none; }
.searchbox {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; height: 40px;
}
.searchbox span { color: var(--muted); }
.searchbox input { border: 0; background: transparent; color: var(--text); outline: none; width: 220px; }
.searchbox input::placeholder { color: var(--muted); }
.notification-btn { position: relative; }
.notification-btn span {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 800; min-width: 17px; height: 17px;
  border-radius: 10px; display: grid; place-items: center;
  padding: 0 4px;
}

/* ---------- Botões ---------- */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--primary-2) 60%, transparent);
  border-radius: 12px; padding: 11px 18px;
  font-weight: 700; font-size: 13.5px; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(20, 42, 71, .06), 0 6px 16px color-mix(in srgb, var(--primary) 22%, transparent);
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.primary-btn:hover {
  background: linear-gradient(180deg, var(--primary-2), var(--primary-2));
  box-shadow: 0 2px 4px rgba(20, 42, 71, .08), 0 10px 22px color-mix(in srgb, var(--primary) 30%, transparent);
  transform: translateY(-1px);
}
.primary-btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(20, 42, 71, .12); }
.primary-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 32%, transparent); outline-offset: 2px; }

.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(20, 42, 71, .04);
  transition: .2s ease;
}
.secondary-btn:hover {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 14%, transparent);
  transform: translateY(-1px);
}
.secondary-btn:active { transform: translateY(0); box-shadow: 0 1px 3px rgba(20, 42, 71, .08); }
.secondary-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent); outline-offset: 2px; }

.danger-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(180deg, var(--danger), color-mix(in srgb, var(--danger) 85%, #000));
  color: #fff; border: 1px solid color-mix(in srgb, var(--danger) 70%, #000);
  border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 13px; cursor: pointer;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(20, 42, 71, .06), 0 6px 16px color-mix(in srgb, var(--danger) 22%, transparent);
  transition: background .2s ease, transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.danger-btn:hover {
  box-shadow: 0 2px 4px rgba(20, 42, 71, .08), 0 10px 22px color-mix(in srgb, var(--danger) 30%, transparent);
  filter: brightness(1.04); transform: translateY(-1px);
}
.danger-btn:active { transform: translateY(0); filter: brightness(.98); box-shadow: 0 1px 3px rgba(20, 42, 71, .12); }
.danger-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--danger) 30%, transparent); outline-offset: 2px; }

/* ---------- Conteúdo / Página ---------- */
.page { padding: 28px 26px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- Cartões ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.module-intro { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.module-intro h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.3px; }
.module-intro p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 640px; }
.module-action { flex-shrink: 0; }

/* ---------- Estatísticas / KPIs ---------- */
.module-stats, .kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.mini-stat, .kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.mini-stat > span, .kpi-head { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini-stat strong, .kpi-value { display: block; font-size: 24px; font-weight: 800; margin: 6px 0; letter-spacing: -.5px; }
.mini-stat small, .kpi-sub { color: var(--muted); font-size: 12px; }

/* ---------- Tabelas ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.table-toolbar h3 { margin: 0; font-size: 16px; }
.table-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-input {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; color: var(--text);
  outline: none; min-width: 200px;
}
.filter-input:focus { border-color: var(--primary); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 22px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; background: var(--surface-2); }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
tbody tr:last-child td { border-bottom: 0; }

.person-cell { display: flex; align-items: center; gap: 12px; }
.table-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 22%, var(--surface)) 0%, color-mix(in srgb, var(--primary) 10%, var(--surface-2)) 100%);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  display: grid; place-items: center;
  font-weight: 800; font-size: 12px; letter-spacing: .03em; flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .05);
  transition: transform .2s ease, box-shadow .2s ease;
}
.table-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--primary) 20%, transparent);
}
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.success { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
.badge.warning { background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); }
.badge.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.row-action {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(20, 42, 71, .04);
  text-decoration: none; font-weight: 800; cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .15s ease;
}
.row-action:hover {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  color: var(--primary);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--primary) 16%, transparent);
  transform: translateY(-1px);
}
.row-action:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(20, 42, 71, .08); }
.row-action:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent); outline-offset: 1px; }

/* ---------- Paginação ---------- */
.pagination { display: flex; gap: 6px; align-items: center; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pagination-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 6px 11px; font-size: 11px; text-decoration: none; }
.pagination-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

/* ---------- Dashboard / Morador ---------- */
.hero-strip { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hero-strip h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.3px; }
.hero-strip p { margin: 0; color: var(--muted); font-size: 13px; }
.period-control { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.period-control button { border: 0; background: transparent; color: var(--muted); padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 12px; transition: .2s; }
.period-control button.active { background: var(--primary); color: #fff; }

.kpi-card { position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; inset: 0; background: var(--tint, var(--surface-2)); opacity: .5; z-index: 0; }
.kpi-head, .kpi-value, .kpi-foot { position: relative; z-index: 1; }
.kpi-head { display: flex; justify-content: space-between; align-items: center; color: var(--tone, var(--muted)); }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--tone, var(--primary)) 14%, transparent); color: var(--tone, var(--primary)); display: grid; place-items: center; font-style: normal; font-weight: 800; }
.kpi-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.trend { font-weight: 700; }
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }

.main-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.main-grid > *, .bottom-grid > * { min-width: 0; }
.bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 16px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.ghost-btn { color: var(--primary); font-weight: 700; font-size: 13px; text-decoration: none; }
.ghost-btn:hover { text-decoration: underline; }

.activity-list { display: flex; flex-direction: column; }
.activity { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity:last-child { border-bottom: 0; }
.activity-icon { width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); display: grid; place-items: center; font-style: normal; flex-shrink: 0; }
.activity div { flex: 1; min-width: 0; }
.activity strong { display: block; font-size: 13.5px; }
.activity span { display: block; color: var(--muted); font-size: 12px; }
.activity time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty-note { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

.status-list { display: flex; flex-direction: column; }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-row span { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-row strong { font-size: 13.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-decoration: none; color: var(--text); transition: .2s; }
.quick-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.quick-tile b { width: 32px; height: 32px; border-radius: 9px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); display: grid; place-items: center; }
.quick-tile span { font-size: 13px; font-weight: 600; }

.progress-card { grid-column: 1 / -1; }
.progress-row { margin-bottom: 14px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12.5px; }
.progress-label strong { color: var(--text); }
.progress-track { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; width: var(--w, 0%); background: var(--c, var(--primary)); border-radius: 20px; }

.chart-area { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding-top: 10px; }
.chart-bars { display: flex; align-items: flex-end; gap: 14px; width: 100%; height: 100%; }
.bar-group { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bar-group .bar { width: 55%; max-width: 34px; background: var(--primary); border-radius: 6px 6px 2px 2px; height: var(--h, 0%); min-height: 2px; }
.bar-group .bar.target { background: color-mix(in srgb, var(--primary) 35%, transparent); }
.bar-label { font-size: 10px; color: var(--muted); }
.chart-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--primary); display: inline-block; }
.chart-legend span:last-child i { background: color-mix(in srgb, var(--primary) 35%, transparent); }

.profile-form .field input { width: 100%; }
.detail-card { padding: 6px 20px 22px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 26px; }
.detail-item { padding: 16px 4px; border-bottom: 1px solid var(--line); }
.detail-item dt { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.detail-item dd { margin: 0; font-size: 15px; font-weight: 600; }
.detail-actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Diálogo ---------- */
.app-dialog { border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); width: min(560px, calc(100vw - 32px)); max-height: 90vh; padding: 0; }
.app-dialog::backdrop { background: rgba(3, 10, 20, .5); }
.app-dialog form { display: flex; flex-direction: column; max-height: 90vh; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 18px; }
.dialog-body { padding: 20px 24px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  padding: 11px 14px; outline: none; transition: .2s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: var(--surface); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 20px; border-top: 1px solid var(--line); }

/* ---------- Mobile overlay ---------- */
.mobile-overlay { display: none; }

/* ---------- Menu inferior ---------- */
.bottom-nav {
  display: none;
  position: fixed; bottom: 12px; left: 12px; right: 12px; height: 64px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(20, 42, 71, .16);
  z-index: 100; align-items: center; justify-content: space-around;
  padding: 6px;
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; height: 100%; color: var(--muted);
  font-size: 10px; font-weight: 600; text-decoration: none;
  border-radius: 18px; transition: color .2s, background .2s;
}
.bottom-nav .nav-item svg {
  width: 22px; height: 22px;
  transition: transform .2s;
}
.bottom-nav .nav-item:active svg { transform: scale(.88); }
.bottom-nav .nav-item.active {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.bottom-nav .nav-item.active svg { transform: translateY(-1px); }

/* ---------- Ícones ---------- */
svg { width: 18px; height: 18px; display: inline-block; vertical-align: middle; }
svg.mini { width: 14px; height: 14px; }
svg.icon-lg { width: 32px; height: 32px; }
.nav-icon svg { width: 15px; height: 15px; }
.nav-icon { display: grid; place-items: center; }
.kpi-icon svg { width: 20px; height: 20px; }
.activity-icon svg { width: 20px; height: 20px; }
.quick-tile b svg { width: 18px; height: 18px; }
.bnav-icon { width: 22px; height: 22px; }
.mini { width: 15px; height: 15px; }
.primary-btn span svg, .btn-icon svg { width: 16px; height: 16px; }
.icon-btn svg { width: 18px; height: 18px; }
.badge svg { width: 12px; height: 12px; }
.profile-mini b svg { width: 15px; height: 15px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }

/* ---------- Responsividade Completa (Mobile, Tablet, Desktop) ---------- */

/* Ajustes gerais de diálogo/modal */
.app-dialog {
  width: min(680px, 94vw);
  max-height: 90vh;
  margin: auto;
  border-radius: 16px;
}
.app-dialog::backdrop {
  background: rgba(15, 23, 42, .65);
  backdrop-filter: blur(4px);
}

@media (max-width: 1120px) {
  .module-stats, .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .searchbox input { width: 160px; }
  .main-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr 1fr; }
  .bottom-grid > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1000;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 50px rgba(0, 0, 0, .35);
  }
  .workspace { margin-left: 0; padding-bottom: 80px; }
  .topbar { left: 0; padding: 0 16px; min-height: 68px; }
  .menu-btn { display: grid; }
  .mobile-overlay.show {
    display: block; position: fixed; inset: 0;
    background: rgba(3, 10, 20, .55); z-index: 998;
    backdrop-filter: blur(2px);
  }
  .module-intro { align-items: flex-start; flex-direction: column; gap: 12px; }
  .module-stats, .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .searchbox { display: none; }
  .bottom-nav { display: flex; }
  .page { padding: 18px 14px 96px; }
  .bottom-grid { grid-template-columns: 1fr; }
  .bottom-grid > :last-child { grid-column: auto; }
  .hero-strip { align-items: flex-start; flex-direction: column; gap: 12px; }

  /* Toolbar de tabelas em mobile */
  .table-toolbar {
    flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 16px;
  }
  .table-tools {
    display: flex; flex-wrap: wrap; gap: 8px; width: 100%; justify-content: flex-start;
  }
  .search-form { flex: 1 1 100%; display: flex; gap: 8px; width: 100%; }
  .search-form .filter-input { flex: 1; min-width: 0; width: 100%; }
  .toast-stack { right: 14px; bottom: 84px; left: 14px; }
}

@media (max-width: 560px) {
  .topbar { padding: 8px 12px; min-height: 64px; }
  .topbar h1 { font-size: 16px; }
  .topbar-sub { display: none; }
  .topbar-actions { gap: 6px; }
  .avatar-btn { width: 36px; height: 36px; }
  .module-stats, .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .mini-stat, .kpi-card { padding: 12px 14px; }
  .mini-stat strong, .kpi-value { font-size: 18px; }
  .table-toolbar { padding: 12px; }
  .filter-input { min-width: 0; width: 100%; font-size: 14px; }
  .dialog-body { grid-template-columns: 1fr; padding: 14px; }
  .field.full { grid-column: auto; }
  .dialog-actions { flex-direction: column-reverse; gap: 8px; padding: 12px 14px; }
  .dialog-actions button { width: 100%; }
  th, td { padding: 10px 12px; font-size: 12px; }
  .hero-strip { display: block; padding: 14px; }
  .period-control { margin-top: 10px; }
  .chart-area { height: 180px; }
  .quick-grid { grid-template-columns: 1fr; gap: 8px; }
  .quick-tile { padding: 12px; }
  .detail-actions { flex-wrap: wrap; gap: 6px; }
  .detail-actions button, .detail-actions a { flex: 1; min-width: 120px; justify-content: center; }
  .field input, .field select, .field textarea { font-size: 16px; padding: 10px 12px; } /* Previne zoom automático no iOS */
}

@media (max-width: 380px) {
  .module-stats, .kpi-grid { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 15px; }
  .page { padding: 14px 10px 90px; }
}
