:root {
    --navy: #0a2540;
    --navy-light: #12365c;
    --orange: #F07830;
    --orange-dark: #d4661f;
    --bg: #f5f7fa;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1a2433;
    --text-muted: #64748b;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --yellow: #ca8a04;
    --purple: #7c3aed;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }
body {
    margin: 0;
    overflow-x: hidden; /* one wide element (e.g. a table) shouldn't push the whole page sideways */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.topbar {
    background: var(--navy);
    border-bottom: 3px solid var(--orange);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
    height: 56px;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-suffix { color: var(--orange); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: #cbd5e1;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.92rem;
}
.nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.08); }
.nav a.active { color: #fff; background: var(--orange); }
.logout { color: #cbd5e1; font-size: 0.88rem; }
.logout:hover { color: #fff; }
.notif-wrap { position: relative; flex-shrink: 0; }
.notif-bell {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; font-size: 1.1rem; flex-shrink: 0;
    background: none; border: none; padding: 0; cursor: pointer;
    filter: grayscale(1) brightness(1.6);
}
.notif-bell:hover, .notif-bell[aria-expanded="true"] { filter: none; }
.notif-badge {
    position: absolute; top: -4px; right: -6px;
    background: var(--red); color: #fff; font-size: 0.62rem; font-weight: 700;
    min-width: 15px; height: 15px; border-radius: 8px; padding: 0 3px;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-panel {
    display: none; position: absolute; top: calc(100% + 10px); right: 0;
    width: 400px; max-width: 90vw; max-height: 70vh; overflow-y: auto;
    background: #fff; color: var(--navy); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18); z-index: 50;
}
.notif-panel.open { display: block; }
.notif-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; font-weight: 700; font-size: 0.88rem;
    border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff;
}
.notif-panel-head a { font-weight: 500; font-size: 0.8rem; }
.notif-panel-empty { padding: 20px 14px; color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.notif-row { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notif-panel .notif-row:last-child { border-bottom: none; }
.notif-row.unread { background: #fff7ed; }
.notif-row-main { font-weight: 600; font-size: 0.9rem; }
.notif-row-msg { font-size: 0.85rem; margin-top: 2px; }
/* Each changed field gets its own block, old/new stacked -- was one run-on line before
   (Amjad, 2026-08-27: "use separate lines for easier understanding at a glance"). */
.notif-container { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--navy); font-size: 0.8rem; margin-bottom: 4px; }
.notif-change { margin-top: 6px; }
.notif-change:first-of-type { margin-top: 0; }
.nc-label { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted); }
.nc-old { font-size: 0.82rem; color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border); }
.nc-new { font-size: 0.85rem; font-weight: 600; }
.notif-row-time { font-size: 0.76rem; margin-top: 2px; }
.quick-add {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--orange); color: #fff !important; font-size: 1.2rem; font-weight: 700;
    line-height: 1; text-decoration: none !important; flex-shrink: 0;
}
.quick-add:hover { background: var(--orange-dark); }
/* Second quick-add shortcut (Amjad, 2026-08-27: "like we have a add buy rate shortcut...
   need another for create quote") -- navy instead of orange so the two are tellable apart
   at a glance without reading the tooltip, not just two identical orange "+" circles. */
.quick-add-quote { background: var(--navy); }
.quick-add-quote:hover { background: var(--navy-light); }

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}
.page.wide { max-width: 1680px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head .sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.btn {
    display: inline-block;
    background: var(--orange);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--orange-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f1f5f9; color: var(--navy); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.wa-btn { background: #25d366; }
.btn.wa-btn:hover { background: #1fb855; }
.btn.action { background: #fef6d6; color: #92400e; border: 1px solid #fde68a; font-weight: 400; }
.btn.action:hover { background: #fdeab3; color: #78350f; }
.btn.action.small { padding: 5px 10px; font-size: 0.8rem; }
.btn.win-btn { background: #fff; color: var(--green); border: 1px solid var(--border); }
.btn.win-btn:hover { background: #f0fdf4; color: #128a3e; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }
.btn.tiny { padding: 3px 9px; font-size: 0.74rem; }

.link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.88rem;
    color: var(--orange-dark);
    cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.archive-link { color: var(--text-muted); }
.link-btn.archive-link:hover { color: var(--red); }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
}

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.filters input, .filters select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.88rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
/* Scroll wrapper for wide tables — putting overflow on a wrapper div (not the
   table itself) keeps the table a real <table> box so width:100% still stretches
   it to fill the page; display:block on the table broke that. */
.table-scroll { overflow-x: auto; }
.scroll-list { max-height: 420px; overflow-y: auto; }
.scroll-list th { position: sticky; top: 0; z-index: 1; }
.table-scroll table { min-width: 100%; }
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
    vertical-align: top;
}
th {
    background: #f1f5f9;
    color: var(--navy);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
a.sort-link { color: inherit; }
a.sort-link:hover { color: var(--orange-dark); text-decoration: none; }
.sort-arrow { color: var(--orange); font-size: 0.6rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfd; }
table.dense th, table.dense td { padding: 6px 9px; font-size: 0.86rem; }
/* Freight and Charges grids (quote_view.php) -- fixed layout with the same column widths
   on every instance, so the 20'/40' boundaries line up as you scroll from one table to the
   next instead of each table auto-sizing its columns independently. */
.charge-grid { table-layout: fixed; }
.charge-grid th:first-child, .charge-grid td:first-child { width: 40%; }
.charge-grid th:not(:first-child), .charge-grid td:not(:first-child) { width: 30%; }
/* A flat charge (no size) sits in the 20' cell (text-align:center on the td), then this
   inline-block wrapper nudges right of dead-center via a plain relative offset -- stays in
   normal flow (unlike position:absolute, which pulled it out of flow entirely and collapsed
   every row's height, overlapping the rows below it -- reverted 2026-08-24). Target span is
   the 20' column's start to roughly the 40' column's data (not its full width) -- Amjad
   marked it with red lines 2026-08-24 at ~40%-82% of the table width; centered = ~61%,
   which is 55% (dead-center of the 20' cell) + 6% of the table (20% of this 30%-wide cell). */
.charge-cell-flat { display: inline-block; position: relative; left: 20%; }
/* Same label-column width as .charge-grid above, so the Service / Buying rate reference
   tables' value column lines up with the Charges/Freight tables' value columns too. */
.label-value-grid { table-layout: fixed; }
.label-value-grid th:first-child, .label-value-grid td:first-child { width: 40%; }
/* td.charge-label (not just .charge-label) -- needs 2 classes + a type selector to beat
   "table.dense td" (0,1,2) elsewhere, which was silently winning and keeping this at
   0.86rem regardless of what was set here (Amjad caught this, 2026-08-22). */
.charge-grid td.charge-label { font-size: 0.978rem; }
/* Freight label -- 1.3x the base 1rem, all caps; its Sell figure and Buy/Margin subline
   below are scaled by the same 1.3x ratio, so the whole Freight row grows in proportion.
   (All charge-grid font sizes scaled to 85% of their prior values 2026-08-24, keeping every
   ratio between them exactly as it was -- Amjad wanted a uniform "zoom out", not a re-tune.) */
.charge-grid td.charge-label.charge-label-emphasize { font-size: 1.105rem; text-transform: uppercase; }
.charge-sell { font-size: 0.893rem; font-weight: 700; color: var(--navy); display: block; }
.freight-grid-table .charge-sell { font-size: 1.009rem; }
/* Plain inline (not flex) so it follows the parent td's text-align -- a flex row ignores
   text-align and would always pack to the left, misaligning under a centered Sell figure. */
.charge-subline { margin-top: 3px; font-size: 0.663rem; }
.freight-grid-table .charge-subline { font-size: 0.7rem; font-weight: 500; }
.charge-subline .buy-fold { display: block; margin-top: 1px; }
.charge-subline .buy { color: var(--text-muted); margin-right: 8px; }
.charge-subline .margin { color: var(--text-muted); }
#charges-card.hide-buy-margin .charge-subline { display: none; }
/* A charge folded into freight, shown for reference right under the Freight row -- smaller
   and not bold so it reads as "already included above", not as an additional charge
   (Amjad, 2026-08-24). Higher specificity needed to beat .freight-grid-table's own
   emphasized sizing above. */
.charge-grid td.charge-label.charge-label-muted { font-size: 0.731rem; font-weight: 400; text-transform: none; color: var(--text-muted); }
.freight-grid-table .charge-sell-muted { font-size: 0.731rem; font-weight: 400; color: var(--text-muted); display: block; }
.freight-grid-table .charge-subline-muted { font-size: 0.638rem; font-weight: 400; }
table.dense .inline-rate { margin-bottom: 0; }
tr.stale-row td { background: #fffbeb; }
tr.stale-row:hover td { background: #fef3c7; }
td.actions { white-space: nowrap; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.route { font-weight: 600; }
/* The Q-32/BK-2 hint was breaking mid-token when the route text itself wrapped (a long
   destination like "Southampton" pushing it onto a new line as "...Q-\n32") -- give it its
   own line always, so it never competes with the port names for space. */
.route .hint { display: block; white-space: nowrap; margin-top: 2px; }
.notes-cell { max-width: 220px; white-space: pre-wrap; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge.active, .badge.won { background: #dcfce7; color: var(--green); }
.badge.expired, .badge.lost { background: #fee2e2; color: var(--red); }
.badge.pending { background: #fef3c7; color: var(--amber); }
.badge.muted { background: #f1f5f9; color: var(--text-muted); }
.badge.stale { background: #fef3c7; color: var(--amber); }
.badge.trade-Gulf { background: #fef3c7; color: #92400e; }
.badge.trade-Europe { background: #dbeafe; color: #1e40af; }
.badge.trade-USA { background: #e0e7ff; color: #3730a3; }
.badge.trade-Fareast { background: #d1fae5; color: #065f46; }
.badge.trade-Oceania { background: #cffafe; color: #155e75; }
.badge.trade-Africa { background: #fce7f3; color: #9d174d; }
.badge.booking_placed { background: #f1f5f9; color: var(--text-muted); }
.badge.cro_sent { background: #fef3c7; color: var(--amber); }
.badge.picked_up { background: #dcfce7; color: var(--green); }
.badge.esi_received { background: #dbeafe; color: #1d4ed8; }
.badge.checking_copy_sent { background: #dbeafe; color: #1d4ed8; }
.badge.bl_confirmed { background: #dbeafe; color: #1d4ed8; }
.badge.loaded_on_vessel { background: #e0e7ff; color: #4338ca; }
.badge.invoice_sent { background: #e0e7ff; color: #4338ca; }
.badge.payment_received { background: #dcfce7; color: var(--green); }
.badge.bl_released { background: #dcfce7; color: var(--green); }
.badge.complete { background: var(--green); color: #fff; }
.badge.fell_through { background: #fee2e2; color: var(--red); }
.badge.trade-Other { background: #f1f5f9; color: var(--text-muted); }
.badge.orange { background: #fef3c7; color: var(--amber); }
.star { color: #d97706; font-weight: 700; }

.lane-picker {
    max-height: 260px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
}
.lane-picker-compact { max-height: 160px; margin-bottom: 4px; border-radius: 4px; }
.lane-picker-compact th, .lane-picker-compact td { padding: 4px 8px; font-size: 0.8rem; }
.lane-picker table { border: none; border-radius: 0; }
.lane-picker tr[data-id] { cursor: pointer; }
.lane-picker tr[data-id]:hover td { background: #fff7ed; }
.lane-picker tr.selected td { background: #ffedd5; }
.lane-picker th { position: sticky; top: 0; z-index: 1; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 5px;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.radio-group { display: flex; gap: 16px; align-items: center; height: 38px; }
.radio-opt { display: flex !important; align-items: center; gap: 5px; font-weight: 400 !important; font-size: 0.9rem !important; color: var(--text) !important; margin: 0 !important; cursor: pointer; }
.radio-opt input { width: auto !important; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; align-items: center; }

.section-h {
    font-size: 1rem;
    color: var(--navy);
    margin: 28px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}
.section-h:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.hint { color: var(--text-muted); font-weight: 400; font-size: 0.82rem; text-transform: none; letter-spacing: normal; }

.line-table { margin-bottom: 10px; }
.line-table th { white-space: normal; }
.line-table input, .line-table select {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.9rem;
}
.line-table td { vertical-align: middle; }

.preview-box {
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    color: var(--text);
    margin-bottom: 8px;
    min-height: 60px;
}

.lane-layout {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 16px;
    align-items: start;
}
.lane-layout.quote-layout { grid-template-columns: 3fr 1fr; }
.preview-col .preview-sticky { position: sticky; top: 16px; }
.preview-col .preview-box { font-size: 0.76rem; padding: 10px 12px; min-height: 40px; }
@media (max-width: 900px) {
    .lane-layout { grid-template-columns: 1fr; }
    .preview-col .preview-sticky { position: static; }
}

/* Shifted right (not flush left) instead of matching the charges table's column widths —
   widening charges' 20'/40' to match freight's squeezed every other charges column
   (Type/Basis/Side/Cur/Margin/Fold all overlapped). This gets the two tables' 20' columns
   roughly under each other without breaking the charges row. Approximate, not exact — the
   charges table's Label/Type widths are percentage-based and shift with viewport width. */
.freight-grid { max-width: 460px; margin: 0 0 8px 124px; border-collapse: collapse; table-layout: fixed; }
.freight-grid th, .freight-grid td { text-align: center; }
.freight-grid thead th { color: var(--navy); font-weight: 700; font-size: 0.95rem; }
.freight-grid th:first-child, .freight-grid td:first-child {
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    font-weight: 700;
    width: 140px;
}
.freight-grid th:nth-child(2), .freight-grid td:nth-child(2),
.freight-grid th:nth-child(3), .freight-grid td:nth-child(3) { width: 160px; }
.freight-grid input { text-align: center; width: 100%; }
.datasheet .freight-grid th, .datasheet .freight-grid td { padding: 10px 12px; }
.datasheet .freight-grid input { font-size: 1.3rem; padding: 10px 8px; }
.freight-grid .sell-row input { font-weight: 700; }
.freight-grid .margin-row input { color: var(--green); font-weight: 600; }

.charge-line-table { table-layout: fixed; width: 100%; min-width: 900px; }
.charge-line-table .col-label { width: 100%; }
.charge-line-table th:first-child, .charge-line-table td:first-child { width: 28px; }
.charge-line-table .type-select { font-size: 0.8rem; width: 100%; }
.charge-line-table th:nth-child(2), .charge-line-table td:nth-child(2) { width: 17%; }
.charge-line-table th:nth-child(3), .charge-line-table td:nth-child(3) { width: 90px; }
.charge-line-table .col-20, .charge-line-table .col-40, .charge-line-table .col-flat-buy, .charge-line-table .col-margin { width: 100%; min-width: 0; }
.charge-line-table th:nth-child(4), .charge-line-table td:nth-child(4),
.charge-line-table th:nth-child(5), .charge-line-table td:nth-child(5) { width: 92px; }
.charge-line-table td:nth-child(4), .charge-line-table td:nth-child(5) { padding: 8px 10px; }
.charge-line-table th:nth-child(10), .charge-line-table td:nth-child(10) { width: 8%; }
.charge-line-table .col-margin { color: var(--green); font-weight: 600; }
.charge-line-table .col-flat-basis { width: 100%; }
.charge-line-table th:nth-child(6), .charge-line-table td:nth-child(6) { width: 9%; }
.charge-line-table th:nth-child(7), .charge-line-table td:nth-child(7) { width: 9%; }
.charge-line-table .col-side, .charge-line-table .col-currency, .charge-line-table .col-fold { width: 100%; }
.charge-line-table th:nth-child(8), .charge-line-table td:nth-child(8) { width: 13%; }
.charge-line-table th:nth-child(9), .charge-line-table td:nth-child(9) { width: 8%; }
.charge-line-table th:nth-child(11), .charge-line-table td:nth-child(11) { width: 11%; }
.charge-line-table .col-fold { font-size: 0.78rem; }
/* Class-targeted, not nth-child — this column only exists on quotes_form.php (buying_form.php
   has no message to include/exclude charges from), so its position isn't the same across
   both pages the way the other columns are. */
.charge-line-table .include-col { width: 46px; text-align: center; }
.charge-line-table .col-include { width: auto; }
.charge-line-table th:last-child, .charge-line-table td:last-child { width: 32px; }
.charge-line-table td.size-only, .charge-line-table td.flat-only { transition: none; }
.charge-line-table td.js-hidden { visibility: hidden; }
.charge-line-table .drag-handle {
    cursor: grab;
    text-align: center;
    color: var(--text-muted);
    touch-action: none;
    user-select: none;
    font-size: 1rem;
}
.charge-line-table .charge-row.dragging { opacity: 0.5; background: #fff7ed; }

.expiry-note {
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 14px 0;
}
.expiry-note b { color: var(--text); }

.terms-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; }
.terms-row .terms-inclusions { flex: 1; min-width: 200px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.88rem; }
.mini-field { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.mini-field input { width: 56px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.88rem; text-align: right; }

/* Datasheet look: fields read as one continuous grid of cells (Excel-style
   gridlines via a 1px background gap), not separate rounded boxes with padding. */
.datasheet.card { padding: 14px 16px; border-radius: 4px; }
.datasheet .section-h { font-size: 0.78rem; margin: 16px 0 6px; padding-top: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }
.datasheet .section-h:first-of-type { margin-top: 0; padding-top: 0; }
.datasheet .section-h .hint { text-transform: none; letter-spacing: normal; font-size: 0.78rem; }

.datasheet .form-grid {
    background: var(--border);
    border: 1px solid var(--border);
    gap: 1px;
    max-width: none;
}
/* The top identity/route grid (Carrier..Trade): label inline with its value
   ("Carrier name : OOCL") instead of stacked above it — stacked was cramping badly at the
   narrow widths this needs to fit into. */
.form-grid.inline-fields .field {
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-grid.inline-fields .field label {
    margin-bottom: 0 !important;
    white-space: nowrap;
    flex: 0 0 auto;
}
.form-grid.inline-fields .field label::after { content: ':'; }
.form-grid.inline-fields .field input,
.form-grid.inline-fields .field select {
    flex: 1;
    min-width: 0;
}

.datasheet .form-grid .field {
    background: var(--card);
    padding: 5px 8px;
}
.datasheet .field label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 1px;
    font-weight: 700;
}
.datasheet .field label .hint { display: none; }
.datasheet .field input,
.datasheet .field select {
    border: none;
    border-radius: 0;
    padding: 3px 0;
    font-size: 0.94rem;
    background: transparent;
}
.datasheet .field input:focus,
.datasheet .field select:focus {
    outline: 2px solid var(--orange);
    outline-offset: -1px;
    background: #fff7ed;
}

.datasheet .line-table { border-radius: 0; border-collapse: collapse; }
.datasheet .line-table th,
.datasheet .line-table td {
    padding: 4px 7px;
    font-size: 0.88rem;
}
.datasheet .line-table input,
.datasheet .line-table select {
    border: none;
    border-radius: 0;
    padding: 4px 5px;
    background: transparent;
    font-size: 0.9rem;
}
.datasheet .line-table input:focus,
.datasheet .line-table select:focus {
    outline: 2px solid var(--orange);
    outline-offset: -1px;
    background: #fff7ed;
}
.datasheet .btn.secondary.small { border-radius: 3px; }

details.more-details {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
details.more-details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--navy);
    font-size: 0.95rem;
}
details.more-details summary:hover { color: var(--orange-dark); }

.inline-rate { margin-bottom: 2px; }
.inline-rate .ir-display {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-muted);
}
.inline-rate .ir-display:hover { color: var(--orange-dark); border-bottom-color: var(--orange-dark); }
.inline-rate .ir-edit input {
    width: 60px;
    padding: 3px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.82rem;
}
.inline-rate .ir-edit button {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 2px;
}
.inline-rate .ir-save { color: var(--green); }
.inline-rate .ir-cancel { color: var(--red); }

.flash {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
}
.stat-card .n { font-size: 1.8rem; font-weight: 700; color: var(--navy); }
.stat-card .l { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* Compact read-only summary line — for View pages. One line per logical group,
   not a form-field grid (labels-above-values eats far too much vertical space
   for data you're only reading, not editing). Explicit feedback, 2026-08-19. */
.info-line { font-size: 0.88rem; line-height: 1.7; margin-bottom: 2px; }
.info-line b { color: var(--navy); font-weight: 600; margin-right: 3px; }
.info-line .sep { color: var(--border); margin: 0 8px; }
.info-line .badge { vertical-align: middle; }
/* Internal buy/sell panel -- two rows of three columns (Amjad, 2026-08-28: Buy/Margin/Sell
   left/center/right, then Rebate to customer/Rebate USD/Margin net of rebate below it). */
.internal-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; font-size: 0.88rem; margin-top: 8px; }
.internal-row:first-of-type { margin-top: 0; }
.internal-row b { color: var(--navy); font-weight: 600; margin-right: 3px; }
.internal-row .il-left { text-align: left; }
.internal-row .il-center { text-align: center; }
.internal-row .il-right { text-align: right; }

.smart-date-hint { display: block; font-size: 0.76rem; margin-top: 3px; min-height: 1em; }

.typeahead-wrap { position: relative; }
.typeahead-list {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 30;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 2px;
}
.typeahead-list.open { display: block; }
.typeahead-item { padding: 8px 12px; font-size: 0.88rem; cursor: pointer; }
.typeahead-item:hover, .typeahead-item.active { background: #fff7ed; }

.highlight-box {
    background: #fff7ed;
    border: 1px solid #fde3c8;
    border-left: 4px solid var(--orange);
    border-radius: 6px;
    padding: 10px 14px;
}
.highlight-box .info-line { font-size: 1rem; font-weight: 600; color: var(--navy); }
.highlight-box .info-line b { color: var(--text); font-weight: 700; }

/* Reusable linear status stepper — done (green, checkmark) / current (orange, filled) /
   upcoming (grey, outline). Each step is its own tiny form so clicking it posts that status. */
/* Compact list-row version of the stepper below -- small dots/connectors, no labels (hover
   for the current step's name via the title attribute). */
.mini-stepper { display: flex; align-items: center; min-width: 90px; }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: 0 0 auto; }
.mini-dot.done { background: var(--green); }
.mini-dot.current { width: 11px; height: 11px; background: var(--orange); }
.mini-line { flex: 1 1 14px; height: 2px; background: var(--border); margin: 0 2px; }
.mini-line.done { background: var(--green); }

.status-stepper { display: flex; align-items: flex-start; margin: 10px 0 18px; flex-wrap: wrap; }
.status-stepper .step { display: contents; }
.step-btn {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 4px 10px; font-family: inherit;
}
.next-action {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.next-action-desc { font-size: 0.85rem; color: var(--text-muted); flex: 1 1 auto; }
.next-action-hint {
    margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
    font-size: 0.85rem; color: var(--text-muted); font-style: italic;
}
.step-dot {
    width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; font-size: 0.8rem; font-weight: 700;
    border: 2px solid var(--border); color: var(--text-muted); background: var(--card);
}
.step-label { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
.step.done .step-dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.done .step-label { color: var(--green); }
.step.current .step-dot { background: var(--orange); border-color: var(--orange); color: #fff; }
.step.current .step-label { color: var(--navy); font-weight: 700; }
/* Overdue step -- a later auto-marked step already happened but this one hasn't. */
.step.urgent .step-dot { border-color: var(--red); color: var(--red); }
.step.urgent .step-label { color: var(--red); font-weight: 700; }
/* Branch step (e.g. "Cancelled") — a non-linear exit, not part of the done/current/upcoming
   sequence, so it always reads red rather than grey-upcoming even when not the current status. */
.step.branch .step-dot { border-color: var(--red); color: var(--red); }
.step.branch .step-label { color: var(--red); }
.step.branch.current .step-dot { background: var(--red); border-color: var(--red); color: #fff; }
.step.branch.current .step-label { font-weight: 700; }
.step-line { width: 32px; height: 2px; background: var(--border); margin: 13px 0 0; align-self: flex-start; }
.step-line.done { background: var(--green); }
@media (max-width: 560px) {
    .step-label { display: none; }
    .step-line { width: 16px; }
}

/* Quick price glance on the booking page — a subdetail under the heading, not a callout box. */
.booking-price-glance {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: -6px 0 18px;
}

/* Read-only booking details — title above value, no highlight box, not bold. A row of
   content-sized cells (flex, not a fixed-column grid, since different rows on this page have
   different item counts) instead of a stretched grid that left empty gaps next to short
   values like "1x20'". Wraps naturally on narrow screens, no breakpoint needed. */
.detail-grid { display: flex; flex-wrap: wrap; gap: 18px 22px; }
.detail-cell { flex: 0 1 auto; min-width: 90px; }
.summary-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 2px;
}
.summary-value { font-size: 0.85rem; font-weight: 400; color: var(--navy); }
.detail-grid .summary-label { font-size: 0.7rem; }
.detail-grid .summary-value { font-size: 0.9rem; }
.vessel-table th, .vessel-table td { font-size: 0.9rem; padding: 5px 8px; }
.vessel-table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 400; }
.vessel-table input { font-size: 0.9rem; }

/* Two cards side by side on the booking page (Details / Containers) — each sized by its own
   content, not forced to match the other's width. */
.booking-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 720px) {
    .booking-two-col { grid-template-columns: 1fr; }
}

/* Parsed container numbers, shown as chips under the raw paste box so what got recognized
   is easy to confirm at a glance. Colored per-container once tracking data exists, so with
   several containers it's obvious at a glance which one specifically has a hold. */
.container-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
    background: #eef2f7;
    color: var(--navy);
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: ui-monospace, Consolas, monospace;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
/* Distinguishes "loaded" from just "no active hold" -- the dot color alone only tells you
   the hold status, not whether it's actually loaded yet. Green chip background, same shade
   as the Position column's loaded highlight (Amjad, 2026-08-25: swapped from a checkmark
   icon to this, to match). */
.chip.loaded { background: #dcfce7; color: var(--green); }
/* Same red highlight as the Position column's rollover flag (bookings.php/dashboard.php),
   now also on the individual container chip it actually belongs to, not just the two list
   pages (Amjad, 2026-08-31: "do it in the booking detail too"). Loaded still wins if a
   container is somehow both (matches the same precedence used everywhere else this shows). */
.chip.rolled { background: #fee2e2; color: var(--red); }

/* Small inline icon button next to a label — e.g. the pencil to reopen a collapsed field. */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0 0 0 4px;
    color: var(--text-muted);
    opacity: 0.6;
    vertical-align: middle;
}
.icon-btn:hover { color: var(--orange); opacity: 1; }

/* Color dot — the hold-urgency indicator, reused on chips and the tracking rows. */
/* display:inline-block so width/height always apply -- a plain <span> ignores them unless
   it's a flex item or has its own display set, which silently made this invisible after
   moving it out of a flex wrapper (Amjad, 2026-08-27: "status lights are not showing"). */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--border); vertical-align: middle; margin-right: 2px; }
.dot-green .dot, .dot-green.dot { background: var(--green); }
.dot-yellow .dot, .dot-yellow.dot { background: var(--yellow); }
.dot-orange .dot, .dot-orange.dot { background: var(--amber); }
.dot-red .dot, .dot-red.dot { background: var(--red); }
.dot-none .dot, .dot-none.dot { background: var(--border); }
.dot-purple .dot, .dot-purple.dot { background: var(--purple); }
.dot-unknown .dot, .dot-unknown.dot { background: var(--border); border: 1px dashed var(--text-muted); }
.cell-highlight-amber { background: #fef3c7; color: var(--amber); border-radius: 4px; padding: 2px 8px; font-weight: 600; display: inline-block; }
.cell-highlight-green { background: #dcfce7; color: var(--green); border-radius: 4px; padding: 2px 8px; font-weight: 600; display: inline-block; }
.cell-highlight-red { background: #fee2e2; color: var(--red); border-radius: 4px; padding: 2px 8px; font-weight: 600; display: inline-block; }

/* Per-container tracking — status/position is the priority item (shown first, larger),
   holds directly under it. Vessel/ETA/ETD/actual sit in their own column so they visually
   mirror the Details card's own Vessel/Cutoff/ETD above, making a mismatch easy to spot. */
.tracking-list { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.tracking-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.tracking-row:last-child { border-bottom: none; }
.tracking-head { display: flex; align-items: center; gap: 8px; }
.tracking-container-no { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--navy); font-size: 0.9rem; }
.tracking-body { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0 0 20px; }
.tracking-main { flex: 1 1 200px; }
.tracking-status { font-size: 0.95rem; font-weight: 600; color: var(--navy); }
.tracking-holds { font-size: 0.85rem; color: var(--amber); margin-top: 2px; }
.tracking-mirror { flex: 1 1 220px; max-width: 100%; }
.tracking-mirror-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tracking-mirror-row .summary-label { margin-bottom: 0; white-space: nowrap; }
.tracking-mirror-row .summary-value { overflow-wrap: break-word; word-break: break-word; min-width: 0; }
.tracking-alert {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #fee2e2; color: var(--red); border-radius: 6px;
    padding: 8px 12px; margin: 8px 0 0 20px; font-size: 0.85rem; font-weight: 600;
}

.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 360px;
}
.login-box h1 { margin: 0 0 4px; font-size: 1.3rem; color: var(--navy); }
.login-box .sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 24px; }
.login-box .error { color: var(--red); font-size: 0.85rem; margin-top: 10px; }
.login-box button { width: 100%; margin-top: 14px; }

.menu-toggle { display: none; }
.mobile-menu { display: none; }

@media (max-width: 720px) {
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .nav { display: none; }
    .logout { display: none; } /* moved into the mobile menu */

    /* .nav was the flex:1 spacer keeping notif-wrap pinned to the right of the topbar --
       hiding it left notif-wrap (and the notif panel anchored to it via right:0) sitting
       right after the logo, near the LEFT edge on a narrow phone, so the 400px/90vw panel
       opened mostly off-screen to the left (Amjad, 2026-08-31, screenshot showed it clipped
       and overlapping the page behind it). Give notif-wrap its own spacer instead. */
    .notif-wrap { margin-left: auto; }

    /* Below this width, .tracking-main and .tracking-mirror (flex:1 1 ~200-220px, both
       shrinkable) still fit side by side by squeezing rather than wrapping -- flex-wrap only
       forces a new line once shrinking can't fit them, and shrinking always "can". Forcing
       full-width basis here removes that option, so they stack instead of squeezing ETA/ETD
       text down to a sliver (Amjad, 2026-08-31, screenshot showed dates cut off mid-string). */
    .tracking-main, .tracking-mirror { flex-basis: 100%; }

    /* The 124px left margin (desktop-only) lines the Freight grid's 20' column up under the
       Charges table's own 20' column -- but the Charges table switches to a stacked card
       layout at this same breakpoint, so that alignment no longer applies, and the margin
       was just pushing Freight off the right edge of the screen instead (124px + 460px max
       width doesn't fit any phone). Quotes/Buying Rate forms didn't open usably on mobile
       because of this (Amjad, 2026-08-25). Percentage widths instead of the fixed 140/160/160
       so it actually fits. */
    .freight-grid { margin-left: 0; max-width: 100%; width: 100%; }
    .freight-grid th:first-child, .freight-grid td:first-child { width: 30%; }
    .freight-grid th:nth-child(2), .freight-grid td:nth-child(2),
    .freight-grid th:nth-child(3), .freight-grid td:nth-child(3) { width: 35%; }
    .datasheet .freight-grid input { font-size: 1.05rem; padding: 8px 4px; }

    /* Hamburger opens a full-width dropdown with every page — tapped open, not
       permanently on screen, so it doesn't eat into the data below it. */
    .menu-toggle {
        display: block;
        background: none;
        border: none;
        color: #fff;
        font-size: 1.4rem;
        line-height: 1;
        padding: 6px 4px;
        cursor: pointer;
        margin-left: auto;
    }
    .mobile-menu {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 56px; left: 0; right: 0;
        background: var(--navy);
        border-bottom: 3px solid var(--orange);
        z-index: 20;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }
    .mobile-menu.open { display: flex; }
    .mobile-menu a {
        color: #cbd5e1;
        padding: 14px 18px;
        font-size: 0.95rem;
        font-weight: 600;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .mobile-menu a.active { color: #fff; background: var(--orange); }
    .mobile-menu a.logout-link { color: #fca5a5; }

    .topbar-inner { padding: 0 14px; gap: 12px; }

    .page { padding: 16px 12px 40px; }
    .card, .datasheet.card { padding: 14px; }
    .page-head h1 { font-size: 1.25rem; }

    .stat-card { padding: 12px 14px; }
    .stat-card .n { font-size: 1.4rem; }

    .lane-layout, .lane-layout.quote-layout { grid-template-columns: 1fr; }

    .preview-box { font-size: 0.8rem; padding: 12px; }

    th, td { padding: 8px 8px; font-size: 0.82rem; }
    table.dense th, table.dense td { padding: 4px 6px; font-size: 0.78rem; }

    .login-box { padding: 28px 22px; }

    /* Charges table -> stacked cards. A wide data-entry table with a select/input in every
       cell just doesn't have a usable narrow form — this is a genuinely different mobile
       layout for the same markup, not a shrink. Each row becomes a card; each cell becomes
       a labeled line (label text comes from data-th, added in charge_row.php) stacked
       vertically instead of a fixed-width column. */
    .charge-line-table { min-width: 0; table-layout: auto; }
    .charge-line-table, .charge-line-table tbody { display: block; width: 100%; }
    .charge-line-table tr:first-child { display: none; } /* header row — labels move onto each field instead */
    .charge-line-table .charge-row {
        display: block;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px 12px;
        margin-bottom: 10px;
    }
    .charge-line-table .charge-row td {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100% !important;
        padding: 7px 0;
        border: none;
    }
    .charge-line-table .charge-row td.js-hidden { display: none; }
    .charge-line-table .charge-row td[data-th=""] { display: block; } /* remove button / drag handle — no label, full width */
    .charge-line-table .charge-row td.drag-handle {
        font-size: 1.4rem;
        padding: 2px 0 8px;
        border-bottom: 1px dashed var(--border);
        margin-bottom: 6px;
    }
    .charge-line-table .charge-row td[data-th]:not([data-th=""])::before {
        content: attr(data-th);
        flex: 0 0 84px;
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: var(--text-muted);
    }
    .charge-line-table .charge-row td input,
    .charge-line-table .charge-row td select {
        flex: 1;
        min-width: 0;
        font-size: 1rem;
        padding: 8px 10px;
    }
    .charge-line-table .charge-row .js-remove-row { width: 100%; margin-top: 4px; font-size: 0.95rem; padding: 10px; }
}

@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    /* Stays 2 columns even here (not 1) — halves the scroll for the 7-field freight block
       (Currency + Buy/Margin/Sell x2 sizes); number inputs don't need full width to be usable. */
    .page { padding: 12px 8px 32px; }
    .card, .datasheet.card { padding: 10px; }
}

/* Invoice (invoice_view.php) -- a real printable document, styled to match Flash's actual
   Excel-template invoices (same header block, same charges table shape), not just another
   in-app card. Kept in the app's own navy/orange palette (theme-factory's flash-logistics
   theme is pulled from this same stylesheet, so this already matches it). */
/* Real A4 dimensions (210mm x 297mm) -- so the on-screen preview is the actual page size/
   proportions the printed PDF will be, not just an arbitrary card width (Amjad, 2026-08-26:
   "can i have it exactly how it wold fill on the a4 size pdf"). mm units render correctly for
   on-screen layout too (browsers assume 96dpi), not just @media print. */
.invoice-sheet {
    background: #fff;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 15mm 18mm;
    border: 1px solid var(--border);
    box-shadow: 0 2px 16px rgba(0,0,0,0.1);
    color: var(--text);
    font-size: 0.78rem;
    line-height: 1.4;
    /* Plain system Arial (Amjad, 2026-08-26: "limit to 2 fonts total" -- Arial everywhere
       except the charges table, no web font to load). */
    font-family: Arial, Helvetica, sans-serif;
    font-feature-settings: 'tnum' 1; /* tabular figures -- amount columns line up cleanly */
}
/* Whitespace direction (Amjad, 2026-08-26): Flexport/CMA CGM references -- no grid borders,
   spacing alone organizes the page; only a single hairline rule survives, above the total. */
.invoice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.invoice-logo-row { display: flex; align-items: center; gap: 10px; }
.invoice-logo-text { display: flex; flex-direction: column; gap: 4px; }
.invoice-logo-icon { height: 63px; width: auto; }
.invoice-logo-wordmark { height: 36px; width: auto; }
.invoice-logo-tagline { height: 17px; width: auto; margin-left: 1px; }
.invoice-head-right { text-align: right; }
.invoice-title { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.09em; color: var(--orange-dark); margin: 0 0 10px; }
.ihr-row { font-size: 0.78rem; margin-top: 3px; color: var(--text); }
.ihr-row .lbl { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-right: 5px; }
.ihr-row b { font-weight: 400; }

/* "Bill To" block. The site-wide `table { overflow:hidden; border-radius:10px }` (for card-
   style data tables elsewhere) was clipping the very first glyph of "Invoice To" against that
   rounded corner (Amjad, 2026-08-26: "the I is still half cut") -- these invoice tables are
   deliberately plain/borderless already, so opt all the way out of that card styling. Same
   reset applied to .invoice-charges and .invoice-bank-table below. */
.invoice-bill-to { width: 100%; border-collapse: collapse; margin-bottom: 14px; overflow: visible; border-radius: 0; background: transparent; border: none; }
.invoice-bill-to td { width: 50%; padding: 0; vertical-align: top; }
.invoice-bill-to td:first-child { padding-right: 24px; }
/* All body/data text on the sheet is one size now, no hierarchy by section (Amjad,
   2026-08-26: "make them all the same size" -- name, shipment details, charges, totals). */
.ibt-name { font-size: 0.78rem; font-weight: 400; color: var(--text); margin-top: 2px; text-transform: uppercase; }
.ibt-caps { text-transform: uppercase; }

.invoice-sec-head { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--navy); border-bottom: 1px solid var(--border); padding-bottom: 5px; margin-bottom: 10px; }

/* Shipment details -- CSS grid, no borders at all; spacing does the organizing. */
.invoice-details-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 10px; margin-bottom: 14px; }
.im-label { font-size: 0.58rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.im-value { font-size: 0.78rem; font-weight: 400; color: var(--text); margin-top: 1px; }
.invoice-details-grid .im-value { text-transform: uppercase; }

/* Container # -- full width of its own so a long list (many boxes) just wraps, no truncation. */
.invoice-container-full { margin-bottom: 14px; }
.invoice-container-full .im-value { line-height: 1.6; }

/* Charges table -- only the header row keeps a rule; body rows separated by spacing, not
   borders, matching the whitespace direction. One font for the whole sheet now (Amjad,
   2026-08-26: "drop to one font" -- the Microsoft Sans Serif/Arial split wasn't visibly
   distinct enough to be worth it). Freight lines read "Ocean Freight -- 20' Container" in
   normal case on purpose (Amjad: "always mention freight as..."); other charge labels are
   stored upper-case already (see invoice_form.php), not forced by CSS here, so the freight
   exception isn't overridden. */
.invoice-charges { width: 100%; table-layout: fixed; border-collapse: collapse; margin-bottom: 0; overflow: visible; border-radius: 0; background: transparent; border: none; }
.invoice-charges th { background: none; color: var(--text-muted); text-align: left; padding: 0 6px 6px 0; font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
/* Hairline row dividers, slightly more visible than the header's own rule so rows read
   clearly at a glance without turning into a heavy grid (Amjad, 2026-08-28, picking the
   artifact's Option 1: "just a little more prominent very little"). */
.invoice-charges td { padding: 4px 6px; font-size: 0.78rem; border: none; border-bottom: 1px solid #dbe1e8; overflow-wrap: break-word; }
.invoice-charges tr:last-child td { border-bottom: none; }
/* Columns: 1 S# / 2 Charges / 3 Currency / 4 Rate / 5 Qty / 6 Amount USD / 7 Amount <local>.
   Currency got split out into its own real column, left-aligned, instead of sharing the Rate
   cell (Amjad, 2026-08-28: "add a currency label before rate... keep the heading and values
   of currency left aligned") -- Rate/Qty/Amount columns stay right-aligned as numbers. */
.invoice-charges td:last-child, .invoice-charges th:last-child,
.invoice-charges td:nth-child(4), .invoice-charges th:nth-child(4),
.invoice-charges td:nth-child(5), .invoice-charges th:nth-child(5),
.invoice-charges td:nth-child(6), .invoice-charges th:nth-child(6) { text-align: right; }
.invoice-charges th:nth-child(1), .invoice-charges td:nth-child(1) { width: 5%; }
.invoice-charges th:nth-child(2), .invoice-charges td:nth-child(2) { width: 34%; }
.invoice-charges th:nth-child(3), .invoice-charges td:nth-child(3) { width: 7%; }
.invoice-charges th:nth-child(4), .invoice-charges td:nth-child(4) { width: 13%; }
.invoice-charges th:nth-child(5), .invoice-charges td:nth-child(5) { width: 8%; }
.invoice-charges th:nth-child(6), .invoice-charges td:nth-child(6) { width: 14%; }
.invoice-charges th:nth-child(7), .invoice-charges td:nth-child(7) { width: 19%; }
.invoice-totals { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--navy); }
.it-words { max-width: 58%; font-size: 0.78rem; }
.it-total { text-align: right; }
.it-total-amount { font-size: 0.78rem; font-weight: 400; color: var(--navy); margin-top: 2px; }
/* Everything from here down stays on the same Arial as Shipment Details -- only the charges
   table gets the second font (Amjad, 2026-08-26: "bank details put in the same font as
   shipment details"). Set explicitly rather than relying on inheritance. */
.invoice-notes { margin-top: 12px; padding: 8px 10px; background: var(--bg); border-radius: 6px; font-size: 0.74rem; white-space: pre-wrap; font-family: Arial, Helvetica, sans-serif; }
.invoice-terms { margin-top: 16px; font-size: 0.68rem; color: var(--text-muted); line-height: 1.4; font-family: Arial, Helvetica, sans-serif; }
.invoice-bank { margin-top: 22px; font-family: Arial, Helvetica, sans-serif; }
/* Same numeric font-size as .invoice-terms still LOOKS bigger here, because this text is
   all-caps and Terms isn't -- caps have no ascender/descender variation, so they read
   visually larger at an identical rem value (Amjad, 2026-08-28: "below text size should be
   same as the above text. they are not the same"). Sized down to compensate. */
/* Was a <table> -- the label column auto-sized to the widest label ("A/C Number:"), leaving
   a big uneven gap on every shorter row ("Bank Name:", "IBAN:", etc.) no matter how tight the
   padding was (Amjad, 2026-08-28: "there is too much space in between"). Plain flowing lines
   instead, so the gap is always just the one space after the colon. */
.invoice-bank-table { font-size: 0.78rem; font-family: Arial, Helvetica, sans-serif; text-transform: uppercase; color: var(--text-muted); }
/* Fixed-width label so values line up as a column (Amjad, 2026-08-28: "left align the values
   so it appears as a column") -- but a modest fixed width, not "widest label" auto-sizing,
   which is what caused the original too-much-space complaint on the old <table> version. */
.invoice-bank-table div { display: flex; margin-top: 1px; }
.invoice-bank-table b { font-weight: 400; flex: 0 0 92px; }
.invoice-footer-note { margin-top: 36px; font-size: 0.74rem; color: var(--text-muted); text-align: center; letter-spacing: 0.02em; font-family: Arial, Helvetica, sans-serif; }

@media print {
    .topbar, .mobile-menu, .no-print { display: none !important; }
    .page { padding: 0; }
    .invoice-sheet { border: none; box-shadow: none; width: auto; min-height: 0; margin: 0; padding: 0; }
    @page { size: A4; margin: 15mm 18mm; }
}

/* invoice_form.php -- main form (whatever the natural width is) + a narrower, sticky
   tracking-reference sidebar so it stays visible while scrolling through the form fields. */
.invoice-form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.invoice-tracking-panel { position: sticky; top: 16px; }
.itp-row { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.itp-row:last-child { border-bottom: none; }
.itp-container { font-weight: 700; font-family: ui-monospace, Consolas, monospace; display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.itp-line { margin-top: 2px; }
@media (max-width: 900px) {
    .invoice-form-layout { grid-template-columns: 1fr; }
    .invoice-tracking-panel { position: static; }
}
