:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #1f2430;
  --color-text-muted: #6a717f;
  --color-primary: #3b5bfd;
  --color-primary-dark: #2a44d6;
  /* success/danger/warning escurecidos em relação ao tom "puro" pra passar contraste WCAG AA
     (4.5:1) como texto, tanto em cima do branco (valores/botões) quanto do fundo claro do
     próprio badge (--badge-*-bg mais abaixo). */
  --color-success: #157d55;
  --color-danger: #cd2222;
  --color-warning: #996300;
  --badge-success-bg: #e3f6ee;
  --badge-warning-bg: #fdf1dc;
  --badge-danger-bg: #fbe6e6;
  --badge-primary-bg: #e8ecfd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 40, 0.08);
  /* Escala de espaçamento — base 4px. Use estes tokens (ou a classe .stack abaixo) em vez de
     margin/padding com pixel solto no meio do HTML/JS; é o que faz o espaçamento entre blocos
     ficar previsível em vez de cada tela ter um valor diferente por acidente. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
}

html[data-theme="dark"] {
  --color-bg: #101218;
  --color-surface: #1f2330;
  --color-border: #3a4159;
  --color-text: #f2f3f7;
  --color-text-muted: #aab0c4;
  --color-primary: #6d8bff;
  --color-primary-dark: #8ba1ff;
  --color-success: #3ddb98;
  --color-danger: #ff6b6b;
  --color-warning: #f0ac4c;
  --badge-success-bg: rgba(61, 219, 152, 0.22);
  --badge-warning-bg: rgba(240, 172, 76, 0.22);
  --badge-danger-bg: rgba(255, 107, 107, 0.22);
  --badge-primary-bg: rgba(109, 139, 255, 0.24);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* --color-primary sozinho (#6d8bff) não dá 4.5:1 com texto branco em cima — só passa quando é
   texto/ícone sobre --color-surface (onde já é usado no resto do app). Botão sólido precisa de um
   tom mais escuro do mesmo azul, só pra essa combinação branco-sobre-preenchido. */
html[data-theme="dark"] button:not(.secondary):not(.danger),
html[data-theme="dark"] .btn:not(.secondary):not(.danger) {
  background: #3f67ff;
}
html[data-theme="dark"] button:not(.secondary):not(.danger):hover,
html[data-theme="dark"] .btn:not(.secondary):not(.danger):hover {
  background: #1647ff;
}

html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .btn.secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
}
html[data-theme="dark"] button.secondary:hover {
  background: var(--color-border);
}
html[data-theme="dark"] button:disabled,
html[data-theme="dark"] .btn:disabled {
  color: #6b7288 !important;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  padding: 0;
  margin-left: auto;
}

.theme-toggle:hover { background: var(--color-bg); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
}

.app-header .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  transition: opacity 0.15s ease;
}

.app-header a.brand:hover {
  opacity: 0.8;
  text-decoration: none;
}

.app-header .brand img {
  display: block;
  height: 38px;
  width: 38px;
  border-radius: 8px;
}

.app-nav {
  display: flex;
  gap: 4px;
}

.app-nav a {
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.app-nav a:hover { background: var(--color-bg); text-decoration: none; }
.app-nav a.active { background: var(--color-primary); color: white; }
.app-nav a.active:hover { background: var(--color-primary-dark); }

main {
  max-width: clamp(1080px, 92vw, 1600px);
  margin: 0 auto;
  padding: 24px;
}

h1 { font-size: 1.5rem; margin: 0 0 20px; }
h2 { font-size: 1.15rem; margin: 24px 0 12px; }

.section-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.section-toggle h2 { margin: 24px 0 12px; }

.section-toggle .chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  margin-right: 4px;
  color: var(--color-text-muted);
}

.section-toggle.open .chevron { transform: rotate(90deg); }

.card-wrap { position: relative; }

.card-wrap #btn-edit-client {
  position: absolute;
  top: 16px;
  right: 16px;
}

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

.grid {
  display: grid;
  gap: var(--space-4);
}

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

/* Regra de organização vertical: qualquer sequência de blocos (cards, tabelas, grids de stat,
   seções com título) que fique uma embaixo da outra usa .stack no container-pai, em vez de cada
   bloco filho carregar sua própria margem solta. Escondendo um bloco do meio da pilha com .hidden
   (display:none) não sobra buraco nem gruda no vizinho: o elemento escondido some da renderização
   (a margem dele não conta), e o próximo bloco visível continua com a própria margem normal.
   Exceção conhecida: se o PRIMEIRO filho da pilha estiver escondido, o segundo ainda ganha uma
   margem acima que "seria" do primeiro — sobra um respiro extra no topo, não um problema visual
   grave, então não vale complicar o seletor por causa disso. */
.stack > * + * { margin-top: var(--space-6); }
.stack-sm > * + * { margin-top: var(--space-4); }

@media (max-width: 800px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.plan-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
}

.plan-card-name { font-weight: 700; font-size: 1.05rem; margin-bottom: 4px; }
.plan-card-price { font-size: 1.4rem; font-weight: 700; margin-bottom: 14px; }
.plan-card-price small { font-size: 0.8rem; font-weight: 500; color: var(--color-text-muted); }
.plan-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; }
.plan-card li::before { content: "✓ "; color: var(--color-success); font-weight: 700; }

.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-radius: 8px;
  cursor: pointer;
}

.funnel-row:hover { background: var(--color-bg); }
.funnel-row.active { background: var(--badge-primary-bg); }

.funnel-label {
  width: 140px;
  flex-shrink: 0;
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.funnel-track {
  flex: 1;
  background: var(--color-bg);
  border-radius: 6px;
  height: 26px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  transition: width 0.2s ease;
}

.funnel-fill-count {
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
}

.funnel-value {
  width: 110px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: 700;
}

.value.danger { color: var(--color-danger); }
.value.warning { color: var(--color-warning); }
.value.success { color: var(--color-success); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.92rem;
}

th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

tr:last-child td { border-bottom: none; }

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

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button, .btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  background: var(--color-primary);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

button:hover, .btn:hover { background: var(--color-primary-dark); text-decoration: none; }

button.secondary, .btn.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
button.secondary:hover { background: var(--color-bg); }

button.danger { background: var(--color-danger); }
button.danger:hover { background: #aa1c1c; }

button.small, .btn.small { padding: 5px 10px; font-size: 0.82rem; }

button:disabled, .btn:disabled {
  background: var(--color-border) !important;
  color: var(--color-text-muted) !important;
  border-color: var(--color-border) !important;
  cursor: not-allowed;
}
button:disabled:hover, .btn:disabled:hover { background: var(--color-border) !important; }

input, select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
}

textarea { width: 100%; min-height: 70px; resize: vertical; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--color-text-muted);
}

.field { margin-bottom: 14px; }

.password-field { position: relative; }

.password-field input { padding-right: 40px; }

.password-field button {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--color-text-muted);
  opacity: 0.8;
}

.password-field button:hover { opacity: 1; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
}

.lead-form-columns {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 14px;
}

@media (max-width: 700px) {
  .lead-form-columns { grid-template-columns: 1fr; }
}

.client-info-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  font-size: 13px;
}

.client-info-panel dl { margin: 0; }
.client-info-panel dt { font-weight: 600; color: var(--color-text-muted); margin-top: 8px; }
.client-info-panel dt:first-child { margin-top: 0; }
.client-info-panel dd { margin: 0 0 4px; color: var(--color-text); }

.client-info-panel-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 40, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  width: clamp(320px, 85%, 1100px);
  box-shadow: 0 8px 30px rgba(20, 24, 40, 0.2);
}

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

.modal-header h2 { margin: 0; }

.confirm-backdrop { z-index: 200; }

.confirm-modal {
  width: clamp(280px, 90%, 400px);
  text-align: center;
  padding: 28px 24px 24px;
}

.confirm-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 10px;
}

.confirm-modal h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.confirm-modal p {
  margin: 0 0 22px;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.confirm-actions button { min-width: 90px; }

.hidden { display: none !important; }

.role-client .admin-only, .role-staff .admin-only { display: none !important; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.ativo, .badge.ativa, .badge.pago { background: var(--badge-success-bg); color: var(--color-success); }
.badge.pausado, .badge.pausada, .badge.pendente { background: var(--badge-warning-bg); color: var(--color-warning); }
.badge.inativo, .badge.encerrada, .badge.atrasado { background: var(--badge-danger-bg); color: var(--color-danger); }

.badge.novo, .badge.contato { background: var(--badge-primary-bg); color: var(--color-primary); }
.badge.qualificado, .badge.proposta { background: var(--badge-warning-bg); color: var(--color-warning); }
.badge.fechado { background: var(--badge-success-bg); color: var(--color-success); }
.badge.perdido { background: var(--badge-danger-bg); color: var(--color-danger); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.actions-cell { white-space: nowrap; width: 1%; }
.actions-row { display: flex; gap: 6px; align-items: center; }

.table-scroll { overflow-x: auto; max-width: 100%; }

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--color-bg);
}

.table-container {
  max-width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin: 0 auto;
}

.table-toolbar + .table-container {
  border-radius: 0 0 var(--radius) var(--radius);
}

.table-scroll-x {
  overflow: auto;
  max-height: 65vh;
  max-width: 100%;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.table-scroll-x::-webkit-scrollbar {
  display: none;
}

.table-hscroll {
  position: sticky;
  top: 76px;
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 3;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.date-filter { position: relative; }

.date-filter-toggle {
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 6px;
  font-size: 0.8rem;
}

.date-filter-toggle:hover { background: var(--color-bg); }

.date-filter-toggle.active {
  border-color: var(--color-primary);
  color: var(--color-text);
}

.date-filter-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 150px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(20, 24, 40, 0.18);
  padding: 10px;
}

.date-filter-popover label {
  font-size: 0.72rem;
  margin-bottom: 0;
}

.bulk-menu { position: relative; }

.bulk-menu-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(20, 24, 40, 0.18);
  padding: 6px;
  text-transform: none;
  letter-spacing: normal;
}

.bulk-menu-dropdown button {
  width: 100%;
  text-align: left;
}

.combo-field { position: relative; }

.combo-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 190px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(20, 24, 40, 0.18);
  padding: 6px;
}

.combo-option {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
}

.combo-option:hover { background: var(--color-bg); }

.combo-option.combo-create { color: var(--color-primary); font-weight: 600; }

.picker-table-wrap {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.picker-table { border: none; border-radius: 0; }

.picker-table th:first-child, .picker-table td:first-child { width: 1%; padding-right: 0; }

.picker-table tbody tr { cursor: pointer; }

.picker-table tbody tr:hover { background: var(--color-bg); }

.picker-table tbody tr.picker-row-none td { color: var(--color-text-muted); }

.picker-table input[type="checkbox"] { pointer-events: none; }

.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  flex: 0 0 250px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

.kanban-column-header {
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
}

.kanban-column-header[draggable="true"] { cursor: grab; }

.kanban-column.column-dragging { opacity: 0.4; }

.kanban-column.column-drag-over { outline: 2px dashed var(--color-primary); outline-offset: -2px; }

.kanban-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.kanban-count {
  background: var(--color-border);
  color: var(--color-text);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.kanban-column-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 60px;
  transition: background 0.1s ease;
}

.kanban-column-body.drag-over { background: var(--badge-primary-bg); }

.kanban-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  padding: 12px 0;
}

.kanban-card {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: grab;
  font-size: 0.85rem;
  overflow: hidden;
}

.kanban-card.dragging { opacity: 0.4; }

.kanban-card-cover { height: 6px; width: 100%; }

.kanban-card-assignee {
  position: absolute;
  top: 6px;
  right: 6px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--color-primary);
  color: white;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.68rem;
  font-weight: 700;
  z-index: 1;
}

.kanban-card-body { padding: 10px; }

.kanban-card-name { font-weight: 600; margin-bottom: 4px; }

.kanban-card-meta { color: var(--color-text-muted); font-size: 0.78rem; margin-bottom: 2px; }

.kanban-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.kanban-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--color-bg);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.kanban-badge.value { background: var(--badge-primary-bg); color: var(--color-primary); }
.kanban-badge.tasks.done { background: var(--badge-success-bg); color: var(--color-success); }
.kanban-badge.due { background: var(--badge-warning-bg); color: var(--color-warning); }
.kanban-badge.overdue { background: var(--badge-danger-bg); color: var(--color-danger); }

.kanban-card-actions { margin-top: 8px; }

.price-tiers-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.price-tier-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.org-chart {
  padding: 40px 20px;
  overflow-x: auto;
  text-align: center;
}

.org-node {
  display: inline-block;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--color-text);
}

.org-node.org-root { margin: 0 auto; }

.org-node.unlocked {
  cursor: pointer;
  border-color: var(--color-primary);
  border-width: 2px;
}

.org-node.unlocked:hover { background: var(--color-bg); text-decoration: none; }

.org-node.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.org-node-hint {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 3px;
}

.org-branches {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.org-branches::before {
  content: '';
  display: block;
  position: relative;
  top: -20px;
  margin: 0 auto;
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.org-branch {
  position: relative;
  padding-top: 20px;
}

.org-branch::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 20px;
  background: var(--color-border);
}

.table-hscroll > div {
  height: 1px;
}

.filter-row th {
  padding: 6px 8px;
  background: var(--color-surface);
}

.filter-row input,
.filter-row select {
  width: 100%;
  font-size: 0.8rem;
  padding: 5px 6px;
}

.table-container table {
  border: none;
  border-radius: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
}

.table-container td:not(.actions-cell) {
  max-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-container thead th {
  position: sticky;
  z-index: 1;
}

.table-container thead tr:first-child th {
  top: 0;
  height: 38px;
  z-index: 4;
}

.table-container thead tr.filter-row th {
  top: 38px;
}

.col-resize-handle {
  position: absolute;
  right: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 2;
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: var(--color-primary);
  opacity: 0.5;
}

.settings-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 170px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  padding-right: 16px;
}

.settings-nav button {
  background: none;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.settings-nav button:hover { background: var(--color-bg); color: var(--color-text); }

.settings-nav button.active { background: var(--color-bg); color: var(--color-primary); }

.settings-content { flex: 1; min-width: 0; }

@media (max-width: 700px) {
  .settings-layout { flex-direction: column; }
  .settings-nav {
    flex-direction: row;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding-right: 0;
    padding-bottom: 12px;
  }
}

.text-muted { color: var(--color-text-muted); }
.text-right { text-align: right; }

.dashboard-layout {
  display: flex;
  align-items: flex-start;
}

.dashboard-sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 24px 16px;
  border-right: 1px solid var(--color-border);
  min-height: calc(100vh - 60px);
}

.dashboard-sidebar-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

#dashboard-nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dashboard-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
}

.dashboard-nav-item:hover { background: var(--color-bg); text-decoration: none; }
.dashboard-nav-item.active { background: var(--color-primary); color: white; }

.dashboard-main {
  flex: 1;
  min-width: 0;
  max-width: clamp(900px, 90vw, 1400px);
  margin: 0 auto;
  padding: 24px;
}

@media (max-width: 800px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-sidebar {
    width: 100%;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  #dashboard-nav-list { flex-direction: row; flex-wrap: wrap; }
}

.widget-card {
  position: relative;
}

.widget-card .widget-remove {
  position: absolute;
  top: 8px;
  right: 8px;
}

.widget-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.widget-bar-label {
  width: 40%;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-bar-track {
  flex: 1;
  background: var(--color-bg);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}

.widget-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
}

.widget-bar-value {
  width: 70px;
  flex-shrink: 0;
  text-align: right;
  font-weight: 600;
}

.chart-row {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: center;
}

.pie-chart {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.chart-legend {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.chart-legend-label { flex: 1; }
.chart-legend-value { font-weight: 600; }
.chart-legend-pct { color: var(--color-text-muted); width: 42px; text-align: right; }
