:root {
  --navy: #0b3a66;
  --navy-2: #0e4d86;
  --ink: #122033;
  --muted: #5b6b7c;
  --line: #d7e0ea;
  --bg: #f4f7fb;
  --card: #fff;
  --ok: #1b8a4a;
  --warn: #c47b00;
  --alert: #c62828;
  --info: #1565c0;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(11, 58, 102, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #0b1726;
  background: var(--bg);
  line-height: 1.45;
}
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #ffb300; outline-offset: 2px; }
a { color: var(--navy-2); text-decoration: none; }
code { background: #eef3f8; padding: 1px 6px; border-radius: 6px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; }
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 14px; letter-spacing: .02em; }
.brand-text small { font-size: 11px; font-weight: 600; color: #9fd0ff; }
.logo {
  background: #fff;
  color: var(--navy);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  letter-spacing: .04em;
}
.logo.lg { font-size: 18px; padding: 6px 10px; }
.nav { display: flex; gap: 8px; flex: 1; align-items: center; }
.nav a {
  color: #d7e8f8;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 9px;
}
.nav a.is-active { background: #145487; color: #fff; }
.nav-board { background: #0e5a8a; color: #fff !important; }
.nav-assign { background: #c47b00; color: #fff !important; }
.nav-data { background: #1b5e20; color: #fff !important; }
.nav-history { background: #37474f; color: #fff !important; }
.nav-notice { color: #d7e8f8; }
.badge {
  background: #ff5252;
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 12px;
}
.who { text-align: right; font-size: 13px; }
.who small { display: block; opacity: .75; }
.who .link { color: #9fd0ff; margin-left: 8px; }
/* Nút "Thoát" nằm trong form POST (chống CSRF) nhưng vẫn nhìn như link cũ. */
.logout-form { display: inline; margin: 0; }
.logout-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #9fd0ff;
  margin-left: 8px;
  cursor: pointer;
  text-decoration: none;
}
.logout-btn:hover { text-decoration: underline; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.muted { color: var(--muted); margin: 0; }
.kicker { margin: 0; color: var(--navy-2); font-weight: 700; letter-spacing: .02em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.danger { background: var(--alert); color: #fff; border-color: var(--alert); }
.btn.lg { min-height: 48px; padding: 12px 18px; font-size: 16px; width: 100%; }

.flash {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 16px;
  border: 2px solid currentColor;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
  box-shadow: 0 4px 14px rgba(7, 21, 34, .14);
}
.flash.ok { background: #d9f7e5; color: #075b2a; }
.flash.error { background: #ffe1de; color: #8e1b1b; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  color: inherit;
}
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { font-size: 24px; }
.stat.alert { border-color: #f3b4b4; }
.stat.progress { border-color: #f3d39a; }
.stat.done { border-color: #b7e0c5; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input { flex: 1; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.actions { display: flex; gap: 10px; }
.form-card, .panel, .auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 16px; }

.job-list { display: grid; gap: 10px; }
.job-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid #90a4ae;
  border-radius: 12px;
  padding: 14px;
  color: inherit;
  box-shadow: var(--shadow);
}
.job-card.status-scheduled { border-left-color: #1565c0; }
.job-card.status-in_progress { border-left-color: #ef6c00; }
.job-card.status-alert { border-left-color: #c62828; background: #fff6f6; }
.job-card.status-completed { border-left-color: #2e7d32; }
.job-card.awaiting-close {
  background: #fff8e1;
  border-left-color: #f2a900;
  box-shadow: 0 2px 10px rgba(242, 169, 0, 0.25);
}
.job-card.awaiting-close .next { color: #b26a00; }
.job-card.unassigned-attention {
  position: relative;
  overflow: hidden;
  background: #fff3f0;
  border-color: #ff8a65;
  border-left-color: #d84315;
  animation: unassigned-pulse 1.1s ease-in-out infinite;
}
.job-card.unassigned-attention::before {
  content: "CẦN GIAO VIỆC";
  position: absolute;
  top: 8px;
  right: -34px;
  transform: rotate(35deg);
  background: #d84315;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  padding: 4px 34px;
  box-shadow: 0 2px 8px rgba(216, 67, 21, .35);
}
.assignee-missing {
  color: #bf360c;
  font-weight: 900;
}
@keyframes unassigned-pulse {
  0%, 100% { box-shadow: 0 2px 10px rgba(216, 67, 21, .18); transform: translateY(0); }
  50% { box-shadow: 0 0 0 4px rgba(216, 67, 21, .12), 0 10px 28px rgba(216, 67, 21, .32); transform: translateY(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .job-card.unassigned-attention { animation: none; }
}
.approval-row { display: flex; gap: 8px; flex-wrap: wrap; }
.reject-note { color: #c62828; font-weight: 600; }
.job-top, .job-foot, .job-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.job-meta { color: var(--muted); font-size: 13px; margin: 6px 0; }
.job-foot .next { font-weight: 700; color: var(--navy); }
.etc { margin-top: 8px; font-size: 13px; color: var(--warn); }
.etc.hot, .hot { color: var(--alert); font-weight: 700; }

.board-head .kicker { color: #0e5a8a; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.schedule-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
  font-size: 13px;
  color: #33485b;
  font-weight: 700;
}
.schedule-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); min-width: 0; }
.schedule-form .grid-2 { grid-template-columns: minmax(0, 1fr); }
.schedule-form input { min-width: 0; }
.schedule-form .btn { width: 100%; }
.type-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.type-picker legend { font-weight: 800; color: var(--navy); }
.type-picker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.type-picker-col h3 { margin: 0 0 8px; font-size: 13px; color: var(--navy-2); }
.check-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
}
.check-item small { display: none; }
.other-label { display: grid; gap: 6px; }
.work-group {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #f8fbfe;
}
.work-group-title { margin: 0 0 10px; font-size: 16px; color: var(--navy); }
.work-group-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (max-width: 860px) {
  .type-picker-grid { grid-template-columns: 1fr; }
}

.pill {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #eceff1;
}
.pill.scheduled { background: #e3f2fd; color: #0d47a1; }
.pill.in_progress { background: #fff3e0; color: #e65100; }
.pill.alert { background: #ffebee; color: #b71c1c; }
.pill.completed { background: #e8f5e9; color: #1b5e20; }
.pill.lg { font-size: 13px; padding: 6px 12px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr); gap: 14px; }
.detail-grid > .panel:only-child { grid-column: 1 / -1; }
.detail-grid:has(> .panel:only-child) { grid-template-columns: minmax(0, 1fr); }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.progress-heading .progress-title { margin: 0; }
.progress-options { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress-toggle { width: auto; white-space: nowrap; }
.completed-always-option { display: inline-flex; align-items: center; gap: 7px; font-size: .86rem; color: var(--muted); cursor: pointer; }
.completed-always-option input { width: 17px; height: 17px; accent-color: var(--primary); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.timeline:not(.show-completed) .completed-step { display: none; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.step-mark {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: #eceff1; font-weight: 800;
}
.step.done .step-mark { background: #2e7d32; color: #fff; }
.step.now .step-mark { background: var(--navy); color: #fff; }
.step-title { display: flex; gap: 8px; align-items: center; }
.step-title em { font-style: normal; font-size: 11px; background: #e3f2fd; padding: 1px 6px; border-radius: 6px; }
.hint { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }
.stamp { margin: 0; font-size: 13px; color: #2e7d32; }
.step-note {
  margin: 8px 0;
  padding: 9px 11px;
  border-left: 4px solid #9bd3ae;
  border-radius: 8px;
  background: #eef8f2;
  color: #16442b;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.step-note-field {
  display: grid;
  gap: 6px;
  margin: 8px 0 10px;
  color: var(--ink);
  font-weight: 800;
}
.step-note-field textarea {
  min-height: 74px;
  resize: vertical;
  border-color: #b8cad8;
  background: #fff;
}
.step-form { max-width: 420px; }
.active-step-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #b8cad8;
  border-radius: 12px;
  background: #f7fbff;
}
.datetime-action-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.datetime-action-row input { min-width: 0; flex: 1 1 auto; }
.save-time-btn { flex: 0 0 48px; width: 48px !important; min-height: 48px !important; padding: 10px !important; }
.save-time-btn svg { width: 24px; height: 24px; }
.check-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid currentColor;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}
.complete-step-btn {
  gap: 8px;
  box-shadow: 0 4px 12px rgba(11, 58, 102, .18);
}
.etc-collapsed { display: flex; align-items: center; justify-content: space-between; gap: 10px; max-width: 420px; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f4f8fb; }
.etc-current-value { color: var(--ink); font-weight: 800; }
.etc-edit-btn { width: auto; min-height: 40px; padding: 8px 14px; }
.bool-row { display: grid; gap: 8px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.files, .logs, .notice-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.files li, .logs li { border-top: 1px solid var(--line); padding-top: 8px; }
.logs li { display: grid; }
.logs small, .files small { color: var(--muted); }
.notice {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px;
}
.notice.unread { border-color: #90caf9; background: #f3f9ff; }
.notice.alert { border-color: #ef9a9a; background: #fff5f5; }
.notice p { margin: 4px 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.push-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  border-left: 5px solid var(--info);
}
.push-box[hidden] { display: none; }
.push-box h2 { margin: 0 0 4px; font-size: 17px; }
.push-box p { margin: 0; }
.push-box[data-state="subscribed"] { border-left-color: var(--ok); background: #f4fbf6; }
.push-box[data-state="denied"],
.push-box[data-state="disabled"],
.push-box[data-state="unsupported"] { border-left-color: var(--warn); background: #fffaf0; }

.auth { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: min(420px, 100%); }
.auth-head { text-align: center; margin-bottom: 16px; }
.auth-head h1 { margin: 10px 0 4px; font-size: 22px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; }
.data-table.vessel-table { table-layout: fixed; }
.data-table.vessel-table th:nth-child(1),
.data-table.vessel-table td:nth-child(1) { width: 34%; }
.data-table.vessel-table th:nth-child(2),
.data-table.vessel-table td:nth-child(2) { width: 31%; }
.data-table.vessel-table th:nth-child(3),
.data-table.vessel-table td:nth-child(3) { width: 35%; }
.data-list-table { table-layout: fixed; }
.data-list-table .data-cell { vertical-align: top; min-width: 0; overflow-wrap: anywhere; }
.data-list-table .data-display { display: grid; gap: 2px; min-width: 0; }
.data-list-table .data-display strong { color: var(--ink); font-size: 15px; font-weight: 800; }
.data-list-table .data-display span { color: var(--ink); font-size: 14px; line-height: 1.25; }
.data-list-table .data-cell.data-note { color: var(--ink); font-size: 14px; }
.data-list-table .data-actions-cell { vertical-align: top; min-width: 0; }
.data-list-table .data-actions-cell .data-row-content { justify-content: flex-start; }
.data-list-table .data-actions-cell .row-actions { justify-content: flex-start; margin-left: 0; min-width: 0; }
.data-table.ports-table th:nth-child(1),
.data-table.ports-table td:nth-child(1) { width: 34%; }
.data-table.ports-table th:nth-child(2),
.data-table.ports-table td:nth-child(2) { width: 31%; }
.data-table.ports-table th:nth-child(3),
.data-table.ports-table td:nth-child(3) { width: 35%; }
.data-table.clients-table th:nth-child(1),
.data-table.clients-table td:nth-child(1) { width: 34%; }
.data-table.clients-table th:nth-child(2),
.data-table.clients-table td:nth-child(2) { width: 31%; }
.data-table.clients-table th:nth-child(3),
.data-table.clients-table td:nth-child(3) { width: 35%; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  color: var(--ink);
}
.tab.on { background: var(--navy); color: #fff; border-color: var(--navy); }
tr.dim td { opacity: .45; }
.data-table { width: 100%; table-layout: fixed; }
.data-table td { vertical-align: top; min-width: 0; }
.icon-btn {
  width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent; color: var(--navy);
  cursor: pointer; font-size: 19px; line-height: 1;
}
.icon-btn:hover, .icon-btn:focus-visible { background: #eaf3fb; }
.icon-btn.delete { color: var(--alert); }
.icon-btn.delete:hover, .icon-btn.delete:focus-visible { background: #fff0f0; border-color: var(--alert); }
.save-trigger { background: #e8f6ee; color: var(--ok); border-color: #9bd3ae; }
.data-edit-row input:disabled { display: none; }
.data-value { display: block; min-height: 32px; padding: 5px 0; }
.data-edit-row.editing .data-value { display: none; }
.data-edit-row input:not(:disabled) { display: block; }
.edit-trigger .save-icon { display: none; }
.edit-trigger.is-saving .edit-icon { display: none; }
.edit-trigger.is-saving .save-icon { display: inline; }
.people-list { display: grid; gap: 10px; }
.person-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); background: transparent; }
.person-summary { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(130px, 1fr) minmax(130px, 1fr) auto; align-items: center; gap: 14px 22px; min-width: 0; flex: 1; }
.person-field { display: grid; gap: 4px; min-width: 0; }
.person-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; line-height: 1.1; text-transform: uppercase; }
.person-field-value, .person-display-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-display-name { color: var(--ink); font-size: 16px; }
.person-field-value { color: var(--ink); font-size: 14px; }
.person-role { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 4px 9px; border: 1px solid #c9dbea; border-radius: 999px; background: #eef6fc; color: var(--navy); font-size: 12px; font-weight: 800; white-space: nowrap; }
.person-card small { display: block; color: var(--muted); margin-top: 3px; }
.data-item { display: grid; gap: 8px; padding: 4px 0; }
.data-row-content { display: flex; justify-content: flex-end; align-items: center; }
.data-row-content .row-actions { margin-left: auto; }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-heading h2 { margin-bottom: 0; }
.add-trigger { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--navy); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; }
.add-trigger:hover, .add-trigger:focus-visible { background: var(--navy-2); }
.data-modal[hidden] { display: none; }
.data-modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(11, 23, 38, .58); backdrop-filter: blur(4px); }
.data-modal-card { position: relative; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 30px; border: 1px solid rgba(255,255,255,.55); border-radius: 18px; background: var(--card); box-shadow: 0 24px 70px rgba(11, 23, 38, .32); }
.data-table .data-item { width: 100%; }
.edit-modal .data-modal-card { width: min(620px, 100%); }
.edit-modal form,
.edit-modal .person-info,
.edit-modal .data-edit-row { display: grid !important; visibility: visible !important; opacity: 1 !important; }
.edit-modal .person-info { grid-template-columns: 1fr !important; gap: 14px !important; }
.edit-modal .data-edit-row { grid-template-columns: 1fr !important; gap: 14px !important; margin: 0 !important; }
.edit-modal input,
.edit-modal select,
.edit-modal textarea { display: block !important; visibility: visible !important; width: 100%; min-height: 44px; opacity: 1 !important; }
.edit-modal .data-value { display: none !important; }
.edit-modal-title { margin: 0 36px 5px 0; color: var(--navy); font-size: 24px; }
.edit-modal-subtitle { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.edit-modal form { display: grid; gap: 14px; }
.edit-modal form label { display: grid; gap: 6px; color: var(--ink); font-weight: 700; }
.edit-modal form input { width: 100%; min-height: 44px; }
.edit-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.edit-modal-actions .btn { min-width: 120px; min-height: 44px; }
.edit-save { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.edit-cancel { background: #f1f4f6; color: var(--ink); }
.modal-close { position: absolute; top: 14px; right: 16px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f1f4f6; color: var(--muted); cursor: pointer; font-size: 26px; line-height: 1; }
.modal-close:hover, .modal-close:focus-visible { background: #e2ebf2; color: var(--navy); }
.person-info { display: grid; grid-template-columns: minmax(160px, 1fr) auto; gap: 4px 10px; align-items: center; flex: 1; }
.person-info input:disabled { display: none; }
.person-value { display: block; }
.person-info.editing .person-value { display: none; }
.person-info input:not(:disabled) { display: block; }
.person-info input { padding: 7px 9px; }
.person-info small { color: var(--muted); }
.data-status { margin-left: 2px; white-space: nowrap; }
.data-row .data-row-content { display: flex; justify-content: flex-end; align-items: center; }
.data-row .data-row-content .row-actions { margin-left: auto; }
.vessel-data-row { width: 100%; min-width: 0; }
.vessel-cell,
.vessel-actions-cell { min-width: 0; }
.vessel-actions-cell .data-row-content { justify-content: flex-start; }
.vessel-display { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.vessel-display strong { color: var(--ink); font-size: 16px; font-weight: 800; }
.vessel-display span { color: var(--ink); font-size: 14px; line-height: 1.25; font-weight: 400; }
.vessel-display span b { font-weight: 800; }
.vessel-note { min-width: 0; color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.vessel-data-row > .data-edit-row { grid-column: 1 / -1; }
.vessel-data-row .data-row-content .row-actions {
  justify-content: flex-start;
  margin-left: 0;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: visible;
}
.vessel-data-row .data-status { flex: 0 0 auto; }
.data-edit-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.edit-modal .data-edit-row label { display: grid; gap: 6px; color: var(--ink); font-weight: 700; }
.edit-modal .data-edit-row input { width: 100%; min-height: 44px; }
.data-edit-row.ports { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
@media (max-width: 860px) {
  .data-table.vessel-table { min-width: 760px; }
  .vessel-actions-cell .row-actions { flex-wrap: nowrap; }
}
@media (max-width: 600px) {
  .data-table.vessel-table { min-width: 760px; }
}
.data-status { margin-left: 4px; }
.vessel-data-row .data-status { white-space: nowrap; }
.row-actions form { margin: 0; }

.step-photos { margin-top: 10px; }
.photo-form { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
.photo-form form { flex: 0 0 auto; margin: 0; }
.photo-form .btn { position: relative; overflow: hidden; font-size: 13px; padding: 8px 12px; }
.photo-icon-btn {
  width: 48px;
  height: 44px;
  padding: 8px !important;
  display: inline-grid;
  place-items: center;
}
.photo-icon-btn svg { width: 24px; height: 24px; }
.photo-form input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0;
}
.photo-grid {
  list-style: none; margin: 0 0 8px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px;
}
.photo-grid img {
  width: 100%; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
}
.photo-item { position: relative; }
.photo-item .photo-actions {
  position: absolute; top: 4px; right: 4px;
  display: flex; gap: 4px; opacity: 0; transition: opacity .15s ease;
}
.photo-item:hover .photo-actions,
.photo-item:focus-within .photo-actions { opacity: 1; }
.photo-item .photo-actions .icon-btn {
  width: 26px; height: 26px; font-size: 15px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 1px 4px rgba(11, 23, 38, .3);
}
.photo-item .photo-actions form { margin: 0; }
.photo-item .photo-download svg { width: 16px; height: 16px; }
.files .file-download { font-size: 12px; margin-left: 8px; }
.photo-open {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
}
.photo-open img { display: block; }
@media (max-width: 860px) {
  .photo-item .photo-actions { opacity: 1; }
  .photo-item .photo-actions .icon-btn { width: 32px; height: 32px; }
}

.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; }
.lightbox[hidden] { display: none; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(6, 15, 26, .82); backdrop-filter: blur(3px); }
.lightbox-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: min(960px, 100%); max-height: 100%; }
.lightbox-bar { display: flex; gap: 10px; align-self: flex-end; }
.lightbox-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--navy);
  cursor: pointer; font-size: 26px; line-height: 1; text-decoration: none;
  box-shadow: 0 4px 14px rgba(6, 15, 26, .4);
}
.lightbox-btn:hover, .lightbox-btn:focus-visible { background: #fff; }
.lightbox-image, .lightbox img {
  max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain;
  border-radius: 10px; background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.lightbox-caption { margin: 0; color: #e7eef5; font-size: 14px; text-align: center; word-break: break-word; }
body.lightbox-open { overflow: hidden; }
.btn-back { display: inline-flex; align-items: center; gap: 6px; }

/* Mobile account summary: show only the role until expanded. */
.who-toggle {
  display: none;
}

@media (max-width: 860px) {
  .person-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .person-name-field { grid-column: 1 / -1; }
  .person-role { justify-self: start; }
}

@media (max-width: 600px) {
  .push-box { align-items: stretch; flex-direction: column; }
  .edit-modal .data-modal-card { padding: 24px 18px; }
  .edit-modal-title { font-size: 21px; }
  .edit-modal-actions { flex-direction: column-reverse; }
  .edit-modal-actions .btn { width: 100%; }
  .who {
    position: relative;
    width: auto;
    min-width: 0;
    margin-left: auto;
    text-align: right;
  }
  .who-toggle {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    padding: 8px 0 8px 8px;
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
  }
  .who-role { white-space: nowrap; }
  .who-chevron {
    display: block;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    transition: transform .18s ease;
  }
  .who-details {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 12;
    min-width: 190px;
    padding: 12px;
    border: 1px solid #9fb3c2;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    text-align: left;
    box-shadow: 0 8px 24px rgba(7, 21, 34, .25);
  }
  .who-details span,
  .who-details small,
  .who-details .link,
  .who-details .logout-form {
    display: block;
    margin: 0 0 5px;
  }
  .who-details small { color: var(--muted); }
  .who-details .link { min-height: 40px; padding-top: 8px; color: var(--navy-2); }
  .who-details .logout-btn {
    display: block;
    width: 100%;
    min-height: 40px;
    padding-top: 8px;
    margin-left: 0;
    text-align: left;
    color: var(--navy-2);
  }
  .who.is-open .who-details { display: block; }
  .who.is-open .who-chevron { transform: rotate(180deg); }
}

/* Surveyor-first field use: high contrast and deliberate touch targets. */
.surveyor-view {
  --bg: #eef2f5;
  --card: #ffffff;
  --ink: #071522;
  --muted: #33485b;
  --line: #aebdca;
  --navy: #06345d;
  --navy-2: #064f8f;
  --shadow: 0 3px 12px rgba(7, 21, 34, .12);
}
.surveyor-view .muted,
.surveyor-view .hint,
.surveyor-view .job-meta,
.surveyor-view .kv dt,
.surveyor-view .logs small,
.surveyor-view .files small {
  color: var(--muted);
}
.surveyor-view .job-card {
  border-color: #8ea2b2;
  box-shadow: var(--shadow);
}
.surveyor-view .job-card:active,
.surveyor-view .job-card:focus-visible {
  outline: 3px solid #f2a900;
  outline-offset: 2px;
  transform: translateY(1px);
}
.surveyor-view .pill {
  border: 1px solid currentColor;
  font-size: 13px;
}
.surveyor-view .step {
  position: relative;
}
.surveyor-view .step-body {
  min-width: 0;
}
.surveyor-view .progress-title {
  font-size: 22px;
  line-height: 1.2;
  margin-bottom: 18px;
}
.surveyor-view .step-title b {
  font-size: 17px;
}
.surveyor-view .step-mark {
  width: 40px;
  height: 40px;
  border: 2px solid #8296a6;
}
.surveyor-view .step.done .step-mark,
.surveyor-view .step.now .step-mark {
  border-color: transparent;
}
.surveyor-view .step-form,
.surveyor-view .step-form input,
.surveyor-view .step-form textarea {
  width: 100%;
  max-width: none;
}
.surveyor-view .photo-form {
  width: auto;
  max-width: none;
  gap: 8px;
  flex-wrap: nowrap;
}
.surveyor-view .photo-form form { flex: 0 0 auto; }
.surveyor-view .photo-form .btn {
  min-height: 48px;
  font-size: 15px;
}
.surveyor-view .photo-icon-btn { width: 52px; }

@media (max-width: 600px) {
  html { overflow-x: hidden; }
  body { min-width: 320px; overflow-x: hidden; }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    flex-wrap: nowrap;
    padding: calc(4px + env(safe-area-inset-top)) 12px 4px;
    align-items: center;
  }
  .brand { display: none; }
  .nav {
    grid-column: 1;
    grid-row: 1;
    order: 0;
    min-width: 0;
    width: auto;
    scrollbar-width: none;
    margin-right: 0;
    padding-right: 4px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 7px 9px;
  }
  .who {
    grid-column: 2;
    grid-row: 1;
    display: block;
    width: auto;
    margin-left: 0;
    font-size: 14px;
  }
  .wrap { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { font-size: 23px; line-height: 1.2; }
  .head-actions { width: 100%; display: grid; gap: 8px; }
  .head-actions .btn { width: 100%; }
  .stats { gap: 8px; margin-bottom: 12px; }
  .stat { padding: 11px 10px; min-height: 72px; }
  .stat span { font-size: 12px; }
  .stat strong { font-size: 22px; }
  .toolbar { gap: 8px; align-items: stretch; }
  .toolbar .btn { flex: 0 0 auto; min-width: 72px; }
  .panel, .form-card { padding: 14px 12px; border-radius: 12px; }
  .job-list { gap: 12px; }
  .job-card { padding: 15px 13px; border-left-width: 7px; }
  .job-top { align-items: flex-start; }
  .job-top b { font-size: 17px; line-height: 1.3; }
  .job-meta, .job-foot { display: grid; grid-template-columns: 1fr; gap: 3px; font-size: 14px; }
  .job-foot .next { margin-top: 3px; }
  .detail-grid { gap: 12px; }
  .progress-heading { align-items: stretch; flex-direction: column; gap: 8px; }
  .progress-options { align-items: stretch; flex-direction: column; gap: 8px; }
  .progress-toggle { width: 100%; min-height: 46px; }
  .timeline { gap: 16px; }
  .step { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; }
  .step-title { align-items: flex-start; flex-wrap: wrap; }
  .flash {
    position: sticky;
    top: 8px;
    z-index: 20;
    min-height: 52px;
    margin-bottom: 16px;
    font-size: 17px;
  }
  .progress-title { font-size: 24px; }
  .step-title b { font-size: 18px; line-height: 1.3; }
  .hint, .stamp, .step-note { font-size: 14px; }
  .step-note-field textarea { min-height: 86px; }
  .step-form { width: 100%; }
  .active-step-form { padding: 12px 10px; }
  .step-form .btn.lg { min-height: 52px; }
  .bool-row { gap: 10px; }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .photo-grid img { height: 82px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { display: grid; grid-template-columns: 1fr auto; }
  .toolbar input { grid-column: 1 / -1; }
  .toolbar .btn { width: 100%; }
  .photo-form form { flex-basis: auto; }
}

/* Keep the mobile topbar to one compact row; navigation remains swipeable. */
@media (max-width: 600px) {
  .topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding-top: calc(4px + env(safe-area-inset-top));
    padding-bottom: 4px;
  }
  .brand {
    display: none;
  }
  .logo {
    padding: 3px 6px;
    font-size: 12px;
  }
  .nav {
    order: 0;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    gap: 4px;
    margin: 0;
    padding: 0 2px 0 0;
  }
  .nav a {
    min-height: 36px;
    padding: 7px 9px;
    border-radius: 7px;
    font-size: 13px;
  }
  .who {
    flex: 0 0 auto;
    margin-left: 0;
    font-size: 13px;
  }
  .who-toggle {
    min-height: 36px;
    padding: 4px 0 4px 4px;
    gap: 4px;
  }
  .who-chevron {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }
}

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .grid-2, .data-edit-row, .data-edit-row.ports { grid-template-columns: 1fr; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand-text { display: none; }
  .nav { order: 3; width: 100%; overflow-x: auto; gap: 8px; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 9px 12px; background: #145487; border-radius: 9px; font-size: 14px; }
  .wrap { padding: 16px 12px 34px; }
  .page-head h1 { font-size: 24px; }
  .toolbar { position: sticky; top: 0; z-index: 5; padding: 8px 0; background: var(--bg); }
  .btn, input, select, textarea { min-height: 46px; }
  .job-card { padding: 16px; border-left-width: 7px; }
  .job-meta, .job-foot { font-size: 14px; }
  .table { display: block; overflow-x: auto; }
  .data-table { min-width: 620px; }
  .person-info { grid-template-columns: 1fr; }
  .icon-btn { width: 44px; height: 44px; }
  body { -webkit-text-size-adjust: 100%; }
  .topbar { flex-wrap: wrap; }
  .who { width: 100%; text-align: left; }
  .page-head { flex-direction: column; }
  .btn.lg { font-size: 17px; }
  .btn.primary, .btn.danger { font-weight: 800; }
}

@media (min-width: 861px) {
  body:not(.admin-view) .job-card { font-size: 16px; }
}

/* Final mobile overrides must follow the generic 860px rules. */
@media (max-width: 600px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: calc(4px + env(safe-area-inset-top)) 12px 4px;
  }
  .brand { display: none; }
  .nav {
    grid-column: 1;
    grid-row: 1;
    order: 0;
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    overflow-x: auto;
    gap: 4px;
    padding: 0 4px 0 0;
  }
  
  .nav a {
    min-height: 36px;
    padding: 7px 9px;
    border-radius: 7px;
    font-size: 13px;
  }
  
  .who {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    margin-left: 0;
    text-align: right;
    flex: 0 0 auto;
    font-size: 13px;
  }
  .who-toggle { min-height: 36px; padding: 4px 0 4px 4px; }
  .photo-form {
    width: auto;
    flex-wrap: nowrap;
  }
  .photo-form form { flex: 0 0 auto; }
}

[hidden] { display: none !important; }

/* Confirmation modal: centered popup on desktop, bottom sheet on mobile. */
.confirm-modal[hidden] { display: none !important; }
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 18, 32, .68);
  backdrop-filter: blur(3px);
}
.confirm-dialog {
  position: relative;
  width: min(420px, 100%);
  padding: 26px 22px 20px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 18px;
  background: #fff;
  color: #071522;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
  text-align: center;
}
.confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff3cd;
  color: #8a5a00;
  font-size: 28px;
  font-weight: 900;
}
.confirm-dialog h2 { margin: 0; font-size: 22px; line-height: 1.25; }
.confirm-dialog p { margin: 10px 0 20px; color: #33485b; font-size: 15px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions .btn { min-height: 50px; font-size: 16px; font-weight: 900; }
.confirm-no { background: #f1f4f6; color: #33485b; }
.confirm-yes { background: #0b5ea8; border-color: #0b5ea8; }

@media (max-width: 600px) {
  .confirm-modal { padding: 16px; align-items: end; }
  .confirm-dialog {
    width: 100%;
    padding: 24px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 12px 12px;
  }
  .confirm-dialog h2 { font-size: 21px; }
  .confirm-dialog p { font-size: 16px; margin-bottom: 18px; }
  .confirm-actions .btn { min-height: 54px; font-size: 17px; }
}
