:root {
  color-scheme: light;
  --paper: #efece4;
  --ink: #1a1916;
  --muted: #6d675f;
  --line: #ddd6c8;
  --card: #fbfaf7;
  --sidebar: #1e2422;
  --accent: #e26d2a;
  --accent-dark: #c85a1c;
  --danger: #9c2f2f;
  --ok: #1d6b45;
  --shadow: 0 1px 0 rgba(26, 25, 22, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  color-scheme: dark;
  background: var(--sidebar);
  color: #f3efe6;
  padding: 22px 16px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 6px;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #2a332f;
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: none;
}

.brand strong { display: block; font-size: 15px; }

.search {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  border-radius: 8px;
  padding: 8px 10px;
}

.search:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.obra-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: auto;
  flex: 1;
  margin: 0 -6px;
  padding: 0 6px;
}

.obra-item {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.obra-item:hover { background: rgba(255, 255, 255, 0.05); }
.obra-item.active { background: rgba(255, 255, 255, 0.1); }

.obra-item b {
  display: block;
  font-weight: 650;
  font-size: 14px;
}

.obra-item small {
  display: block;
  color: rgba(243, 239, 230, 0.6);
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex: none;
  background: #8d8880;
}

.dot.em_curso { background: #3ddc97; }
.dot.suspensa { background: #e2b341; }
.dot.concluida { background: #8d8880; }

.side-empty {
  color: rgba(243, 239, 230, 0.6);
  font-size: 13px;
  padding: 8px;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hint {
  margin: 0;
  color: rgba(243, 239, 230, 0.5);
  font-size: 12px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.login-card h1 { margin: 0; font-size: 28px; }
.login-card .help { margin: 0; }
.login-card .field { color: var(--muted); }

.pair { display: flex; gap: 8px; }
.pair .btn { flex: 1; }

.main {
  height: 100vh;
  overflow: auto;
  padding: 32px 36px 72px;
}

.page {
  max-width: 1120px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.save-state {
  color: var(--ok);
  font-size: 13px;
  min-height: 1em;
}

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 650;
}

h2 { font-size: 16px; margin: 0 0 10px; }

.sub {
  margin: 8px 0 0;
  color: var(--muted);
}

.toolbar, .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

.btn:hover { border-color: #c8bfb0; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn.danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
}

.btn.danger:hover { background: #f8ecec; }

.btn.full { width: 100%; }

.sidebar .btn.ghost {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.16);
}

.sidebar .btn.ghost:hover { background: rgba(255, 255, 255, 0.06); }

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 22px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 128px;
  box-shadow: var(--shadow);
}

.stat b {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.stat span { color: var(--muted); font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 650;
  background: #e7f6ee;
  color: var(--ok);
  white-space: nowrap;
}

.pill.suspensa { background: #fff4d8; color: #8a5a10; }
.pill.concluida { background: #eeeae4; color: #5c564e; }

.filter {
  width: min(360px, 100%);
  margin-bottom: 12px;
  background: white;
  border: 1px solid #d5cfc3;
  border-radius: 8px;
  padding: 8px 10px;
}

.log-head, .log-row {
  display: grid;
  grid-template-columns: 108px 110px minmax(0, 1fr) 108px 88px;
  gap: 12px;
  align-items: center;
}

.log-head {
  padding: 0 14px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.log { display: flex; flex-direction: column; gap: 8px; }

.log-row {
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.log-row:hover { border-color: #c8bfb0; }
.log-row.home { grid-template-columns: 108px minmax(140px, 200px) minmax(0, 1fr) 80px 110px; }

.log-row b { font-weight: 650; }

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #3f3a34;
}

.num { font-variant-numeric: tabular-nums; text-align: left; }
.muted { color: var(--muted); }

.empty {
  background: var(--card);
  border: 1px dashed #d2cbbd;
  border-radius: 16px;
  padding: 28px;
  max-width: 560px;
}

.empty h1 { font-size: 26px; margin-bottom: 8px; }
.empty p { margin: 0 0 16px; color: #3f3a34; }

.sheet {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}

.sheet-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 2px solid var(--sidebar);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.sheet-top p { margin: 4px 0 0; color: var(--muted); }

.meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 8px;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

.block { margin-top: 22px; }
.block h3 { margin: 18px 0 8px; font-size: 15px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.block-head h2 { margin: 0; }
.mapa-faltas { width: max-content; min-width: 100%; border-collapse: collapse; }
.mapa-faltas th, .mapa-faltas td { width: 26px; min-width: 26px; padding: 3px 0; text-align: center; font-size: 11px; font-weight: 600; border: 1px solid var(--line); }
.mapa-faltas th.pessoa { width: auto; min-width: 150px; text-align: left; position: sticky; left: 0; background: white; font-size: 13px; font-weight: 600; border-right: 3px solid #6f685f; border-left: 3px solid #6f685f; }
.mapa-faltas thead th { border-top: 3px solid #6f685f; border-bottom: 3px solid #6f685f; }
.mapa-faltas tr > :last-child { border-right: 3px solid #6f685f; }
.mapa-faltas tbody tr:last-child > th, .mapa-faltas tbody tr:last-child > td { border-bottom: 3px solid #6f685f; }
.mapa-faltas tr.corte > th, .mapa-faltas tr.corte > td { border-top: 3px solid #6f685f; }
.mapa-faltas .fim { background: #f3efe6; color: var(--muted); }
.mapa-faltas td.marca, .legenda i { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.mapa-faltas td.meia, .legenda i.meia { background: #ffe14a; color: #9a4a00; }
.mapa-faltas td.falta, .legenda i.falta { background: #c94545; color: white; }
.mapa-faltas td.ferias, .legenda i.ferias { background: #3d6ea8; color: white; }
.mapa-faltas td.baixa, .legenda i.baixa { background: #6b4c9a; color: white; }
.mapa-faltas td.seguro, .legenda i.seguro { background: #8a847c; color: white; }
.mapa-faltas td.feriado, .legenda i.feriado { background: #c6efd3; color: #14663a; }
.mapa-faltas td.extra, .legenda i.extra { background: #1d6b45; color: white; }
.mapa-faltas td.extra .horas { color: #fff; background: none; font-weight: 700; }
.extra-nota { display: block; margin-top: 4px; color: #1d6b45; font-size: 12px; font-weight: 650; }
.legenda i.horas { background: #e26d2a; }
.mapa-faltas td.meia .horas { color: #e26d2a; background: none; font-weight: 700; }
.mapa-faltas td.falta .horas { color: #fff; background: none; font-weight: 700; }
.legenda { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0 0; font-size: 13px; }
.legenda i { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border-radius: 3px; vertical-align: -2px; }
.pre { white-space: pre-wrap; margin: 0; }

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

td.num, th.num { text-align: left; }
table.grelha { table-layout: fixed; width: 100%; }
table.grelha th, table.grelha td { text-align: left; vertical-align: middle; }
table.grelha th.acao, table.grelha td.acao,
table.grelha td.row-actions { width: 112px; text-align: left; }
table.grelha.com-numero { table-layout: auto; }
table.grelha.com-numero th:first-child,
table.grelha.com-numero td:first-child { width: 1%; white-space: nowrap; }

.sigs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 56px;
}

.sigs div {
  border-top: 1px solid var(--ink);
  padding-top: 8px;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field.full { grid-column: 1 / -1; }

.field > span { font-weight: 650; color: #3a342c; }

input, select, textarea {
  background: white;
  border: 1px solid #d5cfc3;
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  text-align: left;
}

textarea { min-height: 140px; resize: vertical; }

input:focus, select:focus, textarea:focus, .filter:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.segment { display: flex; flex-wrap: wrap; gap: 6px; }

.segment label {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: white;
  cursor: pointer;
  color: var(--ink);
}

.segment input { position: absolute; opacity: 0; width: 1px; height: 1px; }

.segment label:has(input:checked) {
  background: var(--sidebar);
  color: white;
  border-color: var(--sidebar);
}

.line {
  display: grid;
  grid-template-columns: 1.4fr 1fr 90px 36px;
  gap: 8px;
  margin-bottom: 8px;
}

.line.mat { grid-template-columns: 1.6fr 100px 90px 36px; }
.line.occ { grid-template-columns: 190px 1fr 36px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
}

.icon-btn:hover { background: #f6f3ed; }

.add { margin-top: 2px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.error {
  color: var(--danger);
  background: #f8ecec;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0;
}

.error .btn { margin-left: 8px; }

dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  color: var(--ink);
}

dialog::backdrop { background: rgba(24, 22, 18, 0.48); }

dialog header, dialog footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
}

dialog header h2 { margin: 0; font-size: 18px; }
dialog header { border-bottom: 1px solid var(--line); }
dialog footer { border-top: 1px solid var(--line); justify-content: flex-end; gap: 8px; }

.dialog-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--sidebar);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

#toast[hidden] { display: none; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-btn:hover { background: rgba(255, 255, 255, 0.05); }
.nav-btn.active { background: rgba(255, 255, 255, 0.1); }

.nav-label {
  margin: 12px 8px 2px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, 0.45);
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin-top: 14px;
}

.panel h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.panel h2 .muted { font-weight: 500; }

.help { color: var(--muted); margin: 0 0 12px; font-size: 13px; }
.help .btn { margin-left: 6px; }

.line, .line.mo, .line.eq, .line.eq.obra { grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr) 44px; }
.line.sub, .line.sub.obra { grid-template-columns: minmax(0, 1fr) 160px 160px minmax(0, 1fr) 44px; }
.line.aloc { grid-template-columns: minmax(0, 1fr) 160px 44px; }
.diario-table { width: 100%; }
.diario-obras { margin: 28px 0 0; }
.obra-dia { border-top: 3px solid var(--sidebar); }
.obra-dia h3 { margin: 16px 0 8px; font-size: 14px; }
.diario-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--sidebar); }
.sec-toggle {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 18px 0 8px;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.sec-seta { width: 1em; color: var(--muted, #6d655c); }
.sec-resumo { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--muted, #6d655c); }
.sec-toggle:hover { color: var(--accent-dark); }
.line.sub-obra { grid-template-columns: minmax(0, 1fr) 160px 44px; }
.badge.ok { background: #e7f6ee; color: var(--ok); margin-left: 6px; }

.form-grid.dia { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.dia textarea, dialog textarea { min-height: 72px; }

.toolbar, .toolbar.spread { align-items: flex-end; }
.toolbar.spread { margin: 8px 0 16px; }
.toolbar .field, .toolbar.spread .field, .page-head .field, .filter {
  width: 220px;
  min-width: 220px;
  max-width: 100%;
  margin: 0 0 12px;
}

.table-wrap { overflow: auto; margin-top: 8px; }
.input-table { width: 100%; }
.input-table input, .input-table select { min-width: 0; width: 100%; padding: 8px 10px; }
.input-table td { vertical-align: middle; }

tr.total td { border-top: 2px solid var(--ink); border-bottom: none; font-weight: 650; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eeeae4;
  color: #5c564e;
  vertical-align: 1px;
}
.muted.block, small.block { display: block; }
.row-actions { width: 1%; text-align: left; white-space: nowrap; }

.log-head.resumo, .log-row.resumo,
.log-head.days, .log-row.days,
.log-head.wide, .log-row.days.home { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.log-head.mao, .log-row.mao { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.log-row.days .num { text-align: left; }

.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.check input { width: auto; }

dialog footer .btn.danger { margin-right: auto; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .layout { display: block; }
  .sidebar, .main { height: auto; position: relative; }
  .main { padding: 20px 16px 48px; }
  .log-head { display: none; }
  .log-row, .log-head.days, .log-row.days, .log-head.wide, .log-row.days.home, .log-head.resumo, .log-row.resumo { grid-template-columns: 1fr 1fr; }
  .side-nav { display: grid; grid-template-columns: 1fr 1fr; }
  .nav-label { grid-column: 1 / -1; }
  .log-row .span { grid-column: 1 / -1; }
  .form-grid, .meta, .sigs { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; }
  h1 { font-size: 26px; }
}

@media (max-width: 560px) {
  .line, .line.mat, .line.occ, .line.mo, .line.eq, .line.sub, .line.eq.obra, .line.sub.obra, .line.aloc, .line.sub-obra, .form-grid, .form-grid.dia, .meta, .sigs {
    grid-template-columns: 1fr;
  }
  .icon-btn { width: 100%; }
}

@page {
  size: A4 landscape;
  margin: 12mm;
}

@media print {
  body { background: white; }
  .sidebar, .no-print, #toast { display: none !important; }
  .layout { display: block; }
  .main { height: auto; overflow: visible; padding: 0; }
  .sheet { border: none; border-radius: 0; padding: 0; }
  .page { max-width: none; }
  body[data-parte] .sheet > .help { display: none !important; }
  body[data-parte] .sheet .block { display: none !important; }
  body[data-parte="faltas"] .sheet .block[data-parte="faltas"],
  body[data-parte="mao"] .sheet .block[data-parte="mao"],
  body[data-parte="subs"] .sheet .block[data-parte="subs"],
  body[data-parte="eq"] .sheet .block[data-parte="eq"] { display: block !important; }
}
