:root {
  --brick: #b85c38;
  --brick-deep: #8b4513;
  --clay: #d2691e;
  --sand: #e8d5b5;
  --sand-light: #f5ead7;
  --concrete: #6b6560;
  --iron: #2c2416;
  --dust: #c4a574;
  --ok: #3d6b4f;
  --warn: #a65d1e;
  --danger: #8f2f2f;
  --white: #fffaf3;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(44, 36, 22, 0.18);
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--iron);
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, rgba(210, 105, 30, 0.28), transparent 55%),
    radial-gradient(ellipse 90% 60% at 100% 0%, rgba(184, 92, 56, 0.22), transparent 50%),
    linear-gradient(165deg, #f7efe3 0%, #e5d3b8 42%, #d4c0a0 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 11px,
    #8b4513 11px,
    #8b4513 12px
  );
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1rem 1rem 5.5rem;
}

.brand {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  line-height: 0.95;
  color: var(--brick-deep);
  margin: 0;
}

.brand span {
  display: block;
  color: var(--clay);
}

.tagline {
  margin: 0.4rem 0 0;
  color: var(--concrete);
  font-size: 1rem;
  font-weight: 600;
}

.screen {
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-login {
  padding: 2.5rem 0 1.5rem;
}

.panel {
  background: color-mix(in srgb, var(--white) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--dust) 55%, transparent);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 0.9rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  font-size: 1.55rem;
  font-weight: 400;
  color: var(--brick-deep);
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--concrete);
  margin: 0.65rem 0 0.3rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--dust);
  background: var(--sand-light);
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.25;
  color: var(--iron);
  min-height: 3.15rem;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  min-height: 1.4rem;
  max-width: 1.4rem;
  max-height: 1.4rem;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  border: 2px solid var(--brick);
  border-radius: 6px;
  background-color: var(--sand-light);
  background-image: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.95rem 0.95rem;
  box-sizing: border-box;
  cursor: pointer;
  vertical-align: middle;
}

input[type="checkbox"]:checked {
  border-color: var(--brick-deep);
  background-color: var(--brick-deep);
  /* Visto branco desenhado — funciona em mobile/desktop */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.2l3 3.1 6-6.4'/%3E%3C/svg%3E");
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--clay);
  outline-offset: 2px;
}

input[type="date"],
input[type="time"] {
  display: block;
  min-height: 3.15rem;
  max-height: 3.15rem;
  padding: 0.7rem 0.9rem;
}

.subhead {
  margin: 1.1rem 0 0.2rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--brick-deep);
}

.report {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--dust) 70%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  color: #1f1a14;
  overflow: hidden;
}

.report-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid #8b4513;
  margin-bottom: 0.9rem;
}

.report-brand {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  color: #8b4513;
  font-size: 1.4rem;
}

.report-header h2 {
  margin: 0.15rem 0 0.35rem;
  font-size: 1.15rem;
  color: #2c2416;
}

.report-meta,
.report-period {
  margin: 0;
  font-size: 0.88rem;
  color: #5c5348;
}

.report-period {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.report-period span {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

@media (min-width: 420px) {
  .report-kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

.kpi {
  background: #f7efe3;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
}

.kpi span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b6560;
  font-weight: 700;
}

.kpi strong {
  font-size: 1.05rem;
  color: #2c2416;
}

.kpi-extra {
  background: #f3e2c7;
}

.kpi-extra strong {
  color: #a65d1e;
}

.kpi-debit {
  background: #f0d4cf;
}

.kpi-debit strong {
  color: #8f2f2f;
}

.report-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  font-size: 0.82rem;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid #e5d3b8;
  padding: 0.55rem 0.4rem;
  text-align: left;
  white-space: nowrap;
}

.report-table th {
  background: #f0e4d0;
  color: #5a4632;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-table tbody tr:nth-child(even) {
  background: #faf6ef;
}

.row-extra {
  background: #fff6ea !important;
}

.row-debit {
  background: #fbf0ee !important;
}

.extra-cell {
  color: #a65d1e;
  font-weight: 700;
}

.debit-cell {
  color: #8f2f2f;
  font-weight: 700;
}

.empty-cell {
  text-align: center !important;
  color: #6b6560;
  padding: 1.2rem 0.5rem !important;
}

.report-footer {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid #e5d3b8;
  font-size: 0.8rem;
  color: #6b6560;
}

.report-footer p {
  margin: 0.2rem 0;
}

@media print {
  body::before,
  .nav,
  .no-print,
  .topbar .btn {
    display: none !important;
  }

  #app {
    max-width: none;
    padding: 0;
  }

  .report {
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
  }

  .report-table {
    min-width: 0;
    font-size: 10pt;
  }
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--concrete) 50%),
    linear-gradient(135deg, var(--concrete) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--clay) 70%, white);
  border-color: var(--clay);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  align-items: end;
}

.field {
  min-width: 0;
}

.field label {
  margin-top: 0.65rem;
}

.field input,
.field select {
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.95rem 1rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--clay), var(--brick-deep));
  color: var(--white);
  box-shadow: 0 8px 20px rgba(139, 69, 19, 0.28);
  margin-top: 1rem;
}

.btn-secondary {
  background: var(--sand);
  color: var(--iron);
  margin-top: 0.6rem;
}

.btn-ok {
  background: linear-gradient(135deg, #4f8a63, var(--ok));
  color: white;
  margin-top: 0.75rem;
}

.btn-ghost {
  background: transparent;
  color: var(--brick-deep);
  border: 1.5px solid var(--dust);
  margin-top: 0.6rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.msg {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.msg-error {
  background: #f3d4d0;
  color: var(--danger);
}

.msg-ok {
  background: #d5e8db;
  color: var(--ok);
}

.msg-warn {
  background: #f3e2c7;
  color: var(--warn);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.topbar .brand {
  font-size: 2.1rem;
}

.user-chip {
  text-align: right;
  font-size: 0.85rem;
  color: var(--concrete);
}

.user-chip strong {
  display: block;
  color: var(--iron);
  font-size: 0.95rem;
}

.clock {
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--brick-deep);
  margin: 0.2rem 0;
}

.clock-sub {
  text-align: center;
  color: var(--concrete);
  margin: 0 0 1rem;
  font-weight: 600;
}

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-trabalhando {
  background: #d5e8db;
  color: var(--ok);
}
.status-almoco {
  background: #f3e2c7;
  color: var(--warn);
}
.status-saiu {
  background: #ddd8d0;
  color: var(--concrete);
}
.status-sem_batida {
  background: #efe6d8;
  color: var(--brick);
}

.person-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--dust) 70%, transparent);
}

.person-row:last-child {
  border-bottom: none;
}

.person-row .name {
  font-weight: 700;
  font-size: 1.05rem;
}

.person-row .meta {
  grid-column: 1 / -1;
  color: var(--concrete);
  font-size: 0.9rem;
}

.obra-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  padding: 0.55rem 0.5rem calc(0.55rem + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--iron) 94%, black);
  border-top: 1px solid rgba(196, 165, 116, 0.35);
  z-index: 20;
}

.nav button {
  border: none;
  background: transparent;
  color: var(--sand);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.45rem 0.2rem;
  border-radius: 10px;
  cursor: pointer;
}

.nav button.active {
  background: rgba(210, 105, 30, 0.35);
  color: var(--white);
}

.punch-btn {
  min-height: 5.5rem;
  font-size: 1.25rem;
  border-radius: 16px;
  margin-top: 1rem;
}

.timeline {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.timeline li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--dust);
  font-size: 0.95rem;
}

.timeline li span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.foto-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.foto-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0;
  border: 1.5px solid var(--dust);
  border-radius: 10px;
  background: var(--sand-light);
  overflow: hidden;
  cursor: pointer;
  width: 4.5rem;
  font: inherit;
  color: var(--concrete);
  font-size: 0.68rem;
  font-weight: 700;
}

.foto-thumb img {
  width: 100%;
  height: 3.4rem;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.foto-thumb.mini {
  width: 2.2rem;
  border-radius: 6px;
}

.foto-thumb.mini img {
  height: 2.2rem;
}

.foto-thumb span {
  padding: 0.15rem 0.2rem 0.3rem;
  text-align: center;
  line-height: 1.1;
}

.foto-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 14, 8, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  gap: 0.75rem;
}

.foto-lightbox[hidden] {
  display: none !important;
}

.foto-lightbox img {
  max-width: min(96vw, 480px);
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
  background: #111;
}

.foto-lightbox-title {
  color: #fff;
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.foto-lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(20, 14, 8, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0.75rem;
}

.camera-sheet {
  width: min(520px, 100%);
  background: var(--white);
  border-radius: 18px 18px 12px 12px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.camera-sheet h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--brick-deep);
  font-size: 1.35rem;
}

.camera-frame {
  margin-top: 0.75rem;
  border-radius: 14px;
  overflow: hidden;
  background: #1a1410;
  aspect-ratio: 3 / 4;
  max-height: 55vh;
}

.camera-frame video,
.camera-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hint {
  font-size: 0.88rem;
  color: var(--concrete);
  margin: 0.5rem 0 0;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.row-actions .btn {
  margin-top: 0;
}

.crud-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.btn-mini {
  width: auto;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  margin-top: 0;
  background: var(--sand);
  color: var(--iron);
}

.btn-danger-mini {
  background: #f0d4cf;
  color: var(--danger);
}

.btn-ok-mini {
  background: #d5e8db;
  color: var(--ok);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  background: color-mix(in srgb, var(--sand) 70%, white);
  padding: 0.3rem;
  border-radius: 12px;
}

.auth-tab {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 700;
  padding: 0.65rem;
  border-radius: 10px;
  color: var(--concrete);
  cursor: pointer;
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--clay), var(--brick-deep));
  color: var(--white);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.85rem;
  font-size: 0.95rem;
  color: var(--iron);
  cursor: pointer;
  user-select: none;
}

.check-row input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  min-height: 1.4rem;
  margin: 0;
}

.empty {
  text-align: center;
  color: var(--concrete);
  padding: 1.2rem 0.5rem;
  font-weight: 600;
}

.demo-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--concrete);
  line-height: 1.4;
}
