:root {
  --ink: #172033;
  --muted: #647084;
  --line: #d9e0ea;
  --panel: #ffffff;
  --bg: #f4f7fb;
  --navy: #14213d;
  --amber: #fca311;
  --teal: #2a9d8f;
  --red: #d62828;
  --green: #2b9348;
  --blue: #2f6fed;
  --violet: #6d5bd0;
  --gray: #6c757d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 264px 1fr; }
.sidebar { background: var(--navy); color: #fff; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 800; }
.brand img { width: 38px; height: 38px; }
.role { color: #b8c2d8; font-size: 13px; }
.nav { display: grid; gap: 8px; }
.nav button { color: #dfe7f7; background: transparent; text-align: left; padding: 12px 14px; border-radius: 8px; }
.nav button.active, .nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.session { margin-top: auto; display: grid; gap: 10px; }
.sync-state { border-radius: 8px; padding: 10px 12px; font-size: 13px; font-weight: 800; background: rgba(255,255,255,.12); color: #fff; }
.sync-state.online { border-left: 4px solid var(--green); }
.sync-state.offline { border-left: 4px solid var(--amber); }
.content { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 22px rgba(20,33,61,.06); }
.panel { padding: 18px; }
.card { padding: 14px; }
.metric { display: grid; gap: 8px; min-height: 110px; }
.metric strong { font-size: 30px; }
.metric span { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { max-width: 220px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 14px; border-radius: 8px; background: var(--navy); color: #fff; font-weight: 700; }
.btn.secondary { background: #e9eef6; color: var(--ink); }
.btn.danger { background: var(--red); }
.btn.success { background: var(--green); }
.btn.warn { background: var(--amber); color: #1b1b1b; }
.btn.full { width: 100%; }
.icon-btn { width: 42px; height: 42px; padding: 0; border-radius: 8px; background: #e9eef6; color: var(--ink); }

.status { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; color: #fff; font-weight: 800; font-size: 12px; }
.s-aberta { background: var(--blue); }
.s-em-andamento, .s-em-atendimento, .s-check-in-realizado, .s-em-deslocamento { background: var(--teal); }
.s-atrasada, .s-critica { background: var(--red); }
.s-finalizada { background: var(--green); }
.s-aguardando-peca, .s-aguardando-aprovacao, .s-pendente-cliente { background: var(--amber); color: #1b1b1b; }
.s-cancelada { background: var(--gray); }
.s-tecnico-designado, .s-agendada, .s-aberta-pelo-cliente { background: var(--violet); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td { font-size: 14px; }
.table-wrap { overflow-x: auto; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 11px 12px; outline: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #14213d, #274060 52%, #2a9d8f); }
.login-card { width: min(440px, 100%); background: #fff; border-radius: 8px; padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.login-card .brand { color: var(--navy); margin-bottom: 16px; }
.demo-users { display: grid; gap: 8px; margin-top: 16px; }
.demo-users button { background: #eef3fa; color: var(--ink); padding: 10px; border-radius: 8px; text-align: left; }

.orders { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 16px; }
.os-card { display: grid; gap: 10px; border-left: 5px solid var(--blue); }
.os-card.selected { outline: 3px solid rgba(47,111,237,.18); }
.os-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.timeline { display: grid; gap: 10px; margin-top: 12px; }
.timeline-item { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }

.map { min-height: 420px; position: relative; overflow: hidden; background: #d7ecf0; }
.map::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255,255,255,.5) 1px, transparent 1px), linear-gradient(rgba(255,255,255,.5) 1px, transparent 1px); background-size: 44px 44px; }
.pin { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50% 50% 50% 0; rotate: -45deg; background: var(--teal); color: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.22); }
.pin span { rotate: 45deg; font-weight: 900; }
.map-label { position: absolute; transform: translate(-50%, 24px); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 160px; font-size: 12px; box-shadow: 0 8px 20px rgba(0,0,0,.12); }

.mobile-frame { max-width: 560px; margin: 0 auto; }
.action-stack { display: grid; gap: 10px; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 18%); padding: 22px 0 0; }
.signature { height: 180px; border: 1px dashed var(--muted); border-radius: 8px; background: #fff; touch-action: none; width: 100%; }
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-preview img { width: 86px; height: 86px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

.qr-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #eef3f6; }
.qr-card { width: min(720px, 100%); }
.qr-card h1 { margin-top: 0; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.notice { background: #e8f7f2; border: 1px solid #b9e6d7; color: #135b4e; padding: 12px; border-radius: 8px; }
.alert { background: #fff4e2; border: 1px solid #ffd18a; color: #6b4200; padding: 12px; border-radius: 8px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; padding: 14px; }
  .nav { display: flex; overflow-x: auto; padding-bottom: 4px; }
  .nav button { white-space: nowrap; }
  .session { margin-top: 0; }
  .content { padding: 16px; }
  .cols-2, .cols-3, .cols-4, .orders { grid-template-columns: 1fr; }
  .topbar { align-items: start; flex-direction: column; }
}

@media (max-width: 560px) {
  .content { padding: 12px; }
  .panel { padding: 14px; }
  .topbar h1 { font-size: 23px; }
  .metric strong { font-size: 26px; }
  th, td { padding: 10px 8px; }
}
