:root {
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #F8FAFC; --ink: #0F172A; --muted: #64748B; --line: #E2E8F0;
  --accent: #2563EB; --accent-ink: #FFFFFF; --red: #DC2626; --red-bg: #FEF2F2; --amber: #B45309; --amber-bg: #FFFBEB;
  --green: #15803D; --green-bg: #F0FDF4; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --radius: 10px;
}
html[data-theme="dark"] { --bg: #0B1220; --surface: #111A2E; --surface-2: #0F172A; --ink: #E5E7EB; --muted: #94A3B8; --line: #1E293B;
    --accent: #3B82F6; --red: #F87171; --red-bg: #2A1215; --amber: #FBBF24; --amber-bg: #2A2110; --green: #4ADE80; --green-bg: #0F2A1A;
    --shadow: 0 1px 2px rgba(0,0,0,.4); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .sm { font-size: 12px; }
button, input, select { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
input, select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-weight: 500; }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
.erro { color: var(--red); margin: 0; min-height: 1em; text-align: center; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }

/* topo */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); }
main { padding: 12px 16px 24px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { min-width: 220px; flex: 0 1 300px; }
.spacer { flex: 1; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

/* quadro */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 60vh; max-height: calc(100vh - 170px); scroll-snap-align: start; }
.col-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.col-head .nome { font-weight: 700; }
.col-head .cnt { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; line-height: 1.2; }
.col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.vazio { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; box-shadow: var(--shadow); cursor: grab; display: grid; gap: 6px; }
.card.dragging { opacity: .5; }
.card.alerta-red { border-left: 3px solid var(--red); }
.card.alerta-amber { border-left: 3px solid var(--amber); }
.card .l1 { display: flex; align-items: baseline; gap: 6px; }
.card .nome { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.card .tempo { color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; }
.card .sub { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.card .msg { font-size: 13px; color: var(--ink); opacity: .85; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .msg .quem { color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11.5px; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge.red { background: var(--red-bg); color: var(--red); border-color: transparent; font-weight: 600; }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: transparent; font-weight: 600; }
.badge.green { background: var(--green-bg); color: var(--green); border-color: transparent; font-weight: 600; }
.badge.money { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 700; font-variant-numeric: tabular-nums; }
.card .acoes { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.card .acoes a { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 13px; white-space: nowrap; }
.card .acoes .btn { margin-left: auto; }
.card .acoes select { flex: 1 1 100%; padding: 5px 6px; font-size: 12.5px; }
.card .acoes .btn { padding: 3px 8px; font-size: 12.5px; }
.legend { margin-top: 8px; }

/* métricas */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .k { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tabela { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tabela th, .tabela td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tabela th:first-child, .tabela td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.tabela th { font-size: 12px; color: var(--muted); font-weight: 600; }
.tabela tr.total td { font-weight: 800; background: var(--surface-2); }
.tabela tr.total td:first-child { background: var(--surface-2); }
.tabela .bad { color: var(--red); font-weight: 700; } .tabela .good { color: var(--green); font-weight: 700; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-top: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; display: inline; }
details.panel summary { cursor: pointer; }
details.panel ul { margin: 10px 0 0; padding-left: 18px; }
.bar { display: grid; grid-template-columns: 150px 1fr 40px; gap: 8px; align-items: center; margin: 6px 0; font-size: 13px; }
.bar .track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--red); border-radius: 99px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-card { background: var(--surface); border-radius: 14px; padding: 20px; width: 100%; max-width: 380px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-card h3 { margin: 0; }
.modal-card p { margin: 0; }
.modal-card label { display: grid; gap: 6px; font-weight: 500; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }

@media (max-width: 640px) {
  .topbar { gap: 10px; }
  .user span { display: none; }
  .board { grid-auto-columns: 86vw; }
  .toolbar input[type=search] { min-width: 0; flex: 1 1 100%; }
  .bar { grid-template-columns: 110px 1fr 32px; }
}

.theme-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 15px; line-height: 1; }
.login .theme-btn { position: fixed; top: 14px; right: 14px; }
