/* Identidade visual baseada na logo GD: preto, prata metálico e vermelho. */
:root {
  color-scheme: dark;
  --primary: #d4070b;
  --primary-strong: #e4070b;
  --primary-soft: rgba(228, 7, 11, .14);
  --silver: #a1a3a9;
  --silver-light: #d9dbe0;
  --bg: #0b0b0d;
  --surface: #16171a;
  --surface-2: #1e2024;
  --text: #ececee;
  --muted: #9ba0a8;
  --border: #2d3036;
  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, .12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, .12);
  --danger: #ff5a5f;
  --danger-bg: rgba(255, 90, 95, .12);
  --info-bg: rgba(161, 163, 169, .14);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .25);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
[hidden] { display: none !important; }
h1 { font-size: 1.45rem; margin: 0; text-transform: uppercase; letter-spacing: .04em; font-weight: 800; }
h1::after { content: ""; display: block; width: 40px; height: 3px; margin-top: 6px; background: var(--primary); border-radius: 2px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
a { color: var(--silver-light); }
button, input, select { font: inherit; }

/* Botões */
button { cursor: pointer; border-radius: 8px; border: 1px solid transparent; padding: 9px 16px; font-weight: 700; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: linear-gradient(180deg, var(--primary-strong), #a90509); color: #fff; box-shadow: 0 2px 10px rgba(228, 7, 11, .25); }
.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f5161a, var(--primary)); }
.secondary { background: var(--surface-2); color: var(--silver-light); border-color: var(--border); }
.secondary:hover:not(:disabled) { border-color: var(--silver); color: #fff; }
.ghost { background: transparent; color: var(--silver-light); }
.ghost:hover:not(:disabled) { background: var(--info-bg); color: #fff; }
.danger, .secondary.danger, .ghost.danger { color: var(--danger); }
.small { padding: 5px 10px; font-size: .875rem; }
.block { width: 100%; margin-top: 12px; }

/* Formulários */
label { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; color: var(--muted); }
input, select { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; min-width: 0; }
input::placeholder { color: #61656d; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--primary); }
label.inline { display: flex; align-items: center; gap: 8px; }
label.inline select { width: auto; max-width: 60vw; }
label.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 10px; color: var(--text); }
label.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0; padding: 10px 12px 12px; display: grid; gap: 8px; }
legend { font-size: .875rem; font-weight: 700; color: var(--muted); padding: 0 4px; }
.segmented { display: flex; gap: 16px; }
.segmented label { display: flex; align-items: center; gap: 6px; color: var(--text); }
.segmented input { width: auto; }
.hint { margin: 0; font-size: .85rem; color: var(--muted); }
.coords { display: grid; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.unit-input { display: flex; align-items: stretch; max-width: 260px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.unit-input:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; }
.unit-input input { border: 0; background: transparent; text-align: right; }
.unit-input input:focus { outline: none; }
.unit-input span { display: flex; align-items: center; padding: 0 12px 0 6px; color: var(--silver-light); font-weight: 600; }
.settings-card { display: grid; gap: 12px; max-width: 640px; }
.settings-card h2 { margin: 0; }
.money-input { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.money-input:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; }
.money-input span { display: flex; align-items: center; padding: 0 4px 0 12px; color: var(--silver-light); font-weight: 700; }
.money-input input { border: 0; padding-left: 4px; text-align: right; background: transparent; }
.money-input input:focus { outline: none; }
.field-status { font-weight: 400; font-size: .8rem; min-height: 1em; }
.field-status.ok { color: var(--success); }
.field-status.error { color: var(--danger); }
.geo-status { margin: 0; font-size: .85rem; padding: 8px 10px; border-radius: 6px; background: var(--bg); }
.geo-status.ok { color: var(--success); background: var(--success-bg); }
.geo-status.warn { color: var(--warning); background: var(--warning-bg); }
.geo-status.error { color: var(--danger); background: var(--danger-bg); }
.geo-status a { color: inherit; font-weight: 700; }

/* Login */
.login-screen {
  min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 8px; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 20%, rgba(228, 7, 11, .22), transparent 55%), radial-gradient(ellipse at 50% 100%, #1b1c20, var(--bg) 70%);
}
.login-logo { width: min(220px, 56vw); height: auto; filter: drop-shadow(0 10px 30px rgba(228, 7, 11, .3)); }
.login-title { margin: 0 0 8px; text-align: center; font-size: .85rem; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: var(--silver); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 24px; border-top: 3px solid var(--primary); }
.password-input { position: relative; display: block; }
.password-input input { padding-right: 46px; }
.password-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; padding: 0; background: transparent; color: var(--silver); }
.password-toggle:hover { color: #fff; }
.password-toggle:focus-visible { outline: 2px solid var(--primary); }
.password-toggle .eye-closed, .password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }
label.check.remember { align-self: auto; padding: 0; font-weight: 500; cursor: pointer; }
label.check.remember input { width: 18px; height: 18px; margin: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { display: block; }
.brand div { display: grid; line-height: 1.2; }
.brand strong { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; }
.brand span { font-size: .8rem; color: var(--muted); }

/* Estrutura */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: linear-gradient(180deg, #17181b, #0b0b0d); border-bottom: 2px solid var(--primary); color: #fff; flex-wrap: wrap; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav button { background: transparent; color: var(--silver); white-space: nowrap; border-radius: 6px; position: relative; }
.nav button:hover { color: #fff; background: var(--info-bg); }
.nav button.active { color: #fff; }
.nav button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 2px; background: var(--primary-strong); }
.topbar-actions { display: flex; gap: 4px; margin-left: auto; }
.topbar .ghost { color: var(--silver); }
.view { padding: 24px 20px 48px; max-width: 1200px; margin: 0 auto; }
.page { display: grid; gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Cartões */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.record { display: grid; gap: 4px; align-content: start; }
.record-actions { display: flex; gap: 4px; margin-top: 6px; }
.empty { color: var(--muted); text-align: center; display: grid; gap: 12px; justify-items: center; }
.muted { color: var(--muted); font-size: .85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius); padding: 14px 18px; display: grid; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.8rem; color: #fff; }
.badge { display: inline-block; justify-self: start; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge.available { background: var(--success-bg); color: var(--success); }
.badge.base { background: var(--primary-soft); color: #ff6b6e; }
.badge.assigned, .badge.agency { background: var(--info-bg); color: var(--silver-light); }
.badge.cancelled { background: var(--danger-bg); color: var(--danger); }

/* Fila */
.queue-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.queue-layout .card > .secondary { margin-top: 12px; }
.queue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.queue-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.queue-item:first-child { border-color: var(--primary); background: linear-gradient(90deg, var(--primary-soft), var(--surface-2) 60%); }
.queue-item.me { outline: 2px solid var(--silver-light); }
.queue-item .grow { flex: 1; display: grid; gap: 2px; min-width: 0; }
.position { font-size: 1.3rem; font-weight: 800; color: var(--primary-strong); min-width: 44px; text-align: center; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.simple-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.simple-list li { display: grid; padding: 8px 0; border-bottom: 1px solid var(--border); }

/* Tabelas */
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--silver); background: var(--surface-2); }
tbody tr:hover td { background: rgba(255, 255, 255, .02); }
tr:last-child td { border-bottom: 0; }
tr.inactive td { opacity: .55; }
td.actions { text-align: right; white-space: nowrap; }
th.num, td.num { text-align: right; white-space: nowrap; }

/* Motorista */
.driver { max-width: 520px; margin: 0 auto; }
.fleet-card, .position-card, .highlight { display: grid; gap: 4px; }
.position-card { text-align: center; justify-items: center; border-top: 3px solid var(--primary); }
.position-card button { margin-top: 10px; }
.huge { font-size: 3.5rem; line-height: 1; color: var(--primary-strong); text-shadow: 0 0 24px rgba(228, 7, 11, .35); }
.big { font-size: 1.8rem; color: #fff; }
.highlight { border-color: var(--primary); background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%); }

/* Diálogos */
dialog { border: 1px solid var(--border); border-top: 3px solid var(--primary); border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.dialog-form { display: grid; gap: 14px; padding: 22px; }
.dialog-form h2 { margin: 0; font-size: 1.2rem; }
.dialog-form p { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Avisos */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 10px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.success { color: var(--success); border-color: rgba(74, 222, 128, .4); }
.toast.error { color: var(--danger); border-color: rgba(255, 90, 95, .45); }

@media (max-width: 900px) {
  .queue-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar { padding: 8px 16px; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
  .view { padding: 16px 16px 40px; }
  .queue-item { flex-wrap: wrap; }
  .item-actions { flex-basis: 100%; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  /* Tabelas viram cartões no celular */
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  td { border: 0; padding: 3px 0; }
  td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--muted); }
  td.actions, td.num { text-align: left; }
}
