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

:root {
  --bg: #0b0f1a;
  --surface: #111827;
  --surface-2: #1a2234;
  --surface-3: #202a3f;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #8b95a9;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-contrast: #ffffff;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.14);
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 248px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body[data-theme="light"] {
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e8ebf2;
  --border: #e3e7ef;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-contrast: #ffffff;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

button { font-family: var(--font); cursor: pointer; color: inherit; }
input, select, textarea { font-family: var(--font); }
.hidden { display: none; }
[hidden] { display: none !important; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.25s ease, width 0.25s ease;
}

.brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  min-height: 65px;
}

.brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}

.sidebar-close { display: none; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.14s, color 0.14s;
  flex-shrink: 0;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-ico { width: 19px; height: 19px; flex-shrink: 0; }

.nav-item .projeto-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: 4px;
}

.nav-item .count-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 99px;
}

.nav-divider { height: 1px; background: var(--border); margin: 10px 6px; }

.nav-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 4px 12px 6px;
}

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

.collapse-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: none; border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.collapse-btn:hover { background: var(--surface-2); color: var(--text); }
.collapse-btn svg { flex-shrink: 0; }
.collapse-btn .chev-expand { display: none; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 35;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-width);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* ── Topbar ── */
.topbar {
  height: 64px;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  gap: 12px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-btn { display: none; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: none; border: none;
  color: var(--muted);
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.theme-toggle-btn .ico-sun { display: none; }
body[data-theme="light"] .theme-toggle-btn .ico-moon { display: none; }
body[data-theme="light"] .theme-toggle-btn .ico-sun { display: block; }

.search-wrapper {
  position: relative;
  width: 240px;
  flex-shrink: 1;
}
.search-ico {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 32px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); }
.search-clear {
  position: absolute; right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  display: none;
}
.search-clear.visible { display: inline-flex; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent); opacity: 0.88; border-color: var(--accent); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ── Content ── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.view { max-width: 1280px; margin: 0 auto; }

/* ── Stats / metrics (visão geral) ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 28px 0 14px;
}
.section-header h2 {
  font-size: 0.92rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
}

/* frentes / cards de contexto */
.frentes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.frente-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.frente-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.frente-name { font-weight: 700; font-size: 0.94rem; letter-spacing: -0.01em; }
.frente-desc { font-size: 0.82rem; color: var(--muted); }
.frente-pend { font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; }
.frente-pend strong { color: var(--text); font-weight: 600; }

.badge {
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 9px; border-radius: 99px;
  white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }

.status-ativo { background: var(--success-soft); color: var(--success); }
.status-ativo .dot { background: var(--success); }
.status-em_andamento { background: var(--info-soft); color: var(--info); }
.status-em_andamento .dot { background: var(--info); }
.status-quase_pronto { background: var(--warning-soft); color: var(--warning); }
.status-quase_pronto .dot { background: var(--warning); }
.status-proposta { background: var(--accent-soft); color: var(--accent); }
.status-proposta .dot { background: var(--accent); }
.status-feito { background: var(--surface-3); color: var(--muted); }
.status-feito .dot { background: var(--muted); }

/* prioridades (contexto) */
.prio-list { display: flex; flex-direction: column; gap: 8px; }
.prio-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.prio-nivel { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.prio-alta { background: var(--danger); }
.prio-media { background: var(--warning); }
.prio-baixa { background: var(--info); }
.prio-body { flex: 1; }
.prio-frente { font-weight: 600; font-size: 0.86rem; }
.prio-acao { font-size: 0.8rem; color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 0.9rem;
}
.empty svg { opacity: 0.4; margin-bottom: 8px; }

/* ── Filtros (tarefas) ── */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-pill {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem; font-weight: 600;
  transition: all 0.14s;
}
.filter-pill:hover { background: var(--surface-2); color: var(--text); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* ── Lista de tarefas (view tarefas) ── */
.task-list { display: flex; flex-direction: column; gap: 8px; }
.task-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.task-row:hover { border-color: var(--accent); background: var(--surface-2); }
.task-row .check-circle {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: transparent;
}
.task-row.done .check-circle { background: var(--success); border-color: var(--success); color: #fff; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 0.9rem; }
.task-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 3px; font-size: 0.74rem; color: var(--muted); }
.task-meta .meta-tag { display: inline-flex; align-items: center; gap: 4px; }
.task-projeto-dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

.prio-chip {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 8px; border-radius: 99px;
}
.prio-alta-chip { background: var(--danger-soft); color: var(--danger); }
.prio-media-chip { background: var(--warning-soft); color: var(--warning); }
.prio-baixa-chip { background: var(--info-soft); color: var(--info); }

.vencido { color: var(--danger) !important; font-weight: 600; }

/* ── Kanban ── */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: start;
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 12px;
}
.kanban-col-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.kanban-col-title .count { color: var(--muted); font-weight: 600; }
.col-dot { width: 9px; height: 9px; border-radius: 3px; }
.col-todo .col-dot { background: var(--muted); }
.col-doing .col-dot { background: var(--warning); }
.col-done .col-dot { background: var(--success); }

.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-col.drag-over { border-color: var(--accent); background: var(--accent-soft); }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: border-color 0.14s, box-shadow 0.14s, transform 0.14s;
  display: flex; flex-direction: column; gap: 8px;
}
.kanban-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: 0.4; transform: scale(0.98); }
.kanban-card .card-title { font-weight: 600; font-size: 0.87rem; line-height: 1.35; }
.kanban-card .card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.72rem; color: var(--muted); }
.kanban-card .card-tag { background: var(--surface-3); padding: 2px 8px; border-radius: 6px; font-size: 0.68rem; font-weight: 600; }
.kanban-card .card-actions { display: flex; gap: 4px; justify-content: flex-end; }
.card-actions .icon-btn { width: 26px; height: 26px; }

.kanban-add {
  width: 100%; padding: 9px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: none; color: var(--muted);
  font-size: 0.8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 8px;
}
.kanban-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.18s ease;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--border); gap: 8px;
}
.modal-foot-right { display: flex; gap: 8px; margin-left: auto; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { font-size: 0.74rem; font-weight: 600; color: var(--muted); }

.input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
.textarea { resize: vertical; min-height: 60px; }
select.input { appearance: auto; }

.color-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active { border-color: var(--text); }
.color-input { height: 42px; padding: 4px; cursor: pointer; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem; font-weight: 600;
  z-index: 80;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}

/* ── Sidebar colapsável (desktop) ── */
@media (min-width: 701px) {
  body.sidebar-collapsed .sidebar { width: 74px; padding: 0; }
  body.sidebar-collapsed .main { margin-left: 74px; }
  body.sidebar-collapsed .brand { justify-content: center; padding: 18px 10px; }
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .nav-item span,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .collapse-btn span,
  body.sidebar-collapsed .nav-item .count-badge { display: none; }
  body.sidebar-collapsed .nav-item { justify-content: center; padding: 11px 0; }
  body.sidebar-collapsed .nav { padding: 12px 8px; }
  body.sidebar-collapsed .nav-divider { margin: 10px 2px; }
  body.sidebar-collapsed .collapse-btn { justify-content: center; padding: 9px 0; }
  body.sidebar-collapsed .collapse-btn .chev-collapse { display: none; }
  body.sidebar-collapsed .collapse-btn .chev-expand { display: block; }
}

/* ── Mobile ── */
@media (max-width: 700px) {
  .sidebar { transform: translateX(-100%); width: 264px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; margin-left: auto; }
  .menu-btn { display: inline-flex; }
  .main { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .search-wrapper { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: 1fr; }
  .kanban-col { min-height: auto; }
  .field-row { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  #btn-add-tarefa span { display: none; }
  #btn-add-tarefa { width: 38px; height: 38px; padding: 0; }
  .frentes-grid { grid-template-columns: 1fr; }
}
