:root {
  --orange: #fb6019;
  --orange-soft: #ff9a6b;
  --ink: #1f2430;
  --ink-2: #3a4150;
  --muted: #7a8293;
  --line: #e7eaf0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #1e9e6a;
  --warn: #e0a21b;
  --danger: #d64545;
  --info: #2f6fe4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h3 { font-size: 1.05rem; margin-bottom: 16px; }
h4 { font-size: 1rem; }

.muted { color: var(--muted); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar-dot { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(135deg, var(--orange-soft), var(--orange)); }

.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: linear-gradient(180deg, #171b26, #11141d);
  color: #c7cdd8;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.brand img { height: 34px; width: auto; }
.brand span { color: #fff; font-weight: 700; font-size: 1.05rem; }

.nav-user { display: flex; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--orange-soft), var(--orange));
  color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0;
}
.who { min-width: 0; }
.who strong { display: block; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: #8b93a5; }

.nav-links { padding: 14px 12px; overflow-y: auto; }
.nav-section {
  display: block;
  margin: 16px 10px 6px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7383;
}
.nav-links a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: #c7cdd8;
  font-weight: 550;
  margin-bottom: 2px;
}
.nav-links a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }
.nav-links a.active { background: linear-gradient(135deg, var(--orange-soft), var(--orange)); color: #fff; }

/* ---------- Page ---------- */
.page { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .crumb { display: block; font-size: 0.82rem; margin-bottom: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card.narrow { max-width: 520px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.filters .input { width: 160px; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .container-box label, .coverage-box label { font-size: 0.82rem; color: var(--ink-2); font-weight: 600; }
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d5dae4;
  border-radius: 9px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(251, 96, 25, 0.14); }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.grid .field { grid-column: span 3; }
.grid .field.span-2 { grid-column: span 6; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.92rem; color: var(--ink-2); }
.check input { accent-color: var(--orange); width: 16px; height: 16px; }

.inline-form { display: flex; gap: 10px; margin-bottom: 18px; }
.inline-form .input { max-width: 320px; }

.coverage-box {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff7f2;
  border: 1px solid #ffe1d0;
  border-radius: 10px;
  padding: 14px;
}
.coverage-box strong { color: var(--orange); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.03); }
.btn-primary { background: linear-gradient(135deg, var(--orange-soft), var(--orange)); color: #fff; }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-ghost { background: #fff; border-color: #d5dae4; color: var(--ink-2); }
.btn-danger-outline { background: #fff; border-color: #f0caca; color: var(--danger); }
.btn-danger-outline:hover { background: #fdf3f3; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.icon-link { font-size: 0.85rem; font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650; }
.table th.right, .table td.right { text-align: right; }
.table tbody tr:hover { background: #fafbfd; }
.table tr.clickable { cursor: pointer; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.table tfoot td { border-top: 2px solid var(--line); border-bottom: none; font-weight: 700; }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 650; }
.badge-ok { background: #e7f7ef; color: var(--ok); }
.badge-warn { background: #fbf1d7; color: #9a6d0a; }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 0.92rem; margin: 0; }
.alert-success { background: #e7f7ef; color: #0d6b47; border: 1px solid #bfe8d3; }
.alert-danger { background: #fdecec; color: #a52a2a; border: 1px solid #f4c6c6; }
.alert-info { background: #eaf1fe; color: #1d4f9e; border: 1px solid #c8dafb; }

/* ---------- Misc ---------- */
.loading, .loading-screen { color: var(--muted); padding: 40px; text-align: center; }
.empty-state { text-align: center; padding: 80px 20px; }
.empty-state h1 { font-size: 3rem; color: var(--orange); }
.empty-state .btn { margin-top: 12px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cfd5e0; border-radius: 999px; transition: 0.2s; }
.slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- Truck cards ---------- */
.truck-card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; background: #fff; }
.truck-card.new { border-style: dashed; border-color: var(--orange-soft); }
.truck-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.container-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
.container-box { display: flex; flex-direction: column; gap: 6px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }

.pending-card { border-left: 4px solid var(--orange); }
.pending-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pending-row:last-child { border-bottom: none; }

/* ---------- Login ---------- */
.login-body { background: #fff; }
.login-shell { display: flex; min-height: 100vh; }
.login-brand {
  flex: 1.1;
  background: linear-gradient(160deg, #ff9a6b 0%, #fb6019 60%, #d84a0e 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}
.login-brand img { height: 54px; width: auto; align-self: flex-start; margin-bottom: 22px; }
.login-brand h1 { font-size: 2.4rem; color: #fff; }
.login-brand p { max-width: 420px; opacity: 0.95; font-size: 1.05rem; }
.login-form { flex: 1; display: grid; place-items: center; padding: 40px; }
.login-form .card { width: 100%; max-width: 420px; padding: 32px; }
.login-form h2 { margin-bottom: 4px; }
.login-form .field { margin-bottom: 14px; }
.login-form .check { margin-bottom: 16px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; }
  .login-brand { display: none; }
  .grid .field, .grid .field.span-2, .coverage-box { grid-column: span 12; }
  .container-row { grid-template-columns: 1fr; }
  .filters .input { width: 100%; }
}

/* Impresión de listados (equivalente al botón "print" del original) */
@media print {
  .sidebar, .topbar, .page-head .actions, .filters, .btn, .icon-link { display: none !important; }
  .app-main { margin: 0 !important; }
  .page, main, .content { margin: 0 !important; padding: 0 !important; }
  .table { font-size: 10px; }
}
