:root {
  --bg: #eef4f6;
  --card: #fff;
  --ink: #14303a;
  --muted: #5b7380;
  --line: #d4e0e5;
  --accent: #1a5f7a;
  --ok: #1b7a4a;
  --todo: #a15c12;
  --danger: #b42318;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
}

.top {
  background: #123844;
  color: #fff;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 0.02em; line-height: 1.15; }
.brand a { color: #fff; text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.2rem 0.65rem; line-height: 1.2; font-size: 0.92rem; }
.who { color: #fff; font-size: 0.92rem; }
.top nav a { color: #d5e8ef; text-decoration: none; }
.top nav a:hover { color: #fff; }
.view-only {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #2a5563;
  color: #d5e8ef;
}

.wrap { padding: 1rem; max-width: 860px; margin: 0 auto 3rem; }

h1 { font-size: 1.45rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.6rem; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.page-head > * { min-width: 0; }
.page-head .muted { margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

form { display: grid; gap: 0.7rem; }
label { display: grid; gap: 0.3rem; font-size: 0.92rem; color: var(--muted); }
.field-hint { font-size: 0.8rem; color: var(--muted); }
.setting-flag { display: grid; gap: 0.3rem; }
.setting-flag .field-hint { padding-left: 1.5rem; }
input, select, textarea {
  font: inherit;
  padding: 0.7rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
}
.check-row input { width: auto; }

.btn, button, input[type=submit] {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  border: 0;
  border-radius: 8px;
  padding: 0.38rem 0.7rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  width: fit-content;
  max-width: 100%;
}
.btn.secondary, button.secondary { background: #5b7380; }
.btn.danger { background: var(--danger); }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; max-width: 100%; }
.toolbar { margin-bottom: 0.75rem; }

.trip, .leg {
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.leg {
  scroll-margin-top: 4.5rem;
}
.leg.is-complete {
  background: #eef8f2;
  border-color: #9dceb0;
}
.leg.is-todo {
  background: #fff8ee;
  border-color: #e4c48a;
}
.leg.has-actions {
  box-shadow: 0 0 0 2px rgba(201, 162, 12, 0.55);
}
.action-callout {
  margin-top: 0.55rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: #fff3bf;
  border: 1px solid #e6c229;
}
.action-callout-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b5200;
}
.action-callout .prose { margin-top: 0.25rem; }
.action-callout .complete-toggle { margin-top: 0.45rem; }
.card > .action-callout:first-child { margin-top: 0; }
.action-summary { scroll-margin-top: 4.5rem; }
#trip-overview { scroll-margin-top: 4.5rem; }
.action-summary.has-open-actions {
  background: #fff8ee;
  border-color: #e6c229;
  box-shadow: 0 0 0 2px rgba(201, 162, 12, 0.55);
}
.action-summary.all-closed {
  background: #eef8f2;
  border-color: #9dceb0;
}
.action-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.action-summary-head h2 { margin: 0; }
.action-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.action-summary-list li {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.action-summary-list li.is-open {
  background: #fff3bf;
  border-color: #e6c229;
}
.action-summary-list li.is-closed {
  background: #f4faf6;
  border-color: #9dceb0;
}
.action-summary-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-top: 0.4rem;
}
.action-summary-where {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.action-summary-where:hover { text-decoration: underline; }
.trip-block { margin-top: 0.55rem; }
.trip-block:first-child { margin-top: 0; }
.trip-block-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.trip-block .prose { margin-top: 0.25rem; }
.trip-details-edit {
  margin-top: 0.75rem;
}
.trip-details-edit summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}
.trip-details-edit[open] summary {
  margin-bottom: 0.7rem;
}
.trip-files-split {
  border-top: 1px solid var(--line);
  margin-top: 1rem;
  padding-top: 1rem;
}
.trip-files-split h3 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}
.day-leg.has-actions {
  box-shadow: inset 3px 0 0 #e6c229;
}
.leg:target {
  box-shadow: 0 0 0 2px rgba(26, 95, 122, 0.35);
}
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.status-pill.is-complete { background: #d8f0e2; color: var(--ok); }
.status-pill.is-todo { background: #f8e4c4; color: var(--todo); }
.status-pill.is-action { background: #ffe566; color: #6b5200; }
.complete-toggle { display: inline-flex; align-items: center; }
.complete-check { margin: 0; }
.complete-check span { font-size: 0.88rem; }
.trip .when, .leg .meta, .muted { color: var(--muted); }
.trip .route, .leg .route { font-weight: 700; font-size: 1.05rem; }
.trip .meta { font-size: 0.9rem; }

.day {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  scroll-margin-top: 4.5rem;
}

.day-card { scroll-margin-top: 4.5rem; }
.day-card.has-todo { border-color: #e4c48a; }
.day-card.is-complete { border-color: #9dceb0; background: #f4faf6; }
.day-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.day-card-head h2 { margin: 0; font-size: 1.25rem; }
.day-date { margin: 0.15rem 0 0; color: var(--muted); }
.day-spotlight {
  display: grid;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 0.5rem;
}
.day-card.has-todo .day-spotlight {
  background: #fff8ee;
  border-color: #e4c48a;
}
.day-card.is-complete .day-spotlight {
  background: #eef8f2;
  border-color: #9dceb0;
}
.day-spotlight .muted { margin: 0; }
.day-spotlight .route { margin: 0; }
.day-spotlight .btn { justify-self: start; margin-top: 0.25rem; }
.day-leg {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.day-leg > a {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.55rem;
  color: inherit;
  text-decoration: none;
}
.day-leg .time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 2.6rem;
}
.day-leg.is-next {
  background: #fff4e0;
  margin: 0 -1rem;
  padding: 0.7rem 1rem;
}
.day-leg.is-complete .route { color: var(--ok); }
.day-leg.is-todo .route { color: var(--todo); }

.leg-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.7rem;
  margin-bottom: 0.25rem;
}
.type {
  background: #123844;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
}
.hm, .wait { font-size: 0.85rem; color: var(--muted); }
.wait { margin-left: auto; }
.leg-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.7rem; max-width: 100%; }
.inline-form { display: inline; }
.inline-form.complete-toggle { display: inline-flex; align-items: center; }
.inline-form button { width: auto; }
.linkish {
  background: none;
  color: var(--danger);
  padding: 0;
  font-size: 0.8rem;
}

.prose { margin: 0.4rem 0 0; font-size: 0.92rem; }
.prose a { color: var(--accent); }
.private-note {
  background: #f3ead2;
  box-shadow: inset 0 0 0 1px #e4d3a4;
  border-radius: 4px;
  padding: 0.05em 0.28em;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.7rem 0;
}
.thumb {
  margin: 0;
  width: 7.5rem;
}
.thumb img {
  width: 7.5rem;
  height: 7.5rem;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f3f7f8;
}
.thumb figcaption { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }
.thumb .pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f3f7f8;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.4rem;
  text-align: center;
}

.paste-zone {
  margin: 0 0 0.5rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f3f7f8;
  color: var(--muted);
  font-size: 0.92rem;
  cursor: pointer;
  outline: none;
}
.paste-zone:focus {
  border-color: var(--accent);
  color: var(--ink);
}

.flash { background: #e8f6ee; color: var(--ok); padding: 0.7rem 0.8rem; border-radius: 10px; }
.error { background: #fdecec; color: var(--danger); padding: 0.7rem 0.8rem; border-radius: 10px; }

.offline-banner {
  background: #e8f0f4;
  color: var(--ink);
  padding: 0.65rem 1rem;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--line);
}
.offline-banner.is-warn {
  background: #fff4e0;
  color: #7a4a10;
}
.offline-banner.is-ok {
  background: #e8f6ee;
  color: var(--ok);
}
.offline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 56, 68, 0.55);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.offline-overlay[hidden] { display: none; }
.offline-modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 1.15rem 1.2rem 1.3rem;
  box-shadow: 0 12px 40px rgba(18, 56, 68, 0.25);
}
.offline-modal h2 { margin: 0 0 0.5rem; }
.offline-status { margin: 0 0 0.85rem; color: var(--muted); min-height: 2.6em; }
.offline-count { margin: 0.55rem 0 0; font-size: 0.88rem; color: var(--muted); }
.progress-track {
  height: 0.7rem;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}
body.is-offline .top nav a[href="/logout.php"] {
  display: none;
}
body.is-offline .hide-offline,
body.is-offline .leg-actions,
body.is-offline .js-upload-form,
body.is-offline .js-trip-details-form,
body.is-offline .toolbar,
body.is-offline .paste-zone,
body.is-offline .thumb .inline-form,
body.is-guest .hide-readonly,
body.is-guest .leg-actions,
body.is-guest .js-upload-form,
body.is-guest .js-trip-details-form,
body.is-guest .toolbar,
body.is-guest .paste-zone,
body.is-guest .thumb .inline-form {
  display: none !important;
}

.cost-sheet { padding: 0; overflow: hidden; }
.cost-scroll { overflow-x: auto; }
.cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.cost-table th,
.cost-table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.cost-table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f7fbfc;
}
.cost-table th.num,
.cost-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cost-table tbody tr:last-child td { border-bottom: 0; }
.cost-table a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
.cost-table a:hover { color: var(--accent); text-decoration: underline; }
.cost-table tfoot td {
  font-weight: 700;
  background: #f7fbfc;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.cost-note { margin-top: 0; }

.login-wrap { max-width: 460px; margin: 0.6rem auto; }
.login-card { width: 100%; padding: 0.65rem 0.75rem; margin-bottom: 0.45rem; }
.login-card h1 { font-size: 1.25rem; margin: 0; line-height: 1.2; }
.login-card p { margin: 0.15rem 0; }
.login-card form { gap: 0.4rem; margin-top: 0.35rem; }
.login-card label { gap: 0.15rem; line-height: 1.3; }
.login-card input {
  padding: 0.45rem 0.6rem;
  background: #fff;
  width: 100%;
}
.login-form input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  box-shadow: 0 0 0 1000px #fff inset;
  -webkit-text-fill-color: var(--ink);
}
.login-form.is-ready input,
.login-form.is-ready input:-webkit-autofill {
  background: #fff8c5;
  -webkit-box-shadow: 0 0 0 1000px #fff8c5 inset;
  box-shadow: 0 0 0 1000px #fff8c5 inset;
}
.password-line { display: flex; gap: 0.5rem; align-items: stretch; }
.password-line input { flex: 1; min-width: 0; width: auto; }
.password-line button {
  flex: 0 0 auto;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: auto;
  padding: 0 0.7rem;
  border-radius: 10px;
}
.login-form > button[type="submit"] {
  width: 100%;
  max-width: none;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.3;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  background: #1c7a40;
}

@media (max-width: 520px) {
  .row2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; gap: 0.65rem; }
  .wait { margin-left: 0; }
  .btn, button, input[type=submit] {
    font-size: 0.78rem;
    padding: 0.28rem 0.5rem;
    border-radius: 7px;
  }
  .actions { gap: 0.3rem; }
  .page-head .actions { width: 100%; }
  .leg-actions { gap: 0.28rem; margin-top: 0.5rem; }
  .linkish { font-size: 0.75rem; }
  .cost-table thead { display: none; }
  .cost-table,
  .cost-table tbody,
  .cost-table tfoot,
  .cost-table tr,
  .cost-table td { display: block; width: auto; }
  .cost-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.45rem 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--line);
  }
  .cost-table td {
    border: 0;
    padding: 0;
    text-align: left;
    white-space: normal;
  }
  .cost-table td.num { text-align: left; }
  .cost-table td.span-all { grid-column: 1 / -1; }
  .cost-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.1rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .cost-table tfoot td.span-all { display: none; }
  .cost-table tfoot td.num { grid-column: 1 / -1; }
  .cost-table tfoot tr { background: #f7fbfc; }
  .cost-table tfoot td { border-top: 0; }
}

.person {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}
.person:first-of-type { border-top: 0; padding-top: 0; }
.person-tools { flex: 1 1 16rem; max-width: 22rem; }
.person .actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.person .actions form { margin: 0; }
.person-tools form + form { margin-top: 0.45rem; }
@media (max-width: 640px) {
  .person { flex-direction: column; }
}
