/* ══════════════════════════════════════════════════════════
   OS-MVMSTI — Sistema de Gestão de Ordens de Serviço
   Identidade: oficina técnica / bancada de diagnóstico
══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #0b1220;
  --surface: #121b2e;
  --surface2: #1a2740;
  --border: #243352;
  --border2: #2f4368;

  --text: #e7ecf5;
  --text-muted: #8a99b8;
  --text-dim: #4f5d7c;
  --text-on-accent: #07150f;

  --accent: #10b981;
  --accent-hover: #0d9c6f;
  --accent-glow-08: rgba(16,185,129,.08);
  --accent-glow-15: rgba(16,185,129,.15);
  --accent-glow-25: rgba(16,185,129,.25);
  --accent-glow-40: rgba(16,185,129,.40);

  --blue: #3b82f6; --blue-bg: rgba(59,130,246,.12); --blue-text: #93c5fd; --blue-border: rgba(59,130,246,.28);
  --amber: #f59e0b; --amber-bg: rgba(245,158,11,.13); --amber-text: #fcd34d; --amber-border: rgba(245,158,11,.3);
  --red: #ef4444; --red-bg: rgba(239,68,68,.12); --red-text: #fca5a5; --red-border: rgba(239,68,68,.28);
  --green: #10b981; --green-bg: rgba(16,185,129,.12); --green-text: #6ee7b7; --green-border: rgba(16,185,129,.28);
  --gray-bg: rgba(255,255,255,.05); --gray-dot: #64748b;

  --radius: 14px;
  --radius-sm: 9px;
  --font-display: 'Space Grotesk', sans-serif;
  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', monospace;

  --header-bg: rgba(11,18,32,.85);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface2: #eef1f7;
  --border: #dde3ee;
  --border2: #c8d2e3;

  --text: #101826;
  --text-muted: #5b6b88;
  --text-dim: #97a3ba;
  --text-on-accent: #ffffff;

  --accent: #059669;
  --accent-hover: #047857;
  --accent-glow-08: rgba(5,150,105,.07);
  --accent-glow-15: rgba(5,150,105,.13);
  --accent-glow-25: rgba(5,150,105,.2);
  --accent-glow-40: rgba(5,150,105,.32);

  --blue-bg: rgba(59,130,246,.1); --blue-text: #1d4ed8; --blue-border: rgba(59,130,246,.3);
  --amber-bg: rgba(245,158,11,.13); --amber-text: #92400e; --amber-border: rgba(245,158,11,.35);
  --red-bg: rgba(239,68,68,.1); --red-text: #b91c1c; --red-border: rgba(239,68,68,.3);
  --green-bg: rgba(5,150,105,.1); --green-text: #047857; --green-border: rgba(5,150,105,.3);
  --gray-bg: rgba(15,15,30,.05); --gray-dot: #64748b;

  --header-bg: rgba(243,245,249,.85);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-glow-40); }

input, select, textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 13px; color: var(--text);
  font-family: var(--font); font-size: .9rem; outline: none; transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: var(--surface); }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 70px; }
select { cursor: pointer; }
input[type="color"] { padding: 4px; height: 42px; cursor: pointer; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--text-muted); }
.field-hint { font-size: .72rem; color: var(--text-dim); line-height: 1.4; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row label { font-size: .85rem; color: var(--text); cursor: pointer; }

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: var(--radius-sm); font-family: var(--font);
  font-size: .85rem; font-weight: 600; padding: 10px 18px; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--text-on-accent); box-shadow: 0 4px 16px var(--accent-glow-25); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 20px var(--accent-glow-40); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-bg); color: var(--red-text); border: 1px solid var(--red-border); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-icon {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }
.btn-full { width: 100%; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--spinner-track, rgba(255,255,255,.3)); border-top-color: var(--spinner-active, #fff); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-green { background: var(--green-bg); color: var(--green-text); } .badge-green::before { background: var(--green); }
.badge-blue { background: var(--blue-bg); color: var(--blue-text); } .badge-blue::before { background: var(--blue); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); } .badge-amber::before { background: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red-text); } .badge-red::before { background: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--text-muted); } .badge-gray::before { background: var(--gray-dot); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 14px; }
.alert-error { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-text); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .85rem; }
.alert-success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green-text); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .85rem; }
.alert-info { background: var(--blue-bg); border: 1px solid var(--blue-border); color: var(--blue-text); border-radius: var(--radius-sm); padding: 10px 14px; font-size: .85rem; }

.state-msg { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 56px 20px; color: var(--text-muted); font-size: .88rem; text-align: center; }
.state-icon { font-size: 2rem; opacity: .5; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th { text-align: left; padding: 10px 14px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface2); }
.table tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }
.mono { font-family: var(--mono); }
.td-numero { font-family: var(--mono); font-weight: 600; color: var(--accent); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.5); }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 980px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-shrink: 0; }
.btn-close { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.btn-close:hover { background: var(--surface2); color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn { padding: 10px 16px; background: none; border: none; color: var(--text-muted); font-family: var(--font); font-size: .85rem; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color .12s, border-color .12s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.btn-theme-toggle { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; flex-shrink: 0; }
.btn-theme-toggle:hover { color: var(--text); }
.btn-theme-toggle .icon-sun { display: none; }
[data-theme="light"] .btn-theme-toggle .icon-moon { display: none; }
[data-theme="light"] .btn-theme-toggle .icon-sun { display: block; }

/* Trilha de status — signature element: progresso da OS como trilha de circuito */
.trilha-status { display: flex; align-items: flex-start; overflow-x: auto; padding: 8px 2px 4px; gap: 0; }
.trilha-no { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; min-width: 86px; position: relative; }
.trilha-ponto { width: 14px; height: 14px; border-radius: 50%; background: var(--surface2); border: 2px solid var(--border2); z-index: 2; transition: all .2s; }
.trilha-no.feito .trilha-ponto { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow-15); }
.trilha-no.atual .trilha-ponto { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow-25); animation: pulse-no 2s ease-in-out infinite; }
.trilha-no.erro .trilha-ponto { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 3px var(--red-border); }
@keyframes pulse-no { 0%, 100% { box-shadow: 0 0 0 4px var(--accent-glow-25); } 50% { box-shadow: 0 0 0 7px var(--accent-glow-08); } }
.trilha-linha { position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: var(--border2); z-index: 1; }
.trilha-no:first-child .trilha-linha { display: none; }
.trilha-no.feito .trilha-linha, .trilha-no.atual .trilha-linha { background: var(--accent); }
.trilha-label { font-size: .66rem; color: var(--text-dim); text-align: center; margin-top: 8px; line-height: 1.3; max-width: 86px; }
.trilha-no.feito .trilha-label, .trilha-no.atual .trilha-label { color: var(--text); font-weight: 600; }

.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.timeline-item:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 3px; flex-shrink: 0; z-index: 1; }
.timeline-content { flex: 1; }
.timeline-acao { font-size: .85rem; font-weight: 600; }
.timeline-meta { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }
.timeline-detalhe { font-size: .8rem; color: var(--text-muted); margin-top: 5px; background: var(--surface2); padding: 8px 11px; border-radius: 8px; }

.orcamento-item-row { display: grid; grid-template-columns: 1fr 110px 110px 120px 32px; gap: 8px; align-items: center; margin-bottom: 8px; }
.orcamento-total { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; margin-top: 8px; border-top: 1px solid var(--border); font-size: 1.1rem; font-weight: 700; font-family: var(--font-display); }

@media (max-width: 720px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .orcamento-item-row { grid-template-columns: 1fr 1fr; }
}
