/* COMPASS v4 — Forest / Sage / Ink. Calm, hairline, airy. */
:root {
  --bg: #FAFAF8; --surface: #FFFFFF; --surface-2: #F4F4F5; --surface-soft: #E5F2EF;
  --fg: #0D1117; --fg-muted: #5B6660; --fg-faint: #9AA5A0;
  --line: #E6E7E9; --line-strong: #D7DAD9; --line-soft: rgba(13,17,23,0.06);
  --brand: #2E5546; --brand-hover: #264A3C; --brand-press: #1E3D31; --accent: #A6BBAA; --on-brand: #FFFFFF;
  --success-fg: #2E7D5B; --success-bg: #E6F4EC; --success-bd: #BFE0CE;
  --warning-fg: #B07D17; --warning-bg: #FBF3DE; --warning-bd: #ECD79C;
  --danger-fg: #C0392B; --danger-bg: #FBE9E7; --danger-bd: #F0C5BF;
  --info-fg: #2E6A8A; --info-bg: #E6F0F5; --info-bd: #BBD6E4;
  --sidebar: #0D1117;
  --shadow-soft: 0 10px 30px -18px rgba(13,17,23,0.18);
  --display: "Satoshi", "Heebo", system-ui, sans-serif;
  --body: "Heebo", "Inter", system-ui, sans-serif;
  --r-md: 12px; --r-lg: 16px; --r-sm: 8px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="dark"] {
  --bg: #0D1117; --surface: #151A21; --surface-2: #1C232B; --surface-soft: rgba(166,187,170,0.10);
  --fg: #ECEFEC; --fg-muted: #A7B0AB; --fg-faint: #7C857F;
  --line: #2A323A; --line-strong: #36404A; --line-soft: rgba(255,255,255,0.05);
  --brand: #5C9A80; --brand-hover: #6CAB90; --accent: #A6BBAA;
  --success-bg: rgba(95,191,147,0.12); --success-fg: #5FBF93; --success-bd: rgba(95,191,147,0.3);
  --warning-bg: rgba(227,182,90,0.12); --warning-fg: #E3B65A; --warning-bd: rgba(227,182,90,0.3);
  --danger-bg: rgba(224,128,116,0.12); --danger-fg: #E08074; --danger-bd: rgba(224,128,116,0.3);
  --info-bg: rgba(108,182,214,0.12); --info-fg: #6CB6D6; --info-bd: rgba(108,182,214,0.3);
}
* { box-sizing: border-box; }
/* never let one wide element (long URL / commit hash / branch name) force the whole
   page wider than the screen — that is what makes mobile Safari zoom the page out. */
html, body { margin: 0; height: 100%; max-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { font-family: var(--body); background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.6; }
/* grid/flex children must be allowed to shrink, otherwise their content min-width
   pushes the track wider than the viewport. */
.layout, .content, main, .sidebar, .nav, .topbar, .card, .grid, .board, .col, .list-row, .tcard, .kpi, .hero-card, .hero-chips { min-width: 0; }
/* long unbreakable tokens wrap instead of overflowing. */
.tcard-title, .lr-title, .lr-meta, .section-note, .hero-state, .side-link, code,
.tag, .req-badge, .day-group-h, .prow, .kpi-sub { overflow-wrap: anywhere; word-break: break-word; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }

/* RTL: first column (inline-start = right) holds the sidebar, so it must be the fixed 240px. */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* sidebar (right in RTL) */
.sidebar { background: var(--sidebar); color: #ECEFEC; display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.brand { padding: 6px 10px 22px; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 24px; color: #fff; }
.wordmark .dot { color: var(--accent); }
.brand-sub { display: block; font-size: 12px; color: #8A938D; margin-top: 2px; letter-spacing: .04em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #C2C9C4; text-align: right; padding: 10px 12px; border-radius: var(--r-sm); font-size: 14.5px; transition: background .2s var(--ease); position: relative; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: rgba(46,85,70,0.35); color: #fff; }
.nav-item.active::before { content:""; position:absolute; right:0; top:8px; bottom:8px; width:3px; border-radius:3px; background: var(--accent); }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; font-size: 15px; }
.badge-count { margin-inline-start: auto; background: var(--danger-fg); color:#fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: none; align-items: center; justify-content: center; padding: 0 5px; }
.badge-count.show { display: inline-flex; }
.side-links { padding: 8px 4px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 8px; }
.side-links-h { font-size: 11px; color: #6E776F; padding: 4px 10px; letter-spacing: .04em; }
.side-link { display: block; color: #B8C0BA; text-decoration: none; font-size: 13.5px; padding: 7px 10px; border-radius: 6px; transition: background .15s var(--ease); }
.side-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; }
.side-foot-meta { flex: 1; }
.who { font-size: 14px; color: #fff; }
.role { font-size: 11px; color: #8A938D; }
.theme-btn { background: none; border: 1px solid rgba(255,255,255,0.15); color: #C2C9C4; width: 30px; height: 30px; border-radius: 50%; }

/* content */
.content { padding: 28px 36px 64px; max-width: 1180px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.greeting { font-size: 13px; color: var(--fg-muted); }
.page-title { font-size: 28px; font-weight: 600; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.updated { font-size: 12px; color: var(--fg-faint); }

.btn { border: 1px solid transparent; border-radius: var(--r-sm); padding: 9px 16px; font-size: 14px; font-weight: 500; transition: all .2s var(--ease); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-danger { background: transparent; color: var(--danger-fg); border-color: var(--danger-bd); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.loading { color: var(--fg-faint); padding: 40px; text-align: center; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-h h2, .card-h h3 { font-size: 16px; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .cols-4 { grid-template-columns: repeat(2,1fr);} .cols-3,.cols-2{grid-template-columns:1fr;} .layout{grid-template-columns:1fr;} .sidebar{position:sticky; top:0; height:auto; flex-direction:row; width:100%; z-index:5;} }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.kpi-label { font-size: 12.5px; color: var(--fg-muted); margin-bottom: 6px; }
.kpi-value { font-family: var(--display); font-weight: 700; font-size: 38px; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--fg-faint); margin-top: 8px; }
.kpi-value.alarm { color: var(--danger-fg); }
.kpi-value.good { color: var(--brand); }

/* chips / pills */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.chip.urgent { background: var(--danger-bg); color: var(--danger-fg); }
.chip.high { background: var(--warning-bg); color: var(--warning-fg); }
.chip.medium { background: var(--surface-soft); color: var(--brand); }
.chip.low { background: var(--surface-2); color: var(--fg-muted); }
.chip.dot::before { content:""; width:6px;height:6px;border-radius:50%; background: currentColor; }
.chip.up { background: var(--success-bg); color: var(--success-fg); }
.chip.down { background: var(--danger-bg); color: var(--danger-fg); }
.chip.degraded { background: var(--warning-bg); color: var(--warning-fg); }
.chip.treat { background: var(--info-bg); color: var(--info-fg); }
.chip.unknown { background: var(--surface-2); color: var(--fg-faint); }
.tag { font-size: 11px; color: var(--fg-muted); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; }
/* Task category chip (פיתוח / באגים / תשתית / עיצוב / שוטף) */
.cat { font-size: 11px; font-weight: 600; border-radius: 6px; padding: 1px 8px; white-space: nowrap; }
.cat-dev { background: var(--info-bg); color: var(--info-fg); }
.cat-bug { background: var(--danger-bg); color: var(--danger-fg); }
.cat-infra { background: var(--surface-soft); color: var(--brand); }
.cat-design { background: var(--warning-bg); color: var(--warning-fg); }
.cat-ops { background: var(--surface-2); color: var(--fg-muted); }
/* Category filter bar (board) */
.catfilter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.catfilter { display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 13px; font-weight: 500; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg-muted); cursor: pointer; transition: all .12s; }
.catfilter:hover { border-color: var(--brand); }
.catfilter.active { border-color: var(--brand); background: var(--surface-soft); color: var(--brand); font-weight: 600; }
.cf-count { font-size: 11px; opacity: .65; }

/* roadmap board */
.proj-block { margin-bottom: 26px; }
.proj-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.proj-head h2 { font-size: 18px; }
.proj-head .count { font-size: 12.5px; color: var(--fg-faint); }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 1100px){ .board{ grid-template-columns: repeat(2,1fr);} }
.col { background: var(--surface-2); border-radius: var(--r-md); padding: 10px; min-height: 60px; }
.col-h { font-size: 12px; font-weight: 600; color: var(--fg-muted); margin: 2px 4px 10px; display:flex; justify-content:space-between; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s var(--ease); }
.tcard:hover { border-color: var(--line-strong); }
.tcard.l-urgent { border-inline-start: 3px solid var(--danger-fg); }
.tcard.l-high { border-inline-start: 3px solid var(--warning-fg); }
.tcard-title { font-size: 13.5px; font-weight: 500; margin-bottom: 8px; line-height: 1.4; }
.tcard-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tcard-foot { display:flex; justify-content: space-between; align-items:center; margin-top: 8px; font-size: 11px; color: var(--fg-faint); }
.stalled-flag { color: var(--warning-fg); font-weight: 500; }
.req-badge { font-size: 11px; font-weight: 600; color: var(--brand); background: var(--surface-soft); border-radius: 6px; padding: 3px 7px; margin-bottom: 8px; display: inline-block; }
.tcard.is-partial { border-inline-start: 3px solid var(--info-fg); }
.btn-request { background: transparent; color: var(--brand); border-color: var(--brand); }
.btn-request:hover { background: var(--surface-soft); }
.owner-pill { font-size: 11px; color: var(--fg-muted); border:1px solid var(--line); border-radius: 999px; padding: 0 7px; }

/* lists */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-title { flex: 1; font-size: 14px; }
.list-row .lr-meta { font-size: 12px; color: var(--fg-faint); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sd-up { background: var(--success-fg); } .sd-down { background: var(--danger-fg); }
.sd-degraded { background: var(--warning-fg); } .sd-treat { background: var(--info-fg); } .sd-unknown { background: var(--fg-faint); }
.empty { color: var(--fg-faint); padding: 20px; text-align: center; font-size: 13px; }

/* cost */
.cost-hero { display:grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 18px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar > span { display:block; height:100%; background: var(--brand); border-radius:999px; }
.src-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.src-live { background: var(--success-bg); color: var(--success-fg); }
.src-off { background: var(--warning-bg); color: var(--warning-fg); }

/* personal */
.p-quickadd { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.p-quickadd input[type="text"] { flex: 1; min-width: 200px; }
.p-quickadd input, .p-quickadd select { font-family: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; }
.p-quickadd input:focus, .p-quickadd select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46,85,70,0.15); }
.day-group { margin-bottom: 18px; }
.day-group-h { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--fg-muted); letter-spacing: .02em; padding: 4px 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.day-group.dg-overdue .day-group-h { color: var(--danger-fg); }
.day-group.dg-today .day-group-h { color: var(--brand); }
.dg-count { background: var(--surface-2); color: var(--fg-muted); border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
.prow.is-overdue { background: var(--danger-bg); border-radius: var(--r-sm); padding-inline: 8px; }
.pcheck { width: 22px; height: 22px; flex-shrink: 0; border: 1.5px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--on-brand); font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0; transition: all .15s var(--ease); }
.pcheck:hover { border-color: var(--brand); }
.pcheck.on { background: var(--brand); border-color: var(--brand); }
.p-strike { text-decoration: line-through; color: var(--fg-faint); }
.chip.k-reminder { background: var(--info-bg); color: var(--info-fg); }
.chip.k-meeting { background: var(--surface-soft); color: var(--brand); }
.chip.k-trip { background: var(--warning-bg); color: var(--warning-fg); }
.chip.k-errand { background: var(--surface-2); color: var(--fg-muted); }
.chip.k-call { background: var(--success-bg); color: var(--success-fg); }
.chip.k-other { background: var(--surface-2); color: var(--fg-muted); }
.check-inline { flex-direction: row !important; align-items: center; gap: 8px !important; }
.check-inline input { width: 16px; height: 16px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(13,17,23,0.4); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-backdrop[hidden] { display: none; }
/* Lock background scroll while a modal is open (no scrolling behind it). */
body.modal-open { overflow: hidden; }
/* Cap height so the modal never exceeds the screen; head + foot stay fixed and
   the BODY scrolls internally, so the ✕ and the save/cancel buttons are always
   reachable on a short mobile screen (dvh handles the mobile address bar). */
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(560px, 92vw); box-shadow: var(--shadow-soft); border: 1px solid var(--line); max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--fg-muted); }
.modal-body input, .modal-body select, .modal-body textarea { font-family: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; }
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46,85,70,0.15); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); flex-shrink: 0; }
.modal-foot .spacer { flex: 1; }
.icon-btn { background: none; border: 0; font-size: 16px; color: var(--fg-muted); }

.section-note { font-size: 13px; color: var(--fg-muted); margin-bottom: 16px; }
.mini-list .list-row { padding: 9px 2px; }
.hero-card { background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%); border:1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 18px; }
.hero-state { font-size: 18px; font-weight: 500; line-height: 1.5; }
.hero-chips { display:flex; gap:8px; flex-wrap: wrap; margin-top: 14px; }
.progress-row { display:flex; align-items:center; gap:12px; margin: 10px 0; }
.progress-row .pr-label { width: 230px; font-size: 13px; }
.progress-row .pr-pct { width: 42px; text-align: left; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--fg-muted); }
.progress-row .bar { flex: 1; margin: 0; }

/* sparkline */
.spark { display: flex; align-items: flex-end; gap: 6px; height: 86px; padding-top: 6px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spark-bar { width: 70%; max-width: 26px; background: var(--accent); border-radius: 4px 4px 0 0; transition: height .3s var(--ease); }
.spark-bar.spike { background: var(--danger-fg); }
.spark-x { font-size: 10px; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.alert-bar { border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.alert-bar.danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-bd); }
.alert-bar.ok { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
code { font-family: ui-monospace, "Cascadia Code", monospace; font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ── Mobile (phone / small tablet) ─────────────────────────────────────────── */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  /* sidebar → a clean horizontal top bar with a swipeable pill nav */
  .sidebar { position: sticky; top: 0; height: auto; width: 100%; flex-direction: row; align-items: center;
             padding: 10px 12px; gap: 10px; z-index: 10;
             box-shadow: 0 3px 14px -8px rgba(0,0,0,.55); border-bottom: 1px solid rgba(255,255,255,.06); }
  .brand { padding: 0 2px; flex-shrink: 0; }
  .wordmark { font-size: 19px; }
  .brand-sub { display: none; }
  /* min-width:0 is essential: without it this flex item grows to fit all 9 pills
     (~900px) and overflows the screen, which makes mobile Safari zoom the page out. */
  .nav { flex-direction: row; flex: 1; min-width: 0; gap: 7px; overflow-x: auto; padding-bottom: 2px;
         scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 9px 15px; white-space: nowrap; border-radius: 999px; font-size: 14px; min-height: 38px; }
  .nav-item.active { background: rgba(46,85,70,0.55); }
  .nav-item.active::before { display: none; }
  .nav-item .ico { display: none; }
  .badge-count { margin-inline-start: 5px; }
  /* quick-links (מעבר מהיר) → a second, scrollable row of pills on mobile
     (they used to be display:none, so the phone had no way to jump to the
     rak-marak dashboard / platform / sales site — Dor flagged this). */
  .sidebar { flex-wrap: wrap; }
  .side-foot { display: none; }
  .side-links { display: flex; flex-basis: 100%; align-items: center; gap: 7px;
                overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
                padding-top: 8px; margin-top: 4px; border-top: 1px solid rgba(255,255,255,.06); }
  .side-links::-webkit-scrollbar { display: none; }
  .side-links-h { flex-shrink: 0; font-size: 11px; color: #8A9690; padding-inline-end: 2px; margin: 0; }
  .side-link { flex-shrink: 0; white-space: nowrap; background: rgba(255,255,255,.06);
               color: #C2C9C4; padding: 7px 13px; border-radius: 999px; font-size: 13px; text-decoration: none; }
  /* content */
  .content { padding: 16px 14px 56px; max-width: 100%; }
  .topbar { margin-bottom: 16px; gap: 10px; }
  .page-title { font-size: 22px; }
  .grid.cols-4, .cost-hero { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 28px; }
  .hero-card { padding: 18px; }
  .progress-row { flex-wrap: wrap; }
  .progress-row .pr-label { width: 100%; }
  .progress-row .bar { order: 3; flex-basis: 100%; }
  .p-quickadd input[type="text"] { min-width: 100%; }
  .modal { width: 94vw; }
  .modal-body .row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .grid.cols-4, .cost-hero { grid-template-columns: 1fr 1fr; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .spark { gap: 3px; }
}
