:root {
  --fog: #E8EDF1;
  --paper: #FFFFFF;
  --ink: #18222F;
  --muted: #5B6777;
  --line: #D3DBE2;
  --steel: #35679B;
  --bridge: #C8452F;
  --display: 'Bricolage Grotesque', 'Instrument Sans', system-ui, sans-serif;
  --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --namew: 176px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fog);
  color: var(--ink);
  font: 16px/1.5 var(--body);
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Encabezado ---------- */
.top { position: relative; padding: 44px 0 0; overflow: hidden; }
.top h1 {
  margin: 0;
  font: 800 clamp(3rem, 9vw, 5.5rem)/0.9 var(--display);
  letter-spacing: -0.035em;
}
.lede { margin: 14px 0 0; max-width: 46ch; color: var(--muted); font-size: 1.125rem; }
.bridge { display: block; width: 100%; height: 110px; margin-top: 0; pointer-events: none; }
.bridge path { fill: none; stroke: var(--bridge); vector-effect: non-scaling-stroke; }
.b-hang { stroke-width: 1; opacity: .55; }
.b-cable { stroke-width: 2; }
.b-tower { stroke-width: 5; }
.b-deck { stroke-width: 4; }

/* ---------- Secciones ---------- */
main > section {
  background: var(--paper);
  border-radius: 14px;
  padding: 24px;
  margin-top: 20px;
}
main > section:first-child { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
h2 { margin: 0; font: 600 1.375rem/1.2 var(--display); letter-spacing: -0.01em; }
.section-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: .9375rem; max-width: 75ch; }
.hint:empty { display: none; }

/* ---------- Campos ---------- */
input, button { font: inherit; color: inherit; }
input[type="text"], input[type="date"] {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
input:hover { border-color: #AEB9C4; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr)) repeat(2, minmax(150px, 1.2fr)) minmax(120px, .8fr);
  gap: 16px;
  margin-top: 18px;
}
.field > span:first-child { display: block; margin-bottom: 6px; font-size: .875rem; font-weight: 500; color: var(--muted); }
.affix { position: relative; display: block; }
.affix i {
  position: absolute; left: 12px; top: 0; line-height: 42px;
  font-style: normal; color: var(--muted); pointer-events: none;
}
.affix input { padding-left: 30px; text-align: right; }
.affix i:first-child:not(:only-child) + input { padding-left: 30px; }
.money:not(.rate) .affix input { font-weight: 600; }
#usd { padding-left: 48px; }

button {
  height: 42px; padding: 0 18px;
  border: 0; border-radius: 8px;
  background: var(--ink); color: #fff;
  font-weight: 600; cursor: pointer;
}
button:hover { background: #2A3849; }

.add { display: flex; gap: 8px; }
.add input { width: 180px; }

/* ---------- Calendario ---------- */
.cal-scroll { overflow-x: auto; margin: 18px -24px 0; padding: 0 24px; }
.cal {
  display: grid;
  grid-template-columns: var(--namew) repeat(var(--n, 1), minmax(36px, 1fr));
  min-width: min-content;
  user-select: none;
}
.cal-msg { grid-column: 1 / -1; margin: 0; color: var(--bridge); }
.corner, .who {
  position: sticky; left: 0; z-index: 2;
  background: var(--paper);
}
.corner.sub { align-self: end; padding-bottom: 6px; font-size: .8125rem; color: var(--muted); }
.month {
  padding: 0 0 4px 6px;
  font: 600 .9375rem/1.2 var(--display);
  text-transform: capitalize;
  border-left: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
.day {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 0 6px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.corner.sub { border-bottom: 1px solid var(--ink); }
.day small { font-size: .6875rem; color: var(--muted); }
.day b { font-weight: 600; font-size: .9375rem; }
.day.weekend { background: #F1F4F7; }

.who {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding-right: 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.who-name {
  flex: 1; min-width: 0; height: auto; padding: 2px 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; color: var(--ink); font-weight: 500; text-align: left; border-radius: 4px;
}
.who-name:hover { background: none; text-decoration: underline; text-underline-offset: 3px; }
.who-remove {
  flex: none; width: 26px; height: 26px; padding: 0;
  background: transparent; color: var(--muted); font-size: 1.125rem; line-height: 1;
}
.who-remove:hover { background: var(--fog); color: var(--bridge); }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.cell {
  position: relative; height: 40px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: ew-resize;
  touch-action: pan-y;
}
.cell:hover { background: #F1F4F7; }
.cell.on::before {
  content: ''; position: absolute; inset: 8px -1px 8px -1px;
  background: var(--c);
}
.cell.on.first::before { left: 3px; border-top-left-radius: 7px; border-bottom-left-radius: 7px; }
.cell.on.last::before { right: 3px; border-top-right-radius: 7px; border-bottom-right-radius: 7px; }

.who.occ-label { border-bottom: 0; font-size: .8125rem; color: var(--muted); height: 32px; }
.occ {
  height: 32px; line-height: 32px; text-align: center;
  border-left: 1px solid var(--line);
  font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.occ.zero { color: var(--bridge); }

/* ---------- Reparto ---------- */
.mode { display: flex; margin: 0; padding: 3px; border: 0; background: var(--fog); border-radius: 10px; }
.mode label { position: relative; cursor: pointer; }
.mode input { position: absolute; opacity: 0; inset: 0; }
.mode span { display: block; padding: 7px 14px; border-radius: 8px; font-size: .9375rem; font-weight: 500; color: var(--muted); }
.mode input:checked + span { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgba(24, 34, 47, .18); }
.mode input:focus-visible + span { outline: 2px solid var(--steel); outline-offset: 2px; }

.people { width: 100%; margin-top: 18px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.people th { font-size: .875rem; font-weight: 500; color: var(--muted); text-align: left; padding: 0 10px 8px; border-bottom: 1px solid var(--ink); }
.people td { padding: 8px 10px; border-top: 1px solid var(--line); }
.people tbody tr:first-child td { border-top: 0; }
.people .num { text-align: right; white-space: nowrap; }
.people th:first-child, .people td:first-child { padding-left: 0; }
.c-name { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.c-name input { font-weight: 600; }
.c-date input { min-width: 140px; }
.o-usd, .o-clp { font-weight: 600; font-size: 1.0625rem; }
.o-nights.warn { color: var(--bridge); font-weight: 600; }
.c-remove { width: 1%; padding-right: 0 !important; }
.remove {
  height: 34px; padding: 0 10px;
  background: transparent; color: var(--muted);
  font-size: .875rem; font-weight: 500;
}
.remove:hover { background: var(--fog); color: var(--bridge); }
.people tfoot th, .people tfoot td {
  padding-top: 14px; border-bottom: 0; border-top: 1px solid var(--ink);
  font: 600 1.0625rem var(--display); color: var(--ink);
}

.empty { margin: 18px 0 0; padding: 28px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.notes { margin: 16px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .9375rem; }
.notes li + li { margin-top: 4px; }
.foot { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; padding: 20px 0 40px; color: var(--muted); font-size: .875rem; }
.foot p { margin: 0; max-width: 60ch; }
.foot-actions { display: flex; flex-wrap: wrap; gap: 8px; }
button.quiet { background: transparent; color: var(--ink); border: 1px solid #AEB9C4; font-weight: 500; }
button.quiet:hover { background: var(--paper); }

/* ---------- Pantallas chicas ---------- */
@media (max-width: 860px) {
  .fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .field { min-width: 0; }
  .bridge { height: 80px; }
  .fields .rate { grid-column: 1 / -1; }

  .people thead { display: none; }
  .people, .people tbody, .people tfoot { display: block; }
  .people tbody tr {
    display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px 12px;
    padding: 14px 0; border-bottom: 1px solid var(--line);
  }
  .people tbody td, .people tfoot th, .people tfoot td { padding: 0; border: 0; }
  .people tbody td[data-label]:not(.c-name):not(.c-remove)::before {
    content: attr(data-label); display: block;
    font-size: .8125rem; font-weight: 400; color: var(--muted);
  }
  .people tbody .num { text-align: left; }
  .c-name { grid-column: 1 / 3; }
  .c-remove { grid-column: 3; grid-row: 1; width: auto; }
  .c-date { grid-column: span 1; }
  .c-date input { min-width: 0; }
  .c-date + .c-date { grid-column: 2 / 4; }
  .o-nights { grid-column: 1; }
  .o-share { grid-column: 2 / 4; }
  .o-usd { grid-column: 1; }
  .o-clp { grid-column: 2 / 4; }
  .people tfoot tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding-top: 14px; }
  .people tfoot th, .people tfoot td { text-align: left !important; }
  .people tfoot th { grid-column: 1 / -1; }
  .people tfoot td:nth-of-type(1), .people tfoot td:nth-of-type(2), .people tfoot td:last-child { display: none; }
}
@media (max-width: 520px) {
  :root { --namew: 124px; }
  main > section { padding: 18px 16px; }
  .wrap { padding: 0 12px; }
  .cal-scroll { margin: 16px -16px 0; padding: 0 16px; }
  .add { width: 100%; }
  .add input { flex: 1; width: auto; min-width: 0; }
  .mode { width: 100%; }
  .mode label { flex: 1; text-align: center; }
  .mode span { padding: 7px 8px; }
}
