:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f1f3f6; --line: #e3e6eb; --line-2: #d4d8df;
  --text: #15181e; --text-2: #4b5260; --muted: #7a8291;
  --accent: #1f5eff; --accent-soft: #e8efff; --accent-text: #1647c2;
  --good: #12805c; --good-soft: #e3f4ec; --warn: #a85b00; --warn-soft: #fdf0dc;
  --bad: #c0362c; --bad-soft: #fbe6e4; --info-soft: #eef0f4;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.16);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a20; --panel-2: #1d2128; --line: #262b33; --line-2: #323844;
    --text: #e8ebf0; --text-2: #b4bac5; --muted: #858d9b;
    --accent: #5b8cff; --accent-soft: #1b2643; --accent-text: #a9c1ff;
    --good: #3ccb94; --good-soft: #13291f; --warn: #f0a34a; --warn-soft: #2d2213;
    --bad: #f07267; --bad-soft: #2f1716; --info-soft: #20242c;
    --shadow: none; --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
kbd { font: 11px/1 var(--font); color: var(--muted); border: 1px solid var(--line-2); border-radius: 5px; padding: 3px 5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--bad); margin: 0; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 228px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; gap: 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; padding: 2px 6px 6px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.brand-mark.lg { width: 44px; height: 44px; font-size: 20px; border-radius: 12px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
nav a span { flex: 1; }
nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
nav a.on { background: var(--accent-soft); color: var(--accent-text); }
nav a kbd { opacity: 0; } nav a:hover kbd { opacity: 1; }
.count { background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.search-trigger { flex: 1; max-width: 520px; display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); padding: 7px 10px; font: inherit; cursor: text; }
.view { padding: 24px 28px 64px; max-width: 1360px; width: 100%; }
.only-mobile { display: none; }

/* Building blocks */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-h p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; }
.kpi { padding: 14px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-2); }
.bar { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.btn { font: inherit; font-weight: 500; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon { padding: 6px 9px; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 20px; background: var(--info-soft); color: var(--text-2); white-space: nowrap; }
.badge.can { background: var(--good-soft); color: var(--good); }
.badge.recheck { background: var(--warn-soft); color: var(--warn); }
.badge.blocked { background: var(--bad-soft); color: var(--bad); }
.badge.nurture, .badge.lane { background: var(--accent-soft); color: var(--accent-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.can { background: var(--good); } .dot.recheck { background: var(--warn); } .dot.blocked { background: var(--bad); }

.score { display: inline-grid; place-items: center; width: 34px; height: 26px; border-radius: 7px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; background: var(--panel-2); color: var(--text-2); }
.score.hi { background: var(--accent); color: #fff; } .score.mid { background: var(--accent-soft); color: var(--accent-text); }

/* Lists and tables */
.list > * + * { border-top: 1px solid var(--line); }
.item { padding: 12px 16px; display: flex; gap: 12px; align-items: flex-start; }
.item.click { cursor: pointer; } .item.click:hover { background: var(--panel-2); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 12px; color: var(--muted); }
.item .next { color: var(--text-2); margin-top: 2px; }
.why { font-size: 12px; color: var(--muted); margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); cursor: pointer; user-select: none; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow: auto; max-height: calc(100vh - 230px); }
.trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .search-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
.form { display: grid; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; }
.chip { font: inherit; font-size: 13px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text-2); border-radius: 20px; padding: 4px 12px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--panel); border-color: var(--text); }

/* Account page */
.acc-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.acc-head .facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.next-box { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.next-box .lbl { font-size: 12px; color: var(--accent-text); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.next-box .txt { font-size: 15px; font-weight: 500; }
.warn-box { background: var(--bad-soft); color: var(--bad); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-weight: 500; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 500; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.contact-actions a { font-size: 12px; margin-right: 10px; }
.timeline > div { padding: 10px 16px; border-left: 2px solid var(--line); margin-left: 16px; position: relative; }
.timeline > div::before { content: ""; position: absolute; left: -5px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.pre { white-space: pre-wrap; font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 10px 12px; max-height: 320px; overflow: auto; }

/* Meeting brief */
.meeting-brief { max-width: 900px; }
.brief-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
.brief-grid section { border-top: 1px solid var(--line); padding-top: 10px; break-inside: avoid; }
.brief-grid h2 { font-size: 13px; margin-bottom: 7px; }
.brief-grid p { margin: 0; white-space: pre-wrap; }
.brief-list { display: grid; gap: 6px; }
.brief-list span { display: block; color: var(--muted); font-size: 12px; }

/* Pipeline */
.board { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel-2); border-radius: var(--radius); padding: 10px; min-height: 240px; }
.col.drag-over { outline: 2px solid var(--accent); outline-offset: -2px; }
.col h3 { display: flex; justify-content: space-between; font-size: 13px; margin: 2px 4px 10px; color: var(--text-2); }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.deal:hover { border-color: var(--line-2); }
.deal .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.deal-forecast { width: auto; max-width: 110px; padding: 3px 6px; font-size: 12px; }

/* Knowledge doc */
.doc { max-width: 860px; }
.doc h1 { font-size: 20px; margin: 18px 0 8px; } .doc h2 { margin: 18px 0 8px; } .doc h3 { margin: 14px 0 6px; }
.doc table { font-size: 12px; margin: 10px 0; display: block; overflow-x: auto; }
.doc td, .doc th { border: 1px solid var(--line); padding: 5px 8px; position: static; }
.doc mark { background: var(--warn-soft); color: inherit; }

/* Overlays */
.overlay { position: fixed; inset: 0; background: rgba(15,17,21,.42); z-index: 50; display: grid; place-items: start center; padding: 10vh 16px; }
.palette, .modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 580px; overflow: hidden; }
.modal { max-width: 620px; max-height: 80vh; display: flex; flex-direction: column; }
.modal .m-h { padding: 16px 20px 0; } .modal .m-b { padding: 16px 20px; overflow: auto; } .modal .m-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 16px; font-size: 15px; outline: none; }
.palette input:focus { outline: none; }
#palette-results { max-height: 50vh; overflow: auto; }
#palette-results .item.sel { background: var(--accent-soft); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 9px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow-lg); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 4px; } .login-card p { margin: -8px 0 4px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: 1fr 1fr; } .g-main, .g3 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .15s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .only-mobile { display: inline-flex; }
  .top { padding: 10px 16px; } .view { padding: 16px 16px 48px; }
  .g2, .g4, .form .two, .brief-grid { grid-template-columns: 1fr; }
  .search-trigger kbd { display: none; }
  .hide-sm { display: none; }
}
@media print {
  .side, .top, .no-print { display: none !important; }
  .shell, main { display: block; height: auto; }
  .view { max-width: none; padding: 0; }
  .meeting-brief { max-width: none; font-size: 11pt; }
  .brief-grid { gap: 12px 22px; }
  .brief-grid section { padding-top: 7px; }
}
