:root {
  --bg: #07080c;
  --surface: #0e1017;
  --surface-2: #161922;
  --surface-3: #1e212d;
  --border: #252838;
  --border-hover: #363a50;
  --text: #e4e5ed;
  --text-muted: #7e8299;
  --text-dim: #4a4e65;
  --accent: #f05a28;
  --accent-glow: rgba(240, 90, 40, 0.14);
  --accent-2: #ff8c5a;
  --green: #2dd4a0;
  --green-bg: rgba(45, 212, 160, 0.08);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.08);
  --blue: #5b9cf5;
  --blue-bg: rgba(91, 156, 245, 0.08);
  --red: #ef6461;
  --red-bg: rgba(239, 100, 97, 0.08);
  --purple: #9d7af5;
  --purple-bg: rgba(157, 122, 245, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(240,90,40,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(91,156,245,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }

/* ── Header ──────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 14px; }

.logo-icon {
  width: 46px; height: 46px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px;
  box-shadow: 0 6px 28px var(--accent-glow);
}

.logo h1 {
  font-family: 'Space Mono', monospace;
  font-size: 23px; font-weight: 700; letter-spacing: -0.5px;
}
.logo h1 span { color: var(--accent); }


.tab-count {
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border-radius: 100px;
  padding: 0 5px;
  font-size: 10px; font-weight: 700;
  min-width: 16px; text-align: center;
  line-height: 1.7;
}
.filter-tab.active .tab-count { background: rgba(255,255,255,0.25); }

/* ── Info banner ─────────────────────── */
.info-banner {
  background: var(--blue-bg);
  border: 1px solid rgba(91,156,245,0.15);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 13px; color: var(--blue);
  margin-bottom: 24px;
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.55;
}
.info-banner a { color: var(--accent); }

/* ── Navbar Add Button ───────────────── */
.btn-add-nav {
  padding: 9px 20px;
  border-radius: 100px;
  font-size: 13px;
  white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
}

/* ── Add Form (Modal) ────────────────── */
.add-form { display: flex; flex-direction: column; gap: 16px; }

.field label {
  display: block; font-size: 11px; color: var(--text-dim);
  margin-bottom: 5px; font-weight: 500; letter-spacing: 0.3px;
}

.field input {
  width: 100%; padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit; font-size: 14px;
  transition: all 0.2s; outline: none;
}
.field input::placeholder { color: var(--text-dim); }
.field input:focus { border-color: var(--accent); background: var(--surface-3); }

.code-input {
  font-family: 'Space Mono', monospace !important;
  letter-spacing: 1px; text-transform: uppercase;
}

.btn-add {
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%;
}

/* ── Shared accent button base ───────── */
.btn-add,
.btn-add-nav {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none;
  font-family: inherit; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.btn-add:hover,
.btn-add-nav:hover { transform: translateY(-1px); box-shadow: 0 8px 28px var(--accent-glow); }
.btn-add:active,
.btn-add-nav:active { transform: translateY(0); }

/* ── Controls ────────────────────────── */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 12px;
}

.filter-tabs {
  display: flex; gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px; padding: 3px;
}

.filter-tab {
  padding: 7px 15px; border: none; background: none;
  color: var(--text-muted);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; border-radius: 100px; transition: all 0.2s;
}
.filter-tab.active { background: var(--accent); color: #fff; }
.filter-tab:hover:not(.active) { color: var(--text); }

.search-box { position: relative; }
.search-box input {
  padding: 8px 13px 8px 34px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 100px; color: var(--text);
  font-family: inherit; font-size: 13px; width: 220px;
  outline: none; transition: all 0.2s;
}
.search-box input:focus { border-color: var(--accent); width: 260px; }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); pointer-events: none;
  width: 13px; height: 13px;
  color: var(--text-muted);
}

/* ── Cards ───────────────────────────── */
.cards { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 20px;
  display: grid;
  grid-template-columns: 5px minmax(200px, auto) 1fr auto;
  gap: 14px; align-items: center;
  transition: all 0.2s;
  animation: cardIn 0.3s ease-out both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.card:hover { border-color: var(--border-hover); transform: translateX(3px); }
.card-archived { opacity: 0.6; }
.card-archived:hover { opacity: 0.85; }

.card-bar {
  width: 4px; height: 36px;
  border-radius: 4px; flex-shrink: 0;
}

.card-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.card-product {
  font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}

.card-code-wrap {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
}

.card-event-date {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-dim);
  min-width: 0;
}
.card-event-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

@keyframes highlight {
  0%,100% { border-color: var(--border-hover); }
  50%      { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
}
.card.highlighted { animation: highlight 0.8s ease 2; }

.card-code {
  font-family: 'Space Mono', monospace;
  font-size: 11px; color: var(--accent);
  background: var(--accent-glow);
  padding: 3px 9px; border-radius: 6px; letter-spacing: 0.5px;
}
.copy-code-btn {
  background: none; border: none; padding: 0;
  color: var(--accent); opacity: 0.6;
  cursor: pointer; display: inline-flex; align-items: center;
  transition: opacity 0.2s;
}
.copy-code-btn:hover { opacity: 1; }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 100px;
  font-size: 11px; font-weight: 600;
  width: fit-content;
}
.status-badge svg { transform: translateZ(0); }
.status-badge.entregue { background: var(--green-bg); color: var(--green); }
.status-badge.transito { background: var(--blue-bg); color: var(--blue); }
.status-badge.postado { background: var(--yellow-bg); color: var(--yellow); }
.status-badge.problema { background: var(--red-bg); color: var(--red); }
.status-badge.pendente { background: var(--purple-bg); color: var(--purple); }
.status-badge.buscando { background: var(--surface-3); color: var(--text-muted); }


.card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer;
  font-size: 14px; transition: all 0.2s;
  position: relative;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.btn-icon.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }
.btn-icon.spinning { animation: spin 1s linear infinite; pointer-events: none; }
.btn-icon svg { width: 16px; height: 16px; stroke-width: 2; pointer-events: none; transform: translateZ(0); }

.btn-icon.has-update::after {
  content: '';
  position: absolute;
  top: -4px; right: -4px;
  width: 9px; height: 9px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--surface);
  animation: pulse 2s infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* ── Empty ───────────────────────────── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-dim); }
.empty-state .icon { display: flex; justify-content: center; margin-bottom: 14px; }
.empty-state .icon svg { width: 48px; height: 48px; stroke-width: 1.5; }
.empty-state h3 { font-size: 17px; color: var(--text-muted); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── Modal ───────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 540px;
  max-height: 80vh; overflow-y: auto;
  padding: 26px; animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.modal-header h2 { font-size: 17px; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px;
}

.modal::-webkit-scrollbar { width: 6px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 10px;
}
.modal::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
.modal { scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }

.btn-secondary {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer; font-size: 13px;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--surface-3); }
.btn-danger {
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: none; background: var(--red); color: #fff;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

/* ── Token modal ─────────────────────────── */
#modal-token { z-index: 200; }
#modal-token .field input {
  width: 100%; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 14px; outline: none; box-sizing: border-box;
  transition: border-color 0.2s;
}
#modal-token .field input:focus { border-color: var(--accent); }

/*
  Cálculo do alinhamento:
  - .timeline padding-left: 20px  → item começa em 20px do border-left
  - linha: left: 8px, width: 2px  → centro da linha em 9px
  - dot 10px: left relativo ao item = 9 - 5 - 20 = -16px → centro em 20-16+5 = 9px ✓
*/
/* ── Modal info card ─────────────────── */
.modal-info-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
}

/* ── Modal header stat pills ─────────── */
.modal-stat-pill {
  background: var(--accent-glow);
  border: 1px solid rgba(240,90,40,0.2);
  border-radius: 100px;
  padding: 3px 10px;
  font-size: 11px; color: var(--accent);
  white-space: nowrap;
}
.modal-stat-pill span {
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

.timeline { position: relative; padding-left: 20px; }

/* Segmento do topo do item até o dot (exceto o primeiro item) */
.timeline-item:not(:first-child)::before {
  content: ''; position: absolute;
  left: -12px; top: 0; height: 3px; width: 2px;
  background: var(--border); border-radius: 2px;
}

/* Segmento do dot até o fundo do item (exceto o último item) */
.timeline-item:not(:last-child)::after {
  content: ''; position: absolute;
  left: -12px; top: 15px; bottom: 0; width: 2px;
  background: var(--border); border-radius: 2px;
}
.timeline-item:not(:first-child):not(:last-child)::after {
  top: 13px; /* dot de não-primeiro: top(3px) + height(10px) */
}

.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute; left: -17px; top: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
  box-shadow: 0 0 0 0 rgba(240, 90, 40, 0.5);
  animation: pulse-dot 2s ease-out infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(240, 90, 40, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(240, 90, 40, 0); }
  100% { box-shadow: 0 0 0 0 rgba(240, 90, 40, 0); }
}
.timeline-item:not(:first-child) .timeline-dot {
  background: var(--text-dim);
  width: 10px; height: 10px;
  left: -16px; top: 3px;
  animation: none; box-shadow: none;
}

.timeline-date { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; font-family: 'Space Mono', monospace; }
.timeline-desc { font-size: 12px; color: var(--text); line-height: 1.4; font-weight: 400; }
.timeline-loc { font-size: 11px; color: var(--text-muted); margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.timeline-loc svg { transform: translateZ(0); }
.timeline-detail { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-style: italic; }

/* ── Toast ───────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px; font-size: 13px; color: var(--text);
  z-index: 200;
  animation: toastIn 0.3s ease-out, toastOut 0.3s 2.7s ease-in forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: flex; align-items: center; gap: 8px;
}
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(16px); opacity: 0; } }

/* ── Footer ──────────────────────────── */
.app-footer {
  text-align: center;
  padding: 16px 0 24px;
  position: relative;
  z-index: 1;
}

.app-footer a {
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────── */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 14px; align-items: flex-start; }
  .header-right { width: 100%; flex-wrap: wrap; }
  .card { grid-template-columns: 5px 1fr; }
  .card-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .controls { flex-direction: column; align-items: stretch; }
  .search-box input { width: 100%; }
  .search-box input:focus { width: 100%; }
}
