:root {
  --ink: #1f1d54;
  --bg: #e8e9ee;
  --panel: #f5f6fa;
  --page: #ffffff;
  --line: #e4e7ef;
  --muted: #64697a;
  --hover: #f1f1f1;
  --radius: 6px;
  --accent: var(--ink);
  --on-accent: #fff;
  --pos: #17824f;
  --neg: #b3261e;
  --side: 208px;
}
body[data-theme=fin] { --accent: #399780; --on-accent: #fff; }
body[data-theme=cur] { --accent: #FF7E70; --on-accent: #1f1d54; }
body.side-collapsed { --side: 64px; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 12px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink); background: var(--panel); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.cap::first-letter { text-transform: uppercase; }
.material-symbols-outlined {
  width: 1em; overflow: hidden; font-size: 22px; flex: none; line-height: 1;
  font-variation-settings: 'FILL' 0, 'wght' 250, 'GRAD' 0, 'opsz' 24; user-select: none;
}
.material-symbols-outlined.filled { font-variation-settings: 'FILL' 1, 'wght' 250, 'GRAD' 0, 'opsz' 24; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.login-card { width: 380px; max-width: 100%; background: var(--page); border-radius: 12px; padding: 28px; display: grid; gap: 12px; box-shadow: 0 8px 30px rgba(31, 29, 84, .08); }
.login-card .logo { margin-bottom: 8px; }
.login-card input { height: 42px; padding: 0 12px; font-size: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.login-card input:focus { outline: 2px solid var(--ink); border-color: transparent; }
.error { color: var(--neg); font-size: 12px; }

/* ---------- logo ---------- */
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 42px; height: 42px; border-radius: 13px; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.logo-mark .material-symbols-outlined { font-size: 24px; font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24; }
.logo-text { font-size: 17px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; }

/* ---------- barra lateral ---------- */
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--page); border-right: 1px solid var(--line);
  padding: 20px 11px; display: flex; flex-direction: column; gap: 22px; z-index: 30; transition: width .2s;
}
#sidebar .logo { padding: 0 1px; }
#nav { display: grid; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 11px; border: 0; border-radius: 12px;
  background: none; color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer; text-align: left; white-space: nowrap; position: relative;
}
.nav-item:hover { background: #f2f2f8; }
.nav-item.on { background: #eeedf8; font-weight: 600; }
.nav-item.on::after { content: ''; position: absolute; right: 12px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.side-foot { margin-top: auto; }
.collapse-btn {
  position: absolute; top: 28px; right: -16px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--page); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.collapse-btn .material-symbols-outlined { font-size: 18px; }
body.side-collapsed .logo-text, body.side-collapsed .nav-label { display: none; }
body.side-collapsed .nav-item.on::after { display: none; }

.topbar { display: none; }
#scrim { display: none; }

#main { margin-left: var(--side); padding: 28px 32px 80px; transition: margin-left .2s; max-width: calc(1280px + var(--side)); }

/* ---------- cabeçalho de página ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 18px; font-weight: 500; letter-spacing: -.3px; }
.head-actions { display: flex; gap: 8px; }

/* ---------- botões ---------- */
.btn {
  height: 32px; padding: 0 14px; border: 1px solid var(--ink); background: #fff; border-radius: var(--radius); font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn .material-symbols-outlined { font-size: 18px; }
.btn.dark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--neg); border-color: #e7b9b3; }
.btn.big { height: 42px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 32px; height: 32px; border: 0; background: none; border-radius: var(--radius); cursor: pointer; display: inline-grid; place-items: center; padding: 0; text-decoration: none;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small .material-symbols-outlined { font-size: 18px; }
.icon-btn.fav { color: #f5b301; }

/* ---------- cartões ---------- */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; text-align: left; display: block; width: 100%; }
button.stat { cursor: pointer; }
button.stat:hover { border-color: #c9cbe0; }
.stat-title { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #555; margin-bottom: 10px; }
.stat-title .material-symbols-outlined { font-size: 18px; color: #6a6791; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat-detail { margin-top: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.card { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.grid2 .card { margin-bottom: 0; }
.card h2 { font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

/* ---------- barras e histórico ---------- */
.bar-row { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 10px; padding: 5px 0; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: #eef0f6; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #a5a8c9; border-radius: 3px; }
.bar-val { font-variant-numeric: tabular-nums; text-align: right; }
.bar-val small { color: var(--muted); margin-left: 4px; }
.hist { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.hist-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; color: var(--muted); }
.hist-col.on { color: var(--ink); font-weight: 600; }
.hist-bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.hist-bars i { width: 36%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 2px; }
.b-rec { background: #399780; }
.b-des { background: #df984b; }
.legend { display: flex; gap: 14px; margin-top: 10px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }

/* ---------- mês, filtros ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; margin-bottom: 16px; }
.month-nav strong { min-width: 150px; text-align: center; font-size: 14px; font-weight: 600; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills.sub { margin-bottom: 10px; }
.pill {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 11px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.pill:hover { background: var(--hover); }
.pill.on { background: #e8e8fb; color: #2d2a6e; border-color: #e8e8fb; }
.pill i { font-style: normal; color: var(--muted); margin-left: 3px; }
.search { height: 32px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; width: 220px; background: #fff; }
.search::placeholder { font-style: italic; color: #8a8ea0; }
.search:focus, .fld input:focus, .fld select:focus, .fld textarea:focus { outline: 2px solid var(--ink); border-color: transparent; }

/* ---------- tabela ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 400; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--ink); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #fafafa; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .c-chk { width: 34px; }
.tbl .c-date { width: 84px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .c-kind, .tbl .c-status { width: 120px; }
.tbl .c-link { width: 36px; text-align: right; }
.tbl .name { font-weight: 600; }
.tbl tr.done .name { color: var(--muted); text-decoration: line-through; font-weight: 500; }
.sub-line { display: block; color: var(--muted); font-size: 11.5px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.late { color: var(--neg); font-weight: 600; }
.chk { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---------- tags ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 11px; font-weight: 500; color: #222; white-space: nowrap; background: #e6e6e6; }
.tag.blue { background: #d9ebff; } .tag.green { background: #cdf0de; } .tag.yellow { background: #fdf0c9; }
.tag.orange { background: #fde0c4; } .tag.red { background: #ffd9d4; } .tag.pink { background: #fbdcf6; }
.tag.purple { background: #e4dbfb; } .tag.gray { background: #e6e6e6; }

/* ---------- cursos ---------- */
.course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.course { background: var(--page); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.course:hover { border-color: #c9cbe0; }
.course-top { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.course h3 { font-size: 13px; font-weight: 600; }
.progress { height: 6px; background: #eef0f6; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.course-foot { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; font-weight: 600; }
.course-foot .muted { font-weight: 400; }

/* ---------- sistemas ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile-grid.compact { grid-template-columns: repeat(2, 1fr); }
.tile { background: var(--page); border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: center; position: relative; }
.tile:hover { border-color: #c9cbe0; }
.tile-main { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; flex: 1; min-width: 0; }
.logo-tile { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--ink); flex: none; }
.tile-text { display: grid; min-width: 0; }
.t-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-act { display: flex; flex-direction: column; padding-right: 6px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-act, .tile:focus-within .tile-act, .tile-act:has(.fav) { opacity: 1; }

/* ---------- visão geral ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li.col { flex-direction: column; align-items: stretch; gap: 0; }
.r-line { display: flex; justify-content: space-between; gap: 10px; }
.r-date { width: 44px; color: var(--muted); font-variant-numeric: tabular-nums; }
.r-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.r-val.muted { font-weight: 400; }

/* ---------- popup ---------- */
dialog { border: 0; padding: 0; border-radius: 10px; width: 720px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--ink); background: var(--page); }
dialog::backdrop { background: rgba(31, 29, 84, .45); }
#dform { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px 20px; border-bottom: 1px solid var(--ink); }
.dlg-head h2 { font-size: 15px; font-weight: 600; }
.dlg-body { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; overflow-y: auto; }
.fld { display: grid; gap: 4px; align-content: start; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld > span { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.fld input:not([type=checkbox]):not([type=radio]), .fld select, .fld textarea { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; background: #fff; }
.fld textarea { height: auto; padding: 8px 10px; resize: vertical; }
.chk-fld { display: flex; align-items: center; gap: 8px; height: 36px; align-self: end; }
.chk-fld input { width: 16px; height: 16px; accent-color: var(--accent); }
.chk-fld > span { color: var(--ink); font-size: 12px; font-weight: 500; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.sw i { display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.sw i.none { background: #fff; background-image: linear-gradient(135deg, transparent 46%, #b3261e 46%, #b3261e 54%, transparent 54%); }
.sw input:checked + i { border-color: var(--ink); }
.dlg-error { padding: 0 20px 8px; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 20px; background: var(--panel); border-top: 1px solid var(--line); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 100; box-shadow: 0 8px 30px rgba(31, 29, 84, .25); max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.tbl tr.paid .name { color: var(--muted); font-weight: 500; }
