/* ═══════════════════════════════════════════
   Capital Express · Design System
   ═══════════════════════════════════════════ */

:root {
  --red:       #CC0000;
  --red-dark:  #A30000;
  --red-light: #FFF0F0;
  --dark:      #1A1A1A;
  --gray-700:  #5A5A5A;
  --gray-500:  #888780;
  --gray-300:  #D0CFC9;
  --gray-100:  #F5F4F0;
  --white:     #FFFFFF;
  --success:   #3B6D11;
  --warning:   #854F0B;
  --info:      #0C447C;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --mono:      'JetBrains Mono', 'Courier New', monospace;
  --radius:    6px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--dark);
  background: var(--gray-100);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
a  { color: var(--red); text-decoration: none; }

/* ── Layout ─────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo img {
  width: 130px;
  height: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 16px 16px 4px; font-size: 10px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .08em; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.05); }
.nav-item.active { color: var(--white); border-left-color: var(--red); background: rgba(204,0,0,.12); }
.nav-item i { width: 16px; text-align: center; font-size: 15px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-footer .user-name { color: var(--white); font-weight: 500; font-size: 13px; }
.sidebar-footer .user-role { font-size: 11px; color: var(--gray-500); }

.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

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

/* ── Cards ──────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--gray-300); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 16px; }

/* ── Métricas ───────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card { background: var(--white); border: 1px solid var(--gray-300); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.metric-val { font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-lbl { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.metric-card.danger .metric-val  { color: var(--red); }
.metric-card.warning .metric-val { color: var(--warning); }
.metric-card.success .metric-val { color: var(--success); }

/* ── Tabla ──────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; background: var(--gray-100); border-bottom: 1px solid var(--gray-300); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-100); }

/* ── Badges ─────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-red    { background: #FCEBEB; color: #791F1F; }
.badge-blue   { background: #E6F1FB; color: #0C447C; }
.badge-green  { background: #EAF3DE; color: #27500A; }
.badge-amber  { background: #FAEEDA; color: #633806; }
.badge-gray   { background: #F1EFE8; color: #444441; }
.badge-purple { background: #EEEDFE; color: #3C3489; }

/* ── Botones ────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--gray-300); font-size: 13px; font-weight: 500; cursor: pointer; background: var(--white); color: var(--dark); transition: all .15s; font-family: var(--font); white-space: nowrap; }
.btn:hover { background: var(--gray-100); }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Formularios ────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--gray-700); }
.form-label .req { color: var(--red); }
.form-control { padding: 8px 11px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; font-family: var(--font); color: var(--dark); background: var(--white); transition: border-color .15s; width: 100%; }
.form-control:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(204,0,0,.08); }
.form-error { font-size: 11px; color: var(--red); }
.form-hint  { font-size: 11px; color: var(--gray-500); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-section { border-top: 1px solid var(--gray-100); padding-top: 16px; margin-top: 4px; }
.form-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--gray-500); margin-bottom: 14px; }

/* ── Timeline ───────────────────────────── */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; }
.tl-line { display: flex; flex-direction: column; align-items: center; min-width: 18px; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex-shrink: 0; margin-top: 4px; }
.tl-dot.gray { background: var(--gray-300); }
.tl-connector { width: 1px; background: var(--gray-300); flex: 1; min-height: 20px; margin: 2px 0; }
.tl-content { padding-bottom: 18px; flex: 1; }
.tl-meta { font-size: 11px; color: var(--gray-500); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Priority ───────────────────────────── */
.pbar { width: 3px; border-radius: 2px; align-self: stretch; flex-shrink: 0; }
.pbar-urgente { background: #CC0000; }
.pbar-alta    { background: #854F0B; }
.pbar-media   { background: #0C447C; }
.pbar-baja    { background: var(--gray-300); }

/* ── Misc ───────────────────────────────── */
.tracking-num { font-family: var(--mono); font-size: 12px; color: var(--gray-700); letter-spacing: .03em; }
.drop-zone { border: 1.5px dashed var(--gray-300); border-radius: var(--radius); padding: 24px; text-align: center; color: var(--gray-500); font-size: 13px; background: var(--gray-100); cursor: pointer; }
.drop-zone:hover { border-color: var(--red); }
.drop-zone i { font-size: 24px; display: block; margin-bottom: 6px; }
.alert { padding: 11px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.alert-success { background: #EAF3DE; color: #27500A; border: 1px solid #C3DDA5; }
.alert-error   { background: #FCEBEB; color: #791F1F; border: 1px solid #F5C0C0; }
.alert-info    { background: #E6F1FB; color: #0C447C; border: 1px solid #B3D4F0; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-md); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; gap: 8px; justify-content: flex-end; }
.hidden { display: none !important; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .form-control { width: auto; min-width: 140px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.empty-state i { font-size: 40px; display: block; margin-bottom: 10px; opacity: .4; }

/* ── Login ──────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--dark); }
.login-card { background: var(--white); border-radius: 10px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { width: 180px; height: auto; object-fit: contain; }
.login-logo .sub { font-size: 12px; color: var(--gray-500); margin-top: 8px; }

/* ── Spinner ────────────────────────────── */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
