/* =====================================================================
   Open Valor CRM — House identity: black + off-white / light beige.
   Calm, dense, enterprise. No gradients, no decorative color.
   ===================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('../assets/inter-var-sub.woff2') format('woff2-variations');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cairo';
  src: url('../assets/cairo-var-sub.woff2') format('woff2-variations');
  font-weight: 200 1000; font-style: normal; font-display: swap;
}

:root {
  --dark: #0A0A0A;
  --darkest: #050505;
  --bg: #F0F0EE;
  --bg-2: #F6F5F2;
  --card: #FFFFFF;
  --beige: #E9E5DC;
  --beige-2: #F3F1EB;
  --ink: #111111;
  --ink-2: #56564F;
  --ink-3: #8C8C84;
  --line: rgba(17, 17, 17, .09);
  --line-2: rgba(17, 17, 17, .16);
  --line-dark: rgba(255, 255, 255, .12);
  --t-1: #FFFFFF;
  --t-2: rgba(255, 255, 255, .78);
  --t-3: rgba(255, 255, 255, .48);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .28);
  --mono: ui-monospace, 'SF Mono', 'DejaVu Sans Mono', Menlo, Consolas, monospace;
  --en: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ar: 'Cairo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* every inline icon has a sane default size (containers override as needed) */
svg { width: 16px; height: 16px; flex: 0 0 auto; }

html, body { height: 100%; }
body {
  font-family: var(--en);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { font-family: var(--ar); line-height: 1.85; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { line-height: 1.5; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.mono-input { font-family: var(--mono); letter-spacing: .1em; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px; font-weight: 600; white-space: nowrap;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-dark:hover { background: #000; }
.btn-light { background: var(--bg); color: var(--ink); }
.btn-light:hover { background: #fff; }
.btn-outline { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn-outline:hover { background: rgba(17,17,17,.04); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-ghost-danger { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost-danger:hover { background: rgba(17,17,17,.05); color: var(--ink); }

.ghost-btn {
  background: transparent; border: 1px solid var(--line-dark); color: var(--t-2);
  height: 32px; padding: 0 14px; border-radius: 999px;
  font: inherit; font-size: 12px; cursor: pointer; transition: .15s;
}
.ghost-btn:hover { border-color: rgba(255,255,255,.4); color: #fff; }
.app .ghost-btn { border-color: var(--line-2); color: var(--ink-2); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: var(--ink-2);
  cursor: pointer; transition: .15s;
}
.icon-btn:hover { background: rgba(17,17,17,.05); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  height: 40px; padding: 0 13px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 10px 13px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17,17,17,.06); }
.form { display: flex; flex-direction: column; gap: 16px; }
.form-error {
  border: 1px solid rgba(138,59,52,.3); background: rgba(138,59,52,.05);
  color: #7c352e; border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px;
}

/* ---------- Auth (dark) ---------- */
.auth {
  min-height: 100vh; background: var(--dark); color: var(--t-1);
  display: flex; flex-direction: column; padding: 26px 34px;
  position: relative; overflow: hidden;
}
.auth::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(1100px 520px at 78% -10%, rgba(255,255,255,.055), transparent 60%);
  pointer-events: none;
}
.auth__top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.auth__logo { height: 30px; width: auto; display: block; }
.auth__panel { width: 100%; max-width: 392px; margin: auto; position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; padding: 26px 0; }
.auth__panel .eyebrow { color: var(--t-3); }
.auth__title { font-size: 27px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.auth__sub { color: var(--t-2); font-size: 13.5px; margin-bottom: 10px; }
.auth .field > span { color: var(--t-2); }
.auth .field input {
  background: rgba(255,255,255,.035); border-color: var(--line-dark); color: #fff;
}
.auth .field input::placeholder { color: rgba(255,255,255,.3); }
.auth .field input:focus { border-color: rgba(255,255,255,.6); box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.auth .form-error { border-color: rgba(220,120,110,.35); background: rgba(220,120,110,.07); color: #e8b4ad; }
.auth__alt { color: var(--t-3); font-size: 12.5px; text-decoration: none; transition: .15s; }
.auth__alt:hover { color: #fff; }
.auth__foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line-dark); padding-top: 16px; color: var(--t-3);
  font-size: 12px; position: relative; z-index: 1;
}
.auth__foot .mono { color: var(--t-3); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; background: var(--bg); }

.sidebar {
  width: 236px; flex: 0 0 auto; display: flex; flex-direction: column;
  background: var(--bg-2); border-inline-end: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { padding: 20px 20px 16px; }
.sidebar__brand img { height: 22px; width: auto; display: block; }
.nav { flex: 1; padding: 4px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav__label { padding: 14px 10px 6px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; transition: .13s; cursor: pointer;
}
.nav__item svg { width: 16px; height: 16px; flex: 0 0 auto; opacity: .8; }
.nav__item:hover { background: rgba(17,17,17,.045); color: var(--ink); }
.nav__item.active { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); font-weight: 600; }
.nav__item.active svg { opacity: 1; }
.nav__item--muted { color: var(--ink-3); }
.sidebar__foot {
  padding: 14px 20px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px; color: var(--ink-3);
}

.app__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: var(--card); border-bottom: 1px solid var(--line); padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.search {
  display: flex; align-items: center; gap: 9px; width: 360px; max-width: 42vw;
  height: 36px; padding: 0 12px; background: var(--bg); border: 1px solid transparent; border-radius: 999px;
  transition: .15s;
}
.search:focus-within { background: var(--card); border-color: var(--line-2); }
.search__icon svg { width: 15px; height: 15px; color: var(--ink-3); display: block; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.topbar__actions { display: flex; align-items: center; gap: 6px; position: relative; }
.user-chip {
  width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--ink); color: var(--bg); font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}

.content { padding: 28px 32px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- Menu dropdown ---------- */
.menu {
  position: absolute; top: 46px; inset-inline-end: 0; width: 260px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(17,17,17,.12); overflow: hidden; z-index: 40;
}
.menu__head { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.menu__name { font-weight: 600; }
.menu__email { font-size: 12.5px; color: var(--ink-3); }
.menu__item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; background: transparent; border: 0; border-bottom: 1px solid var(--line);
  font: inherit; font-size: 13.5px; color: var(--ink); cursor: pointer; text-align: start;
}
.menu__item:hover { background: var(--bg-2); }
.menu__item:last-child { border-bottom: 0; }
.menu__item--danger { color: #8a3b34; }

/* ---------- Cards & layout ---------- */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 23px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
}
.card--flat { box-shadow: none; }
.card__title { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; }
.card__title .badge { margin-inline-start: auto; }
.card__title svg { width: 16px; height: 16px; color: var(--ink-2); }
.card__body { margin-top: 10px; color: var(--ink-2); font-size: 13.5px; }
.card__big { font-family: var(--mono); font-size: 34px; letter-spacing: -.02em; color: var(--ink); line-height: 1.2; }
.card__big--muted { color: var(--ink-3); }
.card__note { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--bg-2);
}
.badge--dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge--ok { background: var(--beige); border-color: transparent; color: var(--ink); }
.badge--off { background: transparent; color: var(--ink-3); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: start; font-size: 11px; font-family: var(--mono); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; padding: 0 12px 10px 0; border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
html[lang="ar"] .table th { font-family: var(--ar); letter-spacing: 0; font-size: 12px; font-weight: 700; text-transform: none; }
.table td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td:last-child, .table th:last-child { padding-inline-end: 0; }
.table .muted { color: var(--ink-3); font-size: 12.5px; }

.empty {
  text-align: center; padding: 54px 20px; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty svg { width: 26px; height: 26px; opacity: .5; }
.empty h3 { color: var(--ink); font-size: 15.5px; font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  height: 38px; padding: 0 14px; background: transparent; border: 0; border-bottom: 2px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-3); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(5,5,5,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal__panel {
  background: var(--card); border-radius: var(--radius); width: 100%; max-width: 430px;
  padding: 26px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto;
}
.modal__title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: 13px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

/* ---------- Invite result panel ---------- */
.invite-result {
  border: 1px solid var(--line-2); background: var(--beige-2); border-radius: var(--radius);
  padding: 16px 18px; margin-top: 14px; display: flex; flex-direction: column; gap: 10px;
}
.invite-result .code {
  font-family: var(--mono); font-size: 19px; letter-spacing: .12em;
  background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--radius-sm);
  padding: 10px 14px; text-align: center; user-select: all;
}
.invite-result .link { font-size: 12px; color: var(--ink-2); word-break: break-all; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--ink-3); }
.mt-2 { margin-top: 10px; }
.mt-4 { margin-top: 20px; }

/* ---------- Responsive (tablet-first, phone unsupported) ---------- */
@media (max-width: 1024px) {
  .sidebar { width: 208px; }
  .content { padding: 22px 22px 60px; }
}
@media (max-width: 860px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .auth { padding: 20px 18px; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .search { width: 180px; max-width: 40vw; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 60px; }
}

/* =====================================================================
   Phase 1 components — tables, kanban, detail views, dashboard
   ===================================================================== */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar__search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 220px; max-width: 320px;
  height: 36px; padding: 0 12px; background: var(--bg); border: 1px solid transparent; border-radius: var(--radius-sm);
}
.toolbar__search:focus-within { background: var(--card); border-color: var(--line-2); }
.toolbar__search svg { width: 15px; height: 15px; color: var(--ink-3); flex: 0 0 auto; }
.toolbar__search input { flex: 1; border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; }
.toolbar__filters { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar__actions { display: flex; gap: 8px; margin-inline-start: auto; align-items: center; }

.mini-select {
  height: 36px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--card); font: inherit; font-size: 12.5px; color: var(--ink); max-width: 190px;
}
.table--click tbody tr { cursor: pointer; }
.table--click tbody tr:hover { background: rgba(17,17,17,.025); }
.num { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); margin-top: 4px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg__btn { height: 34px; padding: 0 12px; border: 0; background: var(--card); font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.seg__btn.active { background: var(--ink); color: var(--bg); }

/* kanban */
.kanban-scroll { overflow-x: auto; padding-bottom: 6px; }
.kanban { display: grid; grid-template-columns: repeat(9, minmax(190px, 1fr)); gap: 10px; }
.kanban__col { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; min-height: 160px; }
.kanban__head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.kanban__value { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); margin-bottom: 8px; }
.kanban__card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 8px; cursor: pointer; }
.kanban__card:hover { border-color: var(--line-2); }
.kanban__name { font-size: 12.5px; font-weight: 600; line-height: 1.5; }
.kanban__empty { color: var(--ink-3); text-align: center; font-size: 12px; padding: 10px 0; }

/* detail */
.back { display: inline-block; font-size: 12.5px; color: var(--ink-3); text-decoration: none; margin-bottom: 8px; }
.back:hover { color: var(--ink); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px 24px; }
.detail-field__label { font-size: 11px; font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
html[lang="ar"] .detail-field__label { font-family: var(--ar); letter-spacing: 0; text-transform: none; font-size: 12px; font-weight: 600; }
.detail-field__value { font-size: 13.5px; line-height: 1.7; word-break: break-word; }

.progress-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.progress-step { font-size: 11.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-3); background: var(--card); }
.progress-step.done { color: var(--ink); border-color: var(--line-2); background: var(--beige-2); }
.progress-step.current { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.progress-arrow { color: var(--ink-3); font-size: 11px; }

.timeline { display: flex; flex-direction: column; margin-top: 12px; }
.timeline__row { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.timeline__row:last-child { border-bottom: 0; }
.timeline__when { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); flex: 0 0 130px; direction: ltr; }
html[dir="rtl"] .timeline__when { text-align: right; }
.timeline__what { font-size: 13px; }

/* dashboard */
.kpi { padding: 16px 18px; }
.kpi__label { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.kpi__value { font-family: var(--mono); font-size: 22px; letter-spacing: -.02em; }
.action-card { cursor: pointer; transition: border-color .15s; }
.action-card:hover { border-color: var(--line-2); }
.card__link { margin-inline-start: auto; font-size: 12px; color: var(--ink-3); text-decoration: none; font-weight: 500; }
.card__link:hover { color: var(--ink); }

.feed { display: flex; flex-direction: column; margin-top: 8px; }
.feed__row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: default; }
.feed__row:last-child { border-bottom: 0; }
.feed__row[data-goto] { cursor: pointer; }
.feed__row[data-goto]:hover { background: rgba(17,17,17,.02); }
.feed__text { flex: 1; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pipeline-bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pipeline-bar { display: flex; align-items: center; gap: 10px; }
.pipeline-bar__label { flex: 0 0 130px; font-size: 12px; color: var(--ink-2); }
.pipeline-bar__track { flex: 1; height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.pipeline-bar__fill { display: block; height: 100%; background: var(--ink); border-radius: 999px; min-width: 3px; }
.pipeline-bar__count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); flex: 0 0 22px; text-align: end; }

/* notifications */
.notif-btn { position: relative; }
.notif-dot { position: absolute; top: 5px; inset-inline-end: 6px; width: 7px; height: 7px; border-radius: 999px; background: var(--ink); border: 1.5px solid var(--card); }
.menu--notif { width: 320px; max-height: 380px; overflow-y: auto; }
.menu--quick { width: 230px; }
.menu--quick .menu__item, .notif-item { gap: 10px; }
.notif-item.unread { font-weight: 600; }
.notif-item.unread::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: var(--ink); flex: 0 0 auto; }

/* forms */
.form--grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field--wide { grid-column: 1 / -1; }
.form--grid .modal__actions { margin-top: 4px; }

@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kanban { grid-template-columns: repeat(9, minmax(170px, 1fr)); }
}
@media (max-width: 860px) {
  .form--grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .toolbar__search { max-width: none; }
  .pipeline-bar__label { flex-basis: 100px; }
}

/* =====================================================================
   Polish pass (post-review fixes)
   ===================================================================== */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-4 { grid-template-columns: 1fr; } }

.badge { white-space: nowrap; max-width: 100%; }
.empty { padding: 34px 20px; }
.btn:focus:not(:focus-visible) { outline: none; }
.modal__actions { position: sticky; bottom: 0; background: var(--card); padding-top: 12px; }

.kanban-scroll { overflow-x: auto; max-width: 100%; padding-bottom: 10px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 215px; gap: 10px; }
.kanban__col { min-height: 140px; }

.notif-item span:last-child { white-space: nowrap; flex: 0 0 auto; }

/* consistent select chevrons */
.field select, .mini-select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238C8C84' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px;
}
html[dir="rtl"] .field select, html[dir="rtl"] .mini-select {
  background-position: left 11px center; padding-right: 12px; padding-left: 30px;
}

/* Contain form grid inside the modal (long selects must not push the actions out) */
.form--grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form--grid > * { min-width: 0; }
.field select, .field input, .field textarea { max-width: 100%; }
.modal__panel { overflow-x: hidden; }

/* =====================================================================
   Loading screen — between sign-in and the dashboard
   ===================================================================== */
.loading {
  position: fixed; inset: 0; z-index: 300;
  background: var(--darkest); color: var(--t-1);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 1; transition: opacity .45s ease;
}
.loading--out { opacity: 0; pointer-events: none; }
.loading__inner { display: flex; flex-direction: column; align-items: center; gap: 18px; animation: loadingIn .6s ease both; }
.loading__logo { height: 34px; width: auto; }
.loading__eyebrow { color: var(--t-3); }
.loading__bar { width: 190px; height: 2px; border-radius: 999px; background: rgba(255,255,255,.14); overflow: hidden; }
.loading__bar span {
  display: block; height: 100%; width: 42%; border-radius: 999px;
  background: rgba(255,255,255,.85);
  animation: loadingSlide 1.15s cubic-bezier(.45,.05,.35,1) infinite;
}
.loading__text { font-size: 13px; color: var(--t-2); letter-spacing: .01em; }
.loading__foot {
  position: absolute; inset-inline: 34px; bottom: 26px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line-dark); padding-top: 14px; color: var(--t-3);
}
@keyframes loadingSlide {
  0% { transform: translateX(-115%); }
  100% { transform: translateX(355%); }
}
html[dir="rtl"] .loading__bar span { animation-name: loadingSlideRtl; }
@keyframes loadingSlideRtl {
  0% { transform: translateX(115%); }
  100% { transform: translateX(-355%); }
}
@keyframes loadingIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* =====================================================================
   Phase 2 — performance gauges, executive, reports, settings lists
   ===================================================================== */
.gauge-wrap { display: flex; align-items: center; gap: 18px; margin-top: 12px; }
.gauge { width: 150px; height: auto; flex: 0 0 auto; }
.gauge path { fill: none; stroke-width: 9; stroke-linecap: round; }
.gauge__track { stroke: var(--line-2); }
.gauge__fill { transition: stroke-dasharray .7s cubic-bezier(.3,.8,.3,1); }
.gauge--green { stroke: #3E7A52; }
.gauge--yellow { stroke: #C9A227; }
.gauge--red { stroke: #B4453C; }
.gauge--none { stroke: var(--ink-3); }
.gauge-meta { display: flex; flex-direction: column; gap: 4px; }
.gauge-pct { font-family: var(--mono); font-size: 26px; letter-spacing: -.02em; }

.status-chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 11px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-2); }
.status-chip::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.status-chip--green { color: #2F5F41; border-color: rgba(62,122,82,.4); background: rgba(62,122,82,.08); }
.status-chip--yellow { color: #8A6D0F; border-color: rgba(201,162,39,.4); background: rgba(201,162,39,.09); }
.status-chip--red { color: #8E342D; border-color: rgba(180,69,60,.4); background: rgba(180,69,60,.08); }
.status-chip--none { color: var(--ink-3); }

.warning-box { border: 1px solid rgba(180,69,60,.35); background: rgba(180,69,60,.06); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; color: #7C2E28; }
.warning-box strong { display: block; margin-bottom: 4px; }
.warning-box p { font-size: 13px; }

.tips { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.tip-row { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--ink-2); }
.tip-row svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 3px; color: var(--ink-3); }

.calculator { border-top: 1px solid var(--line); padding-top: 14px; }
.calc-input { height: 38px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); font: inherit; font-size: 14px; background: var(--card); min-width: 200px; }
.calc-result { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 16px; }

.targets-block { border-top: 2px solid var(--accent-light); padding-top: 10px; margin-top: 4px; }
.targets-block__title { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.targets-block .field { flex: 1; }

.conflict-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.conflict-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; }

/* settings lists */
.tabs--inner { margin-bottom: 16px; }
.inline-input { height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; background: var(--card); width: 100%; min-width: 120px; }
.inline-input:focus { outline: none; border-color: var(--line-2); }
.inline-input--sm { width: 72px; min-width: 72px; }
.add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--line-2); padding-top: 14px; }
.add-row .inline-input { max-width: 240px; }

/* permission matrix */
.matrix-area td { font-size: 11px; font-family: var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); padding-top: 18px; }
html[lang="ar"] .matrix-area td { font-family: var(--ar); letter-spacing: 0; font-size: 12px; font-weight: 700; }
.tick { color: #2F5F41; font-weight: 700; }
.table td .muted.mono { font-size: 9.5px; margin-inline-start: 6px; }

/* print / PDF */
@media print {
  .sidebar, .topbar, .page-head .row, .btn { display: none !important; }
  .content { padding: 0 !important; max-width: none !important; }
  body { background: #fff !important; }
  .card { break-inside: avoid; border-color: #ddd !important; box-shadow: none !important; }
  .grid-4, .grid-2 { grid-template-columns: 1fr 1fr !important; }
}

/* targets modal layout */
.targets-quarters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field--tight { gap: 4px; }
.field--tight > span { font-size: 11.5px; }
.field--tight input { height: 34px; }
.modal__panel .form { padding-bottom: 6px; }
.conflict-row { flex-wrap: wrap; }
.conflict-row .muted { flex: 1 1 100%; font-size: 12px; }
#perfUser { max-width: 260px; }


/* Arabic uses Cairo only */
html[lang="ar"] body,
html[lang="ar"] button, html[lang="ar"] input, html[lang="ar"] select, html[lang="ar"] textarea,
html[lang="ar"] .btn, html[lang="ar"] .tab, html[lang="ar"] .nav__item, html[lang="ar"] .badge,
html[lang="ar"] .h1, html[lang="ar"] .h2, html[lang="ar"] .h3, html[lang="ar"] .menu__item {
  font-family: var(--ar);
}

/* live clock */
.clock { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; margin-inline-start: auto; margin-inline-end: 8px; line-height: 1.25; }
.clock__time { font-family: var(--mono); font-size: 14px; letter-spacing: .04em; color: var(--ink); direction: ltr; unicode-bidi: isolate; }
.clock__date { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
html[dir="rtl"] .clock { align-items: flex-start; }

.calc-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* =====================================================================
   Phase 3 — usage guide, calendar, import, email settings
   ===================================================================== */
#tourRoot { position: fixed; inset: 0; z-index: 400; }
#tourSpot {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(5, 5, 5, .58);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-tip {
  position: fixed; z-index: 401; background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); border: 1px solid var(--line);
}
.tour-tip__step { font-family: var(--mono); font-size: 10px; letter-spacing: .18em; color: var(--ink-3); direction: ltr; }
.tour-tip__title { font-size: 15px; font-weight: 700; margin: 6px 0; }
.tour-tip__body { font-size: 13px; color: var(--ink-2); line-height: 1.85; }
.tour-tip__optout { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.tour-tip__actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; flex-wrap: wrap; }
.tour-reopen-wrap { display: flex; justify-content: center; margin-top: 28px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__head { font-size: 11px; color: var(--ink-3); text-align: center; padding: 6px 0; }
.cal__cell {
  min-height: 88px; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.cal__cell:hover { border-color: var(--line-2); }
.cal__cell--empty { background: transparent; border: 0; cursor: default; }
.cal__cell--today { border-color: var(--ink); }
.cal__cell--selected { background: var(--beige-2); border-color: var(--ink); }
.cal__num { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.cal__item { font-size: 10.5px; background: var(--bg); border-radius: 6px; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__item--task { background: var(--beige); }
.cal__more { font-size: 10px; color: var(--ink-3); }

.imp-columns { border: 1px dashed var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); background: var(--beige-2); }
.mail-events { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13px; }

@media print { #tourRoot { display: none !important; } }


/* custom file picker (Arabic-friendly) */
.file-picker { display: flex; align-items: center; gap: 10px; }
.file-picker__input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-picker__name { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltr-inline { direction: ltr; unicode-bidi: isolate; display: inline-block; }


/* quick-add menu */
.menu--quick { width: 250px; padding: 6px; }
.menu--quick .menu__item { border-bottom: 0; border-radius: var(--radius-sm); padding: 9px 12px; gap: 10px; justify-content: flex-start; }
.menu--quick .menu__item:hover { background: var(--bg-2); }
.menu--quick .menu__item svg { width: 16px; height: 16px; color: var(--ink-2); }


/* tour: frozen page + centred ending */
html.tour-lock, html.tour-lock body { overflow: hidden !important; }
.tour-tip--center { top: 50% !important; left: 50% !important; transform: translate(-50%, -50%); }


/* live search */
.search-wrap { position: relative; }
.search__icon { cursor: pointer; }
.search__clear { border: 0; background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.search__clear:hover { color: var(--ink); }
.search-results {
  position: absolute; top: 44px; inset-inline-start: 0; width: 100%; max-height: 62vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(17,17,17,.16); z-index: 80; padding: 6px;
}
.search-group { padding: 4px 2px 8px; }
.search-group__title { font-size: 11px; font-family: var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); padding: 6px 10px 4px; }
html[lang="ar"] .search-group__title { font-family: var(--ar); letter-spacing: 0; text-transform: none; font-weight: 700; font-size: 12px; }
.search-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; border-radius: var(--radius-sm);
  font: inherit; text-align: start; cursor: pointer;
}
.search-item:hover { background: var(--bg-2); }
.search-item__title { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.search-item__sub { font-size: 12px; color: var(--ink-3); }
.search-results__empty { padding: 14px 12px; color: var(--ink-3); font-size: 13px; }
.search-viewall {
  position: sticky; bottom: 0; width: 100%; padding: 10px; border: 0; border-top: 1px solid var(--line);
  background: var(--card);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.search-viewall:hover { background: var(--bg-2); }


/* phone block — the system is designed for iPad / laptop */
.phone-block {
  position: fixed; inset: 0; z-index: 600; background: var(--darkest); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px 24px; text-align: center;
}
.phone-block__title { font-size: 18px; font-weight: 600; line-height: 1.8; max-width: 30ch; }
.phone-block__sub { font-size: 13px; color: rgba(255,255,255,.6); max-width: 34ch; }
@media (min-width: 761px) { .phone-block { display: none !important; } }

/* =====================================================================
   Account settings + classic wall clock + compact team table
   ===================================================================== */
.clock--analog { flex-direction: row; align-items: center; gap: 9px; }
html[dir="rtl"] .clock--analog { align-items: center; }
.clock__analog { width: 30px; height: 30px; display: block; }
.clock__analog .ca-rim { fill: #FFFFFF; stroke: #111111; stroke-width: 2.4; }
.clock__analog line { stroke: #111111; stroke-width: 2; stroke-linecap: round; }
.clock__analog .ca-hour { stroke-width: 4.4; }
.clock__analog .ca-min { stroke-width: 2.8; }
.clock__analog .ca-sec { stroke: #8C8C84; stroke-width: 1.2; }
.clock__analog .ca-pin { fill: #111111; }

.cell-sub { font-size: 12px; margin-top: 2px; }
.row--end { justify-content: flex-end; }
.th-end { text-align: end; }
.table--team td { vertical-align: middle; }
.field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--card); font: inherit; font-size: 13.5px; color: var(--ink);
}
.field select:focus { outline: none; border-color: var(--ink); }

/* invite result — approved dark design (never light) */
.invite-result {
  border: 1px solid var(--line-dark); background: var(--dark); color: var(--t-1);
}
.invite-result .muted { color: var(--t-3); }
.invite-result .code {
  background: var(--darkest); border: 1px dashed rgba(255, 255, 255, .28); color: var(--t-1);
}
.invite-result .btn { border-color: rgba(255, 255, 255, .38); color: var(--t-1); background: transparent; }
.invite-result .btn:hover { border-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .06); }
