/* Tema claro (padrão) */
:root {
  color-scheme: light;
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --ink: #101828;
  --ink-soft: #364153;
  --muted: #4a5565;
  --line: #dee4ec;
  --faint: #d1d5dc;
  --brand-900: #5e1a4f;
  --brand-800: #101828;
  --brand-700: #7d2468;
  --brand: #a8328a;
  --brand-2: #a8328a;
  --brand-hover: #8f2a76;
  --brand-50: #faf0f7;
  --brand-100: #f3e0ee;
  --brand-accent: #d1d5dc;
  --brand-ink: #101828;
  --brand-gradient: linear-gradient(135deg, #a8328a 0%, #7d2468 100%);
  --logo-space: #a8328a;
  --logo-brain: #101828;
  --on-brand: #ffffff;
  --alt-bg: #101828;
  --alt-ink: #ffffff;
  --toast-bg: #101828;
  --toast-ink: #ffffff;
  --accent: #a8328a;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-border: #f5d9a8;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --info-bg: #f3f4f6;
  --info: #4a5565;
  --feriado-bg: #f3f4f6;
  --feriado-ink: #4a5565;
  --focus-ring: rgba(168, 50, 138, 0.2);
  --radius: 14px;
  --shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Tema escuro */
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #030712;
  --surface: #0b1018;
  --surface-2: #1e2939;
  --ink: #ffffff;
  --ink-soft: #d1d5dc;
  --muted: #99a1af;
  --line: #1e2939;
  --faint: #364153;
  --brand-900: #ffffff;
  --brand-800: #f3f4f6;
  --brand-700: #c04aa5;
  --brand: #a8328a;
  --brand-2: #e08acb;
  --brand-hover: #c04aa5;
  --brand-50: #241020;
  --brand-100: #33172c;
  --brand-accent: #364153;
  --brand-ink: #ffffff;
  --brand-gradient: linear-gradient(135deg, #a8328a 0%, #7d2468 100%);
  --logo-space: #a8328a;
  --logo-brain: #ffffff;
  --on-brand: #ffffff;
  --alt-bg: #f3f4f6;
  --alt-ink: #030712;
  --toast-bg: #1e2939;
  --toast-ink: #ffffff;
  --accent: #a8328a;
  --ok: #47cd89;
  --ok-bg: #0d2a1d;
  --warn: #fdb022;
  --warn-bg: #2a2110;
  --warn-border: #5a4420;
  --danger: #fda29b;
  --danger-bg: #2a1214;
  --info-bg: #1e2939;
  --info: #d1d5dc;
  --feriado-bg: #1e2939;
  --feriado-ink: #d1d5dc;
  --focus-ring: rgba(224, 138, 203, 0.35);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--brand-2);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
}

.hidden {
  display: none !important;
}

.print-only {
  display: none;
}

@media print {
  .print-only {
    display: block !important;
  }

  .screen-only {
    display: none !important;
  }
}

/* ---------- Login / Setup ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
}

[data-theme='dark'] .auth-page {
  background: linear-gradient(180deg, #070b13 0%, #030712 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 26px 26px;
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
}

[data-theme='dark'] .auth-card {
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 22px;
}

.brand-logo {
  display: inline-flex;
  align-items: baseline;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--logo-brain);
  flex: none;
  user-select: none;
}

.brand-logo-space {
  color: var(--logo-space);
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand-ink);
}

.auth-title {
  font-size: 22px;
  margin-bottom: 4px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.check input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--brand-2);
}

.field-hint {
  display: block;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

input,
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--ink);
  transition: filter 0.15s, transform 0.05s, background 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-accent {
  background: var(--alt-bg);
  color: var(--alt-ink);
}

.btn-outline {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm {
  padding: 7px 11px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
  padding: 15px;
  font-size: 17px;
  border-radius: 13px;
}

.btn-punch {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 8px 20px rgba(168, 50, 138, 0.24);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.btn-punch:disabled {
  box-shadow: none;
}

.alert {
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger);
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--line);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--line);
}

.auth-hint {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.auth-alternative {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.auth-alternative summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  text-align: center;
}

.auth-alternative form {
  margin-top: 16px;
}

.auth-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

.field input.code-input {
  text-align: center;
  letter-spacing: 0.32em;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.auth-alt-actions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.auth-alt-actions .btn {
  padding: 11px;
  font-size: 14px;
  border-radius: 11px;
}

.auth-footer {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.btn-microsoft {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.btn-microsoft:hover {
  background: var(--surface-2);
}

/* ---------- App shell ---------- */
.app-header {
  background: var(--surface);
  color: var(--ink);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
}

/* No tema escuro o cabeçalho acompanha o fundo da página, como na referência. */
[data-theme='dark'] .app-header {
  background: var(--bg);
}

.app-header .brand-logo {
  font-size: 20px;
}

.app-header-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.app-header-sub {
  font-size: 12px;
  color: var(--muted);
}

.app-header-spacer {
  flex: 1;
}

.app-header .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  text-align: right;
}

.app-header .user-chip small {
  display: block;
  color: var(--muted);
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--faint);
}

/* ---------- Alternador de tema ---------- */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme='dark'] .theme-toggle .icon-sun {
  display: block;
}

[data-theme='dark'] .theme-toggle .icon-moon {
  display: none;
}

.app-header .theme-toggle {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
}

.app-header .theme-toggle:hover {
  background: var(--surface-2);
  border-color: var(--faint);
}

.theme-toggle-float {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 30;
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.08);
}

.app-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 16px 48px;
}

.admin-main {
  max-width: 1140px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.card-sub {
  color: var(--muted);
  font-size: 13.5px;
}

.today-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.clock {
  text-align: right;
}

.clock-time {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
  line-height: 1;
}

.clock-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.slot-list {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}

.slot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.slot-row:last-child {
  border-bottom: 0;
}

.slot-row.current {
  background: var(--brand-50);
}

.slot-row.done {
  background: var(--surface-2);
}

.slot-status {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  flex: none;
  background: var(--line);
  color: var(--muted);
}

.slot-row.done .slot-status {
  background: var(--ok-bg);
  color: var(--ok);
}

.slot-row.current .slot-status {
  background: var(--brand-100);
  color: var(--brand-ink);
}

.slot-label {
  flex: 1;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.slot-time {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.slot-time.empty {
  color: var(--faint);
  font-weight: 600;
}

.slot-source {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand-ink);
}

.stat-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.toolbar input[type='month'],
.toolbar select {
  width: auto;
  min-width: 165px;
  padding: 9px 11px;
}

.month-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--ink-soft);
}

.pill strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.pill.ok {
  background: var(--ok-bg);
  border-color: var(--line);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-bg);
  border-color: var(--line);
  color: var(--warn);
}

.pill.danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.badge {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 2px 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge-trabalho {
  background: var(--ok-bg);
  border-color: var(--line);
  color: var(--ok);
}

.badge-falta {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.badge-incompleto,
.badge-hoje {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.badge-feriado {
  background: var(--feriado-bg);
  border-color: var(--line);
  color: var(--feriado-ink);
}

.badge-atestado {
  background: var(--info-bg);
  border-color: var(--line);
  color: var(--info);
}

.badge-folga,
.badge-futuro,
.badge-antes-admissao {
  background: var(--surface-2);
  color: var(--muted);
}

.day-list {
  display: grid;
  gap: 8px;
}

.day-item {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--surface);
}

.day-item.weekend {
  background: var(--surface-2);
}

.day-date {
  font-weight: 700;
  font-size: 14px;
}

.day-date small {
  display: block;
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.day-times {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.time-chip {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 7px;
  color: var(--ink-soft);
}

.time-chip.empty {
  color: var(--faint);
}

.day-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-end;
}

.day-worked {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.day-extra {
  font-size: 11.5px;
  color: var(--ok);
  font-weight: 600;
}

.day-certificate {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 600;
}

.day-adjustment {
  font-size: 11.5px;
  color: var(--warn);
  font-weight: 600;
}

/* ---------- Tabs (admin) ---------- */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 15px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.section {
  display: none;
}

.section.active {
  display: block;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 620px;
}

table.data th,
table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  background: var(--surface-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr:hover {
  background: var(--surface-2);
}

/* Auditoria: a descrição precisa quebrar linha em vez de esticar a tabela. */
table.data td.audit-detail {
  min-width: 320px;
  max-width: 560px;
  white-space: normal;
  line-height: 1.45;
}

table.data td.audit-detail .muted {
  margin-top: 2px;
}

table.data td.audit-when {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* Código de acesso exibido ao administrador para entrega manual */
.code-display {
  margin: 14px 0 8px;
  padding: 16px 12px;
  border: 1px dashed var(--brand);
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--ink);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Modal ---------- */
dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(520px, calc(100vw - 28px));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.modal-body {
  padding: 22px;
}

.modal-title {
  font-size: 18px;
  margin-bottom: 4px;
}

.modal-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--toast-bg);
  color: var(--toast-ink);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.error {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--ink);
}
/* ---------- Espelho / impressão ---------- */
.report {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--surface);
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.report-company {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.report-company strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
}

.report-title {
  text-align: right;
}

.report-title h2 {
  font-size: 20px;
  color: var(--brand-ink);
  letter-spacing: 0.04em;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 16px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.report-meta span {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.report-meta strong {
  font-weight: 600;
}

table.espelho {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

table.espelho th,
table.espelho td {
  border: 1px solid var(--line);
  padding: 4px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

table.espelho th {
  background: var(--surface-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table.espelho td.left {
  text-align: left;
}

table.espelho tr.weekend td,
table.espelho tr.holiday td {
  background: var(--surface-2);
}

table.espelho tfoot td {
  font-weight: 700;
  background: var(--surface-2);
}

.report-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin-top: 36px;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
}

.signature-line {
  border-top: 1px solid var(--ink-soft);
  padding-top: 4px;
}

.signature-name {
  font-weight: 600;
  color: var(--ink);
  margin-top: 3px;
  font-size: 11.5px;
}

.signature-stamp {
  font-size: 10.5px;
  margin-top: 2px;
}

.signature-stamp.signed {
  color: var(--ok);
  font-weight: 600;
}

.signature-stamp.pending {
  color: var(--muted);
}

/* ---------- Atestados ---------- */
.check-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.check-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  color: var(--ink-soft);
}

.check-icon {
  font-weight: 700;
  text-align: center;
}

.check-item.ok .check-icon {
  color: var(--ok);
}

.check-item.warn .check-icon {
  color: var(--warn);
}

.check-item.error .check-icon {
  color: var(--danger);
}

.check-item code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 12px;
  word-break: break-all;
}

.certificate-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.certificate-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  background: var(--surface);
}

.certificate-item.pendente {
  border-left: 4px solid var(--warn);
}

.certificate-item.aprovado {
  border-left: 4px solid var(--ok);
}

.certificate-item.recusado {
  border-left: 4px solid var(--danger);
}

.certificate-item.cancelado {
  border-left: 4px solid var(--line);
  opacity: 0.85;
}

.certificate-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.certificate-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.badge-pendente {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.badge-aprovado {
  background: var(--ok-bg);
  border-color: var(--line);
  color: var(--ok);
}

.badge-recusado {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}

.badge-cancelado {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

.badge-anexo {
  background: var(--info-bg);
  border-color: var(--line);
  color: var(--info);
}

.badge-microsoft {
  background: var(--info-bg);
  border-color: var(--line);
  color: var(--info);
}

.certificate-link {
  color: var(--brand-2);
  font-weight: 600;
  text-decoration: underline;
}

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-soft);
}

.attachment-preview img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  flex: none;
}

.attachment-preview .attachment-name {
  flex: 1;
  word-break: break-word;
}

.certificate-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.report-foot-status {
  margin-top: 12px;
}

.badge-aprovacao {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-aberto {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}

.badge-assinado {
  background: var(--info-bg);
  border-color: var(--line);
  color: var(--info);
}

.badge-aprovado {
  background: var(--ok-bg);
  border-color: var(--line);
  color: var(--ok);
}

/* ---------- Responsivo ---------- */
@media (max-width: 640px) {
  .app-main {
    padding: 14px 12px 40px;
  }

  .card {
    padding: 16px;
    border-radius: 14px;
  }

  .clock-time {
    font-size: 28px;
  }

  .slot-time {
    font-size: 17px;
  }

  .day-item {
    grid-template-columns: 50px 1fr;
    row-gap: 6px;
  }

  .day-side {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed var(--line);
    padding-top: 6px;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .stat {
    padding: 9px 6px;
  }

  .stat-value {
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .report {
    padding: 12px;
    border: 0;
  }

  .report-title {
    text-align: left;
  }

  .report-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header {
    gap: 8px;
    padding: 12px 12px;
  }

  .app-header .brand-logo {
    font-size: 17px;
  }

  .app-header-title {
    font-size: 13px;
  }

  .app-header-sub,
  .app-header .user-chip {
    display: none;
  }

  .icon-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
  }

  .theme-toggle svg {
    width: 16px;
    height: 16px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 9mm;
  }

  html,
  body {
    height: auto;
    min-height: 0;
    background: #fff;
    font-size: 10pt;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Impressão sempre em fundo branco, mesmo no tema escuro */
  html[data-theme='dark'] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f3f4f6;
    --ink: #101828;
    --ink-soft: #364153;
    --muted: #4a5565;
    --line: #d1d5dc;
    --faint: #d1d5dc;
    --brand: #101828;
    --brand-2: #101828;
    --brand-800: #101828;
    --brand-50: #faf0f7;
    --brand-100: #f3e0ee;
    --brand-accent: #d1d5dc;
    --brand-ink: #101828;
    --logo-space: #a8328a;
    --logo-brain: #101828;
    --alt-bg: #101828;
    --alt-ink: #ffffff;
    --ok: #067647;
    --ok-bg: #ecfdf3;
    --warn: #b54708;
    --warn-bg: #fffaeb;
    --warn-border: #f5d9a8;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --info-bg: #f3f4f6;
    --info: #4a5565;
    --feriado-bg: #f3f4f6;
    --feriado-ink: #4a5565;
  }

  .theme-toggle {
    display: none !important;
  }

  .app-header,
  .no-print,
  .tabs,
  .toast,
  .day-list,
  .card-title,
  .card-sub,
  .toolbar,
  .empty-state,
  .report-meta .print-hide {
    display: none !important;
  }

  .app-main {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .card,
  .report {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0;
    background: #fff;
  }

  .report {
    break-inside: avoid;
    page-break-inside: avoid;
    page-break-after: avoid;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .report-head {
    padding-bottom: 4px;
    margin-bottom: 5px;
    gap: 10px;
  }

  .report-company {
    font-size: 8.5px;
    line-height: 1.35;
  }

  .report-company strong {
    font-size: 10px;
  }

  .report-title h2 {
    font-size: 13px;
    letter-spacing: 0.08em;
  }

  .report-title .muted {
    font-size: 8.5px;
  }

  .report-meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px 10px;
    margin-bottom: 6px;
    font-size: 9px;
    line-height: 1.3;
  }

  .report-meta span {
    font-size: 7px;
    letter-spacing: 0.04em;
  }

  table.espelho {
    font-size: 10px;
  }

  table.espelho th,
  table.espelho td {
    padding: 2px 5px;
    line-height: 1.25;
    border-color: #99a1af;
  }

  table.espelho th {
    font-size: 7.5px;
    letter-spacing: 0.02em;
  }

  table.espelho tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table.espelho thead {
    display: table-header-group;
  }

  table.espelho tfoot {
    display: table-row-group;
  }

  .report-signatures {
    margin-top: 12px;
    font-size: 9px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-foot {
    margin-top: 8px;
    align-items: flex-end;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .report-foot-status {
    margin-top: 0;
  }

  .badge-aprovacao {
    font-size: 8px;
    padding: 2px 7px;
  }

  .signature-line {
    padding-top: 2px;
  }

  .signature-name {
    font-size: 9px;
  }

  .signature-stamp {
    font-size: 8px;
  }
}
