/* MASAR FIELD — customer portal.
   A separate surface from the operations console: no sidebar, no internal
   navigation, and only what a customer needs to ask, decide, pay and track. */

:root {
  /* SAJCO green is the anchor; the neutrals are pulled toward it so grey
     reads as a chosen colour rather than an absent one. */
  --green-900: #0d3a22;
  --green-800: #114a2a;
  --green-700: #15602f;
  --green-600: #1a7a3f;
  --green-500: #2e8b4f;
  --green-100: #d9eadf;
  --green-050: #eef5f0;

  --ink:       #0f1d16;
  --ink-soft:  #48594f;
  --ink-faint: #7b8b82;
  --ground:    #f2f5f3;
  --surface:   #ffffff;
  --surface-2: #fafbfa;
  --rule:      #dde5e0;
  --rule-strong: #c2d0c8;

  /* Semantic signals, kept apart from the brand accent so "needs you" never
     reads as decoration. */
  --signal:      #a8620d;
  --signal-soft: #fdf2e3;
  --signal-line: #edd3ac;
  --red:         #a02c2c;
  --red-soft:    #fbeaea;
  --steel:       #245a74;
  --steel-soft:  #e8f1f6;

  --amber: var(--signal);
  --amber-soft: var(--signal-soft);
  --blue: var(--steel);
  --blue-soft: var(--steel-soft);

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(15,29,22,.04), 0 10px 28px -20px rgba(15,29,22,.32);
  --shadow-lift: 0 2px 6px rgba(15,29,22,.06), 0 16px 34px -22px rgba(15,29,22,.42);

  --font-ar:   "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --font-en:   "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Reference numbers are read aloud, compared and typed back. Monospace is
     the convention every waybill and airbill already uses. */
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font: var(--font-ar);
}

[dir="ltr"] {
  --font: var(--font-en);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--ground);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
.muted { color: var(--ink-faint); }
.small { font-size: 13px; }

/* ---------------- Auth ---------------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
}

.lang-switch-btn {
  position: absolute;
  inset-inline-end: 24px;
  top: 20px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 99px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: all .15s ease;
}
.lang-switch-btn:hover {
  border-color: var(--green-600);
  background: var(--green-050);
  color: var(--green-700);
  transform: translateY(-1px);
}

.auth-brand {
  background: linear-gradient(160deg, var(--green-900), var(--green-600));
  color: #fff;
  padding: 56px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}
.auth-brand-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.auth-logo { width: 96px; background: #fff; border-radius: 12px; padding: 10px; }
.auth-brand h1 { font-size: 34px; }
.auth-brand-subtitle {
  font-size: 15px;
  font-weight: 600;
  color: #a7f3d0;
  margin-top: -6px;
  line-height: 1.4;
}
.auth-brand p { margin: 0; opacity: .9; max-width: 42ch; }
.auth-points { margin: 8px 0 0; padding-inline-start: 20px; opacity: .92; }
.auth-points li { margin-bottom: 6px; }
.auth-staff-link {
  margin-top: 20px; color: #fff; opacity: .75; text-decoration: none;
  font-size: 14px; border-bottom: 1px dashed rgba(255,255,255,.4);
  align-self: flex-start; padding-bottom: 2px;
}
.auth-staff-link:hover { opacity: 1; }

.auth-panel {
  display: flex; flex-direction: column; justify-content: center;
  padding: 52px 48px; background: var(--surface);
  max-height: 100vh; overflow-y: auto;
}
.auth-panel-header {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-pill-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--green-050);
  border: 1px solid var(--green-600);
  color: var(--green-700);
  padding: 4px 13px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}
.auth-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green-600);
  animation: pulse-dot 2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}
.auth-panel-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.auth-panel-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.5;
}
.tabs { display: flex; gap: 6px; margin-bottom: 22px; }
.tab {
  flex: 1; padding: 11px 14px; border: 1px solid var(--rule);
  background: var(--ground); color: var(--ink-soft);
  border-radius: 10px; font-family: inherit; font-size: 15px; cursor: pointer;
  font-weight: 600;
}
.tab.is-active { background: var(--green-700); border-color: var(--green-700); color: #fff; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { color: var(--ink-soft); font-weight: 500; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--rule-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--green-600); outline-offset: 1px; border-color: var(--green-600);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-span { grid-column: 1 / -1; }
.form-error {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--red-soft); color: var(--red); font-size: 14px;
}
.form-note { margin: 0; font-size: 13px; color: var(--ink-faint); }
.form-actions { display: flex; gap: 10px; }

.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: filter .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn-outline:hover { border-color: var(--green-600); color: var(--green-700); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-sm { padding: 7px 13px; font-size: 14px; }
.btn-block { width: 100%; }

/* ---------------- Portal ---------------- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--rule);
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 5;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand img { width: 42px; }
.topbar-brand strong { display: block; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.chip {
  background: var(--green-050); color: var(--green-700);
  padding: 5px 11px; border-radius: 99px; font-size: 13px; font-weight: 600;
}

.portal { max-width: 1060px; margin: 0 auto; padding: 24px 20px 60px; }

/* A readout strip, not four boxes: one surface, hairline dividers, labels
   above the figures so the numbers line up as a row the eye can scan. */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 18px;
}
.stat { padding: 14px 18px; position: relative; }
.stat + .stat::before {
  content: ""; position: absolute; inset-block: 12px; inset-inline-start: 0;
  width: 1px; background: var(--rule);
}
.stat span {
  display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 2px;
}
.stat b {
  display: block; font-size: 26px; line-height: 1.15; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.stat.is-signal b { color: var(--signal); }
.stat.is-live b { color: var(--green-600); }

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-head h2 { font-size: 19px; letter-spacing: -.01em; }

/* ---- The active shipment, promoted out of the list ---- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--green-900), var(--green-700) 62%, var(--green-600));
  color: #fff; border-radius: var(--radius); padding: 20px 22px;
  margin-bottom: 18px; box-shadow: var(--shadow-lift); cursor: pointer;
}
.hero::after {
  /* a faint road-marking motif, the one ornament the subject earns */
  content: ""; position: absolute; inset-block: 0; inset-inline-end: -40px; width: 220px;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,.07) 0 14px, transparent 14px 34px);
  pointer-events: none;
}
.hero-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; position: relative;
}
.hero-eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: #a9d9bd;
}
.hero-ref { font-family: var(--font-mono); font-size: 13px; color: #cfe9da; }
.hero-stage { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.hero-cargo { font-size: 14px; color: #d6ebdf; margin-top: 2px; }
.hero-rail {
  height: 6px; border-radius: 99px; background: rgba(255,255,255,.22);
  overflow: hidden; margin: 14px 0 8px; position: relative;
}
.hero-rail > span {
  display: block; height: 100%; border-radius: 99px; background: #9ee7bb;
  transition: width .6s cubic-bezier(.2,.7,.3,1);
}
.hero-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 13px; color: #cfe9da; position: relative;
}
.hero-pct { font-variant-numeric: tabular-nums; font-weight: 700; color: #fff; }

/* ---- Manifest rows ---- */
.request-list { display: flex; flex-direction: column; gap: 10px; }
.request {
  border: 1px solid var(--rule); border-radius: 12px; padding: 0;
  background: var(--surface); cursor: pointer; overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.request:hover, .request:focus-visible {
  border-color: var(--green-500); box-shadow: var(--shadow-lift);
  transform: translateY(-1px); outline: none;
}
.request:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; }
.request.needs-action { border-inline-start: 3px solid var(--signal); }

.req-body {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 18px;
  padding: 14px 16px;
}
.req-ref {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--ink-faint); letter-spacing: .02em;
}
.request-title {
  font-weight: 600; font-size: 15px; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* The route as a corridor: two nodes and the rail between them. */
.req-route {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; font-size: 13.5px; color: var(--ink-soft);
}
.req-node { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.req-node i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong);
  flex: none; display: inline-block;
}
.req-node.is-end i { background: var(--green-600); }
.req-rail {
  flex: 1 1 auto; min-width: 24px; height: 0; border-top: 2px dashed var(--rule-strong);
}
.req-figures {
  margin-top: 6px; font-size: 12.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.req-figures b { color: var(--ink-soft); font-weight: 600; }

.request-side {
  text-align: end; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-end; justify-content: flex-start;
}
.amount {
  font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.req-action {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--signal-soft); color: var(--signal);
  border: 1px solid var(--signal-line);
  padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700;
}
.req-progress { height: 3px; background: var(--green-050); }
.req-progress > span {
  display: block; height: 100%; background: var(--green-500);
  transition: width .5s ease;
}

.pill {
  display: inline-block; padding: 4px 11px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill-new { background: var(--blue-soft); color: var(--blue); }
.pill-wait { background: var(--amber-soft); color: var(--amber); }
.pill-ok { background: var(--green-050); color: var(--green-700); }
.pill-bad { background: var(--red-soft); color: var(--red); }
.pill-muted { background: var(--ground); color: var(--ink-faint); }

.empty {
  padding: 26px; text-align: center; color: var(--ink-faint);
  border: 1px dashed var(--rule-strong); border-radius: 12px;
}

/* ---------------- Modal ---------------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(15,32,24,.45);
  display: grid; place-items: center; padding: 20px; z-index: 30;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: min(720px, 100%); max-height: 88vh; overflow-y: auto;
  padding: 24px 26px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5);
  position: relative;
}
.modal-close {
  position: absolute; inset-inline-end: 18px; top: 16px;
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-faint);
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px;
}
.modal-close:hover { background: var(--ground); color: var(--ink); }

.kv { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14.5px; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.kv td:first-child { color: var(--ink-faint); width: 38%; }

.quote {
  border: 1px solid var(--rule); border-radius: 12px; padding: 16px; margin-top: 12px;
}
.quote.is-active { border-color: var(--green-600); background: var(--green-050); }
.quote-lines { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; font-size: 14px; }
.quote-line { display: flex; justify-content: space-between; }
.quote-total {
  display: flex; justify-content: space-between; font-weight: 700;
  border-top: 1px solid var(--rule-strong); padding-top: 10px; margin-top: 6px; font-size: 17px;
}
.section-label {
  font-size: 12px; letter-spacing: .08em; color: var(--ink-faint);
  text-transform: uppercase; margin: 18px 0 6px; font-weight: 600;
}
.track { display: flex; flex-direction: column; gap: 8px; }
.track-step { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.track-dot {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ground); color: var(--ink-faint); font-size: 12px; flex: none;
  border: 1px solid var(--rule-strong); font-weight: 600;
}
.track-step.done .track-dot { background: var(--green-700); color: #fff; border-color: var(--green-700); }
.track-step.current .track-dot { background: var(--amber); color: #fff; border-color: var(--amber); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 26px; background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 10px; z-index: 50; max-width: 88vw;
  box-shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  font-size: 14px; font-weight: 500;
}
.toast.bad { background: var(--red); }

.portal-foot {
  text-align: center; color: var(--ink-faint); font-size: 13px;
  padding: 20px; border-top: 1px solid var(--rule); background: var(--surface);
}

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 32px 24px; }
  .auth-panel { padding: 28px 22px; }
  .lang-switch-btn { top: 14px; inset-inline-end: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .request { grid-template-columns: 1fr; }
  .request-side { text-align: start; align-items: flex-start; }
  [dir="ltr"] .request-side { text-align: left; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* The layout rules above use display:flex/grid on the same specificity as
   [hidden], so a hidden form would still paint. This settles it. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ */
/* Shipment tracking                                                   */
/* ------------------------------------------------------------------ */
.track-public {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #f8fafc;
}
.track-public-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 13.5px;
}
.link-btn {
  background: none; border: 0; cursor: pointer; font: inherit; font-weight: 600;
  color: var(--green-700, #166534); text-decoration: underline;
}
.track-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.track-stage { font-weight: 800; font-size: 15px; }
.track-pct { font-weight: 800; font-size: 22px; color: var(--green-700, #166534); }
.track-bar {
  height: 8px; border-radius: 999px; background: #e2e8f0;
  overflow: hidden; margin: 8px 0 4px;
}
.track-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #3f9457, #166534);
  transition: width .5s ease;
}
.track-map {
  height: 220px; border-radius: 10px; margin: 10px 0 6px;
  border: 1px solid var(--line, #e2e8f0); overflow: hidden;
}
.track-nopos {
  background: #f1f5f9; border-radius: 8px; padding: 10px 12px; margin: 10px 0 0;
}
.tracking-stale { color: #b45309; font-weight: 700; }
.tracking-live { color: #166534; font-weight: 700; }
.map-config-warning { padding: 8px 10px; margin: 6px 0; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: 12px; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0; }
.tl-step {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 0 0 14px; position: relative;
}
.tl-step:not(:last-child)::before {
  content: ""; position: absolute; inset-inline-start: 10px; top: 20px; bottom: 0;
  width: 2px; background: #e2e8f0;
}
.tl-step.is-done:not(:last-child)::before { background: #86bf9b; }
.tl-dot {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: #e2e8f0; color: #64748b; position: relative; z-index: 1;
}
.tl-step.is-done .tl-dot { background: #86bf9b; color: #0f3d22; }
.tl-step.is-current .tl-dot { background: var(--green-700, #166534); color: #fff; }
.tl-label { font-size: 13.5px; font-weight: 600; }
.tl-step:not(.is-done) .tl-label { color: #94a3b8; font-weight: 500; }
.tl-when { font-size: 11.5px; color: #64748b; margin-top: 1px; }

/* ------------------------------------------------------------------ */
/* Modal header: the manifest treatment                                */
/* ------------------------------------------------------------------ */
.modal-head {
  padding-inline-end: 40px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 14px;
  margin-bottom: 4px;
}
.modal-ref {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  color: var(--ink-faint); letter-spacing: .03em; margin-bottom: 3px;
}
.modal-head h2 { font-size: 20px; letter-spacing: -.01em; }
.modal-chips {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px;
}
.modal-route { font-size: 13.5px; color: var(--ink-soft); }

/* Numbers in a portal about tonnes and riyals should line up. */
.kv td, .amount, .quote-line, .quote-total, .stat b, .hero-pct {
  font-variant-numeric: tabular-nums;
}
.quote-total { letter-spacing: -.01em; }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat + .stat::before { display: none; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .stat:nth-child(even)::before {
    content: ""; display: block; position: absolute;
    inset-block: 12px; inset-inline-start: 0; width: 1px; background: var(--rule);
  }
  .req-body { grid-template-columns: 1fr; }
  .request-side { align-items: flex-start; text-align: start; }
  .req-route { flex-wrap: wrap; }
  .req-rail { min-width: 40px; }
  .hero-stage { font-size: 19px; }
  .hero::after { display: none; }
}

/* ------------------------------------------------------------------ */
/* Invoices and the account statement                                  */
/* ------------------------------------------------------------------ */
.portal-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.ptab {
  appearance: none; background: none; border: 0; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--ink-faint);
  padding: 10px 16px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.ptab:hover { color: var(--ink-soft); }
.ptab.is-active { color: var(--green-700); border-bottom-color: var(--green-600); }
.ptab:focus-visible { outline: 2px solid var(--green-600); outline-offset: -2px; border-radius: 6px; }

.notice-line {
  background: var(--signal-soft); border: 1px solid var(--signal-line);
  color: var(--signal); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 13px; margin-bottom: 12px; line-height: 1.6;
}

.table-scroll { overflow-x: auto; }
.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger th {
  text-align: start; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; padding: 0 12px 8px;
  border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.ledger td { padding: 11px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger tr.is-idle { opacity: .6; }
.led-when { color: var(--ink-faint); font-size: 13px; white-space: nowrap; }
.led-kind { font-weight: 600; }
.led-kind.is-debit { color: var(--ink); }
.led-kind.is-credit { color: var(--green-700); }
.led-ref { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.led-amount, .led-balance {
  font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: end;
}
.led-amount.is-debit { color: var(--ink); }
.led-amount.is-credit { color: var(--green-700); }
.led-amount.is-idle { color: var(--ink-faint); font-weight: 500; }
.led-balance { color: var(--ink-soft); }
.empty-cell { text-align: center; color: var(--ink-faint); padding: 24px; }

/* ---- The invoice sheet ---- */
.invoice { padding: 4px 2px 8px; }
.inv-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--green-700);
}
.inv-kind {
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--green-700);
}
.inv-no { font-family: var(--font-mono); font-size: 21px; font-weight: 600; margin: 2px 0 3px; }
.inv-logo { width: 62px; height: auto; }
.inv-parties {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 16px 0;
}
.inv-party-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 4px;
}
.inv-party-name { font-weight: 700; font-size: 15px; }
.inv-warn { color: var(--signal); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.inv-subject {
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin-bottom: 16px;
}
.inv-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.inv-table th {
  text-align: start; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-faint); padding: 0 0 8px; border-bottom: 1px solid var(--rule-strong);
}
.inv-table td { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.inv-table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-table tfoot td { border-bottom: 0; padding: 7px 0; color: var(--ink-soft); }
.inv-table tfoot tr.inv-total td {
  font-size: 18px; font-weight: 700; color: var(--ink);
  border-top: 2px solid var(--green-700); padding-top: 11px;
}
.inv-paid {
  margin-top: 14px; background: var(--green-050); border: 1px solid var(--green-100);
  color: var(--green-700); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 13.5px; font-weight: 600;
}
.inv-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

@media (max-width: 860px) {
  .inv-parties { grid-template-columns: 1fr; gap: 14px; }
  .portal-tabs { overflow-x: auto; }
}

/* An invoice is a document people file: print it as one, not as a web page
   with a dimmed backdrop around it. */
@media print {
  body { background: #fff; }
  .topbar, .portal-tabs, .portal-foot, .no-print, .modal-close { display: none !important; }
  .backdrop { position: static; background: none; padding: 0; display: block; }
  .modal {
    box-shadow: none; max-height: none; width: 100%; border-radius: 0;
    padding: 0; overflow: visible;
  }
  .invoice { padding: 0; }
}

/* ---------------------------------------------------------------------------
   Phone numbers & BiDi isolation:
   Always render phone numbers and tel: links strictly Left-to-Right
--------------------------------------------------------------------------- */
.dir-ltr,
.phone-ltr,
.phone-link,
a[href^="tel:"],
[data-phone] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  display: inline-flex !important;
  align-items: center;
  white-space: nowrap !important;
  text-align: left;
}

[dir="rtl"] .phone-ltr,
[dir="rtl"] .dir-ltr,
[dir="rtl"] .phone-link,
[dir="rtl"] a[href^="tel:"],
[dir="rtl"] [data-phone] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
  white-space: nowrap !important;
}

input[type="tel"] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
  white-space: nowrap;
}

