* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f6f8;
  color: #1a2733;
}

.topbar {
  background: #0b3d5c;
  color: white;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.topbar .brand { font-weight: 700; font-size: 1rem; letter-spacing: 0.2px; white-space: nowrap; }
.topbar .user { font-size: 0.85rem; opacity: 0.8; margin-left: auto; }
.topbar .logout { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 0.85rem; padding: 6px 10px; border-radius: 6px; }
.topbar .logout:hover { background: rgba(255,255,255,0.12); }

.container { max-width: 640px; margin: 0 auto; padding: 16px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 0.95rem; }
.flash-error { background: #fdecea; color: #9c2b1f; }
.flash-success { background: #e7f6ec; color: #1b6b3a; }

.login-card {
  background: white; border-radius: 12px; padding: 24px; margin-top: 40px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
.login-card h1 { margin-top: 0; font-size: 1.4rem; }
.login-card .subtitle { color: #64748b; margin-top: -8px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 0.85rem; color: #475569; margin-top: 6px; }
.login-card input {
  padding: 12px; font-size: 1rem; border: 1px solid #cbd5e1; border-radius: 8px;
}

.btn {
  border: none; border-radius: 8px; padding: 12px 16px; font-size: 1rem;
  font-weight: 600; cursor: pointer; width: 100%;
}
.btn-start { background: #1d7d3f; color: white; }
.btn-finish { background: #b3541e; color: white; }
.btn-secondary { background: #e2e8f0; color: #1a2733; }
.btn-copy { background: #0b3d5c; color: white; margin-top: 8px; }
.btn-primary { background: #0b3d5c; color: white; }
.btn-add-job {
  display: block; text-align: center; text-decoration: none; background: #1d7d3f;
  color: white; margin-bottom: 14px;
}

.btn, .job-card, input, select, textarea { min-height: 44px; }
textarea { min-height: 66px; }
.checkbox-label input { min-height: auto; width: 18px; height: 18px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toggle-link { font-size: 0.9rem; color: #0b3d5c; }

.job-list { display: flex; flex-direction: column; gap: 12px; }
.job-card {
  display: block; background: white; border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08); text-decoration: none; color: inherit;
  border-left: 6px solid #94a3b8;
}
.job-card.status-to-confirm { border-left-color: #94a3b8; }
.job-card.status-pending { border-left-color: #a78b00; }
.job-card.status-in-process { border-left-color: #1d7d3f; }
.job-card.status-shipped { border-left-color: #0b6ea8; }
.job-card.status-in-lab { border-left-color: #7e3ff2; }
.job-card.status-to-be-invoice { border-left-color: #b3541e; }
.job-card.status-completed { border-left-color: #16a34a; opacity: 0.75; }
.job-card.status-canceled { border-left-color: #dc2626; opacity: 0.6; }

.job-card-top { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.job-number { font-weight: 800; }
.job-card.compact { padding: 12px 14px; }

.job-card-link { display: block; color: inherit; text-decoration: none; }
.draft-card { display: flex; flex-direction: column; }
.draft-actions { display: flex; gap: 8px; margin-top: 10px; }
.draft-actions .btn, .draft-actions .dismiss-form { flex: 1; }
.draft-actions .dismiss-form { display: flex; }
.draft-actions .dismiss-form .btn { width: 100%; margin-top: 0; }

.job-vessel { font-weight: 600; margin-top: 4px; }
.job-meta { font-size: 0.9rem; color: #64748b; margin-top: 2px; }
.job-meta.assigned-to { font-style: italic; }
.lab-flag {
  display: inline-block; margin-top: 6px; background: #ede9fe; color: #6d28d9;
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600;
}

.back-link { display: inline-block; margin-bottom: 10px; color: #0b3d5c; text-decoration: none; }

.status-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 700; background: #e2e8f0; color: #475569; margin-bottom: 14px;
  text-transform: uppercase; white-space: nowrap;
}
.status-badge.status-to-confirm   { background: #e2e8f0; color: #475569; }
.status-badge.status-pending      { background: #fef3c7; color: #92620a; }
.status-badge.status-in-process   { background: #dcfce7; color: #166534; }
.status-badge.status-shipped      { background: #dbeafe; color: #0b5c93; }
.status-badge.status-in-lab       { background: #ede9fe; color: #6d28d9; }
.status-badge.status-to-be-invoice{ background: #ffedd5; color: #9a4a12; }
.status-badge.status-completed    { background: #d1fae5; color: #166534; }
.status-badge.status-canceled     { background: #fee2e2; color: #b91c1c; }

.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
  background: white; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.detail-grid > div { display: flex; flex-direction: column; }
.label { font-size: 0.75rem; text-transform: uppercase; color: #94a3b8; }

.instructions-box, .note-box {
  background: white; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
}
.instructions-box p { margin: 6px 0 0; white-space: pre-wrap; }

.action-row { margin-bottom: 14px; }
.note-box textarea {
  width: 100%; padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.95rem;
  margin: 6px 0 10px;
}

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item { background: white; border-radius: 10px; padding: 10px 14px; }
.history-top { display: flex; justify-content: space-between; }
.history-date { color: #94a3b8; font-size: 0.85rem; }
.history-meta { font-size: 0.8rem; color: #64748b; }
.history-notes { margin-top: 4px; font-size: 0.9rem; }

.empty { color: #94a3b8; text-align: center; padding: 24px 0; }

.dispatch-details { margin-top: 10px; background: white; border-radius: 12px; padding: 10px 14px; }
.dispatch-text {
  width: 100%; min-height: 110px; margin-top: 8px; padding: 8px;
  border-radius: 8px; border: 1px solid #cbd5e1; font-family: inherit; font-size: 0.9rem;
}

.edit-form {
  background: white; border-radius: 12px; padding: 10px 14px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.edit-form label {
  font-size: 0.78rem; color: #475569; display: flex; flex-direction: column; gap: 2px; font-weight: 600;
}
.edit-form input, .edit-form select, .edit-form textarea {
  font-size: 0.92rem; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-family: inherit;
  font-weight: 400; color: #1a2733;
}
.edit-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit-form .field-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.edit-form .field-row.qty-row { grid-template-columns: 2fr 1fr 1fr; }
.edit-form input.qty-input { max-width: 100px; }
.dispatch-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.dispatch-actions .btn { width: auto; flex: 0 1 auto; margin-top: 0; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.assign-fieldset {
  border: 1px dashed #cbd5e1; border-radius: 10px; padding: 8px 10px; margin: 0;
}
.assign-fieldset legend { font-size: 0.8rem; color: #64748b; padding: 0 4px; }
.assign-fieldset select:disabled { background: #f1f5f9; color: #94a3b8; }
.hint { font-size: 0.85rem; color: #94a3b8; margin-top: 2px; }

.toggle-section {
  display: flex; flex-direction: column; gap: 8px;
  margin: 2px 0 6px 0; padding: 8px 10px 2px 10px;
  border-left: 3px solid #cbd5e1;
}
.toggle-btn {
  align-self: flex-start; font-size: 0.78rem; padding: 5px 10px; margin: 0 0 4px 0;
}

@media (min-width: 600px) {
  .edit-form .field-row { grid-template-columns: 1fr 1fr; }
}

/* Office job-list header actions (Add New Job / Email Drafts) */
.office-actions { display: flex; gap: 10px; margin-bottom: 14px; }
.office-actions .btn { width: auto; flex: 1; text-decoration: none; text-align: center; }
.draft-count-badge {
  display: inline-block; background: #b91c1c; color: white; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; padding: 1px 7px; margin-left: 4px;
}

/* Email-draft review (pre-filled new-job form) */
.draft-review-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 14px;
}
.draft-review-title { font-size: 0.9rem; color: #78530a; margin: 0 0 10px; }
.draft-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.draft-legend span {
  font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.draft-email-body {
  background: #f8fafc; border-radius: 8px; padding: 10px 12px; font-size: 0.85rem;
  max-height: 260px; overflow-y: auto; white-space: normal; line-height: 1.5;
}
.dismiss-form { margin-top: 10px; }
.dismiss-form .btn { width: auto; }

mark.hl-client, .draft-legend .hl-client { background: #dbeafe; color: #0b5c93; }
mark.hl-vessel, .draft-legend .hl-vessel { background: #dcfce7; color: #166534; }
mark.hl-port, .draft-legend .hl-port { background: #ede9fe; color: #6d28d9; }
mark.hl-operation, .draft-legend .hl-operation { background: #ffedd5; color: #9a4a12; }
mark.hl-ref, .draft-legend .hl-ref { background: #fce7f3; color: #9d174d; }
mark[class^="hl-"] { padding: 1px 3px; border-radius: 3px; }

/* Top-level nav (My Jobs / Office) - now inline in the single compact header bar */
.topnav {
  display: flex; gap: 2px; align-items: center;
}
.topnav-link {
  color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.85rem;
  font-weight: 600; padding: 6px 12px; border-radius: 6px; transition: background 0.15s, color 0.15s;
}
.topnav-link:hover {
  color: white; background: rgba(255,255,255,0.08);
}
.topnav-link.active {
  color: #0b3d5c; background: #ffffff;
}

.user-form { background: #f7f8fa; padding: 12px; border-radius: 8px; margin-bottom: 20px; }
.user-form .field-row { display: flex; gap: 12px; margin-bottom: 10px; }
.user-form label { flex: 1; display: flex; flex-direction: column; font-size: 13px; }
.user-form input, .user-form select { margin-top: 4px; }

.users-list { display: flex; flex-direction: column; gap: 4px; }
.users-list-header, .users-list-row {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 1fr 0.6fr 1fr 1fr 0.8fr;
  gap: 8px;
  align-items: center;
  padding: 6px 4px;
}
.users-list-header { font-weight: 600; font-size: 12px; color: #667; border-bottom: 1px solid #ddd; }
.users-list-row { border-bottom: 1px solid #eee; }
.username-cell { color: #667; font-size: 13px; }

.field-hint { font-size: 12px; color: #667; margin: 4px 0 10px; }
.badge-pending { background: #fdecea; color: #9c2b1f; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.badge-active { background: #e7f6ec; color: #1b6b3a; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.users-resend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 10px 4px;
  border-bottom: 1px solid #eee;
  background: #fafafa;
}
.users-resend-row .resend-label { font-size: 12px; color: #667; white-space: nowrap; }
.users-resend-row input[type="email"] { flex: 1; font-size: 13px; }

.filter-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: 10px 0 14px;
  font-size: 13px;
}
.filter-bar label { display: flex; flex-direction: column; gap: 2px; color: #667; font-size: 12px; }
.filter-bar select { font-size: 13px; padding: 3px 6px; }

.job-table-wrap { overflow-x: auto; margin-top: 8px; }
.job-table { border-collapse: collapse; width: 100%; font-size: 12px; white-space: nowrap; }
.job-table th, .job-table td { padding: 3px 8px; border-bottom: 1px solid #eee; text-align: left; }
.job-table thead th {
  position: sticky; top: 0; background: #f7f8fa; font-weight: 600;
  border-bottom: 1px solid #ddd; z-index: 1;
}
.job-table tbody tr { cursor: pointer; }
.job-table tbody tr:hover { background: #f5f8ff; }
.job-table tbody tr:nth-child(even) { background: #fafafa; }
.job-table tbody tr:nth-child(even):hover { background: #f5f8ff; }
.job-table .status-badge { padding: 1px 6px; font-size: 11px; }

.job-table td.eta-soon {
  background: #ffe0b2;
  color: #b3261e;
  font-weight: 700;
  border-radius: 3px;
}

.job-table tr.surveyor-tbd td {
  background: #fff59d;
  color: #7a5900;
  font-weight: 700;
}

.job-table tr.surveyor-tbd td.eta-soon {
  background: #ffe0b2;
  color: #b3261e;
  font-weight: 700;
  border-radius: 3px;
  border: 2px solid #b3261e;
}

.job-table td.dispatch-status { font-size: 11px; line-height: 1.6; white-space: nowrap; }
.badge-sent, .badge-accepted, .badge-pending, .badge-notsent {
  display: inline-block; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 600; margin-right: 4px;
}
.badge-sent { background: #dcfce7; color: #166534; }
.badge-accepted { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: #fef3c7; color: #92620a; }
.badge-notsent { background: #f1f5f9; color: #64748b; }

.milestones-panel { margin: 10px 0; }
.milestones-table { border-collapse: collapse; font-size: 12px; width: 100%; max-width: 480px; }
.milestones-table th, .milestones-table td { padding: 3px 8px; text-align: left; border-bottom: 1px solid #e5e7eb; }
.milestones-table th { color: #64748b; font-weight: 600; }

.progress-pill {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.progress-none { background: #f1f5f9; color: #64748b; }
.progress-barge_arrived { background: #fef3c7; color: #92620a; }
.progress-start { background: #dbeafe; color: #1d4ed8; }
.progress-finished { background: #ede9fe; color: #6d28d9; }
.progress-released { background: #dcfce7; color: #166534; }

.job-status-pill {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-accept { background: #1d4ed8; color: white; }

main.container.container-wide {
  max-width: 1800px;
}

/* Office job detail/edit page: wider container so the form fits with less
   scrolling, plus a prominent top-right quick-edit panel for the fields
   office staff change most often (Status, Surveyor A, Surveyor B). */
main.container.container-wide-form {
  max-width: 1200px;
}
.page-header.with-quick-edit {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.quick-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
}
.quick-edit label {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.quick-edit select {
  font-size: 0.85rem;
  padding: 5px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  min-width: 130px;
}
.quick-edit .hint {
  width: 100%;
  text-align: right;
  margin: 2px 0 0 0;
}

