:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f5f7fa;
  --ink: #172230;
  --muted: #5a6575;
  --line: #dce2ea;
  --accent: #2747a8;
  --accent-soft: #e3e9fa;
  --on-accent: #ffffff;
  --today: #d9960f;
  --danger: #c43c3c;
  --shadow: 0 10px 30px rgba(20, 30, 50, 0.16);
  --nav-h: 64px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
html.dark {
  --bg: #0d1218;
  --surface: #151c26;
  --surface-2: #1b2430;
  --ink: #e6ebf2;
  --muted: #97a3b4;
  --line: #263141;
  --accent: #7f9cff;
  --accent-soft: #222d4a;
  --on-accent: #0d1218;
  --today: #f0b53c;
  --danger: #ff7b7b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cor do item: --c muda conforme o tema */
.tint { --c: var(--cl); }
html.dark .tint { --c: var(--cdk); }

/* ---------- Estrutura ---------- */
#app {
  max-width: 780px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 92px);
}
.topbar { display: flex; align-items: center; gap: 8px; padding: 6px 2px 10px; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; flex: 1; font-weight: 750; }
.brand-plus { color: var(--accent); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink);
}
.icon-btn:active { background: var(--line); }

/* ---------- Painel "hoje" ---------- */
.now { display: grid; grid-template-columns: 1.35fr 1fr; gap: 8px; margin-bottom: 14px; }
.now-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 14px; border: 0; text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.now-card .lbl { font-size: 13px; color: var(--muted); }
.status { font-size: 21px; font-weight: 750; line-height: 1.15; display: flex; align-items: center; gap: 6px; }
.status .ic { width: 22px; height: 22px; color: var(--c); }
.status.off { color: var(--muted); }
.now-card .time { font-size: 15px; font-weight: 600; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--c); border-radius: 3px; }
.counts { display: flex; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.counts span { display: inline-flex; align-items: center; gap: 4px; }
.counts .ic { width: 15px; height: 15px; }
.next .date { font-size: 18px; font-weight: 750; }
.next .when { font-size: 13px; color: var(--muted); }
.next .t { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
.next .t .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Calendário ---------- */
.monthbar { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.monthbar h2 { flex: 1; margin: 0 0 0 4px; font-size: 19px; font-weight: 700; }
.monthbar h2 span { color: var(--muted); font-weight: 500; }
.pill-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; height: 36px; padding: 0 14px;
  font-size: 14px; font-weight: 600;
}
.dow { display: grid; grid-template-columns: repeat(7, 1fr); font-size: 12px; color: var(--muted); text-align: center; padding: 0 0 4px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; touch-action: pan-y; }
.day {
  position: relative; min-height: 78px; border: 0; padding: 4px 3px 3px; border-radius: var(--r-sm);
  background: var(--surface); text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden;
}
.day.out { opacity: 0.38; }
.day.duty { background: var(--surface); }
.day > .duty-bg { position: absolute; inset: 0; display: flex; pointer-events: none; z-index: 0; }
.day > .duty-bg i { flex: 1; background: color-mix(in srgb, var(--c) 17%, var(--surface)); box-shadow: inset 0 3px 0 var(--c); }
.day.multi > .duty-bg i { background: color-mix(in srgb, var(--c) 24%, var(--surface)); box-shadow: inset 0 4px 0 var(--c); }
.day.multi > .duty-bg i + i { border-left: 1px solid var(--surface); }
.day > :not(.duty-bg) { position: relative; z-index: 1; }
.multi-svc { display: flex; flex-direction: column; gap: 3px; margin: 6px 0 2px; font-size: 13px; }
.multi-svc .t { display: flex; align-items: center; gap: 6px; }
.multi-svc .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.day .top { display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.day .top .bl { width: 11px; height: 11px; color: var(--muted); margin-right: 1px; }
.day .num { font-size: 13px; font-weight: 650; line-height: 1; padding: 2px 3px; align-self: flex-start; border-radius: 6px; display: flex; align-items: center; gap: 2px; }
.day .num .ic { width: 11px; height: 11px; color: var(--c); }
.day.today { outline: 2.5px solid var(--today); outline-offset: -2.5px; }
.day.today .num { background: var(--today); color: #1a1406; }
.day.sel { outline: 2.5px solid var(--accent); outline-offset: -2.5px; }
.ln {
  display: flex; align-items: center; gap: 3px; font-size: 10.5px; line-height: 1.25; white-space: nowrap; overflow: hidden;
  border-radius: 4px; padding: 1px 3px 1px 2px; min-width: 0;
}
.ln .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.ln .ic { width: 10px; height: 10px; flex: none; }
.ln .tx { overflow: hidden; text-overflow: ellipsis; }
.ln.done .tx { text-decoration: line-through; color: var(--muted); }
.ln .bl { width: 9px; height: 9px; color: var(--muted); }
.ln.svc { font-weight: 700; padding-left: 4px; padding-right: 1px; letter-spacing: -0.02em; box-shadow: inset 2.5px 0 0 var(--c); border-radius: 2px; }
.ln.svc .tx { text-overflow: clip; }
.ln .bar + .tx { margin-left: 0; }
.more { font-size: 10px; color: var(--muted); padding-left: 4px; }
.legend { display: flex; gap: 14px; justify-content: flex-start; padding: 0 4px; font-size: 12px; color: var(--muted); margin: 12px 0 0; flex-wrap: wrap; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.legend .ic { width: 14px; height: 14px; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 18%, var(--surface)); box-shadow: inset 0 3px 0 var(--accent); }
.legend .sw.t { background: var(--surface); outline: 2px solid var(--today); outline-offset: -2px; box-shadow: none; }

/* ---------- Listas ---------- */
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 4px 8px; }
.section-h h2, .section-h h3 { margin: 0; font-size: 17px; font-weight: 700; }
.section-h small { color: var(--muted); font-size: 13px; }
.list { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left;
  padding: 12px 14px; min-height: 60px; border-top: 1px solid var(--line);
}
.list > .row:first-child, .list > :first-child .row { border-top: 0; }
.row .bar { width: 4px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; display: flex; gap: 6px; align-items: center; min-width: 0; }
.row .title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .sub span { display: inline-flex; gap: 4px; align-items: center; }
.row .sub .ic { width: 14px; height: 14px; }
.row .type-ic { color: var(--c); }
.row.done .title > span:first-child { text-decoration: line-through; color: var(--muted); }
.row .late { color: var(--danger); font-weight: 600; }
.check {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--c); background: transparent; flex: none;
  display: grid; place-items: center; color: var(--on-accent); padding: 0;
}
.check .ic { width: 18px; height: 18px; opacity: 0; }
.check.on { background: var(--c); color: #fff; }
.check.on .ic { opacity: 1; }
.check-wrap { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; padding: 0; margin: -7px -7px -7px -9px; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); background: var(--surface); border-radius: var(--r-lg); }
.empty p { margin: 0 0 12px; }
.seg { display: flex; background: var(--surface); border-radius: 999px; padding: 4px; gap: 4px; margin: 4px 0 8px; }
.seg button { flex: 1; border: 0; border-radius: 999px; height: 38px; background: transparent; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.view-title { font-size: 24px; font-weight: 750; margin: 6px 4px 12px; }

/* ---------- Navegação ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-in { max-width: 780px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.nav button {
  border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600;
}
.nav button .ic { width: 23px; height: 23px; }
.nav button[aria-current="page"] { color: var(--accent); }
.fab {
  position: fixed; z-index: 21; right: max(18px, calc(50% - 390px + 18px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 62px; height: 62px; border-radius: 20px; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.fab .ic { width: 28px; height: 28px; stroke-width: 2.4; }
.fab:active { transform: scale(0.96); }

/* ---------- Painéis (bottom sheet) ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 18, 0.45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.18s ease-out;
}
.sheet {
  width: 100%; max-width: 620px; max-height: 92vh; max-height: 92dvh; background: var(--bg);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet.small { background: var(--surface); }
.sheet-h { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 18px; }
.sheet-h h2 { flex: 1; margin: 0; font-size: 19px; font-weight: 750; min-width: 0; }
.sheet-h h2 small { display: block; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-b { overflow-y: auto; padding: 4px 14px 16px; -webkit-overflow-scrolling: touch; }
.sheet-f { padding: 10px 14px 14px; display: flex; gap: 10px; border-top: 1px solid var(--line); background: var(--bg); }
.sheet.small .sheet-f { background: var(--surface); }
@keyframes up { from { transform: translateY(40px); opacity: 0.4; } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 22px; max-height: 86vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.btn {
  height: 50px; border-radius: 14px; border: 0; padding: 0 18px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--on-accent); flex: 1; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn .ic { width: 19px; height: 19px; }

/* Escolha de tipo (botão +) */
.choices { display: grid; gap: 8px; padding: 6px 14px 18px; }
.choice {
  display: flex; align-items: center; gap: 14px; border: 0; background: var(--surface-2); border-radius: 16px;
  padding: 14px 16px; text-align: left; min-height: 64px;
}
.choice .ic { width: 26px; height: 26px; color: var(--accent); }
.choice b { display: block; font-size: 17px; }
.choice small { color: var(--muted); font-size: 13.5px; }

/* ---------- Formulário ---------- */
.fgroup { background: var(--surface); border-radius: var(--r-lg); padding: 4px 14px; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.fgroup > .field:first-child, .fgroup > :first-child { border-top: 0; }
.field > span, .flabel { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field input[type="number"], .field select, .field textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px;
  height: 46px; padding: 0 12px; font-size: 16px;
}
.field textarea { height: auto; min-height: 76px; padding: 10px 12px; resize: vertical; }
.field input.big { font-size: 19px; font-weight: 650; border: 0; background: transparent; padding: 0; height: 44px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.row2 .field { border-top: 0; }
.hint { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.hint.warn { color: var(--today); }
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline input[type="number"] { width: 84px; flex: none; }
.inline select { flex: 1; width: auto; min-width: 120px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; min-height: 38px; padding: 0 14px;
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .x { width: 16px; height: 16px; }
.chip.rem { padding-right: 6px; }
.chip.rem button { border: 0; background: transparent; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: var(--muted); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 56px; }
.fgroup > .toggle:first-child { border-top: 0; }
.toggle .t b { display: block; font-weight: 600; }
.toggle .t small { color: var(--muted); font-size: 13px; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; margin: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; padding: 4px 0; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--c); position: relative; padding: 0; min-height: 38px;
  display: grid; place-items: center; color: #fff;
}
.swatch .ic { width: 18px; height: 18px; opacity: 0; stroke-width: 3; filter: drop-shadow(0 0 1px rgba(0,0,0,.6)); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.swatch[aria-checked="true"] .ic { opacity: 1; }
.color-name { font-size: 13px; color: var(--muted); }

/* Detalhe */
.detail-head { display: flex; gap: 12px; align-items: flex-start; padding: 6px 4px 14px; }
.detail-head .badge { width: 46px; height: 46px; border-radius: 14px; background: color-mix(in srgb, var(--c) 22%, var(--surface)); color: var(--c); display: grid; place-items: center; flex: none; }
.detail-head .badge .ic { width: 25px; height: 25px; }
.detail-head h3 { margin: 0; font-size: 21px; line-height: 1.2; }
.detail-head .tp { font-size: 13px; color: var(--muted); }
.dl { background: var(--surface); border-radius: var(--r-lg); padding: 2px 14px; margin-bottom: 10px; }
.dl > div { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.dl > div:first-child { border-top: 0; }
.dl .ic { color: var(--muted); margin-top: 1px; }
.dl .v { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.dl .v small { display: block; color: var(--muted); font-size: 13px; }

/* Busca */
.search-in { display: flex; gap: 8px; align-items: center; background: var(--surface); border-radius: 14px; padding: 0 12px; margin: 0 0 12px; }
.search-in input { flex: 1; border: 0; background: transparent; height: 50px; font-size: 17px; outline: none; min-width: 0; }

/* Avisos */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 92px);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px;
  max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); animation: fade 0.2s;
}
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 800; padding: 6px; }
html.dark .toast button { color: #3550b5; }
.note { background: var(--accent-soft); border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; margin-bottom: 10px; }
.note.warn { background: color-mix(in srgb, var(--today) 18%, var(--surface)); }

@media (min-width: 640px) {
  .day { min-height: 96px; padding: 6px 5px 4px; }
  .ln { font-size: 12px; }
  .ln .ic { width: 12px; height: 12px; }
  .day .num { font-size: 14px; }
}
@media (max-width: 360px) {
  .now { grid-template-columns: 1fr; }
  .day { min-height: 70px; }
}

/* botão principal dentro das linhas */
.row .main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 2px 0; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.btn.danger-fill { background: var(--danger); color: #fff; }
html.dark .btn.danger-fill { color: #1a0d0d; }
.sheet:focus { outline: none; }
@media (max-width: 639px) {
  .day .num .ic { display: none; }
}
