:root {
  --accent:#2563eb; --accent-dark:#1d4ed8;
  --ok:#16a34a; --warn:#d97706; --err:#dc2626;
  --text:#0f172a; --text-soft:#64748b;
  --bg:#f8fafc; --border:#e2e8f0; --border-strong:#cbd5e1;
  --radius:10px; --radius-sm:8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: system-ui, sans-serif; margin: 0; background:var(--bg); color:var(--text); line-height:1.5; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }

/* Acessibilidade */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.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; }
.skip-link { position:absolute; left:-9999px; top:0; z-index:100; padding:10px 14px; background:var(--accent); color:#fff; border-radius:0 0 var(--radius-sm) 0; text-decoration:none; font-weight:600; }
.skip-link:focus, .skip-link:focus-visible { left:0; color:#fff; }

/* Topbar */
.topbar { background:#0f172a; color:#fff; }
.topbar .container { display:flex; justify-content:space-between; align-items:center; padding:12px 16px; flex-wrap:wrap; gap:8px; }
.topbar a { color:#fff; margin-left:16px; text-decoration:none; }
.topbar nav a { opacity:.85; }
.topbar nav a:hover { opacity:1; }
.brand { font-weight:700; font-size:18px; }

/* Cards de resumo */
.cards { display:flex; gap:12px; margin:16px 0; }
.card { flex:1; background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:16px; text-align:center; box-shadow:var(--shadow-sm); }
.card .num { font-size:28px; font-weight:700; display:block; color:var(--accent); }
.form-card { max-width:520px; margin:24px auto; box-shadow:var(--shadow-sm); }

/* Toolbar de ações */
.toolbar { display:flex; justify-content:flex-end; gap:8px; align-items:center; margin:16px 0; flex-wrap:wrap; }
.inline-form { display:inline-block; margin:0; }

/* Filtros */
.filters-card { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:12px 16px; margin-bottom:16px; box-shadow:var(--shadow-sm); }
.filters-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; gap:8px; }
.filters-title { font-size:12px; font-weight:600; color:var(--text-soft); text-transform:uppercase; letter-spacing:.04em; }
.chip { display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; }
.chip-active { background:#dbeafe; color:#1e40af; }

/* Painel de cota */
.quota { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:12px 16px; margin-bottom:16px; box-shadow:var(--shadow-sm); }
.quota-text { font-size:13px; color:var(--text-soft); margin-bottom:6px; }
.quota-note { font-weight:600; }
.quota-note-warn { color:var(--warn); }
.quota-note-err { color:var(--err); }
.quota-bar { height:8px; background:#e2e8f0; border-radius:999px; overflow:hidden; }
.quota-fill { display:block; height:100%; background:var(--accent); border-radius:999px; transition:width .3s ease; }
.quota-fill--warn { background:var(--warn); }
.quota-fill--err { background:var(--err); }

/* Filtros (form) */
.filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.filters input,.filters select { padding:8px; border:1px solid var(--border-strong); border-radius:8px; background:#fff; }

/* Botões */
.btn { display:inline-block; padding:8px 14px; background:var(--accent); color:#fff; text-decoration:none; border-radius:8px; border:1px solid transparent; font-size:14px; cursor:pointer; }
.btn:hover { background:var(--accent-dark); }
.btn-primary { background:var(--accent); }
.btn-primary:hover { background:var(--accent-dark); }
.btn-secondary { background:#fff; color:var(--text); border-color:var(--border-strong); }
.btn-secondary:hover { background:#f1f5f9; }
.btn-danger { background:var(--err); }
.btn-danger:hover { background:#b91c1c; }
.btn-sm { padding:8px 12px; font-size:13px; min-height:34px; }

/* Tabela */
.table-scroll { overflow-x:auto; }
table { width:100%; border-collapse:collapse; background:#fff; min-width:640px; }
th,td { text-align:left; padding:10px; border-bottom:1px solid var(--border); white-space:nowrap; }
tr.delayed td { background:#fff7ed; }
.code-link { text-decoration:none; font-weight:600; }
.code-link:hover { text-decoration:underline; }

/* Estados / badges */
.state { display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; background:#e2e8f0; color:#334155; }
.state-delivered { background:#dcfce7; color:#166534; }
.state-failed, .state-returned { background:#fee2e2; color:#991b1b; }
.state-in_transit { background:#dbeafe; color:#1e40af; }
.state-delayed { background:#fef3c7; color:#92400e; }
.badge { display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; background:#eef2f7; color:#334155; }
.badge-correios { background:#dcfce7; color:#166534; }
.badge-aliexpress { background:#ffe4e6; color:#9f1239; }
.badge-shopee { background:#ffedd5; color:#c2410c; }
.badge-anjun { background:#e0e7ff; color:#3730a3; }
.badge-jtexpress { background:#fce7f3; color:#9d174d; }
.badge-totalexpress { background:#ccfbf1; color:#115e59; }

/* Detalhe */
.meta { background:#fff; border:1px solid var(--border); padding:16px; border-radius:var(--radius); margin:16px 0; display:flex; flex-wrap:wrap; gap:12px; align-items:center; box-shadow:var(--shadow-sm); }
.meta-status { flex-basis:100%; margin:0; }
.meta-actions { flex-basis:100%; display:flex; gap:8px; }
.warn { background:#fef3c7; border:1px solid #fcd34d; padding:8px; border-radius:8px; flex-basis:100%; }

/* Timeline */
.timeline { list-style:none; position:relative; padding-left:20px; margin:0; }
.timeline::before { content:""; position:absolute; left:6px; top:0; bottom:0; width:2px; background:var(--border); }
.timeline li { position:relative; padding:8px 0 8px 12px; }
.timeline li::before { content:""; position:absolute; left:-18px; top:14px; width:10px; height:10px; border-radius:50%; background:var(--accent); }
.timeline-delivered li::before { background:var(--ok); }
.timeline-failed li::before, .timeline-returned li::before { background:var(--err); }
.timeline li:first-child::after { content:""; position:absolute; left:-23px; top:9px; width:20px; height:20px; border-radius:50%; border:2px solid #93c5fd; }
.timeline-delivered li:first-child::after { border-color:#86efac; }
.timeline-failed li:first-child::after, .timeline-returned li:first-child::after { border-color:#fca5a5; }
.timeline .timeline-date { font-size:12px; font-weight:700; color:var(--text-soft); text-transform:uppercase; margin-top:12px; position:sticky; top:8px; background:var(--bg); z-index:1; }
.timeline .timeline-date::before { display:none; }
.time { color:var(--text-soft); font-size:12px; margin-right:8px; }
.loc { color:var(--text-soft); font-size:12px; }
.toggle-raw { background:none; border:1px solid var(--border-strong); border-radius:6px; font-size:11px; color:var(--text-soft); cursor:pointer; padding:1px 6px; margin-left:6px; }
.toggle-raw:hover { border-color:var(--accent); color:var(--accent); }
.raw { background:#0f172a; color:#a5f3fc; font-size:11px; padding:10px; border-radius:8px; overflow-x:auto; margin:6px 0 0; white-space:pre-wrap; }

/* Empty state */
.empty-state { text-align:center; padding:32px 16px; margin:8px 0; }
.empty-icon { font-size:40px; margin-bottom:8px; }

/* Utilidades */
.count { color:var(--text-soft); font-size:14px; font-weight:400; }
#copy-code.copied { background:var(--ok); border-color:var(--ok); color:#fff; }
button.btn:disabled { opacity:.6; cursor:not-allowed; }
.btn.is-busy { cursor:progress; }

/* Formulário */
.field { margin-bottom:14px; }
.field label { display:block; font-size:13px; font-weight:600; margin-bottom:4px; }
.field input, .field select { width:100%; padding:9px 11px; border:1px solid var(--border-strong); border-radius:8px; background:#fff; font-size:15px; }
.field input:focus, .field select:focus { outline:2px solid #bfdbfe; border-color:var(--accent); }
.field .help { color:var(--text-soft); font-size:12px; }
.field .error { color:var(--err); font-size:12px; display:block; margin-top:4px; }
.error-box { background:#fee2e2; color:#991b1b; border:1px solid #fca5a5; padding:8px 12px; border-radius:8px; margin-bottom:12px; font-size:14px; }

/* Mensagens */
.messages { margin:16px 0; }
.message { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:10px 14px; border-radius:8px; margin-bottom:8px; border:1px solid; animation:msg-in .18s ease-out; }
@keyframes msg-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.message-info, .message-success { background:#dcfce7; border-color:#86efac; color:#166534; }
.message-warning { background:#fef3c7; border-color:#fcd34d; color:#92400e; }
.message-error { background:#fee2e2; border-color:#fca5a5; color:#991b1b; }
.message-close { background:none; border:none; font-size:18px; cursor:pointer; color:inherit; line-height:1; }

/* Paginação */
.pagination { display:flex; gap:12px; align-items:center; justify-content:center; margin:16px 0; }
.pagination a { text-decoration:none; }
.pagination span { color:var(--text-soft); font-size:14px; }
.page-disabled { opacity:.55; cursor:not-allowed; }

/* Responsivo */
@media (max-width: 640px) {
  .cards { flex-direction:column; }
  .filters { align-items:stretch; }
  .filters input, .filters select, .filters .btn { width:100%; }
  .topbar nav a { margin-left:0; margin-right:12px; }
  .toolbar { justify-content:stretch; }
  .toolbar .btn { flex:1; text-align:center; }
  .empty-state { margin:0 auto; }

  .table-scroll { overflow:visible; }
  table { min-width:0; }
  thead { display:none; }
  tbody tr { display:block; background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:10px 14px; margin-bottom:12px; box-shadow:var(--shadow-sm); }
  tbody tr.delayed { background:#fff7ed; border-color:#fdba74; }
  tbody tr.delayed td { background:transparent; }
  tbody td { display:flex; justify-content:space-between; align-items:center; gap:10px; border:none; padding:4px 0; white-space:normal; text-align:right; }
  tbody td[data-label]::before { content:attr(data-label); font-size:11px; font-weight:600; color:var(--text-soft); text-transform:uppercase; letter-spacing:.03em; }
  tbody td[data-label=""] { justify-content:flex-end; }
  tbody tr td:first-child a.code-link { font-size:15px; }
}