/* UaiCanal — visual (claro e escuro automáticos) */
:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --ink: #141414;
  --ink-2: #55524d;
  --ink-3: #8a867f;
  --line: #e4e1db;
  --red: #e3262e;
  --red-ink: #b81a21;
  --red-soft: #fde8e8;
  --green: #12924f;
  --green-soft: #e3f5ea;
  --amber: #b46b00;
  --amber-soft: #fff3dc;
  --field: #faf9f7;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.04);
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --card: #1b1b1b;
    --ink: #f2f0ec;
    --ink-2: #bdb8b0;
    --ink-3: #85817a;
    --line: #2d2c2a;
    --red: #ff4a50;
    --red-ink: #ff7a7f;
    --red-soft: #3a1617;
    --green: #3fcf84;
    --green-soft: #12301f;
    --amber: #f2b24a;
    --amber-soft: #352710;
    --field: #151515;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.n, .big { font-variant-numeric: tabular-nums; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { opacity: .9; }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--card);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top img { width: 34px; height: 34px; border-radius: 8px; background: #fff; }
.top h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; flex: 1; }
.top h1 small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.prism { height: 4px; display: flex; position: sticky; top: calc(env(safe-area-inset-top) + 54px); z-index: 10; }
.prism i { flex: 1; }
.prism i:nth-child(1) { background: #e3262e; }
.prism i:nth-child(2) { background: #f6e51a; }
.prism i:nth-child(3) { background: #13a95b; }
.prism i:nth-child(4) { background: #12a9e8; }
.prism i:nth-child(5) { background: #9a3a96; }

.pill {
  font-size: 12px; padding: 3px 9px; border-radius: 99px;
  background: var(--field); color: var(--ink-2); border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.off { background: var(--amber-soft); color: var(--amber); border-color: transparent; }

/* ---------- conteúdo ---------- */
main {
  max-width: 680px; margin: 0 auto;
  padding: 14px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}
h2 { font-size: 20px; margin: 6px 2px 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card.flat { box-shadow: none; }
.card.warn { background: var(--amber-soft); border-color: transparent; color: var(--ink); }
.card.lock { text-align: center; padding: 28px 18px; }
.card.lock .icon { font-size: 34px; margin-bottom: 6px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.kpi b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--ink-3); }

/* ---------- formulários ---------- */
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=month], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field);
  outline: none; font-size: 16px;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); }
input.sm { padding: 7px 8px; font-size: 15px; text-align: right; }
input.warnin { border-color: var(--amber); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--red); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 11px; padding: 11px 16px; cursor: pointer;
  background: var(--red); color: #fff; font-weight: 600; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--red-soft); color: var(--red-ink); }
.btn.sm { padding: 7px 11px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btns .btn { flex: 1; }
.link { background: none; border: 0; color: var(--red-ink); padding: 0; cursor: pointer; font-weight: 600; }

/* ---------- tabelas ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.n, .tbl td.n { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); }
.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

/* resultado da divisão */
.res { display: grid; gap: 8px; }
.res .item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line);
}
.res .item .name { font-weight: 600; }
.res .item .yt { font-size: 19px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.res .item .meta { font-size: 12.5px; color: var(--ink-3); }
.res .item .meta.r { text-align: right; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green); vertical-align: 1px; }
.tag.red { background: var(--red-soft); color: var(--red-ink); }
.tag.gray { background: var(--field); color: var(--ink-3); border: 1px solid var(--line); }

/* entrada por vídeo */
.vin { display: grid; grid-template-columns: 1fr 104px 84px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vin:last-child { border-bottom: 0; }
.vin.head { font-size: 12px; color: var(--ink-3); padding-top: 0; }
.vin.head span:not(:first-child) { text-align: right; }
.vin .vname { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.vin .vname input { width: 18px; height: 18px; accent-color: var(--red); flex: none; }
.vin .vname .t { overflow: hidden; text-overflow: ellipsis; }
.vin.off { opacity: .5; }

/* lista de meses */
.list { display: grid; gap: 0; }
.list button.li {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 2px; cursor: pointer;
}
.list button.li:last-child { border-bottom: 0; }
.li .grow b { display: block; }
.li .grow span { font-size: 13px; color: var(--ink-3); }
.li .n { text-align: right; font-variant-numeric: tabular-nums; }
.li .n small { display: block; font-size: 12px; color: var(--ink-3); }
.chev { color: var(--ink-3); }

/* linhas do salário */
.lines { display: grid; }
.line { display: grid; grid-template-columns: 1fr auto 56px; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.line:last-child { border-bottom: 0; }
.line .v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.line .p { text-align: right; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.line.total { font-weight: 700; }
.line.hl .v { color: var(--green); }
.line.sub { font-size: 13.5px; color: var(--ink-2); }
.line.sub .v { font-weight: 500; }

/* gráfico */
.chart svg { width: 100%; height: auto; display: block; }
.chart .ax { stroke: var(--line); }
.chart text { fill: var(--ink-3); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- navegação ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs .nav-in { display: flex; width: 100%; max-width: 680px; }
nav.tabs button {
  flex: 1; height: var(--nav-h); background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); font-size: 12px; font-weight: 600;
}
nav.tabs button svg { width: 23px; height: 23px; }
nav.tabs button.on { color: var(--red); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 120px; height: 120px; border-radius: 22px; background: #fff; margin-bottom: 12px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login p { color: var(--ink-2); }
.login form { text-align: left; margin-top: 18px; }
.err { color: var(--red-ink); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }

/* ---------- avisos ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); transition: .2s; z-index: 50;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.banner {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 14px;
}
.banner .btn { background: var(--red); }

/* ---------- janela modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal .sheet {
  background: var(--card); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto;
}
@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal .sheet { border-radius: 18px; }
}
.sheet h3 { font-size: 18px; margin-bottom: 12px; }

details.fold { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
details.fold summary { cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: " ▾"; color: var(--ink-3); }
details.fold[open] summary::after { content: " ▴"; }
