/* ===========================================================
   Polino Dashboard v2 — "carta náutica nocturna"
   Hand-rolled CSS. Tailwind se sumará cuando crezca la base.
   =========================================================== */

:root {
  --ink:           #0A1628;
  --abyssal:       #112236;
  --rule:          #1F3550;
  --rule-soft:     #17283F;
  --chart-white:   #E8EEF5;
  --fog:           #7C90A8;
  --fog-dim:       #4A5C75;
  --amber:         #F4B73C;
  --ais-green:     #3ECF8E;
  --buoy-red:      #E04338;
  --running-light: #5AB0FF;
}

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

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--chart-white);
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* Background reticle */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

/* App shell */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* Top bar */
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--rule);
  background: var(--ink);
  flex-shrink: 0;
}
.brand {
  font-family: 'Boldonse', 'Inter Tight', 'Helvetica Neue', sans-serif;
  font-size: 17px;
  letter-spacing: 0.06em;
  color: var(--chart-white);
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand .lozenge {
  width: 9px; height: 9px;
  background: var(--amber);
  transform: rotate(45deg);
  box-shadow: 0 0 6px rgba(244, 183, 60, 0.5);
}
.top-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 10.5px;
  color: var(--fog);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.top-meta .live-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ais-green);
  margin-right: 7px;
  box-shadow: 0 0 6px var(--ais-green);
  animation: blink 2.4s infinite;
}
.top-meta strong { color: var(--chart-white); font-weight: 500; }
.top-meta .sep { color: var(--fog-dim); }
.logout-btn {
  background: transparent;
  border: 0;
  color: var(--fog);
  cursor: pointer;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0;
  transition: color 140ms;
}
.logout-btn:hover { color: var(--amber); }

/* Sub-nav */
nav.sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 38px;
  border-bottom: 1px solid var(--rule);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
}
nav.sub ul { list-style: none; display: flex; gap: 28px; }
nav.sub a {
  color: var(--fog);
  padding: 11px 0;
  position: relative;
  transition: color 140ms;
}
nav.sub a:hover { color: var(--chart-white); }
nav.sub a.active { color: var(--chart-white); }
nav.sub a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--amber);
  box-shadow: 0 0 6px rgba(244, 183, 60, 0.4);
}
nav.sub .shortcut {
  color: var(--fog);
  display: flex;
  align-items: center;
  gap: 10px;
}
nav.sub .key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--rule);
  color: var(--chart-white);
  font-size: 10px;
}

/* Main grid: map + sidebar */
main.overview {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}
.map-wrap {
  position: relative;
  border-right: 1px solid var(--rule);
  overflow: hidden;
}
.map-wrap #map { width: 100%; height: 100%; background: #06101F; }

.map-overlay {
  position: absolute;
  top: 16px; left: 16px;
  z-index: 500;
  background: rgba(10, 22, 40, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  padding: 8px 12px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fog);
  pointer-events: none;
}
.map-overlay strong { color: var(--chart-white); font-weight: 500; }

.map-legend {
  position: absolute;
  bottom: 16px; left: 16px;
  z-index: 500;
  background: rgba(10, 22, 40, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  padding: 11px 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
  align-items: center;
}
.map-legend .dot { width: 9px; height: 9px; border-radius: 50%; }
.map-legend .square {
  width: 8px; height: 8px;
  background: transparent;
  border: 1px solid var(--amber);
  transform: rotate(45deg);
}

/* Sidebar */
aside.right {
  background: var(--ink);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.panel {
  padding: 22px 24px 24px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

/* Cropmarks */
.cropmark {
  position: absolute;
  width: 10px; height: 10px;
  pointer-events: none;
  opacity: 0.7;
}
.cropmark.tl { top: 8px; left: 8px;  border-top: 1px solid var(--amber); border-left:  1px solid var(--amber); }
.cropmark.tr { top: 8px; right: 8px; border-top: 1px solid var(--amber); border-right: 1px solid var(--amber); }
.cropmark.bl { bottom: 8px; left: 8px;  border-bottom: 1px solid var(--amber); border-left:  1px solid var(--amber); }
.cropmark.br { bottom: 8px; right: 8px; border-bottom: 1px solid var(--amber); border-right: 1px solid var(--amber); }

.panel-title {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.panel-title::before {
  content: "";
  width: 6px; height: 6px;
  background: var(--rule);
  display: inline-block;
}
.panel-title .count {
  margin-left: auto;
  color: var(--fog-dim);
  font-size: 10px;
  letter-spacing: 0.16em;
}

/* PULSE */
.pulse-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pulse-item { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.pulse-num {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 34px;
  line-height: 1;
  color: var(--chart-white);
  letter-spacing: -0.02em;
}
.pulse-num.warn   { color: var(--amber); }
.pulse-num.danger { color: var(--buoy-red); }
.pulse-label {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fog);
}

/* CHANGES */
.change-list { display: flex; flex-direction: column; margin: 0 -10px; }
.change-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 12px;
  padding: 11px 10px;
  border-top: 1px dashed var(--rule);
  align-items: center;
  animation: rowReveal 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms;
}
a.change-row:hover { background: rgba(17, 34, 54, 0.55); }
.change-row:first-child { border-top: 0; padding-top: 2px; }
.change-row:nth-child(1) { animation-delay:  80ms; }
.change-row:nth-child(2) { animation-delay: 130ms; }
.change-row:nth-child(3) { animation-delay: 180ms; }
.change-row:nth-child(4) { animation-delay: 230ms; }
.change-cn {
  font-size: 11px; font-weight: 500;
  color: var(--chart-white);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.change-desc { font-size: 11px; color: var(--fog); line-height: 1.45; }
.change-desc b { color: var(--chart-white); font-weight: 500; }
.delta {
  font-size: 10.5px; font-weight: 500;
  padding: 3px 7px;
  border: 1px solid var(--rule);
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-transform: uppercase;
}
.delta.up      { color: var(--buoy-red);      border-color: rgba(224, 67, 56, 0.45); }
.delta.down    { color: var(--ais-green);     border-color: rgba(62, 207, 142, 0.45); }
.delta.neutral { color: var(--running-light); border-color: rgba(90, 176, 255, 0.45); }

/* ATTENTION */
.attention-list { display: flex; flex-direction: column; gap: 10px; }
.attention-card {
  border: 1px solid rgba(224, 67, 56, 0.42);
  padding: 16px;
  position: relative;
  background: linear-gradient(180deg, rgba(224, 67, 56, 0.04) 0%, transparent 100%);
}
.attention-card .corner-red {
  position: absolute;
  top: -1px; right: -1px;
  width: 14px; height: 14px;
  border-top: 1px solid var(--buoy-red);
  border-right: 1px solid var(--buoy-red);
}
.attention-cn {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 16px;
  color: var(--chart-white);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.attention-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--fog);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.attention-meta .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--buoy-red);
  box-shadow: 0 0 8px rgba(224, 67, 56, 0.7);
  animation: pulseRed 1.6s infinite;
}
.attention-reason {
  margin-top: 11px; font-size: 11px; color: var(--fog); line-height: 1.55;
}
.attention-reason b { color: var(--chart-white); font-weight: 500; }
.attention-reason code { font-family: inherit; color: var(--amber); background: transparent; }

/* Empty / placeholder card */
.empty-panel {
  border: 1px dashed var(--rule);
  padding: 18px;
  text-align: center;
  font-size: 10.5px;
  color: var(--fog-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ===================== LIST =====================  */

main.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px 48px;
}

.list-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 22px;
}
.list-header h1 {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 26px;
  letter-spacing: 0.04em;
  color: var(--chart-white);
  margin: 0;
  font-weight: 400;
}
.list-header .scope {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog);
  margin-top: 6px;
}
.list-header .scope b { color: var(--chart-white); font-weight: 500; }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.filter-bar .label {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog-dim);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
  cursor: pointer;
  transition: all 140ms;
  font-family: inherit;
}
.chip:hover { color: var(--chart-white); border-color: var(--fog-dim); }
.chip.active {
  color: var(--ink);
  background: var(--amber);
  border-color: var(--amber);
}
.chip .count {
  font-size: 9.5px;
  opacity: 0.7;
}
.search-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--rule);
  min-width: 220px;
}
.search-box input {
  background: transparent;
  border: 0;
  color: var(--chart-white);
  font-family: inherit;
  font-size: 11px;
  outline: none;
  width: 100%;
  letter-spacing: 0.04em;
}
.search-box input::placeholder { color: var(--fog-dim); }
.search-box .key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border: 1px solid var(--rule); color: var(--fog);
  font-size: 10px;
}

/* Card list (legacy — usado por account/links) */
.card-list { display: flex; flex-direction: column; gap: 8px; }
.cn-card {
  display: grid;
  grid-template-columns: 180px 1.2fr 1.2fr 130px 90px 100px;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  background: rgba(17, 34, 54, 0.3);
  text-decoration: none;
  color: inherit;
  transition: background 140ms, border-color 140ms;
}
.cn-card:hover { background: rgba(17, 34, 54, 0.7); border-color: var(--fog-dim); }
.cn-card .col-cn {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--chart-white);
}
.cn-card .col-cn small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
  margin-top: 3px;
}
.cn-card .col-route { font-size: 11px; color: var(--fog); line-height: 1.45; }
.cn-card .col-route b { color: var(--chart-white); font-weight: 500; }
.cn-card .col-vessel { font-size: 11px; color: var(--fog); letter-spacing: 0.04em; }
.cn-card .col-vessel b { color: var(--chart-white); font-weight: 500; }
.cn-card .col-eta { font-size: 12px; color: var(--chart-white); font-weight: 500; text-align: right; }
.cn-card .col-eta small {
  display: block;
  font-size: 9.5px;
  color: var(--fog);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.cn-card .col-status { text-align: right; }

/* Container table (sortable) */
.cn-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  color: inherit;
}
.cn-table thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 140ms;
}
.cn-table thead th:hover { color: var(--chart-white); }
.cn-table thead th.active { color: var(--amber); }
.cn-table thead th[data-sort-key]::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0;
  transform: translateY(-1px);
}
.cn-table thead th.active[data-dir="asc"]::after {
  border-bottom: 5px solid var(--amber);
  opacity: 1;
}
.cn-table thead th.active[data-dir="desc"]::after {
  border-top: 5px solid var(--amber);
  opacity: 1;
}
.cn-table thead th.th-eta,
.cn-table thead th.th-status { text-align: right; }

.cn-table tbody tr.cn-row { cursor: pointer; }
.cn-table tbody tr.cn-row.hidden { display: none; }
.cn-table tbody td {
  padding: 14px 14px;
  vertical-align: middle;
  background: rgba(17, 34, 54, 0.3);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  transition: background 140ms, border-color 140ms;
}
.cn-table tbody td:first-child { border-left: 1px solid var(--rule); }
.cn-table tbody td:last-child { border-right: 1px solid var(--rule); text-align: right; }
.cn-table tbody tr.cn-row:hover td {
  background: rgba(17, 34, 54, 0.7);
  border-color: var(--fog-dim);
}

.cn-table .col-cn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--chart-white);
  white-space: nowrap;
}
.cn-table .col-ref {
  font-size: 12px;
  color: var(--chart-white);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.cn-table .col-cliente {
  font-size: 13px;
  color: var(--chart-white);
  font-weight: 500;
}
.cn-table .col-pol,
.cn-table .col-pod {
  font-size: 12px;
  color: var(--chart-white);
  font-weight: 500;
  white-space: nowrap;
}
.cn-table .col-terminal {
  font-size: 12px;
  color: var(--chart-white);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.35;
}
.cn-table .col-terminal b { color: var(--amber); font-weight: 600; letter-spacing: 0.04em; }
.cn-table .col-terminal small { color: var(--fog-dim); font-size: 10px; }
.cn-table .col-terminal .dim { color: var(--fog-dim); }
.cn-table .col-vessel {
  font-size: 12px;
  color: var(--chart-white);
  letter-spacing: 0.04em;
  line-height: 1.45;
}
.cn-table .col-vessel b { color: var(--chart-white); font-weight: 500; }
.cn-table .col-vessel .vessel-carrier {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog-dim);
}
.cn-table .col-vessel .dim { color: var(--fog-dim); }
.cn-table .col-eta {
  font-size: 12px;
  color: var(--chart-white);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}
.cn-table .col-eta.danger { color: var(--buoy-red); }
.cn-table .col-status { text-align: right; }

@media (max-width: 1180px) {
  .cn-table thead th.th-pol,
  .cn-table tbody .col-pol,
  .cn-table thead th.th-pod,
  .cn-table tbody .col-pod { display: none; }
}
@media (max-width: 960px) {
  .cn-table thead th.th-cliente,
  .cn-table tbody .col-cliente,
  .cn-table thead th.th-terminal,
  .cn-table tbody .col-terminal { display: none; }
}
@media (max-width: 720px) {
  .cn-table thead th.th-vessel,
  .cn-table tbody .col-vessel,
  .cn-table thead th.th-eta,
  .cn-table tbody .col-eta { display: none; }
  main.list { padding: 16px 18px 32px; }
  .cn-table tbody td { padding: 12px 10px; }
}

/* Issues card */
.issue-form-wrap { margin-bottom: 14px; }
.issue-toggle {
  display: inline-block;
  cursor: pointer;
  list-style: none;
}
.issue-toggle::-webkit-details-marker { display: none; }
.issue-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--rule);
  background: rgba(17, 34, 54, 0.45);
}
.issue-form label { display: flex; flex-direction: column; gap: 4px; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fog); }
.issue-form label.full { grid-column: 1 / -1; }
.issue-form input, .issue-form select, .issue-form textarea {
  background: var(--abyssal);
  color: var(--chart-white);
  border: 1px solid var(--rule);
  padding: 7px 9px;
  font: inherit;
  font-size: 12px;
  outline: none;
  letter-spacing: 0.02em;
}
.issue-form input:focus, .issue-form select:focus, .issue-form textarea:focus { border-color: var(--amber); }
.issue-form input[readonly] { background: rgba(17, 34, 54, 0.6); color: var(--fog); cursor: not-allowed; }
.issue-form .issue-submit { grid-column: 1 / -1; justify-self: end; cursor: pointer; }
.issue-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.issue-row {
  border: 1px solid var(--rule);
  padding: 10px 12px;
  background: rgba(17, 34, 54, 0.35);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.issue-row.issue-resuelto { opacity: 0.55; }
.issue-head { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; font-size: 10px; color: var(--fog); letter-spacing: 0.12em; text-transform: uppercase; }
.issue-head .issue-ts { color: var(--fog-dim); }
.issue-head .issue-kind { color: var(--chart-white); font-weight: 500; }
.issue-head .issue-status {
  margin-left: auto;
  padding: 2px 8px;
  border: 1px solid var(--rule);
  color: var(--amber);
}
.issue-row.issue-resuelto .issue-head .issue-status { color: var(--ais-green); border-color: rgba(62, 207, 142, 0.45); }
.issue-body { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--chart-white); }
.issue-body .issue-field { color: var(--amber); letter-spacing: 0.04em; font-size: 10px; text-transform: uppercase; }
.issue-body .issue-expected, .issue-body .issue-observed { color: var(--fog); }
.issue-body .issue-expected b, .issue-body .issue-observed b { color: var(--chart-white); }
.issue-body .issue-note { color: var(--fog); font-size: 11px; line-height: 1.5; }
.issue-body .issue-meta { color: var(--fog-dim); font-size: 10px; letter-spacing: 0.08em; margin-top: 4px; }
.issue-resolve { margin: 0; }

/* Issue modal */
dialog.issue-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--abyssal, #0b1828);
  color: var(--chart-white);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: visible;
}
dialog.issue-modal::backdrop {
  background: rgba(5, 12, 22, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.issue-modal-dialog {
  position: relative;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 22px 24px 20px;
}
.issue-modal-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.issue-modal-title {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--chart-white);
}
.issue-modal-close {
  background: transparent;
  border: none;
  color: var(--fog);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.issue-modal-close:hover { color: var(--amber); }
.issue-modal .issue-form {
  margin-top: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.issue-modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.issue-modal-actions .issue-submit { justify-self: auto; }
@media (max-width: 540px) {
  .issue-modal { padding: 12px; }
  .issue-modal-dialog { padding: 18px 16px 16px; }
  .issue-modal .issue-form { grid-template-columns: 1fr; }
}

/* ================== Create container modal ==================
   Fase 2 — alta de container desde dashboard.
   Centrado robusto al viewport con inset:0 + margin:auto. NO usa
   top/left/transform porque algunos ancestros con transform/filter del
   layout v2 crean containing-blocks que rompen el centrado en %.
*/
dialog.create-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(620px, calc(100vw - 32px));
  height: max-content;
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(244, 183, 60, 0.06), transparent 55%),
    radial-gradient(140% 80% at 100% 100%, rgba(62, 207, 142, 0.04), transparent 60%),
    var(--abyssal, #112236);
  color: var(--chart-white);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(244, 183, 60, 0.04) inset;
  overflow: visible;
}
dialog.create-modal::backdrop {
  background: rgba(5, 12, 22, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
dialog.create-modal[open] {
  animation: create-modal-in 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
dialog.create-modal[open]::backdrop {
  animation: create-modal-backdrop-in 220ms ease-out;
}
@keyframes create-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes create-modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.create-modal-dialog {
  position: relative;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 32px 36px 28px;
}

.create-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--rule);
}
.create-modal-heading { display: flex; flex-direction: column; gap: 8px; }
.create-modal-eyebrow {
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 500;
}
.create-modal-title {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--chart-white);
  line-height: 1.2;
}
.create-modal-subtitle {
  margin: 0;
  max-width: 44ch;
  color: var(--fog);
  font-size: 12.5px;
  line-height: 1.55;
}
.create-modal-close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fog);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 140ms, border-color 140ms;
}
.create-modal-close:hover {
  color: var(--amber);
  border-color: rgba(244, 183, 60, 0.4);
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.create-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.create-form .field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.create-form label {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 500;
}
.create-form label .dim {
  color: var(--fog-dim);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 10.5px;
  font-weight: 400;
  margin-left: 4px;
}
.create-form input[type="text"] {
  background: rgba(8, 18, 32, 0.6);
  border: 1px solid var(--rule);
  color: var(--chart-white);
  padding: 11px 13px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.create-form input[type="text"]:focus {
  border-color: var(--amber);
  background: rgba(8, 18, 32, 0.85);
  box-shadow: 0 0 0 3px rgba(244, 183, 60, 0.14);
}
.create-form input[type="text"]::placeholder {
  color: var(--fog-dim);
  letter-spacing: 0.04em;
}
.create-form #cn-container-number {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.12em;
  padding-block: 13px;
}
.field-cn { gap: 10px; }
.field-hint {
  color: var(--fog-dim);
  font-size: 11px;
  line-height: 1.55;
  letter-spacing: 0.02em;
}
.field-error {
  color: var(--buoy-red, #E04338);
  font-size: 11.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-error::before {
  content: "▲";
  font-size: 9px;
  line-height: 1;
}

.create-form-banner {
  padding: 12px 14px;
  border: 1px solid var(--rule);
  font-size: 12.5px;
  line-height: 1.55;
  border-radius: 2px;
}
.create-form-banner.banner-error {
  border-color: var(--buoy-red, #E04338);
  color: #FFB8B0;
  background: rgba(224, 67, 56, 0.08);
}
.create-form-banner.banner-warning {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(244, 183, 60, 0.08);
}
.create-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.create-modal-actions .btn-ghost { padding: 12px 18px; }
.create-modal-actions .btn-primary {
  width: auto;
  min-width: 200px;
}
.create-submit[disabled] {
  opacity: 0.7;
  cursor: progress;
}
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 620px) {
  dialog.create-modal { width: calc(100vw - 20px); }
  .create-modal-dialog { padding: 24px 20px 20px; }
  .create-modal-head { padding-bottom: 16px; margin-bottom: 20px; }
  .create-modal-title { font-size: 19px; }
  .create-form-row { grid-template-columns: 1fr; gap: 22px; }
  .create-form { gap: 20px; }
  .create-modal-actions { flex-direction: column-reverse; }
  .create-modal-actions .btn-primary,
  .create-modal-actions .btn-ghost { width: 100%; text-align: center; justify-content: center; }
}

.flash-banner {
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.55;
  border-radius: 2px;
  border: 1px solid var(--rule);
}
.flash-banner code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  background: rgba(244, 183, 60, 0.08);
  color: var(--amber);
  border: 1px solid rgba(244, 183, 60, 0.25);
}
.flash-banner-ok {
  border-color: var(--ais-green, #3ECF8E);
  background: rgba(62, 207, 142, 0.06);
  color: var(--chart-white);
}
.flash-banner-warn {
  border-color: var(--amber);
  background: rgba(244, 183, 60, 0.06);
  color: var(--chart-white);
}
.flash-banner-err {
  border-color: var(--buoy-red);
  background: rgba(224, 67, 56, 0.06);
  color: var(--chart-white);
}
/* P1-3 · Para detail_v2.html, usar como hijo del grid container */
.flash-banner.grid-full { grid-column: 1 / -1; margin-top: 4px; }

/* Botón de delete + delete modal (variante "destructiva" del create modal). */
.btn-ghost.btn-danger {
  border-color: var(--buoy-red, #E04338);
  color: var(--buoy-red, #E04338);
}
.btn-ghost.btn-danger:hover {
  background: rgba(224, 67, 56, 0.10);
}
.btn-primary.btn-danger {
  background: var(--buoy-red, #E04338);
  border-color: var(--buoy-red, #E04338);
  color: var(--chart-white);
  box-shadow: 0 0 18px rgba(224, 67, 56, 0.28);
}
.btn-primary.btn-danger:hover {
  background: #f0594d;
  border-color: #f0594d;
  box-shadow: 0 0 22px rgba(240, 89, 77, 0.38);
}
.btn-primary.btn-danger[disabled] {
  background: rgba(224, 67, 56, 0.25);
  border-color: rgba(224, 67, 56, 0.4);
  color: rgba(255, 184, 176, 0.6);
  cursor: not-allowed;
  box-shadow: none;
}
.create-modal-eyebrow.danger { color: var(--buoy-red, #E04338); }
dialog.create-modal.delete-modal {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(224, 67, 56, 0.08), transparent 55%),
    radial-gradient(140% 80% at 100% 100%, rgba(244, 183, 60, 0.04), transparent 60%),
    var(--abyssal, #112236);
}
.delete-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: rgba(8, 18, 32, 0.55);
  border-radius: 2px;
}
.delete-summary-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  align-items: baseline;
}
.delete-summary-label {
  color: var(--fog);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.delete-summary-value {
  color: var(--chart-white);
  font-size: 13px;
  line-height: 1.4;
  word-break: break-word;
}
.delete-summary-value code,
code.delete-summary-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  background: rgba(244, 183, 60, 0.08);
  color: var(--amber);
  padding: 2px 6px;
  border: 1px solid rgba(244, 183, 60, 0.25);
}
@media (max-width: 620px) {
  .delete-summary-row { grid-template-columns: 1fr; gap: 2px; }
}

/* ===================== DETAIL =====================  */

main.detail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px 48px;
}

.detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 24px;
  align-items: end;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 20px;
  margin-bottom: 28px;
}
.detail-header .cn {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 28px;
  letter-spacing: 0.02em;
  color: var(--chart-white);
  line-height: 1;
}
.detail-header .breadcrumb {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 8px;
}
.detail-header .breadcrumb a { color: var(--fog); }
.detail-header .breadcrumb a:hover { color: var(--amber); }
.detail-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  font-size: 11px;
  color: var(--fog);
  margin-top: 10px;
  letter-spacing: 0.04em;
}
.detail-header .meta b { color: var(--chart-white); font-weight: 500; }
.detail-header .actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-pill {
  display: inline-block;
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--rule);
  color: var(--fog);
  white-space: nowrap;
}
.status-pill.sailing { color: var(--ais-green); border-color: rgba(62, 207, 142, 0.5); }
.status-pill.port    { color: var(--running-light); border-color: rgba(90, 176, 255, 0.5); }
.status-pill.pending { color: var(--amber); border-color: rgba(244, 183, 60, 0.5); }
.status-pill.blocked { color: var(--buoy-red); border-color: rgba(224, 67, 56, 0.5); }
.status-pill.unknown { color: var(--fog-dim); }
.status-pill.polino-arribado   { color: var(--running-light); border-color: rgba(90, 176, 255, 0.6); background: rgba(90, 176, 255, 0.07); }
.status-pill.polino-descargado { color: var(--amber);         border-color: rgba(244, 183, 60, 0.6); background: rgba(244, 183, 60, 0.07); }
.status-pill.polino-entregado  { color: var(--ais-green);     border-color: rgba(62, 207, 142, 0.6); background: rgba(62, 207, 142, 0.08); }
.status-pill.expense-pending   { color: var(--amber);         border-color: rgba(244, 183, 60, 0.7); background: rgba(244, 183, 60, 0.10); }
.status-pill.expense-requested { color: var(--running-light); border-color: rgba(90, 176, 255, 0.6); background: rgba(90, 176, 255, 0.07); }
.status-pill.expense-received  { color: var(--ais-green);     border-color: rgba(62, 207, 142, 0.6); background: rgba(62, 207, 142, 0.08); }

/* Barra de expense (entre header y grid) */
.expense-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  background: rgba(244, 183, 60, 0.03);
}
.expense-bar .expense-meta {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fog);
}
.expense-inline-form { display: inline; margin: 0; }
.btn-mini {
  padding: 4px 8px;
  font-size: 9.5px;
  letter-spacing: 0.10em;
}

/* Sección Adjuntos */
.attachments-section {
  margin-top: 22px;
  padding: 18px 18px 22px;
  border: 1px solid var(--rule);
  background: rgba(10, 22, 40, 0.35);
}
.attachments-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.attachments-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chart-white);
}
.attachments-count {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
}
.attachments-group { margin-bottom: 16px; }
.attachments-group h3 {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fog);
  font-weight: 500;
}
.attachments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  background: rgba(10, 22, 40, 0.5);
  flex-wrap: wrap;
}
.attachment-name {
  color: var(--amber);
  text-decoration: none;
  font-size: 12px;
  flex: 1 1 220px;
  word-break: break-all;
}
.attachment-name:hover { text-decoration: underline; }
.attachment-meta {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fog);
}
.attachment-delete { margin: 0; }
.attachments-empty {
  margin: 0;
  font-size: 11px;
  color: var(--fog-dim);
  font-style: italic;
}
.attachments-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}
.attachments-upload-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
}
.attachments-upload-field input,
.attachments-upload-field select {
  font-size: 12px;
  text-transform: none;
  letter-spacing: normal;
  color: var(--chart-white);
  background: rgba(10, 22, 40, 0.75);
  border: 1px solid var(--rule);
  padding: 6px 8px;
}
.attachments-upload-hint {
  flex-basis: 100%;
  font-size: 10px;
  color: var(--fog-dim);
  letter-spacing: 0.10em;
}

/* Expense form modal (reutiliza .create-modal de delete) */
.expense-form .field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}
.expense-form .field { margin-bottom: 12px; }
.expense-form input[type="number"],
.expense-form input[type="date"],
.expense-form select,
.expense-form textarea,
.expense-form input[type="file"] {
  width: 100%;
  font-size: 12px;
  color: var(--chart-white);
  background: rgba(10, 22, 40, 0.75);
  border: 1px solid var(--rule);
  padding: 6px 8px;
  box-sizing: border-box;
}

/* Panel Estado Polino */
.polino-state {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.polino-audit {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
  line-height: 1.55;
}
.polino-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}
.polino-form { margin: 0; }
.polino-btn { width: 100%; justify-content: center; }
.polino-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--rule);
  color: var(--fog-dim);
}
.polino-btn[disabled]:hover { background: transparent; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms;
}
.btn-ghost:hover { background: rgba(244, 183, 60, 0.1); }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--amber);
  background: var(--amber);
  color: var(--ink);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(244, 183, 60, 0.28);
  transition: background 140ms, box-shadow 140ms, border-color 140ms, color 140ms;
}
.btn-primary:hover {
  background: var(--chart-white);
  border-color: var(--chart-white);
  color: var(--ink);
  box-shadow: 0 0 22px rgba(232, 238, 245, 0.32);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
}

/* Timeline */
.timeline-v2 {
  position: relative;
  padding-left: 28px;
}
.timeline-v2::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 0;
  width: 1px;
  background: var(--rule);
}
.tl-event {
  position: relative;
  padding: 14px 18px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--rule);
  background: rgba(17, 34, 54, 0.4);
}
.tl-event::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 18px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink);
  background: var(--ais-green);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(62, 207, 142, 0.5);
}
.tl-event.est::before {
  background: var(--ink);
  border-color: var(--fog-dim);
  box-shadow: none;
}
.tl-event.est {
  background: transparent;
  border-style: dashed;
  opacity: 0.85;
}
.tl-event .tl-ts {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tl-event .tl-kind {
  font-size: 9px;
  letter-spacing: 0.16em;
  padding: 2px 5px;
  border: 1px solid var(--rule);
}
.tl-event.act .tl-kind { color: var(--ais-green); border-color: rgba(62, 207, 142, 0.45); }
.tl-event.est .tl-kind { color: var(--fog); border-color: var(--rule); }
.tl-event .tl-code {
  font-size: 13px;
  color: var(--chart-white);
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}
.tl-event .tl-loc {
  font-size: 12px;
  color: var(--fog);
}
.tl-event .tl-vessel {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--fog-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Facts sidebar */
.facts-card {
  border: 1px solid var(--rule);
  padding: 18px;
  margin-bottom: 18px;
  position: relative;
}
.facts-title {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fog);
  margin-bottom: 14px;
}
.facts-grid {
  display: grid;
  gap: 12px;
}
.facts-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
}
.facts-row .k {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fog);
}
.facts-row .v {
  color: var(--chart-white);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.facts-row .v.muted { color: var(--fog); font-weight: 400; }
.facts-row .v.warn { color: var(--amber); }
.facts-row .v.danger { color: var(--buoy-red); }

@media (max-width: 960px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid > * { min-width: 0; }
  .detail-header { grid-template-columns: 1fr; }
  main.detail { padding: 16px 18px 32px; }
}

/* Sync footer */
.sync {
  padding: 14px 24px;
  font-size: 10px;
  color: var(--fog);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}
.sync strong { color: var(--chart-white); font-weight: 500; }

/* Leaflet vessel markers */
.vessel-icon { width: 14px; height: 14px; position: relative; }
.vessel-icon::before {
  content: "";
  position: absolute; inset: 4px;
  background: var(--ais-green);
  border-radius: 50%;
  box-shadow: 0 0 5px var(--ais-green);
}
.vessel-icon::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--ais-green);
  opacity: 0.55;
  animation: aisPing 2.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.vessel-icon.berthed::before { background: var(--running-light); box-shadow: 0 0 5px var(--running-light); }
.vessel-icon.berthed::after  { background: var(--running-light); }
.vessel-icon.delayed::before { background: var(--buoy-red);      box-shadow: 0 0 5px var(--buoy-red); }
.vessel-icon.delayed::after  { background: var(--buoy-red); }
.port-icon {
  width: 8px; height: 8px;
  background: transparent;
  border: 1px solid var(--amber);
  transform: rotate(45deg);
}

/* Leaflet popup — paleta v2 */
.leaflet-popup-content-wrapper,
.leaflet-popup-content {
  background: var(--abyssal) !important;
  color: var(--chart-white);
  border-radius: 0;
  font-family: 'JetBrains Mono', monospace;
}
.leaflet-popup-content-wrapper {
  border: 1px solid var(--rule);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  padding: 0;
}
.leaflet-popup-tip-container {
  background: transparent !important;
  width: 24px;
  height: 14px;
}
.leaflet-popup-tip {
  background: var(--abyssal) !important;
  border: 1px solid var(--rule);
  box-shadow: none;
}
.leaflet-popup-content {
  margin: 14px 16px !important;
  font-size: 11px;
  line-height: 1.5;
  min-width: 180px;
}
.leaflet-popup-close-button {
  color: var(--fog) !important;
  font-size: 16px !important;
  padding: 6px 8px 0 0 !important;
}
.leaflet-popup-close-button:hover { color: var(--amber) !important; }

/* Jerarquia: CN amber grande, vessel/loc en chart-white, meta en fog */
.leaflet-popup-content .cn {
  font-family: 'Boldonse', 'Inter Tight', sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--amber);
  line-height: 1.15;
  margin-bottom: 6px;
  text-shadow: 0 0 8px rgba(244, 183, 60, 0.25);
}
.leaflet-popup-content .vessel {
  font-size: 11px;
  color: var(--chart-white);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.leaflet-popup-content .meta {
  color: var(--fog);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--rule);
}
.leaflet-popup-content .meta b { color: var(--chart-white); font-weight: 500; }
.leaflet-popup-content a {
  color: var(--amber);
  text-decoration: none;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.leaflet-popup-content a:hover { color: var(--chart-white); }
.leaflet-popup-content hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 10px 0;
}
.leaflet-control-attribution {
  background: rgba(10, 22, 40, 0.7) !important;
  color: var(--fog) !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 9px !important;
  border: 1px solid var(--rule) !important;
}
.leaflet-control-attribution a { color: var(--fog) !important; }
.leaflet-control-zoom a {
  background: rgba(10, 22, 40, 0.8) !important;
  color: var(--chart-white) !important;
  border: 1px solid var(--rule) !important;
  font-family: 'JetBrains Mono', monospace !important;
}
.leaflet-control-zoom a:hover { background: var(--abyssal) !important; color: var(--amber) !important; }

/* Scrollbar */
aside.right::-webkit-scrollbar { width: 6px; }
aside.right::-webkit-scrollbar-track { background: var(--ink); }
aside.right::-webkit-scrollbar-thumb { background: var(--rule); }
aside.right::-webkit-scrollbar-thumb:hover { background: var(--fog-dim); }

/* Keyframes */
@keyframes blink     { 0%, 80%, 100% { opacity: 1; } 90% { opacity: 0.25; } }
@keyframes pulseRed  { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes rowReveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes aisPing   { 0% { transform: scale(0.6); opacity: 0.65; } 80%, 100% { transform: scale(3.6); opacity: 0; } }

/* Responsive */
@media (max-width: 960px) {
  main.overview { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .map-wrap { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 50vh; }
  aside.right { max-height: 50vh; }
  .top-meta .sep, .top-meta .email { display: none; }
}

/* ===========================================================
   Terminal match chips (Mejoras v3 — voyage-aware terminal)
   =========================================================== */
.terminal-match {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  background: rgba(124, 144, 168, 0.05);
  cursor: help;
  white-space: nowrap;
}
.terminal-match-voyage-strict    { color: var(--ais-green);     border-color: rgba(62, 207, 142, 0.6);  background: rgba(62, 207, 142, 0.08); }
.terminal-match-voyage-loose     { color: var(--running-light); border-color: rgba(90, 176, 255, 0.6);  background: rgba(90, 176, 255, 0.07); }
.terminal-match-eta-proximity    { color: var(--amber);         border-color: rgba(244, 183, 60, 0.6);  background: rgba(244, 183, 60, 0.07); }
.terminal-match-earliest-future  { color: var(--fog);           border-color: var(--rule); }
.terminal-match-none             { color: var(--fog-dim);       border-color: var(--rule-soft); border-style: dashed; }

/* ===========================================================
   Drift terminales (NTLWEB agregador vs fuente original)
   Mejoras v3 — item 3 post-plan
   =========================================================== */
.drift-help {
  font-size: 11px;
  color: var(--fog);
  line-height: 1.45;
  margin: -2px 0 10px;
}
.drift-block {
  border-top: 1px solid var(--rule-soft);
  padding-top: 10px;
  margin-top: 10px;
}
.drift-block:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.drift-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.drift-terminal {
  color: var(--amber);
  font-weight: 600;
  letter-spacing: 0.08em;
  font-size: 12px;
}
.drift-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--rule);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fog);
  background: rgba(124, 144, 168, 0.05);
  cursor: help;
  white-space: nowrap;
}
.drift-match            { color: var(--ais-green);     border-color: rgba(62, 207, 142, 0.55); background: rgba(62, 207, 142, 0.08); }
.drift-mismatch         { color: var(--amber);         border-color: rgba(244, 183, 60, 0.6);  background: rgba(244, 183, 60, 0.08); }
.drift-only-ntlweb      { color: var(--fog);           border-color: var(--rule); border-style: dashed; }
.drift-only-individual  { color: var(--running-light); border-color: rgba(90, 176, 255, 0.55); background: rgba(90, 176, 255, 0.07); }
.drift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.drift-col {
  background: rgba(124, 144, 168, 0.04);
  border: 1px solid var(--rule-soft);
  padding: 8px 10px;
}
.drift-col-head {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog-dim);
  margin-bottom: 6px;
}
.drift-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  line-height: 1.55;
}
.drift-eta {
  font-variant-numeric: tabular-nums;
  color: var(--chart-white, #E8EEF6);
}
.drift-voyage {
  font-size: 10px;
  color: var(--fog);
  letter-spacing: 0.04em;
}
.drift-empty {
  color: var(--fog-dim);
  font-style: italic;
}

/* Precinto editable (admin) */
.precinto-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.precinto-input {
  background: rgba(10, 22, 40, 0.5);
  border: 1px solid var(--rule);
  color: var(--chart-white);
  padding: 3px 6px;
  font-size: 12px;
  width: 110px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}
.precinto-input:focus {
  border-color: var(--amber);
  outline: none;
}
.btn-mini {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: transparent;
  cursor: pointer;
  transition: background 140ms;
  font-family: inherit;
}
.btn-mini:hover { background: rgba(244, 183, 60, 0.12); }

/* SCAC override (Fase 2 [[Plan - Deteccion Linea SCAC]]) */
.scac-override-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.scac-select {
  background: rgba(10, 22, 40, 0.5);
  border: 1px solid var(--rule);
  color: var(--chart-white);
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
  min-width: 160px;
}
.scac-select:focus {
  border-color: var(--amber);
  outline: none;
}
.scac-override-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background: rgba(244, 183, 60, 0.06);
}
.scac-orphans-card {
  border: 1px solid var(--amber);
  background: rgba(244, 183, 60, 0.04);
  padding: 14px 16px;
  margin-bottom: 18px;
  position: relative;
}
.scac-orphans-card .title {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 8px;
}
.scac-orphans-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 14px;
}
.scac-orphans-card ul li a {
  color: var(--chart-white);
  text-decoration: none;
  border-bottom: 1px dotted var(--rule);
}
.scac-orphans-card ul li a:hover {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

/* Archivar/Activos toggle (admin) */
.archive-toggle {
  display: inline-flex;
  gap: 4px;
}
.archive-toggle .chip {
  text-decoration: none;
}
.archive-toggle .chip.active {
  background: rgba(244, 183, 60, 0.15);
  border-color: var(--amber);
  color: var(--amber);
}

/* Origen del container (Fase 4 — ingestion_source visual) */
.cn-table .col-cn .origin-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amber);
  background: rgba(244, 183, 60, 0.1);
  border: 1px solid rgba(244, 183, 60, 0.4);
  border-radius: 2px;
  vertical-align: 1px;
}
.origin-line {
  font-size: 11px;
  color: var(--fog);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.origin-line b {
  font-weight: 500;
  color: var(--amber);
}
.origin-line b.neutral {
  color: var(--fog);
}
.origin-line .origin-sep {
  color: var(--fog-dim);
  margin: 0 6px;
}

/* ===========================================================
   Mejoras UX/UI Finales — 22-05-2026
   Polish mobile/responsive + sistema de tokens + tipografía fluida.
   Plan: "Mejoras UX  UI Finales.md".
   =========================================================== */

/* ---------- P1-1 · Breakpoint tokens ---------- */
:root {
  --bp-sm: 480px;   /* mobile small */
  --bp-md: 768px;   /* tablet portrait */
  --bp-lg: 1024px;  /* desktop boundary */
  --bp-xl: 1180px;  /* wide */
}

/* ---------- P0-2 / P1-4 · Table scroll wrapper (utility) ---------- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-scroll > table { min-width: 100%; }

/* ---------- P1-4 · Health-table consolidado (era duplicado inline en health/import/users) ---------- */
.health-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.health-table th { text-align: left; padding: 6px 8px; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fog); border-bottom: 1px solid var(--rule); }
.health-table td { padding: 8px; border-bottom: 1px dashed var(--rule); color: var(--chart-white); vertical-align: top; }
.health-table td.danger { color: var(--buoy-red); }
.health-table td.warn { color: var(--amber); }
.health-table td.dim { color: var(--fog-dim); }

/* ---------- P0-1 · Scroll natural en <desktop ---------- */
@media (max-width: 1023px) {
  html, body {
    overflow: visible;
    height: auto;
    min-height: 100%;
  }
  .app {
    height: auto;
    min-height: 100vh;
    display: block;
  }
}

/* ---------- P0-3 + P0-4 · Header + nav responsive ---------- */
@media (max-width: 720px) {
  header.top {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 8px;
    row-gap: 6px;
  }
  nav.sub {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 14px;
    gap: 8px;
  }
  nav.sub ul { gap: 18px; flex-wrap: wrap; }
}

/* P0-4 · Ocultar Sync OK + clock + email en mobile, dejar brand + Salir */
@media (max-width: 540px) {
  header.top .top-meta > span:not(:last-of-type) { display: none; }
  header.top .top-meta .sep,
  header.top .top-meta .email { display: none; }
  header.top .top-meta { gap: 0; }
}

/* P2-5 · Limpiar nav.sub .shortcut en mobile (sin search global aún) */
@media (max-width: 720px) {
  nav.sub .shortcut { display: none; }
}

/* ---------- P0-5 · list-header con wrap y stack de acciones ---------- */
@media (max-width: 720px) {
  .list-header {
    flex-wrap: wrap;
    gap: 14px;
  }
  .list-header > * { min-width: 0; }
  .list-header > div:last-child {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  .list-header > div:last-child .archive-toggle { display: flex; gap: 8px; }
  .list-header > div:last-child .btn-ghost { flex: 1 1 auto; text-align: center; }
}

/* ---------- P0-6 · .cn-card-link (account/links) ---------- */
.cn-card-link {
  grid-template-columns: 180px 1fr 140px 130px 110px;
}
@media (max-width: 720px) {
  .cn-card,
  .cn-card-link {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 14px 16px;
  }
  .cn-card > *,
  .cn-card-link > * {
    width: 100%;
    text-align: left !important;
  }
  .cn-card .col-eta,
  .cn-card .col-status { text-align: left; }
}

/* ---------- P0-7 · detail-header .actions con flex-wrap ---------- */
@media (max-width: 720px) {
  .detail-header {
    grid-template-columns: 1fr;
    row-gap: 12px;
  }
  .detail-header .actions {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .detail-header .actions > * {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}
@media (max-width: 480px) {
  .detail-header .actions > * {
    flex: 1 1 100%;
  }
}

/* ---------- P0-8 · Inputs date/file responsive ---------- */
input[type="date"],
input[type="file"] {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.create-modal .form-grid,
.create-modal-dialog form { min-width: 0; }

/* ---------- P1-2 · Tipografía fluida con clamp() ---------- */
.brand {
  font-size: clamp(14px, 3.6vw, 17px);
  line-height: 1.1;
  white-space: nowrap;
}
.list-header h1 {
  font-size: clamp(22px, 6.5vw, 26px);
  line-height: 1.05;
}
.detail-header .cn {
  font-size: clamp(22px, 7vw, 28px);
  line-height: 1.05;
}
.pulse-num {
  font-size: clamp(28px, 7.5vw, 36px);
}

/* ---------- P1-5 · Touch targets 40x40 mínimo en mobile ---------- */
@media (max-width: 720px) {
  .chip {
    min-height: 36px;
    padding: 7px 12px;
    align-items: center;
  }
  .btn-mini, button.btn-mini {
    min-height: 36px;
    min-width: 36px;
    padding: 6px 10px;
  }
  .logout-btn {
    min-height: 36px;
    padding: 8px 12px;
  }
  .search-box {
    min-height: 40px;
    padding: 6px 10px;
  }
  .btn-ghost,
  .btn-primary {
    min-height: 40px;
  }
}

/* ---------- P1-6 · :focus-visible accesibilidad ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(244, 183, 60, 0.18);
}
/* No quitar el outline:none de algunos inputs específicos, solo agregar focus-visible */

/* ---------- Admin · audit-list (consolidado, era duplicado en health.html) ---------- */
.audit-list { display: flex; flex-direction: column; }
.audit-row {
  display: grid;
  grid-template-columns: 80px 100px 1fr 80px;
  gap: 8px;
  padding: 5px 0;
  font-size: 10px;
  border-top: 1px dashed var(--rule);
  color: var(--fog);
  align-items: center;
}
.audit-row:first-child { border-top: 0; }
.audit-ts { color: var(--fog-dim); letter-spacing: 0.08em; }
.audit-action { color: var(--chart-white); letter-spacing: 0.06em; }
.audit-user { color: var(--fog); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-target { text-align: right; color: var(--fog-dim); }

/* ---------- P1-7 · audit-row + attachment-row responsive ---------- */
@media (max-width: 960px) {
  .audit-row {
    grid-template-columns: 90px 1fr;
    grid-template-areas:
      "ts action"
      "user user"
      "target target";
    gap: 2px 8px;
    padding: 8px 0;
  }
  .audit-ts { grid-area: ts; }
  .audit-action { grid-area: action; }
  .audit-user { grid-area: user; white-space: normal; word-break: break-word; overflow: visible; }
  .audit-target { grid-area: target; text-align: left; color: var(--fog-dim); }
}
@media (max-width: 540px) {
  .audit-row {
    grid-template-columns: 1fr;
    grid-template-areas: "ts" "action" "user" "target";
    gap: 1px;
  }
}

/* ---------- Admin detail-grid modifiers (desktop-only ratios) ---------- */
@media (min-width: 961px) {
  .detail-grid--admin-health { grid-template-columns: 1.6fr 1fr; }
  .detail-grid--admin-users  { grid-template-columns: 1.4fr 1fr; }
}

/* ---------- P1-8 · aside.right scroll independiente del map ---------- */
@media (max-width: 960px) {
  main.overview { grid-template-rows: auto auto; }
  .map-wrap {
    min-height: 320px;
    max-height: 320px;
  }
  aside.right {
    max-height: none;
    overflow-y: visible;
  }
}

/* ---------- Padding lateral mobile (issue transversal #4) ---------- */
@media (max-width: 720px) {
  main.list,
  main.detail,
  main.account,
  main.admin,
  main.overview > aside.right { padding-left: 14px; padding-right: 14px; }
}
main.list { padding: 24px 32px 48px; } /* fallback ya existente, mobile lo pisa */

/* ---------- Cn-table: scroll horizontal contenedor + click feedback ---------- */
@media (max-width: 720px) {
  main.list { overflow-x: hidden; }
}
.cn-table tbody tr.cn-row:active { background: rgba(244, 183, 60, 0.08); }

/* ---------- Filter-bar: search full-width en mobile (P2-1) ---------- */
@media (max-width: 540px) {
  .filter-bar { gap: 8px; }
  .filter-bar .search-box {
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }
}

/* ---------- Bloque admin: padding ---------- */
main.admin { padding: 24px 32px 48px; }
@media (max-width: 720px) {
  main.admin { padding: 18px 14px 36px; }
}

/* ---------- P2-3 · cn-table como cards en <540px ---------- */
@media (max-width: 540px) {
  main.list .table-scroll { overflow-x: visible; }
  .cn-table {
    display: block;
    background: transparent;
    border: none;
  }
  .cn-table thead { display: none; }
  .cn-table tbody { display: block; }
  .cn-table tbody tr.cn-row {
    display: block;
    margin: 0 0 12px;
    padding: 14px 16px;
    border: 1px solid var(--rule);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
  }
  .cn-table tbody tr.cn-row:hover td,
  .cn-table tbody tr.cn-row:active { background: transparent; }
  .cn-table tbody tr.cn-row:active { box-shadow: 0 0 0 2px rgba(244, 183, 60, 0.28) inset; }
  .cn-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
    border: none !important;
    background: transparent !important;
    text-align: right;
    font-size: 12px;
  }
  .cn-table tbody td::before {
    content: attr(data-label);
    color: var(--fog);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    flex-shrink: 0;
    align-self: center;
  }
  /* Re-mostrar columnas escondidas por los media queries 720/650/etc. */
  .cn-table tbody .col-cliente,
  .cn-table tbody .col-pol,
  .cn-table tbody .col-pod,
  .cn-table tbody .col-terminal,
  .cn-table tbody .col-vessel,
  .cn-table tbody .col-eta { display: flex; }
  /* col-cn como encabezado del card: sin label, container number grande */
  .cn-table tbody .col-cn {
    border-bottom: 1px dashed var(--rule) !important;
    padding-bottom: 10px;
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--chart-white);
    justify-content: flex-start;
    text-align: left;
  }
  .cn-table tbody .col-cn::before { content: ""; margin: 0; }
  .cn-table tbody .col-vessel {
    text-align: right;
    flex-wrap: wrap;
  }
  .cn-table tbody .col-vessel br { display: none; }
  .cn-table tbody .col-vessel .vessel-carrier {
    margin-left: 6px;
    font-size: 10px;
  }
  .cn-table tbody .col-status {
    border-top: 1px dashed var(--rule) !important;
    padding-top: 10px;
    margin-top: 4px;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .cn-table tbody .col-status::before { content: ""; margin: 0; }
}
