:root {
  --bg: #0f172a;
  --surface: #ffffff;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --warn: #f59e0b;
  --ok: #10b981;
  --bad: #ef4444;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: #f8fafc; color: #0f172a;
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
header { background: var(--bg); color: #fff; padding: 14px 0; margin-bottom: 28px; }
.nav { display: flex; align-items: center; justify-content: space-between; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
nav a { color: #cbd5e1; text-decoration: none; margin-left: 18px; }
nav a:hover { color: #fff; }
footer { padding: 32px 0 18px; color: var(--muted); text-align: center; }

h1 { margin: 0 0 6px; }
h2 { margin-top: 36px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px; background: var(--surface); border-radius: 8px; text-align: center; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.card span { display: block; color: var(--muted); font-size: 0.85rem; }
.card strong { font-size: 1.6rem; }

.upload { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 28px; }
.dropzone { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dropzone input[type=file] { flex: 1; min-width: 240px; }
button {
  background: var(--accent); color: #fff; border: 0; padding: 10px 18px;
  border-radius: 8px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.1); }
.hint { width: 100%; color: var(--muted); font-size: 0.85rem; margin: 8px 0 0; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { background: #f1f5f9; font-size: 0.85rem; color: var(--muted); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tr.cargo td { background: #fffbeb; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.tag-mercancia { background: #dbeafe; color: #1e40af; }
.tag-servicio { background: #fef3c7; color: #92400e; }
.tag-desconocido { background: #e2e8f0; color: #475569; }
.tag-cargo { background: #fde68a; color: #92400e; margin-left: 6px; }
.warn { color: var(--warn); margin-left: 6px; }

.back { color: var(--muted); text-decoration: none; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin: 16px 0 28px; flex-wrap: wrap; }
.totales { display: flex; gap: 18px; }
.totales div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-width: 120px; }
.totales span { color: var(--muted); font-size: 0.8rem; display: block; }
.totales strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.totales .big strong { color: var(--accent); font-size: 1.5rem; }

.proveedor, section { margin: 28px 0; }
.avisos pre { background: #fffbeb; border: 1px solid #fcd34d; padding: 12px; border-radius: 8px; white-space: pre-wrap; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 36px; margin-bottom: 12px; }
.section-head h1, .section-head h2 { margin: 0; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros input, .filtros select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.filtros button { padding: 8px 14px; }
.link-reset { color: var(--muted); margin-left: 4px; font-size: 0.9rem; }
.tag-cat { background: #ede9fe; color: #5b21b6; }
.tag-best { background: #d1fae5; color: #065f46; margin-left: 6px; }
td.pos { color: #047857; }
td.neg { color: #b91c1c; }
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; height: 380px; }

.userbox { display: flex; align-items: center; gap: 12px; color: #cbd5e1; font-size: 0.9rem; }
.userbox small { padding: 1px 6px; border-radius: 999px; font-size: 0.7rem; margin-left: 4px; }
.role-admin { background: #2563eb; color: #fff; }
.role-viewer { background: #475569; color: #fff; }
.link-btn { background: none; border: 0; color: #cbd5e1; cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { color: #fff; text-decoration: underline; }

.login-body { background: var(--bg); display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
.login-card { background: #fff; padding: 32px; border-radius: 12px; min-width: 360px; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
.login-card h1 { margin-top: 0; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.login-card input { padding: 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.login-card button { padding: 12px; }
.login-error { background: #fee2e2; color: #991b1b; padding: 10px; border-radius: 6px; font-size: 0.9rem; }

.acciones { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.acciones button { padding: 6px 10px; font-size: 0.85rem; }
.acciones select { padding: 6px 8px; font-size: 0.85rem; max-width: 180px; }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-danger { background: var(--bad); }
.tag-ok { background: #d1fae5; color: #065f46; }
.tag-off { background: #fee2e2; color: #991b1b; }
.tag-error { background: #fecaca; color: #991b1b; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-top: 14px; }
.form-card summary { cursor: pointer; font-weight: 600; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.grid-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
.grid-form .span-2 { grid-column: span 2; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin-top: 6px; }
.inline-form input { padding: 5px 8px; font-size: 0.85rem; }
.acciones-toolbar { display: flex; gap: 12px; align-items: center; margin: 14px 0 18px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.btn-link { padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.btn-link:hover { background: #f1f5f9; }
.informe { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.informe-meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 14px; }
.informe-body { white-space: pre-wrap; line-height: 1.6; font-size: 1rem; }
