/* ============================================================
   DnB Logistics — core design system
   Tokens · reset · type · buttons · forms · pills · cards · tables
   Light + dark themes (data-theme on <html>) · RTL via [dir=rtl]
   ============================================================ */

:root {
  --navy-950: #021625;
  --navy-900: #031f33;
  --navy-800: #042f4b;
  --navy-700: #0a4268;
  --navy-600: #0f567f;
  --amber-500: #fbb116;
  --amber-600: #e99d05;
  --amber-100: #fff4d6;

  --font-head: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow-sm: 0 1px 2px rgba(3, 31, 51, .06), 0 1px 1px rgba(3, 31, 51, .04);
  --shadow-md: 0 8px 24px -8px rgba(3, 31, 51, .18), 0 2px 6px rgba(3, 31, 51, .06);
  --shadow-lg: 0 30px 60px -24px rgba(3, 31, 51, .35), 0 8px 20px -8px rgba(3, 31, 51, .15);
}

/* ---------- Light theme (default) ---------- */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fa;
  --bg-soft: #eaf0f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #0a2236;
  --text-mid: #3b5368;
  --muted: #667b8f;
  --border: #e1e8ef;
  --border-strong: #c9d5e0;
  --brand: var(--navy-800);
  --brand-contrast: #ffffff;
  --accent: var(--amber-500);
  --accent-hover: var(--amber-600);
  --accent-ink: #1b1300;
  --link: #0a5c96;
  --focus: rgba(251, 177, 22, .45);
  --tint-blue: #e7f1fa;   --ink-blue: #0a5c96;
  --tint-green: #def7ea;  --ink-green: #0b7a45;
  --tint-amber: #fff1cf;  --ink-amber: #8a5a00;
  --tint-red: #ffe4e4;    --ink-red: #b42318;
  --tint-slate: #e8edf2;  --ink-slate: #44586b;
  --tint-violet: #efe7fb; --ink-violet: #6b3fb5;
  --tint-cyan: #dff5fa; --ink-cyan: #0a6f86;
  --tint-teal: #dcf5ef; --ink-teal: #0b7a68;
  --tint-orange: #ffe8d6; --ink-orange: #b34700;
  --tint-indigo: #e4e8fc; --ink-indigo: #3a4bc2;
  --tint-pink: #fde6f0; --ink-pink: #b3225f;
  --tint-lime: #eaf6d4; --ink-lime: #4d7a0b;
  --hero-from: #021625;   --hero-to: #0a4268;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061420;
  --bg-soft: #0a1c2c;
  --surface: #0d2235;
  --surface-2: #112a40;
  --text: #eaf2f9;
  --text-mid: #b5c6d6;
  --muted: #86a0b6;
  --border: #1b3550;
  --border-strong: #27486a;
  --brand: var(--amber-500);
  --brand-contrast: #1b1300;
  --link: #6fb7ee;
  --focus: rgba(251, 177, 22, .5);
  --tint-blue: rgba(79, 160, 230, .16);   --ink-blue: #8cc6f5;
  --tint-green: rgba(34, 197, 120, .16);  --ink-green: #5fe0a2;
  --tint-amber: rgba(251, 177, 22, .16);  --ink-amber: #fbc84a;
  --tint-red: rgba(248, 90, 80, .16);     --ink-red: #ff9b92;
  --tint-slate: rgba(150, 175, 200, .14); --ink-slate: #b5c6d6;
  --tint-violet: rgba(150,110,230,.18); --ink-violet: #c4a8f5;
  --tint-cyan: rgba(40,190,220,.16); --ink-cyan: #7fdcf0;
  --tint-teal: rgba(30,190,160,.16); --ink-teal: #6fe0c8;
  --tint-orange: rgba(255,140,50,.17); --ink-orange: #ffb27a;
  --tint-indigo: rgba(100,120,240,.18); --ink-indigo: #a3b0fa;
  --tint-pink: rgba(240,90,150,.17); --ink-pink: #f7a0c4;
  --tint-lime: rgba(150,210,50,.16); --ink-lime: #c4ea7e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, .6);
  --shadow-lg: 0 34px 70px -26px rgba(0, 0, 0, .75);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
html[lang="ar"] body, html[lang="ar"] :is(h1,h2,h3,h4,button,input,select,textarea,.btn) { font-family: 'Cairo', var(--font-body); }
html[lang="zh"] body, html[lang="zh"] :is(h1,h2,h3,h4,button,input,select,textarea,.btn) { font-family: 'Noto Sans SC', var(--font-body); }
html[lang="en"] :is(h1,h2,h3,h4,.display) { font-family: var(--font-head); }
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; color: var(--text); }
html[lang="ar"] :is(h1,h2,h3,h4) { letter-spacing: 0; line-height: 1.35; }
p { margin: 0 0 1em; }
::selection { background: var(--amber-500); color: #1b1300; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* logo swap by theme */
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }
.logo-light, .logo-dark { width: auto; vertical-align: middle; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .72rem 1.25rem; border-radius: var(--r-md); border: 1.5px solid transparent;
  font: inherit; font-weight: 700; font-size: .93rem; line-height: 1.1; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s, color .18s;
}
.btn i { font-size: 1.15em; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px rgba(251, 177, 22, .65); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(251, 177, 22, .8); }
.btn-dark { background: var(--navy-800); color: #fff; }
.btn-dark:hover { background: var(--navy-700); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--text); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-mid); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-danger { background: var(--tint-red); color: var(--ink-red); }
.btn-danger:hover { background: var(--ink-red); color: #fff; }
.btn-success { background: #16a05a; color: #fff; }
.btn-success:hover { background: #118049; }
.btn-sm { padding: .5rem .8rem; font-size: .82rem; border-radius: 9px; }
.btn-lg { padding: .95rem 1.7rem; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------- Forms ---------- */
label.lbl, .field > label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-mid); margin-bottom: .35rem; letter-spacing: .01em; }
.input, .select, .textarea {
  width: 100%; padding: .7rem .9rem; border-radius: var(--r-md);
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: .94rem; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--amber-500); box-shadow: 0 0 0 4px var(--focus); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23889bae' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.3rem; }
[dir="rtl"] .select { background-position: left .9rem center; padding-right: .9rem; padding-left: 2.3rem; }
.input[readonly] { background: var(--surface-2); color: var(--text-mid); }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .76rem; color: var(--muted); margin-top: .3rem; }
.field-error { color: var(--ink-red); font-size: .78rem; margin-top: .3rem; }
.grid-2, .grid-3, .grid-4, .grid-5 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; } }
@media (min-width: 761px) and (max-width: 1020px) { .grid-5, .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: flex; align-items: center; padding: 0 .85rem; background: var(--surface-2); border: 1.5px solid var(--border-strong); color: var(--muted); font-size: .85rem; font-weight: 600; }
.input-group .addon:first-child { border-radius: var(--r-md) 0 0 var(--r-md); border-right: 0; }
.input-group .addon:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; border-left: 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
[dir="rtl"] .input-group { flex-direction: row-reverse; }
.check { display: flex; align-items: center; gap: .6rem; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--amber-500); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: #16a05a; }
.switch input:checked + span::after { transform: translateX(20px); }
[dir="rtl"] .switch span::after { left: auto; right: 3px; }
[dir="rtl"] .switch input:checked + span::after { transform: translateX(-20px); }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .65rem; border-radius: 99px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill-blue  { background: var(--tint-blue);  color: var(--ink-blue); }
.pill-green { background: var(--tint-green); color: var(--ink-green); }
.pill-amber { background: var(--tint-amber); color: var(--ink-amber); }
.pill-red   { background: var(--tint-red);   color: var(--ink-red); }
.pill-slate { background: var(--tint-slate); color: var(--ink-slate); }
.pill-violet { background: var(--tint-violet); color: var(--ink-violet); }
.pill-cyan { background: var(--tint-cyan); color: var(--ink-cyan); }
.pill-teal { background: var(--tint-teal); color: var(--ink-teal); }
.pill-orange { background: var(--tint-orange); color: var(--ink-orange); }
.pill-indigo { background: var(--tint-indigo); color: var(--ink-indigo); }
.pill-pink { background: var(--tint-pink); color: var(--ink-pink); }
.pill-lime { background: var(--tint-lime); color: var(--ink-lime); }
.chip { display: inline-block; padding: .15rem .5rem; border-radius: 6px; background: var(--tint-amber); color: var(--ink-amber); font: 800 .72rem/1.4 var(--font-head); letter-spacing: .06em; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--r-md); margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert i { font-size: 1.25rem; margin-top: 1px; }
.alert-success { background: var(--tint-green); color: var(--ink-green); border-color: rgba(22,160,90,.25); }
.alert-error   { background: var(--tint-red);   color: var(--ink-red);   border-color: rgba(220,60,50,.25); }
.alert-info    { background: var(--tint-blue);  color: var(--ink-blue);  border-color: rgba(10,92,150,.2); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.4rem 1.5rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 1rem; letter-spacing: -.01em; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-tight th, .tbl-tight td { padding-inline: .5rem; }
.tbl-tight th:first-child, .tbl-tight td:first-child { padding-inline-start: .9rem; }
.tbl-tight .row-acts { gap: .1rem; flex-wrap: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: start; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: .8rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: end; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-weight: 700; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.flex { display: flex; } .items-center { align-items: center; } .between { justify-content: space-between; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .wrap { flex-wrap: wrap; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* shared: input + button on one row */
.copy-row { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; } .copy-row .input, .copy-row .select { flex: 1; min-width: 0; }

/* confirmation popup */
.cfm-back { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(4, 25, 41, .55); backdrop-filter: blur(2px); }
.cfm { width: 100%; max-width: 400px; background: var(--surface, #fff); color: var(--text, #0a2236); border: 1px solid var(--border, #e3e9ef); border-radius: 16px; padding: 1.4rem 1.4rem 1.2rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.cfm h4 { margin: 0 0 .4rem; font-size: 1.05rem; }
.cfm p { margin: 0 0 1.2rem; color: var(--text-muted, #667b8f); line-height: 1.5; }
.mdl-back { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(4, 25, 41, .55); backdrop-filter: blur(2px); }
.mdl-back[hidden] { display: none; }
.mdl { width: 100%; max-width: 440px; background: var(--surface, #fff); color: var(--text, #0a2236); border: 1px solid var(--border, #e3e9ef); border-radius: 16px; padding: 1.4rem; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.mdl h4 { margin: 0 0 .2rem; font-size: 1.1rem; }
.mdl .sub { margin: 0 0 1rem; color: var(--muted, #667b8f); font-size: .88rem; }
.mdl .bar { height: 8px; border-radius: 99px; background: var(--bg-soft, #eef2f6); overflow: hidden; margin: .5rem 0 1rem; }
.mdl .bar i { display: block; height: 100%; background: #16a05a; border-radius: 99px; }
.mdl .chk { display: flex; gap: .55rem; align-items: flex-start; font-size: .88rem; margin: .2rem 0 1rem; cursor: pointer; }
.mdl .note { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 10px; background: var(--tint-amber); color: var(--ink-amber); font-size: .88rem; }
.money-bal.due { color: var(--ink-red); font-weight: 800; }
.money-bal.clear { color: var(--ink-green); font-weight: 800; }
.cfm-acts { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; }
