/* TD Finance Hub — Saudi green, white pages, Arabic-first (RTL) with English. Flat and calm. */
:root{
  /* TD Logistics brand: black, TD red #B23028, white */
  --brand:#0F0F10;--brand2:#B23028;--brandS:#FBECEA;--gold:#B23028;
  --bg:#F6F6F6;--card:#fff;--ink:#141414;--mut:#646464;--line:#E6E6E6;--soft:#F0F0F0;
  --blue:#B23028;--blueS:#FBECEA;--blueT:#8E2620;
  --ok:#157A46;--okS:#E5F4EB;--warn:#8A5A00;--warnS:#FFF4DC;--bad:#D92D20;--badS:#FDECEA;
  --r:10px;
}
*{box-sizing:border-box;min-width:0}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:14.5px/1.55 Inter,"IBM Plex Sans Arabic",system-ui,sans-serif}
[dir=rtl] body{font-family:"IBM Plex Sans Arabic",Inter,system-ui,sans-serif;font-size:15px}
a{color:#8E2620}
.num,td.n,.n,.v,.big,.kpi .v{font-family:Inter,"IBM Plex Sans Arabic",sans-serif;font-variant-numeric:tabular-nums}

/* ---------- top navigation ---------- */
.topnav{position:sticky;top:0;z-index:40;background:#fff;border-bottom:1px solid var(--line)}
.topnav .bar{box-shadow:inset 0 -3px 0 var(--brand2)}
.topnav .bar{display:flex;align-items:center;gap:18px;padding:0 clamp(14px,2.4vw,32px);min-height:60px;background:var(--brand);color:#fff}
.logo{display:flex;align-items:center;gap:10px;color:#fff;text-decoration:none;flex:none}
.logo .mark{width:34px;height:34px;border-radius:8px;background:var(--brand2);color:#fff;display:grid;place-items:center;font:800 14px Inter,sans-serif;letter-spacing:-.02em}
.logo b{display:block;font-size:15px;line-height:1.15}.logo small{display:block;font-size:11.5px;color:#A3A3A3}
.logo img{height:34px;width:auto;display:block}
.tabs-main{display:flex;gap:2px;flex:1;overflow-x:auto;scrollbar-width:none;align-self:stretch}
.tabs-main::-webkit-scrollbar{display:none}
.tabs-main a{display:flex;align-items:center;gap:6px;padding:0 14px;color:#C9C9C9;text-decoration:none;font-weight:600;font-size:14px;white-space:nowrap;border-bottom:3px solid transparent;border-top:3px solid transparent}
.tabs-main a:hover{color:#fff;background:rgba(255,255,255,.06)}
.tabs-main a.on{color:#fff;background:rgba(255,255,255,.07);border-bottom-color:var(--brand2)}
.count{min-width:19px;height:19px;padding:0 6px;border-radius:99px;background:var(--brand2);color:#fff;font:700 11px Inter,sans-serif;display:inline-grid;place-items:center}
.tools{display:flex;align-items:center;gap:10px;flex:none}
.tools .date{font-size:12.5px;color:#D4D4D4;text-align:end;line-height:1.25}.tools .date small{display:block;color:#9A9A9A;font-size:11.5px}
.lang{display:grid;place-items:center;width:34px;height:34px;border-radius:8px;border:1px solid rgba(255,255,255,.25);color:#fff;text-decoration:none;font-weight:700;font-size:13px}
.lang:hover{background:rgba(255,255,255,.08)}
.bell,.usermenu{position:relative}
.bell>summary,.usermenu>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:6px;height:34px;padding:0 9px;border-radius:8px;border:1px solid rgba(255,255,255,.25);color:#fff}
.bell>summary::-webkit-details-marker,.usermenu>summary::-webkit-details-marker{display:none}
.bell .count{background:var(--brand2);color:#fff}
.avatar{width:22px;height:22px;border-radius:99px;background:var(--brand2);color:#fff;display:grid;place-items:center;font-weight:700;font-size:12px}
.usermenu>summary{padding:0 6px}
.panel{position:absolute;inset-inline-end:0;top:calc(100% + 8px);width:min(400px,92vw);background:#fff;color:var(--ink);border:1px solid var(--line);border-radius:12px;box-shadow:0 14px 40px -12px rgba(16,24,20,.25);z-index:60;padding:6px;max-height:72vh;overflow:auto}
.panel .more{display:block;padding:8px 10px;font-size:13px}
.tabs-sub{display:flex;gap:4px;padding:8px clamp(14px,2.4vw,32px);overflow-x:auto;scrollbar-width:none;background:#fff}
.tabs-sub a{padding:6px 12px;border-radius:8px;color:var(--mut);text-decoration:none;font-size:13.5px;font-weight:500;white-space:nowrap}
.tabs-sub a:hover{background:var(--soft);color:var(--ink)}
.tabs-sub a.on{background:var(--brandS);color:var(--brand2);font-weight:600}

main{padding:22px clamp(14px,2.4vw,32px) 60px;display:flex;flex-direction:column;gap:16px;max-width:1520px;margin:0 auto}
h1{margin:0;font-size:clamp(20px,2.2vw,26px);line-height:1.2;font-weight:700}h2{margin:0 0 10px;font-size:15.5px;font-weight:700}
.sub{margin:4px 0 0;color:var(--mut)}.muted{color:var(--mut);font-size:13px}
.head{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:flex-end;gap:12px}
.row{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:16px 18px}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px}
.kpi .l{font-size:12.5px;color:var(--mut)}.kpi .v{font-size:clamp(19px,2vw,24px);font-weight:700;white-space:nowrap;margin:2px 0}.kpi .n{font-size:12.5px;color:var(--mut)}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,420px),1fr));gap:14px}
.pill{display:inline-block;font-size:12px;font-weight:600;padding:2px 9px;border-radius:6px;white-space:nowrap;background:var(--soft);color:var(--mut)}
.p-ok,.p-paid,.p-approved,.p-posted,.p-Match{background:var(--okS);color:var(--ok)}
.p-warn,.p-pending_approval,.p-partially_paid,.p-draft{background:var(--warnS);color:var(--warn)}
.p-bad,.p-rejected,.p-overdue{background:var(--badS);color:var(--bad)}.p-blue{background:var(--brandS);color:var(--brand)}
.badge{background:var(--brand2);color:#fff;font-size:11px;font-weight:700;padding:1px 8px;border-radius:99px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:38px;padding:0 14px;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);font:600 14px inherit;font-family:inherit;cursor:pointer;text-decoration:none;white-space:nowrap}
.btn:hover{background:var(--soft)}
.btn.pri{background:var(--brand2);border-color:var(--brand2);color:#fff}.btn.pri:hover{background:var(--brand)}
.btn.danger{color:var(--bad)}.btn:disabled{opacity:.45;cursor:not-allowed}.btn.sm{min-height:30px;padding:0 10px;font-size:12.5px}
input,select,textarea{min-height:38px;padding:6px 10px;border:1px solid var(--line);border-radius:8px;background:#fff;color:var(--ink);font:14.5px inherit;font-family:inherit}
input:focus,select:focus,textarea:focus,.btn:focus-visible,a:focus-visible{outline:2px solid var(--brand2);outline-offset:1px}
label{display:grid;gap:4px;font-size:13px;color:var(--mut)}
.form{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:12px}
.scroll{overflow-x:auto}
table{border-collapse:collapse;width:100%;font-size:13.5px;font-variant-numeric:tabular-nums}
th{text-align:start;font-size:12px;color:var(--mut);font-weight:600;padding:9px 10px;border-bottom:1px solid var(--line);white-space:nowrap;background:#FAFBFA;position:sticky;top:0}
td{padding:8px 10px;border-bottom:1px solid var(--line);white-space:nowrap;text-align:start}
.n,td.n,th.n{text-align:end}
tbody tr:hover td{background:#FAFAFA}
tr.sub td{font-weight:600;background:#F7F9F8}tr.tot td{font-weight:700;border-top:2px solid var(--line)}tr.ratio td{color:var(--mut);font-style:italic}
.up{color:var(--ok)}.down{color:var(--bad)}
.flash{background:var(--okS);color:var(--ok);border-radius:8px;padding:10px 14px}.err{background:var(--badS);color:var(--bad);border-radius:8px;padding:10px 14px}
.note{background:var(--warnS);color:var(--warn);border-radius:8px;padding:10px 14px}
.tabs{display:flex;gap:4px;flex-wrap:wrap}.tabs a{padding:6px 12px;border-radius:8px;text-decoration:none;color:var(--ink);background:#fff;border:1px solid var(--line);font-size:13px}.tabs a.on{background:var(--brand);color:#fff;border-color:var(--brand)}
.bars{display:grid;gap:7px}.bar{display:grid;grid-template-columns:minmax(0,180px) 1fr auto;gap:10px;align-items:center;font-size:13px}
.bar .t{height:10px;border-radius:3px;background:var(--soft);overflow:hidden}.bar .t i{display:block;height:100%;background:var(--brand2);border-radius:3px}

/* ---------- numbers ---------- */
.pos{color:var(--ok);font-weight:600}.neg{color:var(--bad);font-weight:600}.zero{color:var(--mut)}
.delta{display:inline-flex;align-items:center;gap:3px;font:600 12px Inter,sans-serif;padding:1px 7px;border-radius:5px;white-space:nowrap;direction:ltr;unicode-bidi:isolate}
.delta.good{background:var(--okS);color:var(--ok)}.delta.bad{background:var(--badS);color:var(--bad)}.delta.flat{background:var(--soft);color:var(--mut)}
.pos,.neg,.zero{direction:ltr;unicode-bidi:isolate}

/* ---------- alerts ---------- */
.alist{display:grid;gap:2px}
.alert-item{display:grid;grid-template-columns:10px 1fr;gap:10px;padding:9px 10px;border-radius:8px;text-decoration:none;color:var(--ink)}
.alert-item:hover{background:#F5F8F6}.alert-item b{font-size:13.5px}.alert-item p{margin:2px 0 0;font-size:12.5px;color:var(--mut);white-space:normal}
.sev{width:9px;height:9px;border-radius:99px;margin-top:6px}.sev.critical{background:var(--bad)}.sev.warning{background:#D99A1E}.sev.info{background:#7A8C85}
.alert-item.unread b::after{content:'';display:inline-block;width:6px;height:6px;border-radius:99px;background:var(--brand2);margin-inline-start:6px;vertical-align:middle}

/* ---------- dashboard ---------- */
.pagehead{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:flex-end;gap:12px}
.kstrip{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));background:#fff;border:1px solid var(--line);border-radius:var(--r)}
.kstrip>div{padding:14px 16px;border-inline-end:1px solid var(--line)}.kstrip>div:last-child{border-inline-end:0}
.kstrip .l{font-size:12.5px;color:var(--mut)}.kstrip .v{font-size:clamp(18px,1.9vw,23px);font-weight:700;margin:3px 0 4px;white-space:nowrap}
.kstrip .cur{font-size:12px;color:var(--mut);font-weight:500;margin-inline-start:4px}
.summary{border-inline-start:4px solid var(--brand2)}
.summary b.h{font-size:15px}.summary p{margin:6px 0 0;color:#33403B;white-space:normal}
.summary .meta{font-size:12px;color:var(--mut)}
.section-title{display:flex;justify-content:space-between;align-items:baseline;gap:10px;margin:4px 2px -4px}
.section-title h2{margin:0;font-size:16px}
.projects{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,250px),1fr));gap:14px}
.proj{position:relative;display:flex;flex-direction:column;gap:10px;text-decoration:none;color:var(--ink);border-top:3px solid var(--c)}
.proj:hover{border-color:#C9D3CE;border-top-color:var(--c)}
.proj .top{display:flex;justify-content:space-between;align-items:center;gap:10px}
.proj .nm{font-weight:700;font-size:14.5px}
.tag{font-size:11.5px;font-weight:600;padding:2px 8px;border-radius:5px;white-space:nowrap}
.tag.risk{background:var(--badS);color:var(--bad)}.tag.watch{background:#F1F1F1;color:#141414}.tag.ok{background:var(--okS);color:var(--ok)}
.proj .big{font-size:23px;font-weight:700;letter-spacing:-.01em;line-height:1.1}
.proj .lbl{font-size:12px;color:var(--mut)}
.proj .mid{display:flex;justify-content:space-between;align-items:center;gap:8px}
.proj .stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;border-top:1px solid var(--line);padding-top:10px}
.proj .stats div{font-size:12px;color:var(--mut)}.proj .stats b{display:block;font-size:14px;color:var(--ink)}
.proj .brief{font-size:12.8px;color:#33403B;background:#F7F9F8;border-radius:6px;padding:8px 10px;white-space:normal}
.spark{display:block;max-width:100%;height:auto}.ring{flex:none}
[dir=rtl] .spark,[dir=rtl] .cols{direction:ltr}
.dash2{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);gap:14px}
@media(max-width:1100px){.dash2{grid-template-columns:1fr}}
.brief-card ul{margin:6px 0 0;padding-inline-start:18px}.brief-card li{margin:4px 0;white-space:normal}
.brief-card h3,.cap{font-size:12px;letter-spacing:.03em;color:var(--mut);margin:14px 0 4px;font-weight:600}
.chip{display:inline-block;font-size:11px;font-weight:600;padding:2px 8px;border-radius:5px;background:var(--brandS);color:var(--brand2)}
.cols{width:100%;height:190px}.cols .ax{font-size:11px;fill:#8A9690}
.meter{height:8px;border-radius:4px;background:var(--soft);overflow:hidden}.meter i{display:block;height:100%;border-radius:4px}
.unit{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px}
.unit .u{padding:12px 14px;border-radius:8px;background:#F7F9F8;border:1px solid var(--line)}.unit .u .l{font-size:12px;color:var(--mut)}.unit .u .v{font-size:21px;font-weight:700}

nav[role=navigation] svg{width:16px}
@media(max-width:1100px){.tools .date{display:none}}
@media(max-width:760px){.topnav .bar{flex-wrap:wrap;padding-top:8px}.tabs-main{order:3;flex-basis:100%;min-height:42px}.logo small{display:none}}
@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}
bdi,.num{unicode-bidi:isolate}
/* clickable rows, sortable headers, in-cell bars */
tr.link{cursor:pointer}tr.link:hover td{background:#FBF3F2}
tr.link td:first-child a{color:var(--ink);font-weight:600;text-decoration:none}tr.link:hover td:first-child a{color:var(--brand2)}
th a.sort{color:inherit;text-decoration:none}th a.sort.on{color:var(--brand2)}
.cellbar{position:relative;min-width:110px}.cellbar i{position:absolute;inset-block:7px;inset-inline-start:0;border-radius:3px;opacity:.16}
.cellbar span{position:relative}
tr.grp td{background:#F7F7F7;font-weight:700;border-top:2px solid var(--line)}
tr.total td{background:#141414;color:#fff;font-weight:700}tr.total td .pos{color:#6EE7A0}tr.total td .neg{color:#FF8A80}
.kpi-mini{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.cardhead{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:8px}
.actions{display:grid;gap:10px}.act{display:grid;grid-template-columns:auto 1fr auto;gap:12px;align-items:center;padding:12px 14px;border:1px solid var(--line);border-radius:10px;background:#fff}
.act .ico{width:34px;height:34px;border-radius:8px;display:grid;place-items:center;background:var(--brandS);color:var(--brand2);font-weight:800}
.act b{display:block}.act .imp{font:700 15px Inter,sans-serif;color:var(--ok);white-space:nowrap}

/* date range picker */
.dr{position:relative;display:flex;gap:10px;align-items:end;flex-wrap:wrap}
.dr-btn{display:inline-flex;align-items:center;gap:10px;min-width:190px;justify-content:space-between;height:40px;padding:0 12px;border:1px solid var(--line,#ddd);border-radius:8px;background:#fff;font:inherit;cursor:pointer}
.dr-pop{display:none;position:absolute;top:100%;right:0;z-index:50;margin-top:6px;background:#fff;border:1px solid var(--line,#e5e5e5);border-radius:12px;box-shadow:0 12px 40px rgba(0,0,0,.12);padding:14px;gap:18px}
.dr.open .dr-pop{display:flex}
.dr-presets{display:flex;flex-direction:column;gap:10px;min-width:170px}
.dr-p{display:flex;align-items:center;gap:10px;font-weight:400;cursor:pointer;margin:0}
.dr-p input{accent-color:var(--brand2);width:16px;height:16px}
.dr-sel{font-weight:700;font-size:13px;min-height:18px;direction:ltr;text-align:start;unicode-bidi:isolate}
.dr-cal{display:flex;gap:22px;position:relative;background:#FAFAFA;border-radius:10px;padding:10px 14px}
.dr-nav{position:absolute;top:10px;inset-inline:10px;display:flex;justify-content:space-between;pointer-events:none}
.dr-nav a{pointer-events:auto;cursor:pointer;font-size:20px;color:#999;padding:0 6px;text-decoration:none}
.dr-m{width:250px}.dr-mh{text-align:center;font-weight:700;color:#777;padding:4px 0 10px;border-bottom:1px solid #eee;margin-bottom:6px}
.dr-g{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;text-align:center}
.dr-g b{font-size:12px;color:#999;padding:6px 0}
.dr-g a{display:block;padding:7px 0;border-radius:50%;cursor:pointer;color:#333;text-decoration:none;font-size:13px}
.dr-g a:hover{background:#f1e1df}
.dr-g a.in{background:#F6E3E1;border-radius:0}
.dr-g a.hv:not(.st):not(.en){background:#FBEFED;border-radius:0}
.dr-hint{font-size:12px;max-width:170px}
.dr-g a.st,.dr-g a.en{background:var(--brand2);color:#fff;border-radius:50%}
.dr-g a.td{outline:1px solid var(--brand2)}
@media (max-width:760px){.dr-pop{flex-direction:column;right:auto;left:0}.dr-cal{flex-direction:column}}
.p-info{background:var(--soft);color:var(--mut)}

/* ---------- dark mode (toggle in the header; remembered per browser) ---------- */
.theme{display:inline-grid;place-items:center;width:38px;height:38px;border-radius:9px;border:1px solid rgba(255,255,255,.22);background:transparent;color:#fff;cursor:pointer}
.theme .sun{display:none}html[data-theme=dark] .theme .sun{display:block}html[data-theme=dark] .theme .moon{display:none}
html[data-theme=dark]{color-scheme:dark;
  --bg:#0F1012;--card:#18191C;--ink:#ECECEE;--mut:#A3A6AD;--line:#2B2D32;--soft:#232529;
  --brandS:#3A1B19;--blueS:#3A1B19;--blueT:#FF8A80;--gold:#E0574D;
  --ok:#4CC38A;--okS:#14301F;--warn:#E8B44A;--warnS:#3A2D10;--bad:#FF6B5E;--badS:#3E1815}
html[data-theme=dark] main a:not(.btn):not(.pill){color:#FF8A80}
html[data-theme=dark] .tabs-main a{color:#C9C9C9}html[data-theme=dark] .tabs-main a.on{color:#fff}
html[data-theme=dark] .tabs-sub a{color:var(--ink)}html[data-theme=dark] .panel a{color:var(--ink)}
html[data-theme=dark] .lang{color:#fff}
html[data-theme=dark] .topnav,html[data-theme=dark] .tabs-sub,html[data-theme=dark] .panel,html[data-theme=dark] .kstrip,
html[data-theme=dark] .dr-btn,html[data-theme=dark] .dr-pop,html[data-theme=dark] .tabs a,html[data-theme=dark] .btn,
html[data-theme=dark] input,html[data-theme=dark] select,html[data-theme=dark] textarea,html[data-theme=dark] .card{background:var(--card);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] .btn.pri,html[data-theme=dark] .tabs a.on{background:var(--brand2);border-color:var(--brand2);color:#fff}
html[data-theme=dark] .btn.danger{background:var(--badS);color:var(--bad)}
html[data-theme=dark] th{background:#1F2124}
html[data-theme=dark] tbody tr:hover td,html[data-theme=dark] .alert-item:hover{background:#1E2023}
html[data-theme=dark] tr.sub td,html[data-theme=dark] tr.grp td,html[data-theme=dark] .proj .brief,html[data-theme=dark] .unit .u,html[data-theme=dark] .dr-cal{background:#202226}
html[data-theme=dark] tr.link:hover td{background:#2A1C1B}
html[data-theme=dark] .summary p,html[data-theme=dark] .proj .brief{color:#C9CBD0}
html[data-theme=dark] .tag.watch{background:#26282C;color:#ECECEE}
html[data-theme=dark] .dr-g a{color:var(--ink)}html[data-theme=dark] .dr-g a:hover{background:#3A1B19}html[data-theme=dark] .dr-g a.in{background:#3A1B19}html[data-theme=dark] .dr-g a.hv:not(.st):not(.en){background:#2C1716}
html[data-theme=dark] .dr-mh{border-color:var(--line);color:var(--mut)}
html[data-theme=dark] .tabs-sub a.on{background:var(--brandS);color:#FF8A80}
html[data-theme=dark] .note{background:#2A2414;color:#F1D48A;border-color:#4A3A14}
html[data-theme=dark] .note.warn{background:#3A2D10}
html[data-theme=dark] .err{background:var(--badS);color:var(--bad)}
html[data-theme=dark] tr.total td{background:#000;color:#fff}
html[data-theme=dark] svg line[stroke="#EEF1F5"],html[data-theme=dark] svg circle[stroke="#EEF1F5"]{stroke:#2B2D32}
html[data-theme=dark] svg rect[fill="#2A2A2A"]{fill:#C9CBD0}
html[data-theme=dark] svg circle[stroke="#fff"]{stroke:#18191C}
html[data-theme=dark] svg .ax,html[data-theme=dark] svg text{fill:#A3A6AD}
html[data-theme=dark] img{opacity:.95}
