/* B-Connect Activity CRM — styles. Uses logical properties so a single sheet
   serves both RTL (Hebrew) and LTR (English). */

:root {
  /* CLOUD247 brand palette (from cloud247.co.il):
     logo violet #6048f0 · deep navy #061b5b · mint green #88f4c1 */
  --bg: #f5f6fc;
  --surface: #ffffff;
  --surface-2: #f7f8fd;
  --border: #e6e6f4;
  --text: #1a1c33;
  --text-muted: #6b6f89;
  --primary: #6048f0;
  --primary-dark: #4d39d1;
  --primary-soft: #eeebfe;
  --accent: #0fb98a;
  --mint: #88f4c1;
  --navy: #061b5b;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #12a374;
  --shadow: 0 1px 3px rgba(6, 27, 91, .08), 0 1px 2px rgba(6, 27, 91, .05);
  --shadow-lg: 0 12px 34px rgba(6, 27, 91, .22);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 280px;
  --sidebar-bg: var(--navy);
  --font: 'Segoe UI', 'Assistant', 'Rubik', system-ui, -apple-system, Arial, sans-serif;
}

/* Dark mode — flips the variable palette; components stay untouched.
   Badges/flow-nodes keep their light pastel chips (readable on dark). */
html[data-theme='dark'] {
  --bg: #0e1120;
  --surface: #171b2e;
  --surface-2: #1d2238;
  --border: #2a2f4d;
  --text: #e6e8f6;
  --text-muted: #99a0c2;
  --primary-soft: #2b2755;
  --primary-dark: #b3a7ff;
  --navy: #e3e6ff;          /* headings turn light… */
  --sidebar-bg: #0a0d1d;    /* …but the sidebar keeps its own dark shade */
  /* Accent/state colors must be lightened too, or the most destructive buttons
     ("Cancel call", "Delete", "Mark lost") end up at ~1.9:1 contrast and links
     at ~3.0:1 — i.e. the riskiest controls become the hardest to read. */
  --primary: #8b7bff;
  --danger: #f87171;
  --warning: #fbbf24;
  --success: #34d399;
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 34px rgba(0,0,0,.6);
}
html[data-theme='dark'] .btn--danger { background: transparent; border-color: #b91c1c; color: var(--danger); }
html[data-theme='dark'] .btn--danger:hover { background: rgba(248,113,113,.15); }
html[data-theme='dark'] .login-error { background: rgba(220,38,38,.12); border-color: #7f1d1d; }
html[data-theme='dark'] ::selection { background: #3b3480; color: #fff; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; color: var(--navy); }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--primary-soft); color: var(--navy); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 15% 10%, #6048f0 0%, #2a1f7a 45%, #061b5b 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 40px 34px;
}
.login-logo {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .5px;
  color: var(--navy);
  text-align: center;
}
.login-logo span { color: var(--primary); }
.login-sub { text-align: center; color: var(--text-muted); margin: 6px 0 26px; font-size: 13px; }
.login-error {
  background: #fef2f2; color: var(--danger); border: 1px solid #fecaca;
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px;
}
.login-hint {
  margin-top: 18px; font-size: 12px; color: var(--text-muted);
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: #c4cbe6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  padding: 20px 20px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__brand span { color: var(--mint); }
.nav { padding: 10px 10px 4px; }
.nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #cbd5e1; cursor: pointer; font-size: 14px; margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: start;
}
.nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav__item.active { background: var(--primary); color: #fff; }
.nav__icon {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; box-shadow: inset 0 -1px 0 rgba(0,0,0,.18);
}
.nav__icon svg { width: 14px; height: 14px; display: block; }
.nav__item.active .nav__icon { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.nav__badge {
  margin-inline-start: auto; background: rgba(255,255,255,.18); color: #fff;
  border-radius: 999px; padding: 1px 8px; font-size: 11px; min-width: 20px; text-align: center;
}
.nav__section { padding: 14px 16px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; }
.folder-list { padding: 0 10px 20px; overflow-y: auto; }
.folder {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; color: #cbd5e1; margin-bottom: 1px;
}
.folder:hover { background: rgba(255,255,255,.06); color: #fff; }
.folder.active { background: rgba(56,217,199,.14); color: #fff; }
.folder__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.folder__badge { background: var(--warning); color: #fff; border-radius: 999px; font-size: 10px; padding: 1px 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar::before {
  content: ''; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--primary) 55%, var(--mint) 100%);
}
.topbar__title { font-size: 17px; font-weight: 700; color: var(--navy); }
.topbar__menu { display: none; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--navy); padding: 0 6px; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--accent:hover { filter: brightness(.95); }
.btn--danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn--danger:hover { background: #fef2f2; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--block { width: 100%; justify-content: center; padding: 11px; }

/* ---------- Cards / layout ---------- */
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.page-head h2 { font-size: 20px; color: var(--navy); }
.page-head .spacer { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.card__body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--form { grid-template-columns: 1fr 1fr; gap: 14px; }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat__label { color: var(--text-muted); font-size: 12.5px; }
.stat__value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--navy); }
.stat__accent { position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--primary); }
.stat--warn .stat__accent { background: var(--warning); }
.stat--ok .stat__accent { background: var(--success); }
.stat--accent .stat__accent { background: var(--accent); }
.stat--link { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .06s; }
.stat--link:hover { border-color: var(--primary); box-shadow: 0 3px 12px rgba(37,99,235,.14); }
.stat--link:active { transform: translateY(1px); }
.stat__go { position: absolute; inset-block-start: 14px; inset-inline-end: 14px; color: var(--text-muted); font-size: 20px; line-height: 1; opacity: .5; }
[dir=rtl] .stat__go { transform: scaleX(-1); }
.stat--link:hover .stat__go { opacity: 1; color: var(--primary); }

/* Sortable table headers */
.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort:hover { color: var(--text); }
.th-sort--active { color: var(--primary); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); }
.table th { color: var(--navy); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: var(--primary-soft); }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table__empty { text-align: center; color: var(--text-muted); padding: 30px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.badge--default { background: #f1f5f9; color: #475569; }
.badge--open { background: #eff6ff; color: #2563eb; }
.badge--in_progress { background: #fef9c3; color: #a16207; }
.badge--pending_billing { background: #ffedd5; color: #c2410c; }
.badge--billed { background: #dcfce7; color: #15803d; }
.badge--closed { background: #f1f5f9; color: #64748b; }
.badge--cancelled { background: #fee2e2; color: #b91c1c; }
.badge--active { background: #dcfce7; color: #15803d; }
.badge--suspended { background: #fef9c3; color: #a16207; }
.badge--inactive { background: #f1f5f9; color: #64748b; }
.badge--archived { background: #ede9fe; color: #6d28d9; }
.badge--pending { background: #ffedd5; color: #c2410c; }
.badge--invoiced { background: #eff6ff; color: #2563eb; }
.badge--paid { background: #dcfce7; color: #15803d; }
.badge--failed { background: #fee2e2; color: #b91c1c; }
.badge--urgent { background: #fee2e2; color: #b91c1c; }
.badge--high { background: #ffedd5; color: #c2410c; }
.badge--normal { background: #f1f5f9; color: #475569; }
.badge--low { background: #f1f5f9; color: #94a3b8; }
.badge--role { background: var(--primary-soft); color: var(--primary-dark); }
.badge--ct_fixed { background: #ede9fe; color: #6d28d9; }
.badge--ct_one_time { background: #f1f5f9; color: #475569; }
/* ---------- Form validation + wide-table scrolling ---------- */
.toast__x {
  border: none; background: none; color: inherit; cursor: pointer; font-size: 18px; line-height: 1;
  margin-inline-start: 10px; padding: 0 4px; opacity: .7;
}
.toast__x:hover { opacity: 1; }

.input--error { border-color: var(--danger) !important; background: rgba(220,38,38,.05); }
.input--error:focus { outline-color: var(--danger); }
.field__error { display: block; color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 4px; }

/* Wide registers (10+ columns) scroll inside their card instead of forcing the
   whole document to scroll sideways on phones and tablets. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ---------- Optimization: suggestion status colors + comments ---------- */
/* rgba tints keep working over both light and dark card surfaces. */
.sug--planned { border-inline-start: 4px solid #eab308; background: rgba(234,179,8,.06); }
.sug--done { border-inline-start: 4px solid #16a34a; background: rgba(22,163,74,.06); }
.sug--declined { border-inline-start: 4px solid #dc2626; background: rgba(220,38,38,.06); }
/* 'open' (new) intentionally has no tint — colorless. */

.cmt-list { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cmt-item { background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 11px; font-size: 12.5px; }
.cmt-item__head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.cmt-item__author { font-weight: 700; font-size: 12px; }
.cmt-item__time { color: var(--text-muted); font-size: 11px; }
.cmt-row { display: flex; gap: 8px; margin-top: 8px; }
.cmt-row .input { flex: 1; }

/* ---------- Service tags ---------- */
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
  max-width: 100%;
}
.tag-chip__x {
  border: none; background: none; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 0 1px; opacity: .55;
}
.tag-chip__x:hover { opacity: 1; color: var(--danger); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-btn {
  border: 1px dashed var(--border); background: none; color: var(--text-muted);
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.tag-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Workflows page (process diagrams) ---------- */
.wf-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0; }
.wf-node {
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px;
  background: var(--primary-soft); color: var(--primary-dark); border: 1px solid transparent;
}
.wf-node--start { background: #eff6ff; color: #2563eb; }
.wf-node--warn { background: #fef9c3; color: #a16207; }
.wf-node--accent { background: #ede9fe; color: #6d28d9; }
.wf-node--ok { background: #dcfce7; color: #15803d; }
.wf-node--muted { background: #f1f5f9; color: #64748b; }
.wf-node--danger { background: #fee2e2; color: #b91c1c; }
.wf-arrow { color: var(--text-muted); font-size: 16px; user-select: none; }
.wf-arrow::before { content: '→'; }
html[dir='rtl'] .wf-arrow::before { content: '←'; }
.wf-notes { margin: 12px 0 0; padding-inline-start: 20px; color: var(--text-muted); font-size: 12.5px; line-height: 1.9; }
.wf-roles { margin-top: 10px; font-size: 12px; color: var(--primary-dark); background: var(--primary-soft); display: inline-block; padding: 4px 10px; border-radius: 999px; }
.wf-intro { color: var(--text-muted); font-size: 13.5px; margin: -6px 0 18px; max-width: 720px; }

.badge--stage_lead { background: #f1f5f9; color: #475569; }
.badge--stage_qualified { background: #eff6ff; color: #2563eb; }
.badge--stage_proposal { background: #ffedd5; color: #c2410c; }
.badge--stage_negotiation { background: #fef9c3; color: #a16207; }
.badge--stage_won { background: #dcfce7; color: #15803d; }
.badge--stage_lost { background: #fee2e2; color: #b91c1c; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 16px; height: 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; cursor: pointer; border: none; background: none; color: var(--text-muted); font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Customers folder grid ---------- */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.cust-card {
  display: flex; align-items: center; gap: 13px; text-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; font: inherit; color: inherit;
  transition: border-color .12s, box-shadow .12s, transform .06s;
}
.cust-card:hover { border-color: var(--primary); box-shadow: 0 3px 12px rgba(37,99,235,.14); }
.cust-card:active { transform: translateY(1px); }
.cust-card__icon { font-size: 26px; line-height: 1; }
.cust-card__body { flex: 1; min-width: 0; }
.cust-card__name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cust-card__meta { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 16px; }
.cust-card__stats { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }

/* ---------- Detail info grid ---------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 24px; }
.info { display: flex; flex-direction: column; gap: 2px; }
.info__label { font-size: 12px; color: var(--text-muted); }
.info__value { font-size: 14px; font-weight: 500; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ''; position: absolute; inset-block: 6px; inset-inline-start: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -19px; top: 4px; width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface); }
.tl-item.comment::before { background: var(--accent); }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-actor { font-weight: 600; }
.tl-action { font-size: 12px; color: var(--text-muted); }
.tl-chip { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; color: var(--text-muted); font-weight: 500; }
.tl-item.comment .tl-chip { background: #e6fffb; border-color: #99e6dd; color: #0f766e; }
.tl-time { font-size: 12px; color: var(--text-muted); margin-inline-start: auto; }
.tl-msg { margin-top: 2px; }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.spinner { border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; width: 28px; height: 28px; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.filter-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar .input { width: auto; min-width: 150px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; inset-block-end: 20px; inset-inline-end: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1e293b; color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: 13.5px; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; max-width: 340px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { background: #166534; }
.toast--error { background: #b91c1c; }
.toast--warning { background: #b45309; }

/* ---------- Modal ---------- */
#modal-root { display: none; }
/* Must match #modal-root's specificity (id) or the display:none above wins and
   modals open invisibly. Keep the id in this selector. */
#modal-root.modal-root--open { display: block; }
.modal__overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 500; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; }
.modal__head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__head h3 { flex: 1; font-size: 16px; }
.modal__x { border: none; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--text-muted); }
.modal__body { padding: 20px; overflow-y: auto; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
/* Esc on a dirty form: inline unsaved-changes confirmation bar. */
.modal__escbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  background: rgba(234, 179, 8, .12); color: var(--warning);
  border-bottom: 1px solid rgba(234, 179, 8, .35);
  animation: modal-nudge .25s ease;
}

/* Backdrop clicks no longer close the dialog — they trigger this hint instead. */
.modal--nudge { animation: modal-nudge .25s ease; }
@keyframes modal-nudge {
  0% { transform: scale(1); }
  40% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* ---------- Search + autocomplete + toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar__spacer { flex: 1; }
.toolbar__count { font-size: 13px; }
.toolbar select.input { width: auto; min-width: 140px; }
.search { position: relative; min-width: 240px; }
.quick-search { margin-bottom: 20px; }
.search--wide { min-width: 0; max-width: 560px; }
.search--wide .search__input { padding: 12px 14px; font-size: 15px; box-shadow: var(--shadow); }
.search__input { width: 100%; }
.search__menu {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 300px; overflow-y: auto;
}
.search__opt { padding: 8px 12px; cursor: pointer; font-size: 13.5px; }
.search__opt strong { color: var(--primary); font-weight: 700; }
.search__opt:hover, .search__opt.active { background: var(--primary-soft); }

/* ---------- Report bars ---------- */
.bar-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.bar-row__label { width: 150px; flex-shrink: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-row__fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; min-width: 3px; }
.bar-row__val { width: 56px; text-align: end; font-size: 13px; font-weight: 700; color: var(--navy); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.pager__info { font-size: 13px; color: var(--text-muted); min-width: 90px; text-align: center; }

/* ---------- Confirm dialog ---------- */
.confirm { display: flex; gap: 14px; align-items: flex-start; }
.confirm__icon { font-size: 26px; line-height: 1.2; flex-shrink: 0; }
.confirm__msg { font-size: 15px; font-weight: 500; }
.confirm__note { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

/* ---------- Responsive ---------- */
/* Tab strips (customer detail, accessories) can outnumber a phone's width —
   scroll the strip instead of clipping the last tabs out of existence. */
.tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab { white-space: nowrap; flex-shrink: 0; }

/* Backdrop behind the slide-over sidebar: tap anywhere outside to close.
   Driven purely by the sibling selector, so the ☰ toggle needs no extra JS. */
.sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 100; transform: translateX(-100%); transition: transform .2s; }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar.open + .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 99; background: rgba(6, 27, 91, .45);
  }
  .topbar__menu { display: inline-block; }
  .grid--2, .grid--form { grid-template-columns: 1fr; }
}

/* Phones: the topbar and multi-select filter toolbars were never adapted, so a
   6-item topbar and a 7-select toolbar used to overflow horizontally. */
@media (max-width: 640px) {
  .content { padding: 14px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar__user > div { display: none; }         /* keep the avatar, drop name+role */
  .topbar__title { font-size: 15px; }
  .toolbar { gap: 6px; }
  .toolbar .input, .toolbar select.input, .search { width: 100%; min-width: 0; }
  .cust-grid { grid-template-columns: 1fr; }
  .grid--stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  /* Comfortable tap targets — in-table actions were ~26px tall. */
  .btn--sm { padding: 9px 12px; font-size: 13px; }
  .modal__x { padding: 6px 10px; }
  .tag-chip__x { padding: 2px 6px; }
  /* iOS Safari auto-zooms the page on focusing any input under 16px — in a
     form-heavy CRM that means zooming on every field. 16px disarms it. */
  .input { font-size: 16px; }
  /* Modals get nearly the whole phone screen; dvh (where supported) tracks the
     real visible height under Safari's collapsing URL bar. */
  .modal__overlay { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
}

/* ---- Pasted screenshots on suggestions ---------------------------------- */
.shots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.shot {
  position: relative;
  inline-size: 132px;
  block-size: 88px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.shot__img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
/* Positioned by physical side, not logical: the control belongs in the image's
   top-right corner in both LTR and RTL — it is a badge on a picture, not text. */
.shot__x {
  position: absolute;
  top: 4px;
  right: 4px;
  inline-size: 22px;
  block-size: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shot__x:hover { background: rgba(0, 0, 0, .85); }
.shot__x:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
