:root {
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e3e5ea;
  --text: #1d2129; --muted: #6b7280; --accent: #4f46e5; --accent-soft: #eef0ff;
  --late: #dc2626; --today: #ea580c; --soon: #ca8a04;
  --green: #16a34a; --green-bg: #dcfce7; --orange: #ea580c; --orange-bg: #ffedd5;
  --yellow: #a16207; --yellow-bg: #fef9c3; --red: #dc2626; --red-bg: #fee2e2;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b22; --surface-2: #1f232c; --border: #2b303b;
    --text: #e6e8ec; --muted: #9aa1ad; --accent: #8b85ff; --accent-soft: #24234a;
    --green-bg: #12301d; --orange-bg: #3a2210; --yellow-bg: #332a0b; --red-bg: #3a1414;
    --green: #4ade80; --orange: #fb923c; --yellow: #facc15; --red: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Topo */
.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a.active, .nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.main.wide { max-width: none; }
.flash { background: var(--accent-soft); color: var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* Botões e formulários */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.inline { display: inline; }

/* Quadro */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 150px); }
.column-head { padding: 10px 12px; font-weight: 600; display: flex; justify-content: space-between; }
.column-head .count { color: var(--muted); font-weight: 400; }
.cards { padding: 0 8px 8px; overflow-y: auto; min-height: 60px; flex: 1; }
.cards.over { background: var(--accent-soft); border-radius: 8px; }
.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); color: var(--text); cursor: grab; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card.dragging { opacity: .5; }
.card-title { font-weight: 600; margin-bottom: 6px; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.labels { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.label { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.due { padding: 1px 6px; border-radius: 4px; }
.due.late { background: var(--red-bg); color: var(--late); font-weight: 600; }
.due.today { background: var(--orange-bg); color: var(--today); font-weight: 600; }
.due.soon { background: var(--yellow-bg); color: var(--yellow); }

/* Card detalhado */
.job-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
@media (max-width: 900px) { .job-layout { grid-template-columns: 1fr; } }
.desc { white-space: pre-wrap; word-wrap: break-word; }
.comment { border-top: 1px solid var(--border); padding: 10px 0; }
.files li { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Financeiro */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.good .v { color: var(--green); }
.stat.bad .v { color: var(--red); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.orange { background: var(--orange-bg); color: var(--orange); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill.red { background: var(--red-bg); color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bar { width: 40%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.fat { background: var(--accent); }
.bar.luc { background: var(--green); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.error { color: var(--red); margin-bottom: 12px; }

@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand { display: none; }
  .main { padding: 16px; }
  .who .name { display: none; }
}
