:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1d1f23;
  --muted: #6b6f76;
  --line: #e2dfd8;
  --accent: #1f4e79;
  --accent-ink: #ffffff;
  --accent-soft: #e3ecf5;
  --ok: #2d7a4f;
  --ok-soft: #e1f1e7;
  --warn: #9a6200;
  --warn-soft: #fbefd9;
  --bad: #b3261e;
  --bad-soft: #f9e3e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #262a2f;
    --text: #eceae6;
    --muted: #9aa0a8;
    --line: #33373d;
    --accent: #7fb0e0;
    --accent-ink: #0e1a26;
    --accent-soft: #1f2f40;
    --ok: #6cc391;
    --ok-soft: #1c3226;
    --warn: #e2b05a;
    --warn-soft: #382c16;
    --bad: #ef8a83;
    --bad-soft: #3a1f1d;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 60px; }
.topbar .marca { font-weight: 650; font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); object-fit: cover; flex: none; display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--muted); }
main { padding: 24px 0 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 9px; padding: 8px 14px; font: inherit; font-weight: 550; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.marcada { background: var(--accent-soft); color: var(--accent); }
.tag.realizada { background: var(--ok-soft); color: var(--ok); }
.tag.falta { background: var(--warn-soft); color: var(--warn); }
.tag.cancelada { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; }
.barra { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.aviso { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.erro-box { padding: 12px 14px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 14px; }

/* agenda semanal */
.semana { margin-top: 20px; }
.semana h3 { margin-bottom: 8px; color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.sgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dia { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 8px; min-width: 0; }
.dia.vazio { background: transparent; border-style: dashed; }
.dia .cab { text-align: center; margin-bottom: 8px; }
.dia .cab b { display: block; font-size: 13px; }
.dia .cab span { font-size: 12px; color: var(--muted); }
.slot {
  display: block; width: 100%; margin-top: 6px; padding: 8px 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); text-align: center; cursor: default; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot small { display: block; font-size: 11px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.slot.livre { background: var(--surface); border-color: var(--accent); color: var(--accent); cursor: pointer; }
.slot.livre:hover { background: var(--accent-soft); }
.slot.minha { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.slot.ocupada, .slot.bloqueada, .slot.indisponivel { opacity: 0.55; text-decoration: line-through; }
.slot.adm { cursor: pointer; text-decoration: none; opacity: 1; }
.slot.adm.ocupada { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent); }
.slot.adm.realizada { background: var(--ok-soft); border-color: var(--ok-soft); color: var(--ok); }
.slot.adm.falta { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn); }
.slot.adm.bloqueada { opacity: 0.6; text-decoration: line-through; }
.slot.adm.livre { border-style: dashed; border-color: var(--line); color: var(--muted); }
.legenda { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 5px; border: 1px solid var(--line); }

/* listas e tabelas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.lista li:first-child { border-top: 0; }
.lista .quando { flex: 1; min-width: 160px; }
.tabela-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 550; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* modal */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog .corpo { padding: 20px; }
dialog .acoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 0 20px 20px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.login { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.login .card { padding: 32px 24px; }
.login #gbtn { display: flex; justify-content: center; margin-top: 20px; min-height: 44px; }
.copiar { display: flex; gap: 8px; }
.copiar input { font-size: 13px; min-width: 0; }
.copiar .btn { white-space: nowrap; flex: none; }

@media (max-width: 560px) {
  .sgrid { gap: 4px; }
  .dia { padding: 8px 3px; }
  .slot { font-size: 13px; padding: 7px 2px; }
  .slot small { display: none; }
  .card { padding: 16px; }
}
