/* JOFCLEAN — Operação de campo
   Design system enxuto: cores semânticas por ação, cartões claros,
   tipografia do sistema (rápida e 100% offline) e alvo de toque grande
   para uso em campo com uma mão só. */

:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --border: #dde4ec;
  --text: #14212e;
  --text-muted: #5b6b7b;
  --brand: #112a36;
  --brand-2: #1c4a63;
  --accent: #c3d62a;
  --accent-ink: #2b3300;
  --success: #1a9c5c;
  --success-bg: #e7f6ee;
  --warning: #b3760a;
  --warning-bg: #fdf3e0;
  --danger: #c93636;
  --danger-bg: #fbeaea;
  --info: #2563a8;
  --info-bg: #e8f1fb;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 35, 55, .06);
  --shadow: 0 10px 30px -12px rgba(11, 51, 80, .25);
  --shadow-lg: 0 24px 60px -20px rgba(11, 51, 80, .35);
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1420;
    --surface: #111d2b;
    --surface-2: #17263a;
    --border: #223347;
    --text: #eaf1f8;
    --text-muted: #9fb2c3;
    --brand: #16374a;
    --brand-2: #235e7d;
    --accent: #c3d62a;
    --accent-ink: #2b3300;
    --success: #35c07d;
    --success-bg: #103524;
    --warning: #e0a53a;
    --warning-bg: #3a2c0d;
    --danger: #f2726b;
    --danger-bg: #3a1414;
    --info: #6fb1ee;
    --info-bg: #10263c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .55);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; }
p { margin: 0; }
/* appearance:none evita que o Chrome pinte um widget nativo (que muda de
   cara sozinho com color-scheme:dark) por cima do fundo/cor que definimos. */
button { font: inherit; color: inherit; background: none; border: none; appearance: none; -webkit-appearance: none; }
input, select { font: inherit; color: inherit; }

/* Garante que [hidden] sempre vença qualquer `display` definido por um
   componente (.button, .login-screen, .modal-overlay etc.) — sem esta regra,
   a especificidade de classe do componente venceria o `[hidden]` do navegador. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Botões ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .85rem 1.2rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; cursor: pointer; transition: transform .12s ease, filter .15s ease, opacity .15s ease;
}
.button:active { transform: scale(.98); }
.button--block { width: 100%; }
.button--primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.button--primary:hover { filter: brightness(1.08); }
.button--ghost { background: transparent; color: var(--brand-2); border-color: var(--border); }
.button:disabled, .button.is-busy { opacity: .6; cursor: default; pointer-events: none; }

/* ---------- Tela de login ---------- */
.login-screen {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background:
    radial-gradient(1100px 500px at 15% -10%, color-mix(in srgb, var(--brand) 30%, transparent), transparent),
    radial-gradient(900px 500px at 100% 110%, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 32px 28px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 28px; text-align: center; }
.brand__logo { width: min(230px, 70%); height: auto; border-radius: 10px; }
.brand__tagline { color: var(--text-muted); font-size: .85rem; }

.field-label { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; display: block; }
.field { display: block; margin-top: 18px; }

.employee-chips { display: flex; flex-direction: column; gap: 8px; }
.employee-chip {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; text-align: left;
  transition: border-color .15s ease, background .15s ease;
}
.employee-chip:hover { border-color: var(--brand-2); }
.employee-chip.is-selected {
  border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, var(--surface-2));
  box-shadow: inset 0 0 0 1px var(--brand);
}
.employee-chip.is-selected .employee-chip__avatar { background: var(--accent); color: var(--accent-ink); }
.employee-chip__avatar {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; flex: none;
  background: var(--brand); color: #fff; font-weight: 700; font-size: .78rem;
}

.welcome-employee { color: var(--text-muted); font-size: .9rem; margin-top: 6px; }
.welcome-employee:empty { display: none; }

.pin-field { position: relative; margin-top: 6px; }
.pin-field input {
  width: 100%; padding: .9rem 3rem .9rem 1rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface-2); letter-spacing: .3em; font-size: 1.1rem;
}
.pin-field input:focus { outline: none; border-color: var(--brand); background: var(--surface); }
.pin-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent;
  padding: 8px; border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.pin-toggle.is-active, .pin-toggle:hover { color: var(--brand); }

#login-form .button--primary { margin-top: 22px; }
#login-form .button--ghost { margin-top: 10px; }
.button--sync-login { color: var(--text-muted); font-size: .85rem; font-weight: 600; border-style: dashed; }

/* ---------- Faixa offline ---------- */
.offline-banner {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--warning-bg); color: var(--warning); font-size: .85rem; font-weight: 600; padding: 8px 12px; text-align: center;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--brand); color: #fff; box-shadow: var(--shadow-sm);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; }
.topbar__brand img { border-radius: 7px; flex: none; }
.topbar__employee {
  display: flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 4px;
  font-size: .85rem; opacity: .9; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__actions { display: flex; align-items: center; gap: 4px; }
.icon-button {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: none; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; transition: background .15s ease;
}
.icon-button:hover { background: rgba(255,255,255,.22); }
.icon-button:disabled { opacity: .5; }
.pending-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800; display: grid; place-items: center;
}

/* ---------- Conteúdo ---------- */
.content { max-width: 720px; margin: 0 auto; padding: 20px 16px 100px; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel__title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }

.services-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.service-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.service-card__time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--brand-2); min-width: 48px; }
.service-card__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.service-card__client { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-card__os { font-size: .8rem; color: var(--text-muted); }
.service-card__badge {
  margin-left: auto; font-size: .72rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--success-bg); color: var(--success); white-space: nowrap;
}
.service-card__badge--next { background: var(--info-bg); color: var(--info); }
.service-card.is-current { border-color: var(--success); }
.service-card.is-next { border-color: var(--info); }

.schedule-empty { display: flex; align-items: center; gap: 10px; color: var(--text-muted); padding: 10px 4px; }

/* ---------- Ações ---------- */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.action-button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px 14px; min-height: 92px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface-2);
  cursor: pointer; text-align: left; transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}
.action-button:hover { border-color: var(--brand-2); box-shadow: var(--shadow-sm); }
.action-button:active { transform: scale(.97); }
.action-button span { font-weight: 700; font-size: .88rem; line-height: 1.2; }
.action-button .icon { width: 22px; height: 22px; }

.action-button--start { color: var(--brand-2); }
.action-button--start .icon { color: var(--brand-2); }
.action-button--finish { color: var(--success); }
.action-button--finish .icon { color: var(--success); }
.action-button--pause, .action-button--resume, .action-button--wait { color: var(--warning); }
.action-button--pause .icon, .action-button--resume .icon, .action-button--wait .icon { color: var(--warning); }
.action-button--danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.action-button--danger .icon { color: var(--danger); }
.action-button--end { color: var(--text-muted); }
.action-button--neutral { color: var(--info); }
.action-button--neutral .icon { color: var(--info); }

.actions-notice {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--warning-bg); color: var(--warning); font-size: .88rem; font-weight: 600;
}

/* ---------- Modal de fechamento ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; background: rgba(8, 18, 28, .55); backdrop-filter: blur(2px);
  align-items: flex-end; justify-content: center; padding: 0;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 24px; }
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); padding: 22px 20px 28px;
}
@media (min-width: 640px) {
  .modal-card { border-radius: var(--radius-lg); }
}
.modal-card h2 { font-size: 1.15rem; margin-bottom: 16px; }
.modal-card fieldset { border: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-card legend {
  font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  padding: 0; margin-bottom: 4px;
}
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; font-weight: 600; }
.modal-card input, .modal-card select {
  padding: .7rem .8rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface-2);
  font-weight: 500;
}
.modal-card input:focus, .modal-card select:focus { outline: none; border-color: var(--brand); }
.modal-card .checkbox-row { flex-direction: row; align-items: center; gap: 8px; }
.modal-card .checkbox-row input { width: 18px; height: 18px; }
.closure-note { font-size: .82rem; color: var(--text-muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px); z-index: 60;
  display: flex; align-items: center; gap: 10px; max-width: min(92vw, 420px); padding: 12px 16px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: .86rem; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast__icon { display: grid; place-items: center; flex: none; }
.toast[data-tone="success"] .toast__icon { color: var(--success); }
.toast[data-tone="error"] .toast__icon { color: var(--danger); }
.toast[data-tone="warning"] .toast__icon { color: var(--warning); }
.toast[data-tone="info"] .toast__icon { color: var(--info); }
.toast__icon svg { width: 18px; height: 18px; }
