:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #243040;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #EAAB1C;
  --accent-hover: #c99214;
  --ok: #16a34a;
  --ok-bg: #14532d;
  --warn: #f59e0b;
  --info: #38bdf8;
  --radius: 14px;
  --tap: 48px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}

a {
  color: var(--info);
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px 40px;
}

.app-wide {
  max-width: 960px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 16px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.brand-left {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  height: 44px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  flex-shrink: 0;
  background: #000;
  border-radius: 8px;
  padding: 4px 8px;
}

.logo-mark {
  /* legacy fallback */
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7743BD, #EAAB1C);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

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

.card h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

label .hint {
  font-weight: 400;
  color: var(--muted);
}

.field {
  margin-bottom: 14px;
}

.field.highlight {
  padding: 12px;
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.field.highlight.required-wrap.is-error {
  border-color: var(--accent);
  background: rgba(225, 29, 72, 0.08);
}

input[type="text"],
input[type="tel"],
input[type="date"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* avoid iOS zoom */
  font-family: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.area-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.area-btn {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.area-btn.active {
  background: rgba(225, 29, 72, 0.2);
  border-color: var(--accent);
  color: #fecdd3;
}

.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.check-item input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check-item span {
  font-size: 0.95rem;
}

.check-item:has(input:checked) {
  border-color: var(--accent);
  background: rgba(225, 29, 72, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: var(--accent);
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

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

.btn-ok {
  background: var(--ok);
}

.btn-ok:hover {
  background: #15803d;
}

.btn-sm {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(120%);
  max-width: min(420px, calc(100% - 24px));
  background: var(--ok-bg);
  border: 1px solid var(--ok);
  color: #bbf7d0;
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease;
  z-index: 50;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #450a0a;
  border-color: var(--accent);
  color: #fecaca;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text);
}

/* Admin */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--info);
  color: #bae6fd;
}

.job-card {
  border-left: 4px solid var(--warn);
}

.job-card.faturado {
  border-left-color: var(--ok);
}

.job-card.anulado {
  border-left-color: var(--muted);
  opacity: 0.75;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.job-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.badge.faturado {
  background: rgba(22, 163, 74, 0.2);
  color: #86efac;
}

.badge.anulado {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 12px 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 12px;
}

.table-wrap {
  overflow-x: auto;
}

table.catalog {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.catalog th,
table.catalog td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

table.catalog th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

@media (min-width: 720px) {
  .modal-backdrop {
    align-items: center;
  }
  .modal {
    border-radius: 16px;
  }
}

/* —— Check-in / clôture extras —— */

.main-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.nav-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  min-height: var(--tap);
}

.nav-tile-title {
  font-weight: 700;
  font-size: 1rem;
}

.nav-tile-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.steps .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
}

.steps .step span {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.8rem;
}

.steps .step.active {
  color: #fecdd3;
}

.steps .step.active span {
  background: rgba(225, 29, 72, 0.35);
  border-color: var(--accent);
}

.steps .step.done span {
  background: rgba(22, 163, 74, 0.35);
  border-color: var(--ok);
  color: #bbf7d0;
}

.presence-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.presence-btn {
  min-height: var(--tap);
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 12px;
}

.presence-btn.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--info);
  color: #bae6fd;
}

.signature-wrap {
  background: #f8fafc;
  border-radius: 12px;
  border: 1px dashed var(--border);
  overflow: hidden;
  touch-action: none;
}

.signature-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}

.todo-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed rgba(245, 158, 11, 0.5);
  color: #fcd34d;
  font-size: 0.8rem;
}

.photo-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.photo-preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-sig img {
  max-width: 220px;
  max-height: 110px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.job-summary {
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge.ouvert {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

.job-card.ouvert {
  border-left-color: var(--info);
}

input[type="email"],
input[type="file"] {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

input[type="file"] {
  padding: 10px;
}
