/* TransPrime Forwarding Lite — matches the approved prototype:
   light Apple-clean, teal primary, system fonts, 1060px container. */

:root {
  --teal: rgb(15 118 110);
  --teal-soft: rgb(240 253 250);
  --ink: rgb(26 28 31);
  --muted: rgb(26 28 31 / 55%);
  --border: rgb(26 28 31 / 10%);
  --border-soft: rgb(26 28 31 / 7%);
  --bg: rgb(250 250 249);
  --card-bg: rgb(255 255 255);
  --amber-bg: rgb(255 251 235);
  --amber-text: rgb(180 83 9);
  --green-bg: rgb(240 253 244);
  --green-text: rgb(21 128 61);
  --red-bg: rgb(254 242 242);
  --red-text: rgb(185 28 28);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 40px) 72px;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 20px; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 14px; }
h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 8px;
}
section.card > h3:first-of-type { margin-top: 4px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Top bar + nav */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--teal);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.account { display: flex; align-items: center; gap: 12px; }

.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 30px; }
.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { color: var(--ink); background: rgb(26 28 31 / 5%); text-decoration: none; }
.nav a.active { color: var(--teal); background: var(--teal-soft); }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 26px;
  box-shadow: 0 1px 2px -1px rgb(0 0 0 / 6%);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.stat-warn .stat-value { color: var(--amber-text); }
.stat-danger .stat-value { color: var(--red-text); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgb(26 28 31 / 5%);
  font-size: 12px;
  font-weight: 500;
}

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
th {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
td { padding: 13px 8px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.job-link { font-weight: 600; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-lg { font-size: 13px; padding: 5px 13px; }
.badge-neutral { background: rgb(26 28 31 / 6%); color: var(--muted); }
.badge-progress { background: var(--teal-soft); color: var(--teal); }
.badge-good { background: var(--green-bg); color: var(--green-text); }
.badge-warn { background: var(--amber-bg); color: var(--amber-text); }
.badge-danger { background: var(--red-bg); color: var(--red-text); }

/* Reminders (dashboard attention list + shipment operations card) */
.reminder-list { margin: 4px 0 8px; padding: 0; list-style: none; }
.reminder-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgb(26 28 31 / 4%);
}
.reminder-list li.reminder-danger { background: var(--red-bg); }
.reminder-list li.reminder-warn { background: var(--amber-bg); }
.reminder-msg { flex: 1; }

/* Operations card */
.milestone-action { text-align: right; }
.milestone-action form { display: inline; }
.ops-form { margin-top: 6px; }
.ops-form .btn { margin-top: 16px; }

/* Document generation (shipment detail) */
.doc-gen { display: flex; flex-direction: column; }
.doc-gen-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft);
}
.doc-gen-row:last-child { border-bottom: 0; }
.doc-gen-name { flex: 0 0 170px; font-weight: 600; }
.doc-gen-status {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  min-width: 0;
}
.doc-gen-note { font-size: 12px; color: var(--muted); }
.doc-gen-warning { color: var(--amber-text); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary[disabled]:hover { background: var(--teal); }

.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.doc-actions form { display: flex; align-items: center; gap: 6px; }
.doc-accept-form input[type="text"] { width: 110px; padding: 5px 8px; font-size: 13px; }
.doc-filename { font-size: 11px; }

/* Detail page */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.detail-header h1 { margin-bottom: 4px; }
.detail-header p { margin: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 22px; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--teal); background: var(--teal-soft); text-decoration: none; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px 28px;
  margin-bottom: 8px;
}
.field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-value { overflow-wrap: break-word; }
.field-error { color: var(--amber-text); font-size: 12px; }

.conflict-list, .missing-list { margin: 4px 0 8px; padding: 0; list-style: none; }
.conflict-list li {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  color: var(--amber-text);
}
.missing-list li {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgb(26 28 31 / 4%);
}

/* Page header (title + primary action) */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-header h1 { margin-bottom: 20px; }
.detail-badges { display: flex; align-items: center; gap: 8px; }
a.badge:hover { text-decoration: none; }

/* New-shipment flow */
.template-picker { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.template-option {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.template-option:hover { border-color: var(--teal); background: var(--teal-soft); }
.template-option input[type="radio"] { accent-color: var(--teal); }
.template-body { display: flex; flex-direction: column; gap: 2px; }
.template-name { font-weight: 600; }
.template-picker .btn { align-self: flex-start; margin-top: 10px; }

/* Template-prefilled values awaiting confirmation */
.unconfirmed-card { border-color: rgb(180 83 9 / 25%); background: var(--amber-bg); }
.unconfirmed-list { margin: 4px 0 10px; padding: 0; list-style: none; }
.unconfirmed-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--amber-bg);
  color: var(--amber-text);
}
.unconfirmed-list form { display: inline; }

/* Forms and buttons */
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: rgb(26 28 31 / 4%); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: rgb(26 28 31 / 5%); }
.btn-primary { border-color: transparent; background: var(--teal); color: #fff; }
.btn-primary:hover { background: rgb(13 100 94); }

.status-form {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.status-form .field-label { margin: 0; }
.status-form select { width: auto; min-width: 180px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 22px;
}
.field-wide { grid-column: 1 / -1; }

.flash {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--teal-soft);
  color: var(--teal);
  font-weight: 500;
}
.flash-warn { background: var(--amber-bg); color: var(--amber-text); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: min(380px, 100%); }
.login-card h1 { margin-bottom: 4px; }
.login-card p { margin: 0 0 18px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack .btn { margin-top: 8px; }

code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgb(26 28 31 / 6%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

/* Finance (Phase 4) */
.tabular-nums { font-variant-numeric: tabular-nums; }
th.num, td.num { text-align: right; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  font-weight: 600;
}
.finance-sublabel { font-size: 11px; font-weight: 400; }
.finance-top {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.profit-box {
  flex: 0 0 auto;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--teal-soft);
}
.profit-box .stat-value { color: var(--teal); }
.finance-side { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.finance-flows { display: flex; gap: 28px; }
.rates-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.rates-form .field { width: 130px; }
.finance-fee-note { margin: 0; font-size: 12px; }
.entry-form .btn { margin-top: 14px; }

@media (max-width: 640px) {
  .detail-header { flex-direction: column; }
  .status-form { flex-wrap: wrap; }
  table { display: block; overflow-x: auto; }
}
