:root {
  /* paleta Fatorizze: azul royal, degrade azul -> menta, branco */
  --bg: #f4f7fc; --card: #ffffff; --text: #16255a; --muted: #6b7a99; --line: #e1e7f2;
  --primary: #1f4db8; --primary-2: #2a62d6; --mint: #5fd3b8; --mint-dark: #1fa98a;
  --green: #1fa98a; --red: #d93025; --amber: #d98e00;
  --side: #16389a; --side-2: #1f4db8; --side-text: #d6e0f7; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p.muted, .muted { color: var(--muted); }
small { color: var(--muted); }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: linear-gradient(180deg, var(--side-2) 0%, var(--side) 55%, #0f2a72 100%); color: var(--side-text); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .02em; padding: 4px 8px 14px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 30px; height: 30px; }
.wordmark { font-weight: 800; letter-spacing: -.01em; }
.wordmark .zz { color: var(--mint); }
.brand small { background: var(--mint); color: #0f2a72; border-radius: 6px; padding: 1px 6px; font-size: 10px; font-weight: 700; margin-left: 2px; }
.nav a { display: block; color: var(--side-text); padding: 8px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--mint); }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #9fb3e6; margin: 14px 10px 6px; }
.sidebar .foot { margin-top: auto; padding: 12px 8px 0; font-size: 12px; color: #b3c3ea; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar .foot strong { color: #fff; display: block; }
.main { margin-left: 236px; flex: 1; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 28px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 5; }
.topbar .spacer { flex: 1; }
.topbar select { min-width: 260px; }
.content { padding: 24px 28px 48px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f5f8fd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.subtotal td { font-weight: 700; background: #f8fafc; }
tr.group td { font-weight: 600; }
tr.category td:first-child { padding-left: 26px; color: #374151; }
tr.overdue td:first-child { border-left: 3px solid var(--red); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table { border: 0; }
tfoot td { font-weight: 700; background: #f8fafc; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #e5e7eb; color: #374151; white-space: nowrap; }
.badge.pendente, .badge.em_andamento { background: #fff4d6; color: #8a5a00; }
.badge.pago, .badge.conciliado, .badge.concluida, .badge.ok { background: #dcf5e7; color: #0b6b3a; }
.badge.cancelado, .badge.ignorado { background: #eceef2; color: #6b7280; }
.badge.atrasado, .badge.err { background: #fde2df; color: #a11a10; }
.badge.receber { background: #dcf5e7; color: #0b6b3a; }
.badge.pagar { background: #fde2df; color: #a11a10; }
.badge.admin { background: #e0e7ff; color: #3730a3; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=month], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd2dd; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(45,90,142,.35); border-color: var(--primary-2); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: auto; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > * { margin: 0; }
.inline-form .field { min-width: 140px; }
form.inline { display: inline; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .field { min-width: 130px; margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cbd2dd; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn.primary { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn.primary:hover { background: var(--primary); }
.btn.success { background: var(--mint-dark); border-color: var(--mint-dark); color: #fff; }
.btn.danger { background: #fff; color: var(--red); border-color: #f2b8b3; }
.btn.danger:hover { background: #fde2df; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.link { border: 0; background: transparent; color: var(--primary-2); padding: 4px 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tabs a.active { color: var(--primary-2); border-color: var(--primary-2); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.success { background: #e9f8ef; border-color: #b7e4c7; color: #0b6b3a; }
.flash.error { background: #fde8e6; border-color: #f5b5af; color: #a11a10; }
.flash.warning { background: #fff6df; border-color: #f7dd9b; color: #7a5200; }

/* misc */
details.row-action { display: inline-block; }
details.row-action summary { list-style: none; cursor: pointer; display: inline-block; }
details.row-action summary::-webkit-details-marker { display: none; }
details.row-action .popover { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(20,33,61,.15); min-width: 300px; margin-top: 6px; }
.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #2f7be0, #5fd3b8); }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 6px 4px 0; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 100%; position: relative; }
.chart .bar { width: 38%; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.rec { background: linear-gradient(180deg, #2f7be0, #5fd3b8); }
.chart .bar.des { background: #e07b71; }
.chart-labels { display: flex; gap: 10px; }
.chart-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); padding-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.plan { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: #fff; }
.plan.current { border-color: var(--mint-dark); box-shadow: 0 0 0 2px rgba(95,211,184,.35); }
.plan .price { font-size: 26px; font-weight: 700; margin: 8px 0; }
.plan ul { padding-left: 18px; color: #374151; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 12px; }

/* auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1f4db8 0%, #2f7be0 55%, #5fd3b8 100%); padding: 20px; }
.auth .brand { color: var(--primary); font-size: 22px; }
.auth .brand img { width: 36px; height: 36px; }
.auth .box { background: #fff; border-radius: 14px; padding: 30px 32px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth .box h1 { margin-bottom: 14px; }
.auth .field { margin-bottom: 12px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 6px; }

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; inset: auto; }
  .main { margin-left: 0; }
  .app { flex-direction: column; }
  .topbar select { min-width: 160px; }
}
@media print {
  .sidebar, .topbar, .filters, .page-head .actions, .btn { display: none !important; }
  .main { margin: 0; }
}

/* ---- sugestoes do motor ---- */
.suggestions { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.sugg { display: flex; align-items: center; gap: 8px; background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.sugg .what { flex: 1; font-size: 13px; }
.score { display: inline-block; min-width: 34px; text-align: center; font-weight: 700; font-size: 12px; padding: 3px 6px; border-radius: 6px; background: #eceef2; }
.score.hi { background: #dcf5e7; color: #0b6b3a; } .score.mid { background: #fff4d6; color: #8a5a00; } .score.lo { background: #eceef2; color: #6b7280; }

/* ---- projetos / kanban ---- */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.project-card { display: block; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--primary-2); border-radius: var(--radius); padding: 14px; color: var(--text); }
.project-card:hover { text-decoration: none; box-shadow: 0 6px 20px rgba(20,33,61,.08); }
.project-card strong { display: block; margin-bottom: 2px; }
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { flex: 0 0 250px; background: #eaf0fb; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kanban-col.over { outline: 2px dashed var(--primary-2); }
.kanban-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13px; margin-bottom: 8px; padding: 0 2px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.kcard { display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; color: var(--text); cursor: grab; }
.kcard:hover { text-decoration: none; border-color: #b9c4d6; }
.kcard.dragging { opacity: .5; }
.kcard.late { border-left: 3px solid var(--red); }
.kcard-top { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.kcard-title { font-weight: 600; font-size: 13px; }
.kcard-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.kcard-tags { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.avatar { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, #2f7be0, #5fd3b8); color: #fff; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin-left: auto; }
.kanban-add input { margin-top: 8px; background: transparent; border: 1px dashed #b9c4d6; }
.kanban-add input:focus { background: #fff; }
.prio { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #eceef2; color: #4b5563; }
.prio.alta { background: #fde2df; color: #a11a10; } .prio.urgente { background: var(--red); color: #fff; } .prio.baixa { background: #e5e7eb; }
.badge.todo, .badge.backlog { background: #eceef2; color: #4b5563; } .badge.doing { background: #dbeafe; color: #1e40af; } .badge.review { background: #fff4d6; color: #8a5a00; } .badge.done { background: #dcf5e7; color: #0b6b3a; }

/* ---- pagina da tarefa ---- */
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; margin-bottom: 18px; }
.task-title { font-size: 24px; font-weight: 700; border: 0; border-bottom: 1px solid transparent; padding: 6px 0; margin-bottom: 14px; background: transparent; }
.task-title:focus { outline: 0; border-bottom-color: var(--primary-2); }
.task-desc { min-height: 220px; font-size: 14px; line-height: 1.5; }
.task-props { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; height: fit-content; }
.task-props .field { margin-bottom: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.check-row .done { text-decoration: line-through; color: var(--muted); }
.checkbox { width: 20px; height: 20px; border: 1.5px solid #9aa5b8; border-radius: 5px; background: #fff; cursor: pointer; font-size: 12px; line-height: 1; color: #fff; }
.checkbox.on { background: var(--green); border-color: var(--green); }
.comment { border-bottom: 1px solid var(--line); padding: 8px 0; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }

/* ---- agenda ---- */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.cal-head { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px; }
.cal-day { min-width: 0; min-height: 96px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.cal-day.out { background: #f8fafc; color: #9aa5b8; }
.cal-day.today { border-color: var(--primary-2); box-shadow: inset 0 0 0 1px var(--primary-2); }
.cal-num { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.cal-ev { display: block; font-size: 11px; line-height: 1.25; padding: 2px 4px; margin-bottom: 2px; border-left: 3px solid; background: #f3f5f9; border-radius: 3px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.done { opacity: .5; text-decoration: line-through; }
.cal-ev.late { background: #fde2df; }
@media (max-width: 900px) { .task-layout { grid-template-columns: 1fr; } .cal-day { min-height: 60px; } }
