/* Layout: dark side rail + content column, MasarClear guidelines (navy/midnight, 5% yellow, Cairo + Montserrat, 16px cards, pill controls). */
:root {
  --canvas: #EEF1F7; --surface: #FFFFFF; --surface-2: #F6F8FC; --tint: #E8EDF8;
  --ink: #0E1A33; --muted: #5A6680; --line: #DCE2EE;
  --navy: #1D3A8A; --navy-deep: #152C6B; --navy-soft: #E1E8F8; --on-navy: #FFFFFF;
  --rail: #0E1A33; --rail-ink: #C8D3EE;
  --yellow: #F5B700; --yellow-ink: #2B1F00; --yellow-soft: #FDF1C7;
  --ok: #0B8A67; --ok-soft: #DDF5EB; --warn: #8A5B00; --warn-fill: #B97A00; --warn-soft: #FFF1CF;
  --bad: #C8303A; --bad-fill: #E5484D; --bad-soft: #FDE7E7;
  --shadow-card: 0 8px 22px -14px rgba(14, 26, 51, .30); --shadow-lift: 0 18px 36px -18px rgba(14, 26, 51, .45);
  --scrim: rgba(14, 26, 51, .45);
  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-pill: 999px;
  --f-ar: "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif;
  --f-en: "Montserrat", "Cairo", "Segoe UI", system-ui, sans-serif;
  --f-num: "Montserrat", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0A0F1C; --surface: #151E33; --surface-2: #18233F; --tint: #111A2E;
    --ink: #E4E9F5; --muted: #929EB8; --line: #26314A;
    --navy: #8AA7F7; --navy-deep: #B7C8F7; --navy-soft: #1A2850; --on-navy: #0A1633;
    --rail: #070D1B; --rail-ink: #B3C1E2;
    --yellow: #FFC933; --yellow-ink: #2B1F00; --yellow-soft: #3A2E0A;
    --ok: #3FD9A8; --ok-soft: #0F3A2F; --warn: #F2B53A; --warn-fill: #F2B53A; --warn-soft: #3A2C0C;
    --bad: #FF7B7F; --bad-fill: #E5484D; --bad-soft: #42181B;
    --shadow-card: 0 8px 22px -14px rgba(0, 0, 0, .6); --shadow-lift: 0 18px 36px -18px rgba(0, 0, 0, .7); --scrim: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #0A0F1C; --surface: #151E33; --surface-2: #18233F; --tint: #111A2E;
  --ink: #E4E9F5; --muted: #929EB8; --line: #26314A;
  --navy: #8AA7F7; --navy-deep: #B7C8F7; --navy-soft: #1A2850; --on-navy: #0A1633;
  --rail: #070D1B; --rail-ink: #B3C1E2;
  --yellow: #FFC933; --yellow-ink: #2B1F00; --yellow-soft: #3A2E0A;
  --ok: #3FD9A8; --ok-soft: #0F3A2F; --warn: #F2B53A; --warn-fill: #F2B53A; --warn-soft: #3A2C0C;
  --bad: #FF7B7F; --bad-fill: #E5484D; --bad-soft: #42181B;
  --shadow-card: 0 8px 22px -14px rgba(0, 0, 0, .6); --shadow-lift: 0 18px 36px -18px rgba(0, 0, 0, .7); --scrim: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--canvas); color: var(--ink); font: 400 14px/1.6 var(--f-ar); }
html[lang="en"] body { font-family: var(--f-en); font-weight: 500; font-size: 13.5px; }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; font-weight: 800; }
h1 { font-size: 22px; } h2 { font-size: 16px; display: flex; gap: 8px; align-items: center; margin-bottom: 12px; } h3 { font-size: 14px; }
a { color: var(--navy); }
.num, .grid td.t-number, .grid td.t-int, .grid td.t-percent, .grid td.t-date, .grid td.t-computed { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .nowrap { white-space: nowrap; } .wrap { white-space: normal; max-width: 300px; }
.pad { padding: 18px 18px 0; } .grow { flex: 1; } [hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- shell: side rail + main ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brand .mark { width: 36px; height: 36px; flex: none; }
.brand b { display: block; font-size: 15px; font-weight: 800; line-height: 1.25; color: #fff; }
.brand span { display: block; font-size: 11.5px; color: var(--rail-ink); opacity: .85; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); font-weight: 700; font-size: 13.5px; color: var(--rail-ink); text-decoration: none; min-height: 42px; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: var(--yellow); color: var(--yellow-ink); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-inline-start: auto; }
.badge { background: var(--bad-fill); color: #fff; border-radius: var(--r-pill); font: 700 11px/18px var(--f-num); padding: 0 7px; }
.nav a.on .badge { background: var(--yellow-ink); color: var(--yellow); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12.5px; }
.rail-foot .me { color: #fff; text-decoration: none; line-height: 1.35; }
.rail-foot .me small { display: block; color: var(--rail-ink); font-size: 11.5px; }
.rail-foot .row { display: flex; gap: 14px; flex-wrap: wrap; }
.rail .link-btn { color: var(--rail-ink); font-weight: 700; }
.main { min-width: 0; padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- controls ---------- */
.btn { font: inherit; font-weight: 700; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 16px; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--on-navy); }
.btn.primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); }
.btn.danger { background: var(--bad-fill); border-color: var(--bad-fill); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.ghost.danger, .btn.danger.ghost { color: var(--bad); background: transparent; border-color: transparent; }
.btn.small { padding: 3px 12px; font-size: 12px; min-height: 30px; }
.btn.block { width: 100%; justify-content: center; min-height: 48px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.small { font-size: 12px; }
.icon-btn { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 10px; border-radius: var(--r-pill); }
.icon-btn:hover { background: var(--surface-2); }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; background: var(--surface); width: 100%; min-height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); outline-offset: 0; border-color: var(--navy); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--navy); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input[type=email], input[type=tel], input[type=date], input[type=number], code { direction: ltr; }
[dir=rtl] input[type=email], [dir=rtl] input[type=tel], [dir=rtl] input[type=number] { text-align: right; }
.frow { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.flabel { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; } .hint.ok { color: var(--ok); font-weight: 700; } .hint.bad { color: var(--bad); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.form-err { color: var(--bad); min-height: 1em; margin: 4px 0 10px; font-weight: 600; }
.success { background: var(--ok-soft); color: var(--ok); padding: 14px 16px; border-radius: var(--r-sm); font-weight: 600; }
form.inline { display: flex; gap: 8px; flex-wrap: wrap; } form.inline input { width: 260px; max-width: 100%; }
.narrow { max-width: 400px; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.auth-side { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; justify-content: center; gap: 26px; padding: 40px 56px; position: relative; overflow: hidden; }
.auth-side .brand { position: absolute; top: 40px; inset-inline-start: 56px; }
.auth-side .brand { padding: 0; }
.auth-side .brand .mark { width: 44px; height: 44px; }
.auth-side .brand b { font-size: 18px; }
.auth-hero { max-width: 640px; margin-top: 72px; position: relative; z-index: 1; }
.auth-hero h2 { color: #fff; font-size: clamp(30px, 3.2vw, 46px); line-height: 1.4; font-weight: 800; display: block; margin: 0 0 14px; }
.auth-hero p { font-size: 17px; line-height: 1.75; margin: 0; max-width: 620px; }
.hl { background: linear-gradient(transparent 60%, var(--yellow) 60%); color: inherit; padding: 0 2px; }
.auth-steps { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.auth-steps span { border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--r-pill); padding: 4px 12px; }
.auth-side::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: var(--yellow); inset-inline-end: -60px; top: -60px; opacity: .95; }
.auth-card { align-self: center; justify-self: center; width: min(440px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lift); padding: 32px; margin: 32px 16px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.auth-foot { text-align: center; margin: 18px 0 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--yellow); border-radius: 50%; animation: spin 1s linear infinite; margin: 14px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- pages & cards ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.company-pick { display: flex; align-items: center; gap: 10px; } .company-sel { min-width: 260px; font-weight: 700; }
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 18px; min-width: 0; }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > h2 { padding: 18px 18px 0; }
.empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0 0 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg a { padding: 5px 14px; text-decoration: none; color: var(--ink); border-radius: var(--r-pill); font-weight: 700; font-size: 13px; } .seg a.on { background: var(--navy); color: var(--on-navy); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 14px 16px; border: 0; text-align: start; font: inherit; color: inherit; cursor: pointer; border-inline-start: 4px solid transparent; }
.kpi b { display: block; font: 800 26px/1.2 var(--f-num); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.kpi.on { box-shadow: 0 0 0 2px var(--navy), var(--shadow-card); }
.kpi.action { border-inline-start-color: var(--warn-fill); } .kpi.action b { color: var(--warn); }
.kpi.hold { border-inline-start-color: var(--bad-fill); } .kpi.hold b { color: var(--bad); }
.kpi.done b { color: var(--ok); }

.tabs { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: var(--r-pill); box-shadow: var(--shadow-card); overflow-x: auto; width: max-content; max-width: 100%; }
.tabs button { font: inherit; font-weight: 700; font-size: 13px; background: none; border: 0; padding: 8px 16px; cursor: pointer; color: var(--muted); border-radius: var(--r-pill); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--navy); color: var(--on-navy); }
.tabs .cnt { font: 700 11.5px/18px var(--f-num); background: var(--surface-2); color: var(--muted); border-radius: var(--r-pill); padding: 0 8px; }
.tabs button.on .cnt { background: rgba(255, 255, 255, .18); color: inherit; }
.tabs .cnt:empty { display: none; }
.tabs .uns { background: var(--yellow); color: var(--yellow-ink); border-radius: var(--r-pill); padding: 0 7px; font: 700 11px/18px var(--f-num); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { width: 300px; } .toolbar select { width: 210px; }

/* ---------- status pills (brand semantics) ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 800; white-space: nowrap; background: var(--navy-soft); color: var(--navy-deep); }
.st-transit { background: var(--navy-soft); color: var(--navy-deep); }
.st-progress { background: var(--yellow-soft); color: var(--yellow-ink); }
.st-action, .pill.pending { background: var(--warn-soft); color: var(--warn); }
.st-hold, .pill.blocked, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.st-done, .pill.active, .pill.approved { background: var(--ok-soft); color: var(--ok); }
.st-cancel { background: var(--surface-2); color: var(--muted); }
:root:not([data-theme="light"]) .st-progress { color: var(--yellow); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .st-progress { color: var(--yellow-ink); } }
:root[data-theme="light"] .st-progress { color: var(--yellow-ink); }
.state { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: var(--r-pill); }
.state.draft { background: var(--warn-soft); color: var(--warn); } .state.changed { background: var(--yellow); color: var(--yellow-ink); } .state.ok { color: var(--ok); }

/* ---------- shipments grid ---------- */
.table-box { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); overflow: auto; max-height: calc(100vh - 330px); min-height: 220px; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.grid th { position: sticky; top: 0; z-index: 3; background: var(--tint); color: var(--ink); font-weight: 800; font-size: 12px; padding: 10px 12px; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--line); }
.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.grid tbody tr { cursor: pointer; } .grid tbody tr:hover td { background: var(--surface-2); }
.grid .stick { position: sticky; z-index: 2; } .grid th.stick { z-index: 4; }
.grid:not(.staff) .s0 { inset-inline-start: 0; min-width: 64px; } .grid:not(.staff) .s1 { inset-inline-start: 64px; min-width: 124px; box-shadow: inset -1px 0 0 var(--line); }
[dir=rtl] .grid:not(.staff) .s1, [dir=rtl] .grid.staff .s1 { box-shadow: inset 1px 0 0 var(--line); }
.grid.staff th.sel, .grid.staff td.sel { position: sticky; inset-inline-start: 0; z-index: 2; width: 40px; min-width: 40px; text-align: center; } .grid.staff th.sel { z-index: 4; }
.grid.staff .s0 { inset-inline-start: 40px; min-width: 64px; } .grid.staff .s1 { inset-inline-start: 104px; min-width: 124px; box-shadow: inset -1px 0 0 var(--line); }
.grid td.s0 { font-weight: 800; font-family: var(--f-num); }
.grid .t-number, .grid .t-percent, .grid .t-int { text-align: end; }
.grid .t-date, .grid .t-computed { text-align: center; }
.grid .t-longtext { max-width: 380px; }
td.changed, .frow.changed input, .frow.changed select, .frow.changed textarea { box-shadow: inset 0 0 0 2px var(--yellow); }
td.req, dd.req { position: relative; }
td.req::after, .frow.req .flabel::after { content: ""; position: absolute; top: 4px; inset-inline-end: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn-fill); }
.frow.req .flabel { position: relative; padding-inline-end: 14px; }
td.expired { background: var(--bad-soft) !important; color: var(--bad); font-weight: 800; }
td.expiring { background: var(--warn-soft) !important; color: var(--warn); font-weight: 800; }
td.eta { color: var(--bad); font-weight: 800; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.sw.expired { background: var(--bad-soft); border: 1px solid var(--bad); } .sw.expiring { background: var(--warn-soft); border: 1px solid var(--warn); }
.sw.eta { background: var(--bad); width: 12px; height: 3px; border-radius: 2px; }
.sw.changed { box-shadow: inset 0 0 0 2px var(--yellow); } .sw.req { background: var(--warn-fill); border-radius: 50%; width: 8px; height: 8px; }

/* ---------- lists ---------- */
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 800; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tr.dim td { opacity: .55; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(500px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lift); }
.modal.wide { width: min(780px, 100%); }
.modal-head, .drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2, .drawer-head h2 { margin: 0; }
.modal-body { padding: 20px; overflow: auto; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.drawer-wrap { position: fixed; inset: 0; z-index: 50; background: var(--scrim); }
.drawer { position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(740px, 100vw); background: var(--canvas); display: flex; flex-direction: column; box-shadow: var(--shadow-lift); }
.drawer-head { background: var(--surface); }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.drawer-actions { position: sticky; bottom: -18px; background: var(--canvas); display: flex; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
fieldset { border: 0; background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 14px 16px 2px; margin: 0; }
legend { font-weight: 800; color: var(--navy); padding: 0; float: left; width: 100%; margin-bottom: 10px; }
[dir=rtl] legend { float: right; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; clear: both; } .fgrid .full { grid-column: 1 / -1; }
.ship-form { display: flex; flex-direction: column; gap: 14px; }
.ship-form > .frow { margin: 0; }
.detail-group { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 14px 16px; }
.detail-group h3 { color: var(--navy); margin-bottom: 4px; }
.detail { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); margin: 0; }
.detail dt { color: var(--muted); padding: 8px 0; border-bottom: 1px solid var(--line); }
.detail dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; min-width: 0; }
.detail dt:nth-last-of-type(1), .detail dd:last-child { border-bottom: 0; }
.detail dd .val { white-space: pre-wrap; font-weight: 600; overflow-wrap: anywhere; } .detail dd.req::after { inset-inline-end: auto; inset-inline-start: -12px; top: 15px; }
.detail dd .link-btn { white-space: nowrap; opacity: .7; } .detail dd:hover .link-btn { opacity: 1; }
.cm-wrap { display: flex; flex-direction: column; height: 100%; gap: 12px; }
.comments { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.cmt { border-radius: var(--r-md); padding: 10px 14px; max-width: 88%; background: var(--surface); box-shadow: var(--shadow-card); }
.cmt.from-client { align-self: flex-start; } .cmt.from-fh { align-self: flex-end; background: var(--navy-soft); }
.cmt p { margin: 6px 0 0; white-space: pre-wrap; } .cmt-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 12px; } .cmt-head .link-btn { margin-inline-start: auto; }
.cm-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
code { font-family: var(--f-num); }
code.pw { display: block; font-size: 18px; font-weight: 700; padding: 14px; background: var(--surface-2); border-radius: var(--r-sm); text-align: center; user-select: all; }
code.code-big { font-size: 18px; font-weight: 800; letter-spacing: .08em; background: var(--yellow-soft); color: inherit; padding: 2px 12px; border-radius: var(--r-sm); }
code.link { font-size: 12px; word-break: break-all; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; unicode-bidi: isolate; }

/* ---------- stage tracker (completed = navy, current = yellow with midnight ring, upcoming = line) ---------- */
.tracker { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow-card); padding: 16px; }
.tracker ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tracker li { position: relative; text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding-top: 26px; }
.tracker li::before { content: ""; position: absolute; top: 9px; inset-inline-start: -50%; width: 100%; height: 3px; background: var(--line); }
.tracker li:first-child::before { display: none; }
.tracker li i { position: absolute; top: 3px; inset-inline-start: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--line); z-index: 1; }
.tracker li.done { color: var(--ink); } .tracker li.done::before, .tracker li.cur::before { background: var(--navy); } .tracker li.done i { background: var(--navy); border-color: var(--navy); }
.tracker li.cur { color: var(--ink); } .tracker li.cur i { background: var(--yellow); border-color: #0A1633; width: 20px; height: 20px; top: 1px; inset-inline-start: calc(50% - 10px); }
.tracker .note { margin: 12px 0 0; font-size: 12.5px; font-weight: 700; }
.tracker .note.hold { color: var(--bad); }

#toasts { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
[dir=rtl] #toasts { transform: translateX(50%); }
.toast { background: var(--rail); color: #fff; padding: 11px 20px; border-radius: var(--r-pill); box-shadow: var(--shadow-lift); max-width: 90vw; font-weight: 600; }
.toast.err { background: var(--bad-fill); }

@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 8px; }
  .brand { padding: 0; } .nav { flex-direction: row; overflow-x: auto; flex-basis: 100%; order: 3; } .nav a { white-space: nowrap; min-height: 38px; }
  .rail-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; } .rail-foot .me small { display: none; }
  [dir=rtl] .rail-foot { margin: 0 auto 0 0; }
  .main { padding: 16px; }
  .auth { grid-template-columns: minmax(0, 1fr); } .auth-side { padding: 24px 16px; gap: 20px; } .auth-hero h2 { font-size: 24px; } .auth-steps { display: none; }
  .toolbar input[type=search], .toolbar select, .company-sel { width: 100%; min-width: 0; }
  .tracker ol { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; } .tracker li::before { display: none; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media print { .rail, .toolbar, .tabs, .legend, .kpis { display: none; } .shell { display: block; } .table-box { max-height: none; overflow: visible; box-shadow: none; } }
.stack { display: flex; flex-direction: column; gap: 14px; } .stack > p { margin: 0; }

/* ---------- MasarClear integration ---------- */
.mc-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mc-title .mark { width: 34px; height: 34px; }
.mc-arrows { color: var(--muted); font-weight: 400; }
.masar-mark { flex: none; vertical-align: middle; }
.mc-badge { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: 6px; padding: 0 6px 0 2px; border-radius: var(--r-pill); background: var(--navy-soft); color: var(--navy-deep); font-size: 11px; font-weight: 800; vertical-align: middle; }
.mc-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mc-flow h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 6px; }
.mc-flow h3 .mark { width: 18px; height: 18px; }
.mc-flow ul { margin: 0; padding-inline-start: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.9; }
.mc-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.bad-row td { background: var(--bad-soft); } .bad-text { color: var(--bad); }
.tracker.mc .mc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.mc-bar { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.mc-bar i { height: 8px; border-radius: var(--r-pill); background: var(--line); }
.mc-bar i.done { background: var(--navy); } .mc-bar i.cur { background: var(--yellow); box-shadow: 0 0 0 2px #0A1633; }
/* simulated MasarClear agent app (demo only) */
.sim { background: var(--rail); color: var(--rail-ink); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-lift); }
.sim-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sim-head b { color: #fff; font-size: 15px; } .sim-head .tag { background: var(--yellow); color: var(--yellow-ink); font: 800 10.5px/1 var(--f-en); letter-spacing: .06em; text-transform: uppercase; padding: 4px 8px; border-radius: var(--r-pill); }
.sim-note { font-size: 12.5px; margin: 0; }
.sim-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.sim-card { background: #fff; color: #0E1A33; border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.sim-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sim-card .ref { font: 800 13px var(--f-num); color: #1D3A8A; }
.sim-card .goods { font-size: 12.5px; color: #5A6680; }
.sim-card .stage { font-size: 12.5px; font-weight: 700; }
.sim-card .bar { display: grid; grid-template-columns: repeat(15, 1fr); gap: 3px; } .sim-card .bar i { height: 6px; border-radius: 4px; background: #DCE2EE; }
.sim-card .bar i.done { background: #1D3A8A; } .sim-card .bar i.cur { background: #F5B700; }
.sim-card .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.sim-card .btn { min-height: 30px; padding: 3px 12px; font-size: 12px; background: #fff; color: #0E1A33; border-color: #DCE2EE; }
.sim-card .btn.primary { background: #1D3A8A; border-color: #1D3A8A; color: #fff; }
.sim-card .pill { font-size: 11px; }
.sim-new { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sim-new input, .sim-new select { width: auto; flex: 1; min-width: 150px; background: #fff; color: #0E1A33; border-color: #DCE2EE; }
.sim-new .btn.primary { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
@media (max-width: 960px) { .mc-flow, .mc-two { grid-template-columns: minmax(0, 1fr); } }

/* ---------- notifications ---------- */
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }
.ch-icon { width: 22px; height: 22px; flex: none; }
.ch-icon.em { color: var(--navy); } .ch-icon.wa { color: #128C4A; }
:root:not([data-theme="light"]) .ch-icon.wa { color: #3FD9A8; }
.nf-channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 14px; }
.nf-ch { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; background: var(--surface); }
.nf-ch span { display: flex; flex-direction: column; gap: 2px; min-width: 0; } .nf-ch small { overflow-wrap: anywhere; }
.nf-ch.off { opacity: .6; cursor: default; }
.nf-ch:has(input:checked) { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.nf-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; margin: 6px 0 14px; }
.nf-groups .check { align-items: flex-start; } .nf-groups .check span { display: flex; flex-direction: column; } .nf-groups input { margin-top: 4px; }
.card h3 { margin: 6px 0 4px; }
.mail-host { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); }
.wa-screen { background: #E9E2D7; border-radius: var(--r-md); overflow: hidden; }
.wa-top { background: #075E54; color: #fff; padding: 10px 14px; display: flex; flex-direction: column; } .wa-top small { opacity: .8; font-family: var(--f-num); }
.wa-chat { padding: 18px 14px 22px; min-height: 180px; }
.wa-bubble { background: #fff; color: #111B21; max-width: 88%; padding: 10px 12px 18px; border-radius: 10px; border-start-start-radius: 2px; white-space: pre-wrap; position: relative; line-height: 1.7; font-size: 14px; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.wa-time { position: absolute; bottom: 3px; inset-inline-end: 8px; font-size: 10.5px; color: #667781; font-family: var(--f-num); }

/* ---------- manual notifications & deep links ---------- */
#notifyBtn .ch-icon { width: 18px; height: 18px; }
.btn .ch-icon { width: 18px; height: 18px; }
.ch-icon.nf-bell { color: currentColor; } .nf-bell .nf-arrow { stroke: var(--yellow, #F5B700); }
.focus-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--yellow-soft); color: var(--yellow-ink); border-radius: var(--r-md); padding: 10px 14px; font-weight: 700; }
:root:not([data-theme="light"]) .focus-bar { color: var(--ink); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .focus-bar { color: var(--yellow-ink); } }
:root[data-theme="light"] .focus-bar { color: var(--yellow-ink); }
.focus-bar .ch-icon { color: inherit; }
.nf-ships { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.nf-ship { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 4px 3px 10px; }
[dir=rtl] .nf-ship { padding: 3px 10px 3px 4px; }
.nf-recips { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 14px; }
.nf-recips .check { align-items: flex-start; } .nf-recips .check span { display: flex; flex-direction: column; } .nf-recips input { margin-top: 4px; }
.warn-text { color: var(--warn); font-weight: 700; }
.nf-linkhint { display: flex; align-items: center; gap: 8px; margin: 0; }
.nf-result { margin: 0; padding-inline-start: 18px; }
.row-actions.spread { justify-content: space-between; align-items: center; }
.wa-bubble a { color: #027EB5; word-break: break-all; }

/* ---------- email signature & sender ---------- */
.sig-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 8px; }
.sig-grid textarea { font-family: inherit; }
.sig-preview { border: 1px dashed var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); min-height: 96px; }
.sig-closing { margin-bottom: 6px; }
.sig-block { display: inline-block; min-width: 180px; padding-top: 8px; border-top: 2px solid var(--yellow); }
.sig-name { font-weight: 700; } .sig-line { color: var(--muted); font-size: 13px; }
.sender-box { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--tint); margin: 6px 0 12px; }
.sender-box .ch-icon { margin-top: 4px; }
.sender-addr { display: block; }
.sig-grid textarea { unicode-bidi: plaintext; }
.mail-own { margin: 4px 0 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.mail-own .btn.ghost { margin-bottom: 6px; }
.ok-text { color: var(--ok); font-weight: 700; }
.mail-card .check small { display: block; }
.sender-hint strong { unicode-bidi: plaintext; }
@media (max-width: 760px) { .sig-grid { grid-template-columns: 1fr; } }
html[dir="rtl"] .sig-preview { text-align: right; } html[dir="ltr"] .sig-preview { text-align: left; }

/* ---------- staff permissions ---------- */
.perm-group { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.perm-group > .flabel { margin-bottom: 4px; }
.perm-row { padding: 6px 0; align-items: flex-start; }
.perm-row small { display: block; }
.perm-dlg .row-actions { flex-wrap: wrap; align-items: center; }
.perm-note { align-self: center; }

/* ---------- sign-in: model A (live shipment card) ---------- */
.auth-demo { position: relative; z-index: 1; max-width: 720px; background: #FFFFFF; color: #0E1A33; border-radius: var(--r-md); padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 18px 36px -18px rgba(0, 0, 0, .6); }
.auth-demo .muted { color: #5A6680; }
.auth-demo-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.auth-demo-head > div { display: flex; flex-direction: column; gap: 2px; }
.auth-demo-head strong { font-size: 17px; }
.auth-demo .tracker { background: none; box-shadow: none; padding: 0; }
.auth-demo .tracker li { color: #5A6680; } .auth-demo .tracker li.done, .auth-demo .tracker li.cur { color: #0E1A33; }
.auth-demo .tracker li::before { background: #DCE2EE; } .auth-demo .tracker li.done::before, .auth-demo .tracker li.cur::before { background: #1D3A8A; }
.auth-demo .tracker li i { background: #FFFFFF; border-color: #DCE2EE; } .auth-demo .tracker li.done i { background: #1D3A8A; border-color: #1D3A8A; }
.auth-demo .tracker li.cur i { background: #F5B700; border-color: #0A1633; }
.auth-demo .tracker .note { display: none; }
.auth-demo-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid #DCE2EE; padding-top: 10px; }
.auth-toast { position: relative; z-index: 1; align-self: flex-start; display: flex; align-items: center; gap: 10px; background: #1D3A8A; color: #FFFFFF; border-radius: 14px; padding: 10px 16px; font-size: 14px; }
.auth-toast .ch-icon { color: #FFFFFF; }
.auth-links { display: flex; flex-direction: column; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 16px; }
@media (max-width: 980px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side .brand { position: static; }
  .auth-hero { margin-top: 0; }
  .auth-demo, .auth-toast { display: none; }
}
