/* ─────────────────────────────────────────────
   EnviosFut — ERP Logístico
   ───────────────────────────────────────────── */

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

:root {
  --bg:          #0f1117;
  --bg2:         #161822;
  --bg3:         #1e2030;
  --bg4:         #252840;
  --border:      #2a2d42;
  --border2:     #353858;
  --text:        #e8e9f0;
  --text2:       #9b9db8;
  --text3:       #5c5f7a;
  --primary:     #6366f1;
  --primary-h:   #4f52d4;
  --green:       #22c55e;
  --green-bg:    rgba(34,197,94,.12);
  --yellow:      #f59e0b;
  --yellow-bg:   rgba(245,158,11,.12);
  --red:         #ef4444;
  --red-bg:      rgba(239,68,68,.12);
  --blue:        #3b82f6;
  --blue-bg:     rgba(59,130,246,.12);
  --orange:      #f97316;
  --orange-bg:   rgba(249,115,22,.12);
  --purple:      #a855f7;
  --purple-bg:   rgba(168,85,247,.12);
  --radius:      8px;
  --radius-lg:   12px;
  --sidebar-w:   220px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Mono', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

input, select, textarea, button {
  font-family: var(--font);
  font-size: 14px;
}

/* ── Layout ────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-logo-text { font-size: 15px; font-weight: 600; color: var(--text); }
.sidebar-logo-sub  { font-size: 11px; color: var(--text3); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text3);
  padding: 10px 8px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--text2); cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none; user-select: none;
  position: relative;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item span { font-size: 13px; font-weight: 500; }

.nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  background: var(--red); color: #fff;
  padding: 1px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}
.nav-badge.yellow { background: var(--yellow); color: #000; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius);
  cursor: pointer;
}
.sidebar-user:hover { background: var(--bg3); }
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.sidebar-user-name  { font-size: 12px; font-weight: 600; }
.sidebar-user-role  { font-size: 10px; color: var(--text3); }

/* ── Main ──────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 12px;
  width: 280px;
}
.topbar-search input {
  background: none; border: none; outline: none;
  color: var(--text); flex: 1; font-size: 13px;
}
.topbar-search svg { color: var(--text3); width: 14px; height: 14px; }

.content { padding: 24px; flex: 1; }

/* ── Cards de métricas ─────────────────────── */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: default;
  transition: border-color .2s;
}
.metric-card:hover { border-color: var(--border2); }

.metric-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 10px;
}
.metric-label { font-size: 11px; color: var(--text2); margin-bottom: 4px; font-weight: 500; }
.metric-value { font-size: 28px; font-weight: 700; line-height: 1; }
.metric-sub   { font-size: 11px; color: var(--text3); margin-top: 4px; }

.c-blue   { background: var(--blue-bg);   color: var(--blue);   }
.c-green  { background: var(--green-bg);  color: var(--green);  }
.c-yellow { background: var(--yellow-bg); color: var(--yellow); }
.c-red    { background: var(--red-bg);    color: var(--red);    }
.c-orange { background: var(--orange-bg); color: var(--orange); }
.c-purple { background: var(--purple-bg); color: var(--purple); }
.c-gray   { background: var(--bg4);       color: var(--text2);  }

.text-green  { color: var(--green);  }
.text-yellow { color: var(--yellow); }
.text-red    { color: var(--red);    }
.text-blue   { color: var(--blue);   }
.text-orange { color: var(--orange); }

/* ── Table ─────────────────────────────────── */

.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-header {
  display: flex; align-items: center;
  padding: 14px 18px; gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-title { font-size: 14px; font-weight: 600; flex: 1; }

.filter-tabs {
  display: flex; gap: 4px;
  background: var(--bg3); padding: 3px;
  border-radius: var(--radius);
}
.filter-tab {
  padding: 5px 12px; border-radius: 5px; font-size: 12px;
  font-weight: 500; cursor: pointer; color: var(--text2);
  border: none; background: none; transition: all .15s;
}
.filter-tab.active { background: var(--primary); color: #fff; }
.filter-tab:hover:not(.active) { color: var(--text); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text3); padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}
.data-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.015); cursor: pointer; }

/* ── Badges ────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 20px; white-space: nowrap;
}
.badge-transit   { background: var(--blue-bg);   color: var(--blue);   }
.badge-postado   { background: var(--bg4);        color: var(--text2);  }
.badge-taxado    { background: var(--red-bg);     color: var(--red);    }
.badge-entregue  { background: var(--green-bg);   color: var(--green);  }
.badge-saindo    { background: var(--orange-bg);  color: var(--orange); }
.badge-problema  { background: var(--red-bg);     color: var(--red);    }
.badge-devolvendo{ background: var(--yellow-bg);  color: var(--yellow); }
.badge-default   { background: var(--bg4);        color: var(--text2);  }

.stale-warn     { color: var(--yellow); }
.stale-critical { color: var(--red); font-weight: 700; }

/* ── Buttons ───────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }
.btn-ghost { background: transparent; color: var(--text2); border-color: var(--border2); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: transparent; }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ── Modal ─────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: 560px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--bg3); border: none; color: var(--text2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.modal-close:hover { background: var(--bg4); color: var(--text); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Form ──────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; display: block; }
.form-control {
  width: 100%; padding: 8px 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text3); }

/* ── Timeline ──────────────────────────────── */

.timeline { padding: 0 4px; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute;
  left: 7px; top: 16px; bottom: 0;
  width: 2px; background: var(--border);
}
.tl-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg3); border: 2px solid var(--border2);
  flex-shrink: 0; margin-top: 2px;
}
.tl-dot.delivered  { background: var(--green);  border-color: var(--green); }
.tl-dot.customs    { background: var(--red);    border-color: var(--red);   }
.tl-dot.transit    { background: var(--blue);   border-color: var(--blue);  }
.tl-dot.out        { background: var(--orange); border-color: var(--orange);}
.tl-dot.problem    { background: var(--yellow); border-color: var(--yellow);}
.tl-body { flex: 1; }
.tl-desc { font-size: 13px; color: var(--text); }
.tl-loc  { font-size: 11px; color: var(--text3); margin-top: 2px; }
.tl-time { font-size: 11px; color: var(--text3); }

/* ── Alerts / Notices ──────────────────────── */

.notice {
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; border: 1px solid transparent;
}
.notice-success { background: var(--green-bg);  border-color: rgba(34,197,94,.3);  color: var(--green); }
.notice-error   { background: var(--red-bg);    border-color: rgba(239,68,68,.3);  color: var(--red);   }
.notice-warn    { background: var(--yellow-bg); border-color: rgba(245,158,11,.3); color: var(--yellow);}
.notice-info    { background: var(--blue-bg);   border-color: rgba(59,130,246,.3); color: var(--blue);  }

/* ── Pagination ────────────────────────────── */

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text2);
}

/* ── Spinner ───────────────────────────────── */

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(15,17,23,.7);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg); z-index: 10;
}

/* ── Empty state ───────────────────────────── */

.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text3);
}
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Live dot ──────────────────────────────── */

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── Scrollbar ─────────────────────────────── */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── Login ─────────────────────────────────── */

.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 36px;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .icon {
  font-size: 40px; display: block; margin-bottom: 8px;
}
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p  { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ── Reports ───────────────────────────────── */

.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.report-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--text2); }

.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-val { font-weight: 600; }

/* ── Utility ───────────────────────────────── */

.mono { font-family: var(--font-mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.mt-8 { margin-top: 8px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text3); }
.fw-600 { font-weight: 600; }
.hidden { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}
