/* ==========================================================================
   CORE O.S. — Design System
   Identidade visual industrial: sala de controle, alto contraste,
   alvos de toque grandes para uso no chão de fábrica.
   ========================================================================== */

:root {
  /* Superfícies */
  --bg: #070a11;
  --bg-elev: #0c111b;
  --surface: #111827;
  --surface-2: #161f30;
  --surface-3: #1d2739;

  /* Linhas */
  --line: rgba(148, 163, 184, 0.14);
  --line-2: rgba(148, 163, 184, 0.26);

  /* Texto */
  --text: #e9eef7;
  --muted: #9aa8bd;
  --faint: #6b7a91;

  /* Marca */
  --brand: #3b82f6;
  --brand-hi: #60a5fa;
  --brand-dim: rgba(59, 130, 246, 0.14);
  --cyan: #22d3ee;

  /* Semáforo */
  --ok: #10b981;
  --ok-dim: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-dim: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.14);
  --info: #0ea5e9;
  --info-dim: rgba(14, 165, 233, 0.14);
  --violet: #8b5cf6;
  --violet-dim: rgba(139, 92, 246, 0.14);

  /* Forma */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-3: 0 28px 60px -20px rgba(0, 0, 0, 0.75);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --tap: 44px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(59, 130, 246, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 211, 238, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

/* ---------------------------------------------------------------- Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 32px);
  background: rgba(7, 10, 17, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand) 0%, #1d4ed8 100%);
  box-shadow: 0 8px 20px -8px rgba(59, 130, 246, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-weight: 800; font-size: 15px; letter-spacing: -0.5px; color: #fff;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: -0.02em; }
.brand-text span { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.14em; }

.topbar-spacer { flex: 1 1 auto; }

.identity { display: flex; align-items: center; gap: 12px; }
.identity-text { text-align: right; line-height: 1.2; }
.identity-text strong { display: block; font-size: 13.5px; }
.identity-text span { font-size: 11px; color: var(--faint); font-family: var(--mono); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-2);
  font-weight: 700; font-size: 13px; color: var(--brand-hi);
}

/* ------------------------------------------------------------------ KPIs */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 18px clamp(14px, 3vw, 32px) 4px;
}

.kpi {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--kpi-accent, var(--brand));
}
.kpi-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--faint); font-weight: 600; margin-bottom: 6px;
}
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* --------------------------------------------------------------- Toolbar */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px clamp(14px, 3vw, 32px) 6px;
}

.search {
  position: relative; flex: 1 1 260px; max-width: 420px;
}
.search input { padding-left: 40px; }
.search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--faint); pointer-events: none;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--faint); font-weight: 600;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="search"], input[type="datetime-local"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
  background: var(--surface-2);
}
select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7a91' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* --------------------------------------------------------------- Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 17px; height: 17px; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-hi), var(--brand));
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(59, 130, 246, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary:hover { background: linear-gradient(180deg, #7cb0fb, #2f6fe0); }

.btn-ok { background: var(--ok); color: #04150e; box-shadow: 0 10px 22px -14px rgba(16, 185, 129, 0.9); }
.btn-ok:hover { background: #0ea371; }
.btn-warn { background: var(--warn-dim); color: #fcd34d; border-color: rgba(245, 158, 11, 0.4); }
.btn-warn:hover { background: rgba(245, 158, 11, 0.24); }
.btn-danger { background: var(--danger-dim); color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.24); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-lg { min-height: 54px; padding: 0 24px; font-size: 15px; }
.btn-icon { width: var(--tap); padding: 0; }

/* ---------------------------------------------------------------- Kanban */
.board-wrap { padding: 10px clamp(14px, 3vw, 32px) 40px; }

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(296px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
}

.col {
  display: flex; flex-direction: column;
  min-height: 240px;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.72), rgba(12, 17, 27, 0.72));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
}

.col-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}
.col-rail { width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 12px currentColor; }
.col-title { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.col-count {
  margin-left: auto;
  min-width: 28px; height: 24px; padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgba(2, 6, 16, 0.7); border: 1px solid var(--line-2);
  font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--muted);
}
.col-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* Cartão de O.S. */
.os-card {
  position: relative;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.os-card::after {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--card-accent, var(--faint));
}
.os-card:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow-2); }
.os-card.is-urgent { border-color: rgba(239, 68, 68, 0.45); }

.os-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.os-num { font-family: var(--mono); font-size: 14px; font-weight: 700; letter-spacing: -0.02em; }
.os-asset {
  font-size: 11.5px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px;
}
.os-symptom {
  margin-top: 10px; font-size: 12.5px; color: #cbd5e1; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.os-meta {
  display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 11px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
}
.os-alert {
  margin-top: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  background: var(--warn-dim); color: #fcd34d;
  font-size: 10.5px; font-family: var(--mono); font-weight: 600;
  display: flex; align-items: center; gap: 7px;
}
.os-alert.is-danger { background: var(--danger-dim); color: #fca5a5; }
.os-actions { display: flex; gap: 8px; margin-top: 12px; }
.os-actions .btn { flex: 1; min-height: 40px; padding: 0 10px; font-size: 12px; }
.os-actions .btn-icon { flex: 0 0 40px; }

/* Pills de status/prioridade */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-aberta { background: var(--info-dim); color: #7dd3fc; border-color: rgba(14, 165, 233, 0.35); }
.pill-planejada { background: var(--violet-dim); color: #c4b5fd; border-color: rgba(139, 92, 246, 0.35); }
.pill-em_execucao { background: var(--brand-dim); color: var(--brand-hi); border-color: rgba(59, 130, 246, 0.4); }
.pill-aguardando_peca { background: var(--warn-dim); color: #fcd34d; border-color: rgba(245, 158, 11, 0.38); }
.pill-encerrada { background: var(--ok-dim); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.38); }
.pill-cancelada { background: var(--danger-dim); color: #fca5a5; border-color: rgba(239, 68, 68, 0.38); }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(2, 6, 16, 0.55); border: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted); font-family: var(--mono);
}

/* --------------------------------------------------------------- Estados */
.empty {
  padding: 26px 12px; text-align: center;
  color: var(--faint); font-size: 12.5px;
  border: 1px dashed var(--line-2); border-radius: var(--r-md);
}
.loading-bar {
  height: 3px; border-radius: 999px; overflow: hidden;
  background: rgba(148, 163, 184, 0.12); margin: 0 clamp(14px, 3vw, 32px);
}
.loading-bar::after {
  content: ""; display: block; height: 100%; width: 34%;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: slide 1.15s infinite ease-in-out;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(360%); } }

/* ---------------------------------------------------------------- Modais */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(6px);
  animation: fade 0.16s ease;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(880px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise 0.18s ease;
}
@keyframes rise { from { transform: translateY(14px) scale(0.99); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), transparent);
}
.modal-head h2 { font-size: 17px; }
.modal-head .mono { color: var(--brand-hi); font-size: 15px; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 16px 22px; border-top: 1px solid var(--line); background: rgba(2, 6, 16, 0.4);
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

/* Abas do wizard */
.tabs {
  display: flex; gap: 6px; padding: 5px;
  background: rgba(2, 6, 16, 0.55);
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow-x: auto;
}
.tab {
  flex: 1; min-width: max-content;
  min-height: 40px; padding: 0 14px;
  border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-1); }
.tab-panel[hidden] { display: none; }

.info-strip {
  padding: 13px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 5px; font-size: 12.5px; color: #cbd5e1;
}
.info-strip b { color: var(--faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; margin-right: 6px; }

.notice {
  padding: 12px 14px; border-radius: var(--r-md); font-size: 12.5px;
  background: var(--brand-dim); border: 1px solid rgba(59, 130, 246, 0.32); color: #bfdbfe;
}
.notice.is-warn { background: var(--warn-dim); border-color: rgba(245, 158, 11, 0.35); color: #fde68a; }
.notice[hidden] { display: none; }

.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
}
.row-item .grow { min-width: 0; }
.row-item strong { font-size: 13px; display: block; }
.row-item small { font-size: 11px; color: var(--faint); font-family: var(--mono); }

.timeline { display: flex; flex-direction: column; gap: 14px; padding-left: 6px; }
.timeline-item { display: flex; gap: 12px; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 6px; box-shadow: 0 0 0 4px var(--brand-dim); flex: 0 0 auto; }
.timeline-item p { font-size: 12.5px; }
.timeline-item small { font-size: 11px; color: var(--faint); font-family: var(--mono); }

/* ------------------------------------------------------------ QR / voz */
.qr-box {
  display: grid; place-items: center; gap: 12px;
  padding: 16px; border-radius: var(--r-lg);
  background: #05070c; border: 1px solid var(--line-2);
}
#leitor-qr { width: 100%; max-width: 320px; min-height: 220px; }
#leitor-qr video { border-radius: var(--r-md); }
.qr-box[hidden] { display: none; }

.inline-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  max-width: 380px; padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-3);
  font-size: 13px; font-weight: 500;
  animation: rise 0.2s ease;
}
.toast[hidden] { display: none; }
.toast.is-ok { border-color: rgba(16, 185, 129, 0.45); color: #a7f3d0; }
.toast.is-error { border-color: rgba(239, 68, 68, 0.45); color: #fecaca; }

.hidden { display: none !important; }

/* --------------------------------------------------------------- Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(430px, 100%);
  padding: 34px 30px;
  background: linear-gradient(180deg, var(--surface), var(--bg-elev));
  border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
}
.login-head { text-align: center; margin-bottom: 26px; }
.login-head .brand-mark { margin: 0 auto 16px; width: 54px; height: 54px; font-size: 18px; }
.login-head h1 { font-size: 21px; }
.login-head p { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--faint); }

.hint-list { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.hint {
  display: flex; align-items: center; gap: 9px;
  font-size: 12px; color: var(--muted);
}
.hint svg { width: 15px; height: 15px; color: var(--brand); flex: 0 0 auto; }

/* ------------------------------------------------------------ Responsivo */
@media (max-width: 720px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 22px; }
  .identity-text { display: none; }
  .modal-body { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
