/* ASL Customer Portal */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #182230;
  --muted: #5b687a;
  --border: #dfe4eb;
  --primary: #0a4d8c;
  --primary-hover: #083d70;
  --primary-soft: #e7f0fa;
  --success: #17703f;
  --success-soft: #e3f4ea;
  --warning: #8a5300;
  --warning-soft: #fdf0d8;
  --danger: #b3261e;
  --danger-soft: #fce9e7;
  --neutral: #3d4a5c;
  --neutral-soft: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--neutral-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; border-radius: 6px; padding: 6px 10px; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.brand-mark img { display: block; height: 18px; width: auto; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a, .linklike { color: var(--muted); font: inherit; }
.nav a:hover, .linklike:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--primary); font-weight: 600; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; }
.inline { display: inline; margin: 0; }

main.wrap { padding-top: 28px; padding-bottom: 48px; min-height: calc(100vh - 120px); }
.footer { color: var(--muted); font-size: 13px; padding-bottom: 24px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; margin-bottom: 20px; }
.page-head p { margin: 0; }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.grid .card { margin-bottom: 0; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h1 { color: var(--text); }

/* Alerts */
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bfe3cc; }
.alert-info { background: var(--primary-soft); color: var(--primary); border-color: #c6dcf2; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #f3d9a6; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #f4c7c2; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--neutral-soft); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; }

/* Forms */
.form { display: grid; gap: 16px; }
.form h2 { margin: 0; }
.form p { margin: 0; }
.narrow { max-width: 560px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 400;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .stat:focus-visible, .linklike:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.form-actions { display: flex; gap: 10px; }

/* Sign-in */
.auth { display: grid; place-items: center; min-height: 60vh; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card form { display: grid; gap: 16px; margin: 20px 0 16px; }
.auth-card .alert { margin: 16px 0 0; }

/* Stage counters */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
  font: inherit; color: inherit; cursor: pointer;
}
.stat:hover { border-color: #b9c6d6; }
.stat.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.stat-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border); }
.toolbar input { flex: 1; }
.toolbar select { width: auto; min-width: 140px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; background: var(--surface-alt);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: var(--surface-alt); }
.actions { white-space: nowrap; text-align: right; }
.actions a + a { margin-left: 12px; }
.arrow { color: var(--muted); padding: 0 6px; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.mode {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 8px; border-radius: 6px; border: 1px solid var(--border); color: var(--neutral);
}
.mode-sea { color: #0a4d8c; border-color: #c6dcf2; background: #f2f7fc; }
.mode-air { color: #6b3fa0; border-color: #ddd0ee; background: #f7f3fc; }
.mode-land { color: #7a4b00; border-color: #eedcbc; background: #fcf7ee; }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--success); }
.tag-muted { color: var(--muted); }

/* Progress tracker */
.tracker { display: flex; list-style: none; margin: 0; padding: 0; }
.tracker li { flex: 1; position: relative; text-align: center; padding-top: 30px; }
.tracker li::before { content: ""; position: absolute; top: 10px; right: 50%; width: 100%; height: 3px; background: var(--border); }
.tracker li:first-child::before { display: none; }
.tracker li.done::before { background: var(--primary); }
.tracker .dot {
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--border);
}
.tracker li.done .dot { background: var(--primary); border-color: var(--primary); }
.tracker li.current .dot { box-shadow: 0 0 0 4px var(--primary-soft); }
.tracker strong { display: block; }
.tracker .when { color: var(--muted); font-size: 13px; }

/* Shipment facts */
.facts { display: grid; grid-template-columns: minmax(110px, 42%) 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.containers { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.containers li { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--neutral-soft); border-radius: 6px; padding: 3px 8px; }

/* New temporary password box (Customers page, shown once) */
.credentials { border: 2px solid var(--primary); }
.credentials h2 { font-size: 18px; margin-bottom: 4px; }
.credentials h3 { font-size: 14px; margin: 20px 0 8px; }
.password-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 10px; }
.password {
  font-family: ui-monospace, Consolas, monospace; font-size: 30px; font-weight: 700; letter-spacing: .08em;
  background: var(--primary-soft); color: var(--primary); border: 1px dashed var(--primary);
  border-radius: 8px; padding: 10px 18px; user-select: all; overflow-wrap: anywhere;
}
.message-preview {
  white-space: pre-wrap; font: inherit; font-size: 14px; margin: 0 0 12px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px;
}

/* Shipments list: five groups (In progress … All) and the filter row */
.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.toolbar:has(+ .filter-row) { border-bottom: 0; padding-bottom: 8px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 14px 14px; border-bottom: 1px solid var(--border); }
.filter-row select { width: auto; min-width: 150px; max-width: 240px; }
.filter-row .linklike { color: var(--primary); margin-left: 4px; }

/* Shipment detail: places in the timeline, and the Routing / Equipment tables */
.tracker .where { display: block; font-size: 13px; margin-top: 2px; }
.section-gap { margin-top: 16px; }
.card-title { margin: 0; padding: 16px 20px 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }

/* Phones: tables turn into stacked cards */
@media (max-width: 760px) {
  h1 { font-size: 21px; }
  .nav { gap: 14px; }
  .brand-name { display: none; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-num { font-size: 22px; }
  .stat-label { font-size: 13px; }
  .toolbar { flex-direction: column; }
  .toolbar select { width: 100%; }
  .stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-row select { flex: 1 1 140px; max-width: none; }
  /* Timeline runs top to bottom on phones */
  .tracker { flex-direction: column; }
  .tracker li { text-align: left; padding: 0 0 18px 32px; }
  .tracker li:last-child { padding-bottom: 0; }
  .tracker li::before { display: none; }
  .tracker li::after { content: ""; position: absolute; left: 8px; top: 21px; bottom: 0; width: 3px; background: var(--border); }
  .tracker li:last-child::after { display: none; }
  .tracker li.done:not(.current)::after { background: var(--primary); }
  .tracker .dot { left: 0; transform: none; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex-shrink: 0; }
  .table td .stack { align-items: flex-end; }
  .table td.actions { justify-content: flex-end; padding-top: 8px; }
  .table td.actions::before { content: none; }
  .table tr[data-href]:hover td { background: none; }
}
