:root {
  --brand: #1f4a8a;
  --brand-dark: #163764;
  --opt: #1f6fd1;
  --ref: #d9363e;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5d6878;
  --line: #dfe4ec;
  --good: #1d7a46;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;  /* a name of 80 letters without spaces does not widen the page */
}

h1 { font-size: 1.35rem; margin: 0 0 .75rem; color: var(--brand-dark); }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; color: var(--brand-dark); }
h3 { font-size: .9rem; margin: 0 0 .4rem; color: var(--muted); font-weight: 600; }

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 2000;  /* over the map controls (Leaflet uses up to 1000) */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  padding: .5rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
/* over a map the bar scrolls away: sticky, it would cover the zoom and the layers of the map */
body[data-view=voyage] .topbar, body[data-view=port] .topbar { position: static; }
.logo { height: 34px; width: auto; }
.topbar-actions { display: flex; gap: .25rem; margin-left: auto; align-items: center; }

main { padding: 1rem; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); margin-bottom: .75rem; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .75rem; }
fieldset label { flex-direction: row; align-items: center; gap: .4rem; margin: .2rem 0; }
details > summary { cursor: pointer; color: var(--brand); font-weight: 600; margin: .25rem 0 .75rem; }

/* grid columns minmax(0, ...): a wide content (a table) scrolls in its card instead of widening the page */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: span 2; }
}

.btn {
  font: inherit;
  padding: .5rem .9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--brand);
  cursor: pointer;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-ghost { border-color: transparent; }
.btn-icon { width: 2.4rem; padding: .4rem; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }

.error { color: #b42318; min-height: 1em; margin: .25rem 0; }
p.ok { color: var(--good); margin: .25rem 0; }  /* the messages, not the cards or badges of class ok */
.topbar .btn { padding: .45rem .6rem; }
.hint, .muted { color: var(--muted); }
.small { font-size: .8rem; }

.spinner {
  width: 36px; height: 36px; margin: .5rem auto 1rem;
  border: 4px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.voyage-head { margin-bottom: .75rem; }
.voyage-head h1 { margin-bottom: .2rem; }
.voyage-head p { margin: 0; }

.savings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.saving {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .9rem;
}
.saving .value { font-size: 1.5rem; font-weight: 700; color: var(--good); line-height: 1.2; }
.saving .value.neg { color: #b42318; }
.saving .value.zero { color: var(--brand-dark); }
.saving .label { font-size: .8rem; color: var(--muted); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
}

.map-panel { padding: 0; overflow: hidden; }
#map { height: 62vh; min-height: 320px; background: #1b1f27; }
.timeline { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-top: 1px solid var(--line); }
.timeline input[type=range] { flex: 1; min-width: 0; padding: 0; }
.time-label { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .85rem; }
.map-controls { padding: 0 .8rem .6rem; }
.layer-choice { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.layer-choice label { flex-direction: row; align-items: center; gap: .3rem; margin: .2rem 0; color: var(--text); }
.legend { margin-top: .4rem; font-size: .75rem; color: var(--muted); }
.legend .bar { height: 10px; border-radius: 3px; }
.legend .ticks { display: flex; justify-content: space-between; }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; }
.kpi td:first-child { color: var(--muted); white-space: normal; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .3rem; vertical-align: baseline; }
.dot.opt { background: var(--opt); }
.dot.ref { background: var(--ref); }
/* warnings of the limits of the ship and of rolling (renderSafety) */
.safety-route { margin: .6rem 0 .3rem; color: var(--text); }
.safety { margin: 0 0 .5rem; padding-left: 1.1rem; font-size: .85rem; }
.safety li { margin-bottom: .45rem; overflow-wrap: anywhere; }
/* the highest waves and wind of the voyage (renderWorst) */
.worst { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.worst-item { background: var(--bg); border-radius: 8px; padding: .6rem .75rem; overflow-wrap: anywhere; }
.worst-item .label { font-size: .8rem; color: var(--muted); }
.worst-item .value { font-size: 1.35rem; font-weight: 700; color: var(--brand-dark); line-height: 1.25; margin-bottom: .15rem; }
.worst-item .value.over { color: #b42318; }
.worst-item .badge { display: inline-block; margin-top: .3rem; }
.worst-card .muted.small { margin: .6rem 0 0; }
/* the zone form: vertices by taps on the map or typed */
.zone-tools { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .75rem; }
textarea { resize: vertical; font-variant-numeric: tabular-nums; }
label.check { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); }

.section-title { margin-top: .5rem; }
.charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1rem; }
@media (min-width: 900px) { .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: 1rem; }
.chart-box { position: relative; height: 210px; }

.disclaimer { text-align: center; margin: 1.5rem 0 2rem; }

/* home: dashboard of the voyages */
#logo-link { display: flex; }
.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
}
.hero > div { min-width: 0; }
.hero h1 { color: #fff; margin-bottom: .3rem; }
.hero p { margin: 0; max-width: 46rem; color: #dbe5f5; }
.btn-cta {
  background: #fff;
  color: var(--brand-dark);
  border: none;
  font-weight: 700;
  font-size: 1.05rem;
  padding: .8rem 1.3rem;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
@media (max-width: 640px) { .btn-cta { width: 100%; } }
.saving .value.plain { color: var(--brand-dark); }

.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin: .5rem 0 .6rem; }
.list-head h2 { margin: 0; }
.trips { display: grid; grid-template-columns: minmax(0, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 700px) { .trips { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .trips { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.trip {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  cursor: pointer;
}
.trip:hover, .trip:focus-visible { border-color: var(--brand); box-shadow: 0 2px 10px rgba(31, 74, 138, .12); }
.trip-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.trip-top .muted { margin-left: auto; }
.trip-route { font-weight: 700; color: var(--brand-dark); margin-bottom: .1rem; }
.trip-metrics { display: flex; gap: 1.2rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.trip-metrics div { display: flex; flex-direction: column; }
.trip-metrics b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.trip-metrics b.good { color: var(--good); }
.trip-metrics b.neg { color: #b42318; }
.trip-metrics span { font-size: .75rem; color: var(--muted); }
.trip-error { color: #b42318; font-size: .85rem; margin: .5rem 0 0; }
.badge { font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; }
.badge.ok { background: #e3f4ea; color: var(--good); }
.badge.bad { background: #fde8e7; color: #b42318; }
.badge.busy { background: #e6eefb; color: var(--brand); }
.badge.next { background: #fff4d6; color: #8a5a00; }
.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: .25rem 0 .5rem; }
.progress-bar { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .6s ease; }
.progress.thin { height: 5px; margin: .6rem 0 .2rem; }
#status-view h1, #status-view #status-detail { text-align: center; }
.validation { border-left: 4px solid var(--brand); }
.validation p { margin: .3rem 0; }
.link-btn { background: none; border: none; color: var(--brand); font: inherit; padding: 0; margin-bottom: .5rem; cursor: pointer; }

/* ships of the user */
.btn-small { padding: .3rem .7rem; font-size: .85rem; }
.btn-danger { color: #b42318; border-color: #f1c4c0; }
.actions .spacer { flex: 1; }
.flash { background: #e3f4ea; color: var(--good); border-radius: var(--radius); padding: .6rem .9rem; margin: 0 0 1rem; font-weight: 600; }
.ship-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.ship-actions { display: flex; align-items: center; gap: .4rem; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.ship-actions .muted { margin-left: auto; }
.ship-group { margin: 0 0 1rem; padding: .6rem .8rem .2rem; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.ship-group label { flex-direction: column; align-items: stretch; gap: .25rem; margin: 0 0 .75rem; }
.ship-group > legend { color: var(--brand-dark); font-weight: 700; padding: 0 .3rem; }
details.ship-group > summary { margin: .1rem 0 .6rem; }
.ship-group .hint { margin: -.3rem 0 .6rem; }
label small { color: var(--muted); font-size: .75rem; }
.field-link { margin-bottom: .75rem; }
.field-link label { margin-bottom: .15rem; }
.field-link .link-btn { margin: 0; }
.field-link small { display: block; margin: -.05rem 0 .1rem; font-size: .75rem; }
.port-map { height: 300px; border-radius: 8px; border: 1px solid var(--line); margin: .25rem 0 .4rem; background: #1b1f27; }
.port-check { min-height: 1.2em; margin: 0 0 .75rem; }
.port-check.ok { color: var(--good); }
.port-check.bad { color: #b42318; }
.with-btn { display: flex; gap: .4rem; min-width: 0; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn .btn { flex: none; }
.ship-estimate { margin: -.3rem 0 .6rem; }
#ship-lookup.ok { color: var(--good); }
#ship-lookup.bad, .ship-estimate.bad { color: #b42318; }
.ship-estimate { color: var(--brand-dark); }
.ship-estimate:empty { display: none; }
.onboarding { border-left: 4px solid var(--brand); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: .25rem 0 1rem; display: grid; gap: .7rem; }
@media (min-width: 800px) { .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.steps li { counter-increment: step; position: relative; padding-left: 2.6rem; color: var(--muted); }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; background: var(--line); color: var(--muted);
}
.steps li b { display: block; color: var(--text); }
.steps li span { font-size: .85rem; }
.steps li.current::before { background: var(--brand); color: #fff; }
.steps li.done::before { content: '✓'; background: var(--good); color: #fff; }
.steps li.done b { color: var(--good); }

.leaflet-container { font: inherit; }
.leaflet-bar a.map-fit { display: flex; align-items: center; justify-content: center; color: #333; }

/* voyage watch (watch.js): panel of the voyage, alerts of the dashboard, e-mail in Cuenta */
.badge.warn { background: #fff4d6; color: #8a5a00; }
.badge.plain { background: var(--line); color: var(--muted); }
.watch-panel { border-left: 4px solid #e08a00; }
.watch-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .5rem; }
.watch-head h2 { margin: 0; }
.watch-status { margin: 0 0 .4rem; }
.watch-facts { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem 1.2rem; margin: .6rem 0 .8rem; }
@media (min-width: 700px) { .watch-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.watch-facts div { min-width: 0; }
.watch-facts dt { font-size: .75rem; color: var(--muted); }
.watch-facts dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.watch-actions { justify-content: flex-start; }
.watch-actions .muted { align-self: center; }
.watch-form { border-top: 1px solid var(--line); margin-top: .6rem; padding-top: .6rem; }
.watch-form h3 { color: var(--brand-dark); }
.watch-more { margin-top: .6rem; }
.watch-more > summary { margin-bottom: .4rem; }
.watch-history { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.watch-entry { border-top: 1px solid var(--line); padding-top: .45rem; min-width: 0; overflow-wrap: anywhere; }
.watch-entry .link-btn { margin: .2rem 0 0; }
.watch-lines { margin: .3rem 0 .6rem; padding-left: 1.1rem; overflow-wrap: anywhere; }
.watch-lines li { margin-bottom: .2rem; }
.watch-home { border-left: 4px solid #e08a00; }
.watch-home h2 { display: flex; align-items: center; gap: .5rem; }
.watch-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .7rem; }
.watch-chip {
  display: inline-flex; flex-direction: column; align-items: flex-start; max-width: 100%;
  font: inherit; font-size: .85rem; text-align: left; color: var(--brand-dark); cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .6rem; overflow-wrap: anywhere;
}
.watch-chip small { color: var(--muted); font-size: .72rem; }
.watch-chip:hover, .watch-chip:focus-visible { border-color: var(--brand); }
.alerts { display: grid; grid-template-columns: minmax(0, 1fr); gap: .6rem; }
@media (min-width: 900px) { .alerts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.alert-item {
  min-width: 0; background: var(--card); border: 1px solid var(--line); border-left: 4px solid #e0a800;
  border-radius: var(--radius); padding: .7rem .9rem;
}
.alert-item.alerta { border-left-color: #b42318; }
.alert-item.unread { box-shadow: 0 2px 10px rgba(31, 74, 138, .14); }
.alert-item .trip-route { overflow-wrap: anywhere; }
.alert-title { font-weight: 600; margin: .15rem 0 .2rem; overflow-wrap: anywhere; }
.alert-more > summary { margin: .2rem 0 .3rem; }
.alert-more p { margin: .2rem 0; overflow-wrap: anywhere; }
.alert-item .ship-actions { flex-wrap: wrap; }
.account-section { border-top: 1px solid var(--line); margin-top: 1.2rem; padding-top: 1rem; }

/* planning (planning.js): modes of the voyage form, comparison of departures, panel over the results */
.modes { display: grid; grid-template-columns: minmax(0, 1fr); gap: .4rem; padding: .3rem .6rem .6rem; margin: 0 0 1rem; min-width: 0; }
@media (min-width: 640px) { .modes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.modes legend { color: var(--brand-dark); font-weight: 700; padding: 0 .3rem; }
.modes label.mode { flex-direction: row; align-items: flex-start; gap: .5rem; margin: 0; padding: .55rem .6rem;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--text); }
.modes label.mode:has(input:checked) { border-color: var(--brand); background: #eef4fd; }
.modes label.mode input { flex: none; margin: .15rem 0 0; padding: 0; }
.modes label.mode span { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.modes label.mode b { color: var(--brand-dark); font-size: .9rem; }
.modes label.mode small { color: var(--muted); font-size: .78rem; }
.plan-info { margin: -.35rem 0 .75rem; color: var(--brand-dark); }
.plan-info.bad { color: #b42318; }
/* a voyage longer than its forecast: the question of the form and the note of the results */
.beyond { border-left: 4px solid #c27c00; background: #fffaf0; padding: .7rem .9rem; border-radius: 8px; margin: .25rem 0 .75rem; }
.beyond p { margin: 0 0 .6rem; overflow-wrap: anywhere; }
.beyond p:last-child { margin-bottom: 0; }
.card.beyond { margin-bottom: 1rem; }
.badge.plan { background: #eef4fd; color: var(--brand-dark); }
.plan-panel { border-left: 4px solid var(--brand); }
.plan-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .4rem; }
.plan-head h2 { margin: 0; }
.plan-message { margin: 0 0 .75rem; font-size: 1rem; }
.plan-panel .savings { margin-bottom: .5rem; }
.plan-panel .saving { background: var(--bg); border-color: transparent; }
.plan-panel .muted { margin: 0; }
.plan-key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: -.4rem 0 1rem; }
.plan-key .key { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.plan-key .key.rec { background: var(--opt); }
.plan-key .key.over { background: #b42318; }
.plan-key .key.other { background: #8794a8; }
.plan-key .key.limit { width: 1.2rem; height: 0; border-top: 2px dashed var(--text); border-radius: 0; vertical-align: 3px; }
.plan-table th { white-space: normal; vertical-align: bottom; }
.plan-table td .badge { display: table; margin-top: .2rem; }
.plan-table tr.rec td { background: #eef4fd; }
.plan-table td.over { color: #b42318; font-weight: 600; }
.plan-table td.plan-error { color: #b42318; text-align: left; white-space: normal; min-width: 14rem; }
.plan-table .link-btn { margin: 0; font-weight: 600; }
/* add-on: hull and engine performance from the noon reports (performance.js) */
.ship-actions { flex-wrap: wrap; }  /* the buttons of the add-ons wrap on a phone */
.pf-sub { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.pf-advice { border-left: 4px solid var(--line); }
.pf-advice.clean { border-left-color: #b42318; background: #fff7f6; }
.pf-advice.watch { border-left-color: #c27c00; background: #fffaf0; }
.pf-advice.ok { border-left-color: var(--good); }
.pf-chart { height: 280px; }
.pf-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .4rem; }
.pf-actions a.btn { text-decoration: none; }
.pf-table td { vertical-align: top; font-variant-numeric: tabular-nums; }
.pf-table td.pf-status { text-align: left; white-space: normal; min-width: 13rem; }
.pf-table .pf-reason { color: var(--muted); font-size: .8rem; }
.pf-table .badge { display: inline-block; margin-top: .15rem; }
.pf-table .link-btn { margin: 0; text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pf-upload { border-radius: 8px; padding: .5rem .75rem; margin: .25rem 0 .75rem; background: #e6eefb; font-size: .9rem; }
.pf-upload p { margin: .2rem 0; }
.pf-upload.ok { background: #e3f4ea; color: var(--good); }
.pf-upload.warn { background: #fffaf0; }
.pf-upload.bad { background: #fde8e7; color: #b42318; }
.pf-errors { margin: .3rem 0; padding-left: 1.2rem; max-height: 14rem; overflow-y: auto; font-size: .85rem; }

/* a phone: iOS zooms in on fields under 16 px, and a finger needs targets of 40 px */
@media (pointer: coarse), (max-width: 640px) {
  input, select, textarea { font-size: 16px; }
  .btn, .link-btn, #logo-link { min-height: 40px; }
  .link-btn { display: inline-flex; align-items: center; }
  details > summary { padding: .6rem 0; }
}
@media (max-width: 640px) {
  /* the reason a departure failed spans the table, wider than the phone: its lines fit what is seen
     of it next to the first column (a percentage of the table) */
  .plan-table td.plan-error { min-width: 0; padding-right: calc(100% - 21rem); }
}
