:root {
  --bg: #f4f6f5; --panel: #ffffff; --panel-2: #f8faf9; --ink: #13211d; --ink-2: #44544f; --muted: #6f7f7a;
  --line: #e2e8e5; --line-2: #eef2f0;
  --brand: #0b6b57; --brand-2: #0e8a70; --brand-soft: #e3f3ee; --accent: #c8a24a;
  --good: #1a7f4e; --good-soft: #e3f4ea; --bad: #b42318; --bad-soft: #fde8e6; --warn: #b26b00; --warn-soft: #fff3dc;
  --info: #2459a8; --info-soft: #e6eefb;
  --s1: #0b6b57; --s2: #3b82c4; --s3: #c8a24a; --s4: #8b5cf6; --s5: #e0723a; --s6: #4aa39a; --s7: #9f4f7e; --s8: #6b7a3a;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 40, 32, .05), 0 1px 1px rgba(16, 40, 32, .03);
  --font: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1513; --panel: #131e1b; --panel-2: #172420; --ink: #e6efec; --ink-2: #b7c6c1; --muted: #8a9b96;
    --line: #24332f; --line-2: #1c2926; --brand: #3fbf9d; --brand-2: #5fd3b3; --brand-soft: #173a31;
    --good: #4cc38a; --good-soft: #15322a; --bad: #ff7b6e; --bad-soft: #3a1d1a; --warn: #f0b44c; --warn-soft: #3a2e17;
    --info: #79a8f0; --info-soft: #172843;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1513; --panel: #131e1b; --panel-2: #172420; --ink: #e6efec; --ink-2: #b7c6c1; --muted: #8a9b96;
  --line: #24332f; --line-2: #1c2926; --brand: #3fbf9d; --brand-2: #5fd3b3; --brand-soft: #173a31;
  --good: #4cc38a; --good-soft: #15322a; --bad: #ff7b6e; --bad-soft: #3a1d1a; --warn: #f0b44c; --warn-soft: #3a2e17;
  --info: #79a8f0; --info-soft: #172843;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.45; }
body { -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
a { color: var(--brand); cursor: pointer; text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.ar { font-family: "IBM Plex Sans Arabic", var(--font); }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.err { color: var(--bad); min-height: 1em; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% 0%, var(--brand-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-weight: 500; font-size: 13px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.brand-lg { display: flex; gap: 12px; align-items: center; font-size: 22px; }
.brand-lg small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.mark { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-family: "IBM Plex Sans Arabic"; font-weight: 700; font-size: 22px; flex: none; }

/* shell */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 16px; }
.brand .mark { width: 34px; height: 34px; font-size: 18px; }
.brand b { font-size: 16px; } .brand small { display: block; color: var(--muted); font-size: 11px; }
nav { display: grid; gap: 2px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500; }
nav a i { font-style: normal; width: 18px; text-align: center; color: var(--muted); }
nav a:hover { background: var(--panel-2); }
nav a.active { background: var(--brand-soft); color: var(--brand); } nav a.active i { color: var(--brand); }
.side-foot { margin-top: auto; padding: 12px 8px 0; display: grid; gap: 6px; }
.demo-pill { display: inline-block; justify-self: start; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 11px; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; }
main { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; gap: 12px; }
.crumbs { color: var(--muted); display: flex; gap: 8px; } .crumbs span:last-child { color: var(--ink); font-weight: 500; }
.top-r { display: flex; gap: 8px; align-items: center; }
.user { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 13px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 600; }
#view { padding: 24px; max-width: 1480px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); max-width: 820px; }

/* components */
.btn { font: inherit; font-weight: 500; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; } .btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.kpi { display: grid; gap: 4px; }
.kpi .v { font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .d { font-size: 12px; color: var(--ink-2); }
.bar-row { display: grid; grid-template-columns: 110px 1fr 52px; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.bar-row:hover .bar-track { background: var(--line); }
.bar-track { height: 10px; background: var(--line-2); border-radius: 99px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); }
.bar-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); opacity: .5; }
.num { font-variant-numeric: tabular-nums; text-align: end; font-weight: 500; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: start; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: 560px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.list { display: grid; }
.list-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); align-items: center; cursor: pointer; }
.list-item:hover { background: var(--panel-2); }
.list-item .t { font-weight: 600; } .list-item .s { color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.High, .dot.Blocking { background: var(--bad); } .dot.Medium, .dot.Warning { background: var(--warn); } .dot.Low { background: var(--info); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { font: inherit; background: none; border: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; border: none; background: var(--panel); padding: 6px 12px; cursor: pointer; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.seg button.active { background: var(--brand); color: #fff; }
.heat { display: grid; gap: 4px; }
.heat-row { display: grid; grid-template-columns: 120px repeat(3, 1fr); gap: 4px; align-items: center; }
.heat-cell { border-radius: 6px; padding: 10px 8px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.heat-h { font-size: 11px; color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.flow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; align-items: stretch; }
.flow-step { position: relative; padding: 14px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; margin-inline-end: 22px; }
.flow-step:not(:last-child)::after { content: "→"; position: absolute; inset-inline-end: -19px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; }
[dir="rtl"] .flow-step:not(:last-child)::after { content: "←"; }
.flow-step b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.flow-step span { color: var(--muted); font-size: 12px; }
.chart-box { position: relative; height: 280px; } .chart-box.sm { height: 200px; } .chart-box.lg { height: 360px; }
.note { background: var(--info-soft); color: var(--info); border-radius: 8px; padding: 10px 12px; font-size: 12px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.callout { border-inline-start: 3px solid var(--brand); padding: 8px 12px; background: var(--brand-soft); border-radius: 0 8px 8px 0; font-size: 13px; }
[dir="rtl"] .callout { border-radius: 8px 0 0 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.form-grid label.check { display: flex; gap: 8px; align-items: center; } .form-grid label.check input { width: auto; }
.timeline { display: grid; gap: 0; }
.timeline .ev { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.skeleton { color: var(--muted); padding: 40px; text-align: center; }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(10, 20, 18, .35); z-index: 20; display: flex; justify-content: flex-end; }
.drawer-panel { width: min(640px, 100%); height: 100%; background: var(--panel); overflow: auto; padding: 24px; position: relative; box-shadow: -8px 0 24px rgba(0, 0, 0, .1); }
[dir="rtl"] .drawer { justify-content: flex-start; }
.x { position: absolute; top: 12px; inset-inline-end: 12px; border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; z-index: 30; font-weight: 500; }

/* chat */
.chat { display: flex; flex-direction: column; height: 620px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel-2); }
.chat-head { padding: 12px 14px; background: var(--brand); color: #fff; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-head small { opacity: .8; display: block; }
.chat-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.msg.assistant { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; border-end-start-radius: 4px; }
.msg.user { background: var(--brand); color: #fff; align-self: flex-end; border-end-end-radius: 4px; }
.msg.sys { align-self: center; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 500; }
.chat-foot { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-foot input { flex: 1; }
.progress { height: 6px; background: rgba(255, 255, 255, .25); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: #fff; }
.typing { display: inline-flex; gap: 4px; } .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: b 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.ask-answer { display: grid; gap: 10px; }
.sql { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow: auto; max-height: 220px; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.suggest button { font: inherit; font-size: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 10px; cursor: pointer; color: var(--ink-2); text-align: start; }
.suggest button:hover { border-color: var(--brand); color: var(--brand); }

@media (max-width: 1100px) {
  .g4, .g6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g-2-1, .g-1-2, .g2 { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; } .flow-step { margin: 0 0 22px; } .flow-step:not(:last-child)::after { content: "↓"; inset-inline-end: 50%; top: auto; bottom: -21px; transform: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } #view { padding: 16px; }
  .top { padding: 10px 16px; flex-wrap: wrap; } .crumbs { display: none; } .form-grid { grid-template-columns: 1fr; }
  .heat-row { grid-template-columns: 80px repeat(3, 1fr); }
  .demo-banner { padding: 7px 16px; }
}

/* co-branding & demo disclaimer */
.demo-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); padding: 7px 24px; font-size: 12px; line-height: 1.4; }
.cobrand { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cobrand-label, .side-cobrand > span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.cnhi-logo { display: block; max-width: 100%; height: auto; }
.cobrand .cnhi-logo { width: 100%; max-width: 340px; max-height: none; padding: 10px 14px; }
.side-cobrand { display: grid; gap: 6px; justify-items: start; margin: 0 8px 8px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; }
.side-cobrand .cnhi-logo { max-height: 40px; }
.cnhi-fallback { font-weight: 600; color: var(--ink-2); font-size: 13px; }
/* logos are designed for light backgrounds: give them a white plate so they work in dark mode */
.cnhi-logo, .prepared img { background: #fff; border-radius: 6px; padding: 4px 6px; }
.disclaimer-box { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.disclaimer-box b { display: block; margin-bottom: 2px; }
.prepared { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 11px; }
.prepared img { height: 44px; width: auto; }
.prepared.sm { justify-content: flex-start; } .prepared.sm img { height: 34px; }
@media (max-width: 760px) { .demo-banner { padding: 7px 16px; } }

@media print {
  body * { visibility: hidden; }
  #printable, #printable * { visibility: visible; }
  #printable { position: absolute; inset: 0; padding: 24px; color: #000; }
  .drawer { background: none; }
}
