:root {
  --ink: #15231f;
  --ink-2: #4a5a54;
  --muted: #7a8983;
  --paper: #f1f4f1;
  --card: #ffffff;
  --rule: #d8dfda;
  --pine: #0d5b4b;
  --pine-soft: #dcebe6;
  --amber: #d99a00;
  --amber-soft: #fbf0cf;
  --red: #a63a2b;
  --radius: 10px;
  --head: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; margin: 0; letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* ---------- Acceso ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 32px; }
.gate-card h1 { font-size: 28px; line-height: 1.1; margin-bottom: 6px; }
.gate-card p { color: var(--ink-2); margin: 0 0 22px; }
.gate-strip { display: flex; gap: 3px; margin-bottom: 22px; }
.gate-strip i { height: 8px; flex: 1; border-radius: 2px; background: var(--pine); }
.gate-strip i:nth-child(n+6) { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); }
.gate-strip i:nth-child(6) { background: var(--amber); box-shadow: none; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.field small { display: block; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=search], select {
  width: 100%; padding: 10px 12px; background: #fff; border: 1.5px solid var(--rule); border-radius: 8px; min-height: 42px;
}
input:focus, select:focus { border-color: var(--pine); outline: none; box-shadow: 0 0 0 3px var(--pine-soft); }
.btn { border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; background: var(--pine); color: #fff; min-height: 42px; }
.btn:hover { background: #0a4a3d; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn.ghost:hover { background: #fff; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: default; }
.error { color: var(--red); font-weight: 500; min-height: 22px; margin: 4px 0 10px; }

/* ---------- Estructura ---------- */
.shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--ink); color: #e7eeea; padding: 22px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { padding: 0 10px 18px; }
.brand h1 { font-size: 21px; line-height: 1.1; color: #fff; }
.brand p { margin: 4px 0 0; color: #9fb3ab; font-size: 13.5px; }
.tab { display: block; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; padding: 11px 10px 10px; border-radius: 9px; }
.tab:hover { background: rgba(255,255,255,.07); }
.tab[aria-current=true] { background: rgba(255,255,255,.12); }
.tab-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.tab-top b { font-weight: 500; color: #9fb3ab; font-variant-numeric: tabular-nums; }
.tab .bar { display: block; height: 4px; background: rgba(255,255,255,.14); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.tab .bar i { display: block; height: 100%; background: #5fc4a8; }
.rail-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 13.5px; color: #b6c6bf; }
.rail-foot strong { display: block; color: #fff; font-weight: 600; }
.rail-foot .links { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; color: #dfe9e4; text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; }

.main { padding: 26px 32px 60px; min-width: 0; }
.main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.main-head h2 { font-size: 30px; line-height: 1.05; }
.main-head p { margin: 4px 0 0; color: var(--ink-2); }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tools input[type=search] { width: 260px; }
.tools select { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--rule); background: #fff; border-radius: 99px; padding: 5px 13px; font-weight: 500; font-size: 14px; min-height: 34px; }
.chip b { font-weight: 500; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed=true] b { color: #b6c6bf; }

/* ---------- Lista de contratos ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: minmax(200px, 1.3fr) minmax(180px, 1.2fr) minmax(170px, 1fr) 54px;
  gap: 18px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 13px 16px;
}
.row:hover { border-color: var(--pine); }
.row-name b { display: block; font-family: var(--head); font-weight: 700; font-size: 16px; line-height: 1.2; }
.row-name span { display: block; color: var(--ink-2); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.row-name em { font-style: normal; color: var(--muted); font-size: 13px; }
.now { font-size: 14px; line-height: 1.3; }
.now b { display: block; font-weight: 600; }
.now span { color: var(--ink-2); }
.now.done b { color: var(--pine); }
.pct { font-family: var(--head); font-weight: 700; font-size: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px 10px; text-align: center; color: var(--ink-2); }

/* Tira de etapas: una marca por etapa; la ámbar es la que sigue. */
.strip { display: flex; gap: 3px; align-items: center; }
.strip i { flex: 1; height: 12px; border-radius: 3px; min-width: 5px; box-shadow: inset 0 0 0 1.5px #c3cdc7; background: transparent; }
.strip i.done { background: var(--pine); box-shadow: none; }
.strip i.na { background: repeating-linear-gradient(135deg, #dfe5e1 0 3px, #f3f6f4 3px 6px); box-shadow: inset 0 0 0 1px #d2dad5; }
.strip i.next { background: var(--amber); box-shadow: none; }
.strip i.gap { flex: 0 0 8px; background: none; box-shadow: none; height: 12px; position: relative; min-width: 0; }
.strip i.gap::after { content: ""; position: absolute; left: 3px; top: 1px; bottom: 1px; width: 2px; background: var(--rule); border-radius: 1px; }

/* ---------- Detalle ---------- */
.scrim { position: fixed; inset: 0; background: rgba(21,35,31,.45); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--paper); z-index: 21;
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.18); animation: slide .22s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.d-head { padding: 22px 24px 14px; background: #fff; border-bottom: 1px solid var(--rule); }
.d-head .kind { color: var(--muted); font-size: 13.5px; }
.d-head h2 { font-size: 24px; line-height: 1.12; margin: 2px 0 2px; }
.d-head .prov { color: var(--ink-2); }
.d-head .top { display: flex; justify-content: space-between; gap: 12px; }
.d-prog { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.d-prog .strip { flex: 1; }
.d-prog .pct { font-size: 22px; }
.d-tabs { display: flex; gap: 4px; padding: 0 18px; background: #fff; border-bottom: 1px solid var(--rule); }
.d-tab { background: none; border: 0; padding: 12px 8px; margin: 0 6px; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; }
.d-tab[aria-selected=true] { color: var(--ink); border-bottom-color: var(--pine); }
.d-body { flex: 1; overflow: auto; padding: 8px 24px 40px; }
.phase { font-family: var(--head); font-weight: 700; font-size: 15px; margin: 20px 0 6px; color: var(--ink-2); }
.stage { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: start; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.check {
  width: 26px; height: 26px; border-radius: 7px; border: 2px solid #aab8b1; background: #fff; display: grid; place-items: center; padding: 0; margin-top: 1px;
}
.check:hover { border-color: var(--pine); }
.check svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check[aria-checked=true] { background: var(--pine); border-color: var(--pine); }
.check[aria-checked=true] svg { opacity: 1; }
.stage.na .check { border-style: dashed; background: #eef2ef; }
.stage .nm { font-weight: 600; }
.stage.next .nm::after { content: "sigue"; margin-left: 8px; font-size: 12px; font-weight: 600; background: var(--amber-soft); color: #7a5600; padding: 1px 8px; border-radius: 99px; }
.stage.na .nm { color: var(--muted); text-decoration: line-through; text-decoration-color: #b8c4bd; }
.stage .meta { color: var(--ink-2); font-size: 13.5px; margin-top: 1px; }
.stage .own { color: var(--muted); font-size: 13.5px; }
.stage .na-btn { font-size: 13px; background: none; border: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.log { list-style: none; margin: 14px 0 0; padding: 0; }
.log li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.log .when { display: block; color: var(--muted); font-size: 13.5px; }

/* ---------- Diálogos ---------- */
dialog { border: 0; border-radius: 14px; padding: 26px; width: min(520px, calc(100% - 32px)); background: #fff; color: var(--ink); }
dialog::backdrop { background: rgba(21,35,31,.5); }
dialog h2 { font-size: 22px; margin-bottom: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ulist { list-style: none; margin: 0 0 18px; padding: 0; max-height: 260px; overflow: auto; }
.ulist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.ulist small { color: var(--muted); display: block; }
.ulist .off { opacity: .55; }
.ulist .acts { display: flex; gap: 12px; }
.ulist .acts button { background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); font-size: 13.5px; padding: 4px 0; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--red); }

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand { width: 100%; padding-bottom: 4px; }
  .tab { width: auto; flex: 1 1 140px; }
  .rail-foot { width: 100%; margin-top: 4px; }
  .main { padding: 18px 14px 50px; }
  .row { grid-template-columns: 1fr 54px; gap: 10px; }
  .row .strip, .row .now { grid-column: 1 / -1; }
  .row .pct { grid-row: 1; grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } #toast { transition: none; } }
