:root {
  --blue: #3F7FC4;
  --blue-d: #2B5F9E;
  --navy: #1E3354;
  --orange: #FF8A4C;
  --yellow: #FBD03E;
  --green: #16A34A;
  --red: #DC2626;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --line: #E2E8F0;
  --text: #1E293B;
  --muted: #64748B;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
a { color: var(--blue-d); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); min-height: 1em; margin: 6px 0 0; font-size: 13px; }

/* ---------- botões e campos ---------- */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #CBD5E1; background: #F8FAFC; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(63, 127, 196, .35); border-color: var(--blue); }
textarea { min-height: 80px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #EAF2FC, #FFF6EE); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center; }
.login-card img { margin: 0 auto; }
.login-card label { text-align: left; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--navy); white-space: nowrap; }
.brand b { color: var(--orange); }
.tabs { display: flex; gap: 2px; overflow-x: auto; flex: 1; }
.tabs button { font: inherit; font-weight: 600; border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { background: var(--bg); color: var(--navy); }
.tabs button.active { background: #EAF2FC; color: var(--blue-d); }
.who { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.view { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--green); } .down { color: var(--red); }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.st-ideia { background: #F1F5F9; color: #475569; }
.st-planejada { background: #EAF2FC; color: var(--blue-d); }
.st-andamento { background: #FEF3C7; color: #92400E; }
.st-concluida { background: #DCFCE7; color: #166534; }
.st-pausada { background: #FEE2E2; color: #991B1B; }
.pr-alta { color: var(--red); } .pr-media { color: #B45309; } .pr-baixa { color: var(--muted); }

/* ---------- progresso ---------- */
.bar { height: 8px; background: #EEF2F7; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: 99px; }
.bar.good > span { background: var(--green); }
.bar.warn > span { background: var(--yellow); }
.bar.bad > span { background: var(--orange); }

/* ---------- listas ---------- */
.list { display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; }
.item:hover { background: #F8FAFC; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12px; color: var(--muted); }
.clickable { cursor: pointer; }
.date-pill { flex: none; width: 46px; text-align: center; border-radius: 8px; background: var(--bg); padding: 4px 0; font-size: 11px; color: var(--muted); line-height: 1.15; }
.date-pill b { display: block; font-size: 16px; color: var(--navy); }
.date-pill.late { background: #FFF1E8; }
.date-pill.late b { color: #C2410C; }
.date-pill.today { background: #EAF2FC; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #CBD5E1; background: #fff; cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 14px; flex: none; padding: 0; }
.check:hover { border-color: var(--green); }
.check.done { background: var(--green); border-color: var(--green); }

/* ---------- tabela ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #F8FAFC; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-weight: 600; border: 0; background: none; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button.active { background: #EAF2FC; color: var(--blue-d); }

/* ---------- kanban ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #EEF2F7; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col.drop { outline: 2px dashed var(--blue); }
.col-head { display: flex; justify-content: space-between; font-weight: 700; color: var(--navy); margin: 2px 4px 10px; }
.kcard { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border-left: 4px solid var(--blue); }
.kcard .title { font-weight: 600; color: var(--navy); margin-bottom: 6px; }

/* ---------- calendário ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal .dow { padding: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); background: #F8FAFC; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 118px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.cal .day.other { background: #FAFBFD; }
.cal .day.other .n { color: #CBD5E1; }
.cal .day.today { background: #F3F8FE; }
.cal .n { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cal .day.today .n { color: var(--blue-d); }
.ev { display: flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 6px; border-radius: 6px; margin-bottom: 3px; background: var(--bg); color: var(--navy); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-left: 3px solid var(--blue); }
.ev:hover { filter: brightness(.96); }
.ev.done { opacity: .6; text-decoration: line-through; }
.ev.late { background: #FFF1E8; }
.ev span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .grid-line { stroke: #EEF2F7; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 40px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.hbar .bar { height: 10px; }

/* ---------- metas ---------- */
.goal { padding: 14px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; }
.goal-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.goal-num { font-weight: 700; color: var(--navy); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(15, 23, 42, .3); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal-body .full { grid-column: 1 / -1; }
.modal .error { padding: 0 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .left { margin-right: auto; }
.section-title { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 18px; color: var(--navy); }
.stat span { font-size: 11px; color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; }
.toast.err { background: var(--red); }

@media (max-width: 900px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .who { margin-left: auto; }
  .view { padding: 16px 16px 60px; }
  .cal .day { min-height: 80px; padding: 3px; }
  .ev { font-size: 10px; padding: 2px 4px; }
  .modal-body { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: 90px 1fr 32px; }
}
