:root {
  --bg: #eef2ef;
  --surface: #ffffff;
  --ink: #17262b;
  --muted: #5e6e70;
  --line: #d3dcd7;
  --route: #1f6f5c;
  --route-soft: #d6e8e1;
  --warn: #9a6512;
  --warn-soft: #f6e8cc;
  --danger: #a3392b;
  --danger-soft: #f5dcd7;
  --focus: #2b6cb0;
  --radius-s: 6px;
  --radius-l: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10181a; --surface: #172225; --ink: #e4ece8; --muted: #93a39f; --line: #2a3a3d;
    --route: #4fb394; --route-soft: #1d3a33; --warn: #e0a84a; --warn-soft: #3a2d14;
    --danger: #e07a6a; --danger-soft: #3d1f1a; --focus: #7fb2ec;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--route); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1 { font-size: 1.9rem; line-height: 1.15; margin: 0 0 .25rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; }
code { font-size: .9em; background: var(--route-soft); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.sep { color: var(--line); margin: 0 .25rem; }

.top {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 2.5rem); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; align-items: center; }
.top nav a, .link { color: var(--ink); text-decoration: none; font: inherit; }
.top nav a:hover, .link:hover { color: var(--route); }
.top nav form { margin: 0; }
.link { background: none; border: 0; padding: 0; cursor: pointer; }

.wrap { max-width: 1180px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 4rem; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--route); color: var(--surface); border: 0; border-radius: var(--radius-s); padding: .6rem 1.1rem;
}
.btn:hover { filter: brightness(1.08); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: .55rem .7rem; margin-top: .3rem;
}
textarea { resize: vertical; }
label { display: block; font-weight: 500; font-size: .95rem; }

.flash { background: var(--route-soft); border-left: 4px solid var(--route); padding: .7rem 1rem; border-radius: var(--radius-s); }
.error { background: var(--danger-soft); border-left: 4px solid var(--danger); padding: .7rem 1rem; border-radius: var(--radius-s); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: clamp(1.25rem, 4vw, 2rem); max-width: 70ch; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
.stack { display: grid; gap: 1rem; }
.login h1 { margin-bottom: 1.25rem; }

.summary { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.75rem; }
.summary p { margin: 0; }
.alert {
  background: var(--warn-soft); color: var(--warn); font-weight: 600; text-decoration: none;
  padding: .55rem 1rem; border-radius: 999px; border: 1px solid currentColor;
}

/* Ruta de etapas: la pieza central del panel */
.route { margin-bottom: 1.75rem; overflow-x: auto; padding-bottom: .5rem; }
.route ol { list-style: none; display: flex; margin: 0; padding: 0; min-width: 640px; }
.route li { flex: 1; position: relative; text-align: center; }
.route li::before {
  content: ""; position: absolute; top: 22px; left: -50%; width: 100%; height: 3px; background: var(--line); z-index: 0;
}
.route li:first-child::before { display: none; }
.route li.has::before { background: var(--route); }
.route a { position: relative; z-index: 1; display: inline-flex; flex-direction: column; align-items: center; gap: .4rem; text-decoration: none; color: var(--muted); }
.route .dot {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 3px solid var(--line); color: var(--muted); font-weight: 700; font-size: 1.05rem;
}
.route li.has .dot { border-color: var(--route); color: var(--route); }
.route li.on .dot { background: var(--route); color: var(--surface); border-color: var(--route); }
.route li.on .lbl, .route a:hover .lbl { color: var(--ink); }
.route .lbl { font-size: .85rem; font-weight: 500; }
.off-route { display: inline-block; margin-top: .75rem; font-size: .9rem; color: var(--muted); }
.off-route.on { color: var(--ink); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.filters input { flex: 1 1 280px; margin: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; font-weight: 600; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--route-soft) 45%, transparent); }
td.late { color: var(--warn); font-weight: 600; }

.badge {
  display: inline-block; white-space: nowrap; font-size: .82rem; font-weight: 600;
  padding: .2rem .6rem; border-radius: 999px; background: var(--route-soft); color: var(--route);
}
.b-nuevo { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.b-seguimiento { background: var(--warn-soft); color: var(--warn); }
.b-cliente { background: var(--route); color: var(--surface); }
.b-descartado { background: transparent; color: var(--muted); text-decoration: line-through; }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-l); padding: 2rem; text-align: center; }

.sheet fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 1.5rem; padding: 1.25rem 0 0; }
.sheet legend { font-weight: 700; font-size: 1.1rem; padding-right: .75rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.25rem; margin-bottom: 1rem; }
.actions { display: flex; gap: 1.25rem; align-items: center; }

.history { margin-top: 3rem; max-width: 760px; }
.inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.inline input { flex: 1 1 260px; margin: 0; }
.history ol { list-style: none; padding: 0; margin: 1.25rem 0 0; border-left: 3px solid var(--route-soft); }
.history li { padding: .4rem 0 .4rem 1rem; }
.history time { color: var(--muted); font-size: .85rem; margin-right: .5rem; }
.danger-zone { margin-top: 3rem; }

@media (max-width: 600px) {
  h1 { font-size: 1.5rem; }
  .actions { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
