/* WG Shipment Tracking — one stylesheet, light + dark. */
:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #15191f;
  --text-2: #4b5360;
  --muted: #6b7380;
  --brand: #0e3a66;
  --brand-ink: #ffffff;
  --accent: #2a78d6;          /* data series 1 */
  --accent-soft: #e6f0fb;
  --ok: #157a3d;   --ok-soft: #e4f4ea;
  --warn: #9a5b00; --warn-soft: #fdf1dc;
  --danger: #b42318; --danger-soft: #fde8e6;
  --info: #1d5fae; --info-soft: #e6f0fb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111418; --surface: #1a1e24; --surface-2: #20252c; --border: #2c323b; --border-strong: #3a414c;
    --text: #eef1f5; --text-2: #c3c9d2; --muted: #9099a6; --brand: #5b9be0; --brand-ink: #0b1220;
    --accent: #3987e5; --accent-soft: #1b2d44;
    --ok: #4cc27a; --ok-soft: #173023; --warn: #e3a54a; --warn-soft: #33270f;
    --danger: #f2756a; --danger-soft: #3a1b18; --info: #78aef0; --info-soft: #1b2d44;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418; --surface: #1a1e24; --surface-2: #20252c; --border: #2c323b; --border-strong: #3a414c;
  --text: #eef1f5; --text-2: #c3c9d2; --muted: #9099a6; --brand: #5b9be0; --brand-ink: #0b1220;
  --accent: #3987e5; --accent-soft: #1b2d44;
  --ok: #4cc27a; --ok-soft: #173023; --warn: #e3a54a; --warn-soft: #33270f;
  --danger: #f2756a; --danger-soft: #3a1b18; --info: #78aef0; --info-soft: #1b2d44;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .15rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: .92em; }
.upper { text-transform: uppercase; }
.count { font-weight: 400; font-size: 1rem; }
.req { color: var(--danger); }
.danger-text { color: var(--danger) !important; }
.warn-text { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .85rem; letter-spacing: .5px; }
.brand-mark.lg { width: 44px; height: 44px; font-size: 1rem; }
.global-search { flex: 1; max-width: 560px; }
.global-search input { width: 100%; }
.nav-toggle { display: none; background: none; border: 0; font-size: 1.3rem; color: var(--text); cursor: pointer; }
.user-menu { margin-left: auto; position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; z-index: 30; display: flex; flex-direction: column; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu form { display: flex; flex-direction: column; gap: 4px; padding: 4px 0; border-top: 1px solid var(--border); }
.menu input { margin: 0 6px; }
.menu-head { padding: 6px 10px; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.sidenav a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-section { margin: 16px 12px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav-section.first { margin-top: 0; }
.sidenav a { display: flex; align-items: center; gap: 10px; }
.ni { width: 18px; text-align: center; color: var(--muted); font-size: .95rem; }
.sidenav a.active .ni { color: var(--accent); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center; }
.main { padding: 24px; min-width: 0; max-width: 1400px; width: 100%; }

/* ---------- basics ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: .2rem 0 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0; }
.section-title { font-size: 1rem; font-weight: 600; margin: 0 0 10px; }
.section-head .section-title { margin: 0; }
summary.section-title { cursor: pointer; margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.empty-state { text-align: center; padding: 32px 16px; color: var(--text-2); }
.notice { background: var(--info-soft); color: var(--text); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.notice-warn { background: var(--warn-soft); }
.notice-info { background: var(--info-soft); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border: 0; }
.tag { font-size: .7rem; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); font-weight: 400; }
code { font-family: var(--mono); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-info { background: var(--info-soft); color: var(--info); }
body.bare > .flash { max-width: 420px; margin: 16px auto; }

/* ---------- forms ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input[disabled] { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"] { min-height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
textarea { resize: vertical; width: 100%; }
label { display: block; font-weight: 500; font-size: .9rem; color: var(--text-2); }
label > input:not([type="checkbox"]), label > select, label > textarea { display: block; width: 100%; margin-top: 4px; font-weight: 400; color: var(--text); }
label > .input-pair { margin-top: 4px; }
label > .input-pair > select { flex: 1; min-width: 0; }
label > .field-error, label > .link-btn, label > a.hint { display: block; margin-top: 4px; }
label.inline { display: flex; align-items: center; gap: 6px; font-weight: 400; }
label.inline > input { width: auto; margin-top: 0; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
.field-error { color: var(--danger); font-size: .82rem; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.form-narrow { max-width: 520px; }
.input-pair { display: flex; gap: 8px; }
.input-pair > .grow, .grow { flex: 1; min-width: 0; }
.w-qty { width: 90px; }
.w-code { width: 90px; }
fieldset { border: 0; margin: 0 0 16px; padding: 16px; }
fieldset.card { border: 1px solid var(--border); }
fieldset.plain { padding: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 12px; float: left; width: 100%; }
legend + * { clear: both; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
form.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }

/* ---------- pills, flags ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.stage-badge { display: inline-block; vertical-align: middle; font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.stage-badge.stage-5, .stage-badge.stage-6 { background: var(--info-soft); color: var(--info); }
.stage-badge.stage-7 { background: var(--ok-soft); color: var(--ok); }

/* ---------- KPIs & pipeline ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi-value { font-size: 1.75rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-2); font-size: .85rem; }
.kpi-alert { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); background: var(--warn-soft); }
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; margin-bottom: 20px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.pipeline-step { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; color: var(--text); position: relative; }
.pipeline-step:hover { background: var(--accent-soft); text-decoration: none; }
.pipeline-step::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.pipeline-step.is-empty::after { background: var(--border); }
.pipeline-count { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.pipeline-name { font-size: .8rem; color: var(--text-2); }

/* ---------- order list ---------- */
.order-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.order-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.order-row:hover { border-color: var(--accent); text-decoration: none; }
.order-row-title { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.order-row-meta { font-size: .85rem; }
.order-row-status { text-align: right; }
.order-row-status .flags { justify-content: flex-end; }
.stage-name { font-weight: 600; }
.dates { font-size: .85rem; }
.order-row .stage-strip { grid-column: 1 / -1; }
.route { display: flex; align-items: center; gap: 8px; margin: 4px 0; max-width: 360px; }
.port { font-family: var(--mono); font-size: .85rem; font-weight: 600; }
.route-line { flex: 1; height: 4px; border-radius: 4px; background: var(--border); position: relative; overflow: hidden; }
.route-line span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 4px; }

.stage-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; list-style: none; margin: 4px 0 0; padding: 0; }
.stage-strip li { height: 6px; background: var(--border); border-radius: 3px; position: relative; }
.stage-strip li span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stage-strip li.done { background: var(--accent); }
.stage-strip li.current { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.stage-strip.is-cancelled li { background: var(--border); }
.route-card .stage-strip li { height: auto; background: none; padding-top: 10px; }
.route-card .stage-strip li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; border-radius: 3px; background: var(--border); }
.route-card .stage-strip li.done::before { background: var(--accent); }
.route-card .stage-strip li.current::before { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.route-card .stage-strip li span { position: static; width: auto; height: auto; clip: auto; overflow: visible; font-size: .72rem; color: var(--muted); display: block; text-align: center; line-height: 1.2; }
.route-card .stage-strip li.current span { color: var(--text); font-weight: 600; }

/* ---------- filters, tables ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters > input[type="search"] { min-width: 220px; }
.more-filters { width: 100%; order: 10; }
.more-filters summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.filters-inner { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.quick-ranges { display: flex; gap: 4px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table.compact td { padding: 6px 8px; }
.table tr:last-child td { border-bottom: 0; }
.row-danger td:first-child { box-shadow: inset 3px 0 var(--danger); }
.row-muted { opacity: .6; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 12px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.activity li:last-child { border: 0; }

/* ---------- board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; }
.board-col header { display: flex; justify-content: space-between; padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.board-col .count { background: var(--surface); border-radius: 999px; padding: 0 8px; font-size: .8rem; border: 1px solid var(--border); }
.board-cards { display: flex; flex-direction: column; gap: 8px; padding: 8px; max-height: 70vh; overflow-y: auto; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 10px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.board-card:hover { border-color: var(--accent); text-decoration: none; }
.board-card.tone-danger { border-left-color: var(--danger); }
.board-card.tone-warn { border-left-color: var(--warn); }
.board-card-top { display: flex; justify-content: space-between; gap: 8px; }
.board-empty { text-align: center; }

/* ---------- order detail ---------- */
.order-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.route-card { padding: 20px; }
.route-ends { display: grid; grid-template-columns: minmax(110px, auto) 1fr minmax(110px, auto); gap: 16px; align-items: center; margin-bottom: 12px; }
.route-end.right { text-align: right; }
.route-code { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
.route-track { position: relative; padding: 18px 0 0; }
.route-track-line { height: 6px; border-radius: 3px; background: var(--border); position: relative; overflow: hidden; }
.route-track-line span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.route-ship { position: absolute; top: 0; left: var(--p, 0); transform: translateX(-50%); font-size: 1.2rem; line-height: 1; }
.route-vessel { text-align: center; margin-top: 8px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.record-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.record-form select { max-width: 100%; flex: 1 1 260px; }
.record-form .grow { flex: 1 1 200px; }
[data-extra-fields] { display: contents; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-stage { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px 28px; }
.timeline-stage:first-child { margin-top: 0; }
.timeline-item { display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; padding: 4px 0 8px; position: relative; color: var(--muted); }
.timeline-item::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: -6px; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-item .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); margin: 5px 0 0 4px; position: relative; z-index: 1; }
.timeline-item.done { color: var(--text); }
.timeline-item.done .dot { background: var(--accent); border-color: var(--accent); }
.timeline-item.done::before { background: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.timeline-item.next .dot { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline-item.next .timeline-title { color: var(--text); font-weight: 600; }
.timeline-title { font-weight: 500; }
.details { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0 0 8px; font-size: .92rem; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.parties summary, .add-block summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin: 8px 0; }
.checklist { list-style: none; margin: 0 0 12px; padding: 0; }
.checklist li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; padding: 5px 0; align-items: center; border-bottom: 1px dashed var(--border); }
.check-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.check-ok .check-icon { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.check-info .check-icon { background: var(--info-soft); color: var(--info); border-color: transparent; }
.check-warn .check-icon { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.doc-list li:last-child { border: 0; }
.review-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 8px; background: var(--info-soft); border-radius: 8px; }
.thread { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; margin-bottom: 10px; }
.msg { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); max-width: 92%; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.msg-body { white-space: normal; overflow-wrap: anywhere; }
.msg-meta { color: var(--muted); }
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; max-width: 520px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog h2 { margin-top: 0; }

/* ---------- map ---------- */
.map { height: 340px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); z-index: 0; }
.map-facts { margin-top: 12px; grid-template-columns: auto 1fr; }
.ship-icon svg { fill: var(--accent); stroke: #fff; stroke-width: 1.5; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.ship-icon.is-stale svg { fill: var(--warn); }
.leaflet-tooltip.map-label { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; font: 600 12px var(--font); padding: 2px 6px; }
.leaflet-tooltip.map-label::before { display: none; }
@media (max-width: 640px) { .map { height: 260px; } }

.ship-icon.is-arrived svg { fill: var(--ok); }
.fleet-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.fleet-map-card { padding: 8px; }
.fleet-list { max-height: 540px; overflow-y: auto; }
.fleet-list li { display: flex; flex-direction: column; gap: 2px; }
.fleet-list .pill { align-self: flex-start; }

/* ---------- schedule ---------- */
.day { margin-bottom: 14px; }
.day.past { opacity: .75; }
.day-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: 4px 0; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.sched-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 6px; border-radius: 6px; color: var(--text); flex-wrap: wrap; }
.sched-row:hover { background: var(--surface-2); text-decoration: none; }
.sched-main { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.sched-status { display: flex; gap: 4px; align-items: center; }

/* ---------- inbox ---------- */
.inbox { padding: 0; overflow: hidden; }
.inbox-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.inbox-row:last-child { border-bottom: 0; }
.inbox-row:hover { background: var(--surface-2); text-decoration: none; }
.inbox-row.unread { background: var(--accent-soft); }
.inbox-row.unread .inbox-body { font-weight: 600; }
.inbox-main { display: flex; flex-direction: column; min-width: 0; }
.inbox-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.inbox-body { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

/* ---------- live container activity ---------- */
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-left: 6px; vertical-align: middle;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: livepulse 2s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.activity-feed { list-style: none; margin: 0; padding: 0; }
.af-day { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 4px; }
.af-day:first-child { margin-top: 0; }
.af-item { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.af-item:last-child { border-bottom: 0; }
.af-icon { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: .9rem; }
.af-body { display: flex; flex-direction: column; min-width: 0; }
.af-text { overflow-wrap: anywhere; }

/* ---------- report centre ---------- */
.report-group { margin-top: 18px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 8px; }
.report-card { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.report-card:hover { border-color: var(--accent); text-decoration: none; }
.report-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 1.1rem; }
.report-text { display: flex; flex-direction: column; gap: 3px; }
.report-formats { display: flex; gap: 4px; margin-top: 4px; }
.report-table td, .report-table th { white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.total-row td { font-weight: 700; border-top: 2px solid var(--border-strong); background: var(--surface-2); }
@media print {
  .topbar, .sidenav, .filters, .row-actions, .page-head .btn, .flash { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .85rem; }
.chip b { color: var(--text); margin-left: 4px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- order form ---------- */
.wizard-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; list-style: none; padding: 0; margin: 0 0 16px; counter-reset: s; }
.wizard-steps li { padding: 10px 12px; border-bottom: 3px solid var(--border); color: var(--muted); font-weight: 500; font-size: .9rem; cursor: pointer; }
.wizard-steps li.current { border-color: var(--accent); color: var(--text); }
.wizard-steps li.done { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--text-2); }
.order-form.is-wizard .step { display: none; }
.order-form.is-wizard .step.active { display: block; }
.review { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.review h3 { font-size: .95rem; margin: 0 0 8px; }
.review dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: .9rem; }
.review dt { color: var(--muted); }
.review dd { margin: 0; }

/* ---------- admin lists ---------- */
.list-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-row input:not([type="checkbox"]) { flex: 1 1 140px; }
.list-new { padding-bottom: 14px; margin-bottom: 6px; border-bottom: 2px solid var(--border); }

/* ---------- bars (single-series chart) ---------- */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: .88rem; padding: 2px 0; border-radius: 4px; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; }
.bar { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-value { font-variant-numeric: tabular-nums; color: var(--text); text-align: right; min-width: 3ch; }

/* ---------- login & public ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, var(--bg), color-mix(in srgb, var(--brand) 12%, var(--bg))); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.login-title { font-size: 1.2rem; font-weight: 650; }
.public-wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
.public-head { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }

/* ---------- language switch ---------- */
.lang-switch { padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-2); font-size: .85rem; white-space: nowrap; }
.lang-switch:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.lang-switch[lang="ar"] { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; }
.lang-switch.floating { position: absolute; top: 14px; right: 16px; background: var(--surface); }

/* ---------- Arabic / right-to-left ---------- */
[dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", "Arabic Typesetting", sans-serif; }
[dir="rtl"] .user-menu { margin-left: 0; margin-right: auto; }
[dir="rtl"] .menu { right: auto; left: 0; }
[dir="rtl"] .menu a, [dir="rtl"] .menu button { text-align: right; }
[dir="rtl"] .sidenav { border-right: 0; border-left: 1px solid var(--border); }
[dir="rtl"] .nav-badge { margin-left: 0; margin-right: auto; }
[dir="rtl"] .order-row-status { text-align: left; }
[dir="rtl"] .order-row-status .flags { justify-content: flex-start; }
[dir="rtl"] .route-end.right { text-align: left; }
[dir="rtl"] .route-track-line span { inset: 0 0 0 auto; }
[dir="rtl"] .route-ship { left: auto; right: var(--p, 0); transform: translateX(50%) scaleX(-1); }
[dir="rtl"] .timeline-item::before { left: auto; right: 9px; }
[dir="rtl"] .timeline-item .dot { margin: 5px 4px 0 0; }
[dir="rtl"] .timeline-stage { margin: 14px 28px 4px 0; }
[dir="rtl"] .table th { text-align: right; }
[dir="rtl"] .table .num { text-align: left; }
[dir="rtl"] .inbox-meta { align-items: flex-start; }
[dir="rtl"] .msg.mine { align-self: flex-start; }
[dir="rtl"] .msg:not(.mine) { align-self: flex-end; }
[dir="rtl"] .bar { border-radius: 4px 0 0 4px; }
[dir="rtl"] .bar-value { text-align: left; }
[dir="rtl"] .lang-switch.floating { right: auto; left: 16px; }
[dir="rtl"] .mono, [dir="rtl"] input[type="date"], [dir="rtl"] input[type="email"] { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .row-danger td:first-child { box-shadow: inset -3px 0 var(--danger); }
@media (max-width: 900px) {
  [dir="rtl"] .sidenav { left: auto; right: 0; transform: translateX(100%); }
  [dir="rtl"] .sidenav.open { transform: none; }
}
@media (max-width: 640px) {
  [dir="rtl"] .order-row-status { text-align: right; }
  [dir="rtl"] .order-row-status .flags { justify-content: flex-start; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
  .fleet-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .sidenav { position: fixed; top: 56px; left: 0; width: 240px; z-index: 25; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
  .sidenav.open { transform: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .user-name, .brand-text { display: none; }
}
@media (max-width: 640px) {
  .main { padding: 16px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .order-row { grid-template-columns: 1fr; }
  .order-row-status { text-align: left; }
  .order-row-status .flags { justify-content: flex-start; }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .wizard-steps { grid-template-columns: repeat(4, 1fr); }
  .wizard-steps li { font-size: 0; padding: 8px 0; }
  .wizard-steps li::first-letter { font-size: .9rem; }
  .route-ends { grid-template-columns: 1fr 1fr; }
  .route-track { grid-column: 1 / -1; grid-row: 2; }
  .route-code { font-size: 1.25rem; }
  .route-card .stage-strip li span { display: none; }
  .route-card .stage-strip li.current span { display: block; position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
  .route-card .stage-strip { margin-bottom: 16px; }
  .activity li { grid-template-columns: 1fr; gap: 0; }
  .filters > * { flex: 1 1 140px; }
  .filters > input[type="search"] { min-width: 0; flex-basis: 100%; }
  .bar-row { grid-template-columns: minmax(80px, 40%) 1fr auto; }
}
