/* ============================================================
   InnovateFlow — Hebrew RTL interface
   Palette: violet-tinted neutrals, deep violet accent,
   jade / amber / rose for state. Rubik for headings,
   Assistant for everything you actually read.
   ============================================================ */

/* ---------- light (complete palette on bare :root) ---------- */
:root {
  --bg:            #F7F6FC;
  --bg-tint:       radial-gradient(1200px 520px at 88% -8%, #EFE9FF 0%, transparent 62%);
  --surface:       #FFFFFF;
  --surface-2:     #F2F0FA;
  --surface-3:     #E9E6F6;
  --glass:         rgba(255, 255, 255, .74);

  --border:        #E6E2F2;
  --border-2:      #D6D0E9;

  --text:          #191630;
  --text-soft:     #5C5680;
  --text-faint:    #928CB2;

  --primary:       #6142E5;
  --primary-ink:   #5433D6;
  --primary-soft:  #EEE9FE;
  --primary-glow:  rgba(97, 66, 229, .28);

  --jade:          #0E9F6E;
  --jade-soft:     #DCF5EC;
  --amber:         #C77A06;
  --amber-soft:    #FBF0DC;
  --rose:          #DC3355;
  --rose-soft:     #FCE7EC;
  --grape:         #8B45D6;
  --grape-soft:    #F2E8FC;
  --slate:         #7C8398;
  --slate-soft:    #ECEEF3;

  /* legacy aliases used by the board dot colours */
  --gray:   var(--slate);
  --orange: var(--amber);
  --purple: var(--grape);
  --green:  var(--jade);
  --red:    var(--rose);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sh-1: 0 1px 2px rgba(25, 22, 48, .05);
  --sh-2: 0 1px 2px rgba(25, 22, 48, .05), 0 6px 20px rgba(25, 22, 48, .07);
  --sh-3: 0 18px 50px rgba(25, 22, 48, .18);

  --sidebar-w: 244px;
  --topbar-h:  64px;

  --ease: cubic-bezier(.32, .72, .28, 1);
}

/* ---------- dark, for the un-stamped (system) state ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0B0916;
    --bg-tint:       radial-gradient(1200px 520px at 88% -8%, #1C1440 0%, transparent 62%);
    --surface:       #151228;
    --surface-2:     #1D1936;
    --surface-3:     #272147;
    --glass:         rgba(21, 18, 40, .74);

    --border:        #2A2449;
    --border-2:      #3B3466;

    --text:          #EEEBFA;
    --text-soft:     #ABA4CC;
    --text-faint:    #7B749E;

    --primary:       #9B85FF;
    --primary-ink:   #B4A3FF;
    --primary-soft:  #241D48;
    --primary-glow:  rgba(155, 133, 255, .30);

    --jade:          #3FCB98;
    --jade-soft:     #10312A;
    --amber:         #E9A94A;
    --amber-soft:    #33260F;
    --rose:          #FF6B85;
    --rose-soft:     #37121D;
    --grape:         #BE8BF0;
    --grape-soft:    #2B1B42;
    --slate:         #8B93AC;
    --slate-soft:    #23203A;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .45);
    --sh-3: 0 18px 50px rgba(0, 0, 0, .6);
  }
}

/* ---------- dark, when explicitly chosen ---------- */
:root[data-theme="dark"] {
  --bg:            #0B0916;
  --bg-tint:       radial-gradient(1200px 520px at 88% -8%, #1C1440 0%, transparent 62%);
  --surface:       #151228;
  --surface-2:     #1D1936;
  --surface-3:     #272147;
  --glass:         rgba(21, 18, 40, .74);

  --border:        #2A2449;
  --border-2:      #3B3466;

  --text:          #EEEBFA;
  --text-soft:     #ABA4CC;
  --text-faint:    #7B749E;

  --primary:       #9B85FF;
  --primary-ink:   #B4A3FF;
  --primary-soft:  #241D48;
  --primary-glow:  rgba(155, 133, 255, .30);

  --jade:          #3FCB98;
  --jade-soft:     #10312A;
  --amber:         #E9A94A;
  --amber-soft:    #33260F;
  --rose:          #FF6B85;
  --rose-soft:     #37121D;
  --grape:         #BE8BF0;
  --grape-soft:    #2B1B42;
  --slate:         #8B93AC;
  --slate-soft:    #23203A;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .45);
  --sh-3: 0 18px 50px rgba(0, 0, 0, .6);
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; padding: 0; }

body {
  background: var(--bg-tint), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: Assistant, "Segoe UI", system-ui, "Noto Sans Hebrew", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: Rubik, Assistant, "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.011em;
  margin: 0;
}

a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: .18em; }

.num, td.num, .tabular { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--primary-soft); color: var(--text); }

/* thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- boot ---------- */
.app-loading { display: grid; place-items: center; height: 100vh; }

.boot { display: flex; align-items: center; gap: 12px; color: var(--text-faint); }

.boot-mark {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border-2);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Login
   ============================================================ */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 15% 15%, rgba(97,66,229,.30), transparent 60%),
    radial-gradient(800px 600px at 85% 80%, rgba(139,69,214,.26), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  padding: 40px 36px;
  position: relative;
}

.login-card h1 { font-size: 27px; font-weight: 600; margin-bottom: 4px; }
.login-card .sub { color: var(--text-soft); margin: 0 0 28px; }
/* The password fallback is for the rare case an administrator cannot get in
   with Microsoft 365, so it reads as a quiet link rather than a second
   call-to-action competing with the SSO button. */
.login-fallback {
  position: absolute;
  bottom: 9px;
  right: 14px;
  padding: 2px 4px;
  background: none;
  border: 0;
  box-shadow: none;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-faint);
  cursor: pointer;
}
.login-fallback:hover { background: none; color: var(--text-soft); text-decoration: underline; }
.login-fallback:active { transform: none; }

/* ---------- brand ---------- */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: Rubik, sans-serif;
  font-weight: 600;
  font-size: 17.5px;
  letter-spacing: -.015em;
  margin-bottom: 20px;
}

.brand-mark i {
  width: 34px; height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary) 0%, #8B45D6 100%);
  box-shadow: 0 4px 14px var(--primary-glow);
  display: grid; place-items: center;
  color: #fff; font-style: normal; font-size: 17px;
  flex: 0 0 auto;
}

/* ============================================================
   Shell
   ============================================================ */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand-mark { padding: 20px 18px 14px; margin: 0; }

.nav {
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14.5px;
  position: relative;
  transition: background .16s var(--ease), color .16s var(--ease);
}

.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}

.nav a.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 99px;
  background: var(--primary);
}

.nav a .ico {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  flex: 0 0 auto;
  transition: background .16s var(--ease);
}

.nav a.active .ico { background: var(--surface); color: var(--primary); }
.nav a .badge { margin-inline-start: auto; }

.nav-section {
  padding: 16px 14px 6px;
  font-size: 11px;
  letter-spacing: .1em;
  color: var(--text-faint);
  font-weight: 700;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }

/* ---------- search trigger (opens the command palette) ---------- */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(300px, 32vw);
  padding: 7px 13px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-faint);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}

.search-trigger:hover { border-color: var(--border-2); background: var(--surface); }

.search-trigger .k {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  letter-spacing: .04em;
}

.content { padding: 24px 22px 60px; flex: 1; }

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h2 { font-size: 22px; font-weight: 600; }
.page-head .spacer { flex: 1; }

/* ============================================================
   Controls
   ============================================================ */

/* An author rule setting display beats the browser's own [hidden] rule, so a
   hidden button would otherwise still be laid out. Anything marked hidden is
   hidden, whatever else it is. */
[hidden] { display: none !important; }

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 15px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .12s var(--ease), box-shadow .15s var(--ease);
}

button:hover, .btn:hover { background: var(--surface-3); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(145deg, var(--primary) 0%, #7B4FE8 100%);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(145deg, var(--primary-ink) 0%, var(--primary) 100%);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-2); }

.btn-danger { background: transparent; color: var(--rose); border-color: var(--rose); }
.btn-danger:hover { background: var(--rose-soft); }

.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-icon { padding: 7px 9px; background: transparent; border-radius: 9px; }
.btn-icon:hover { background: var(--surface-2); }

/* The reporting assistant's trigger. Tinted so it reads as a distinct kind of
   action next to the search field, without shouting. */
.agent-trigger {
  color: var(--primary);
  font-size: 15px;
  line-height: 1;
}
.agent-trigger:hover { background: var(--primary-soft); color: var(--primary-ink); }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { min-height: 96px; resize: vertical; }

/* Checkboxes must not inherit the full-width text-field styling. */
input[type="checkbox"], input[type="radio"] {
  width: 15px;
  height: 15px;
  min-width: 15px;
  padding: 0;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--primary);
  flex: 0 0 auto;
  cursor: pointer;
}

input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }

/* A checkbox sitting inside a chip is a filter toggle. */
.chip:has(input[type="checkbox"]) {
  cursor: pointer;
  user-select: none;
  padding: 6px 12px;
  transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}

.chip:has(input[type="checkbox"]:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 600;
}

.chip:has(input[type="checkbox"]):hover { border-color: var(--border-2); }

label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--text-soft);
}

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

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}

/* Checkboxes are excluded: the min-width would stretch them into slabs. */
.filters select,
.filters input:not([type="checkbox"]):not([type="radio"]) {
  width: auto;
  min-width: 140px;
}

/* ============================================================
   Cards, tables
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.card-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14.5px;
}

.card-head .spacer { flex: 1; }
.card-body { padding: 18px 20px; }
.card + .card { margin-top: 16px; }

/* ---------- stat tiles ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px 15px;
  box-shadow: var(--sh-1);
  cursor: pointer;
  overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              border-color .18s var(--ease);
}

.stat::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: transparent;
  transition: background .18s var(--ease);
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
  border-color: var(--border-2);
}

.stat .n {
  font-family: Rubik, sans-serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

.stat .l { color: var(--text-soft); font-size: 12.5px; margin-top: 3px; }

.stat.alert::before { background: var(--rose); }
.stat.alert .n { color: var(--rose); }
.stat.warn::before  { background: var(--amber); }
.stat.warn .n { color: var(--amber); }
.stat.good::before  { background: var(--jade); }
.stat.good .n { color: var(--jade); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }

th {
  text-align: start;
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 700;
  letter-spacing: .04em;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr { transition: background .13s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.row-link { cursor: pointer; }
.muted { color: var(--text-faint); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }

.empty { padding: 44px 16px; text-align: center; color: var(--text-faint); }

.empty .big {
  font-size: 26px;
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* ============================================================
   Pills & badges — tinted, not solid
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.pill.s-new,   .pill.s-draft       { background: var(--slate-soft);   color: var(--slate); }
.pill.s-in_progress, .pill.s-sent  { background: var(--amber-soft);   color: var(--amber); }
.pill.s-waiting, .pill.s-negotiation { background: var(--grape-soft); color: var(--grape); }
.pill.s-done,  .pill.s-won         { background: var(--jade-soft);    color: var(--jade); }
.pill.s-cancelled, .pill.s-lost    { background: var(--rose-soft);    color: var(--rose); }
.pill.s-open                       { background: var(--primary-soft); color: var(--primary-ink); }
.pill.s-expired                    { background: var(--slate-soft);   color: var(--slate); }

.pill.p-urgent { background: var(--rose-soft);    color: var(--rose); }
.pill.p-high   { background: var(--amber-soft);   color: var(--amber); }
.pill.p-normal { background: var(--primary-soft); color: var(--primary-ink); }
.pill.p-low    { background: var(--slate-soft);   color: var(--slate); }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--rose);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge.quiet { background: var(--surface-3); color: var(--text-soft); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-soft);
}

.avatar {
  width: 27px; height: 27px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px var(--surface);
}

.avatar.lg { width: 36px; height: 36px; font-size: 13px; }
.who { display: inline-flex; align-items: center; gap: 8px; }

/* Several people on one task: overlapping faces, newest tucked behind. */
.stack { display: inline-flex; align-items: center; flex-direction: row-reverse; }
.stack .avatar { margin-inline-start: -8px; }
.stack .avatar:last-child { margin-inline-start: 0; }

.avatar.more {
  background: var(--surface-3);
  color: var(--text-soft);
  font-size: 10.5px;
}

/* ---------- people picker ---------- */

.pp {
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.pp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 9px 11px;
  min-height: 44px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.pp-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 5px 3px 3px;
  padding-inline-end: 4px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
}

.pp-tag .avatar { width: 21px; height: 21px; font-size: 9.5px; box-shadow: none; }

.pp-tag .x {
  background: transparent;
  border: none;
  padding: 0 3px;
  min-height: 0;
  font-size: 11px;
  color: inherit;
  opacity: .65;
  border-radius: 99px;
}

.pp-tag .x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }

.pp-search {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 9px 12px;
  font-size: 13.5px;
}

.pp-search:focus { box-shadow: none; border-color: var(--border); }

/* Tall enough that a team of six needs no inner scrollbar — a nested
   scrolling list inside a scrolling modal is the wrong feel. */
.pp-options {
  max-height: 244px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pp-option {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 9px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  font-weight: 500;
  text-align: start;
}

.pp-option:hover { background: var(--surface-2); }
.pp-option .nm { flex: 1; min-width: 0; }
.pp-option .avatar { width: 24px; height: 24px; font-size: 10px; box-shadow: none; }
.pp-option .tick { color: var(--primary); font-weight: 700; }

.pp-option.on { background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; }
.pp-option.on:hover { background: var(--primary-soft); }

/* who opened a task — recorded, never editable */
.made-by {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.late { color: var(--rose); font-weight: 700; }
.soon { color: var(--amber); font-weight: 700; }

/* ============================================================
   Kanban board
   ============================================================ */

.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(262px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
  align-items: start;
}

.col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  min-height: 140px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}

.col.drop {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.col-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 13.5px;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  z-index: 1;
}

.col-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.col-body { padding: 11px; display: flex; flex-direction: column; gap: 10px; }

.tcard {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 12px;
  padding-inline-start: 15px;
  cursor: grab;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease),
              border-color .15s var(--ease);
}

.tcard::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 99px;
  background: var(--slate);
  opacity: .55;
}

/* The rail encodes deadline pressure: overdue, due today, due within days. */
.tcard[data-due="late"]::before  { background: var(--rose);   opacity: 1; }
.tcard[data-due="today"]::before { background: var(--amber);  opacity: 1; }
.tcard[data-due="soon"]::before  { background: var(--primary); opacity: .8; }
.tcard[data-due="none"]::before  { background: var(--slate);  opacity: .4; }

.tcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
  border-color: var(--border-2);
}

.tcard:active { cursor: grabbing; }
.tcard.dragging { opacity: .4; transform: rotate(1.5deg); }
.tcard .t { font-weight: 600; margin-bottom: 8px; line-height: 1.45; }

.tcard .meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-soft);
}

/* ============================================================
   Modal
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 26, .5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade .14s var(--ease);
}

@keyframes fade { from { opacity: 0; } }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  width: min(690px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: rise .2s var(--ease);
}

.modal.wide { width: min(940px, 100%); }

.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-head h3 { font-size: 17px; font-weight: 600; flex: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }

.modal-foot {
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 9px;
  background: var(--surface-2);
}

.modal-foot .spacer { flex: 1; }

/* ============================================================
   Command palette
   ============================================================ */

.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 26, .48);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 20px 20px;
  animation: fade .12s var(--ease);
}

.cmdk {
  width: min(620px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  animation: rise .18s var(--ease);
  display: flex;
  flex-direction: column;
  max-height: 66vh;
}

.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 5px 18px;
  border-bottom: 1px solid var(--border);
}

.cmdk-input-row .ico { color: var(--text-faint); font-size: 17px; }

.cmdk input {
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 16px;
}

.cmdk input:focus { outline: none; box-shadow: none; }

.cmdk-list { overflow-y: auto; padding: 8px; }

.cmdk-group {
  padding: 10px 12px 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-faint);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text);
}

.cmdk-item .ico {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  flex: 0 0 auto;
}

.cmdk-item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.cmdk-item .t {
  display: block;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.cmdk-item .s {
  display: block;
  font-size: 12.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.cmdk-item[aria-selected="true"] { background: var(--primary-soft); }
.cmdk-item[aria-selected="true"] .ico { background: var(--surface); color: var(--primary); }

.cmdk-foot {
  border-top: 1px solid var(--border);
  padding: 9px 18px;
  display: flex;
  gap: 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--surface-2);
}

kbd {
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ============================================================
   Timeline, toasts, popover
   ============================================================ */

.timeline { display: flex; flex-direction: column; gap: 14px; }

.tl-item { display: flex; gap: 11px; }
.tl-item .body { flex: 1; min-width: 0; }
.tl-item .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-item .txt { white-space: pre-wrap; word-break: break-word; }

.tl-item.k-comment .txt {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 12px;
  margin-top: 3px;
}

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: 12px 16px;
  max-width: 380px;
  animation: slide .2s var(--ease);
}

.toast.err { border-inline-start-color: var(--rose); }
.toast.ok  { border-inline-start-color: var(--jade); }

@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

.pop-wrap { position: relative; }

.pop {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(390px, 88vw);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  z-index: 50;
  max-height: 70vh;
  overflow-y: auto;
  animation: rise .16s var(--ease);
}

.pop .item {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.pop .item:last-child { border-bottom: none; }
.pop .item .body { flex: 1; min-width: 0; }

/* ============================================================
   Misc
   ============================================================ */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--text-soft);
  padding: 10px 15px;
}

.tabs button:hover { background: transparent; color: var(--text); }
.tabs button.active { color: var(--primary-ink); border-bottom-color: var(--primary); }

.split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1050px) { .split { grid-template-columns: 1fr; } }

.help {
  background: var(--primary-soft);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 12px 15px;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 16px;
}

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; }

hr.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* theme switch in the sidebar footer */
.theme-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
}

.theme-switch button {
  flex: 1;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 99px;
  padding: 5px 4px;
  font-size: 12px;
  color: var(--text-soft);
}

.theme-switch button:hover { background: var(--surface); }

.theme-switch button.active {
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--sh-1);
}

/* ============================================================
   Long forms — opening a customer card
   ============================================================ */

.form-page { max-width: 940px; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}

.form-card-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.form-card-head h3 { font-size: 15px; font-weight: 600; }
.form-card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-faint); }

.form-card-head .step {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.form-card-body { padding: 18px 20px 4px; }
.form-card-body .field:last-child { margin-bottom: 16px; }

.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: var(--sh-2);
}

/* Latin-script values (phone, e-mail, company number) read left-to-right
   even inside a right-to-left form. */
.ltr, .ltr-cell { direction: ltr; text-align: start; unicode-bidi: plaintext; }

/* ---------- per-field validation ---------- */

.field-err {
  min-height: 0;
  color: var(--rose);
  margin-top: 4px;
  display: none;
}

.field.bad .field-err { display: block; }

.field.bad input,
.field.bad select,
.field.bad textarea,
.field.bad .verify {
  border-color: var(--rose);
  background: var(--rose-soft);
}

/* ---------- company number, checked against the register ---------- */

.verify { position: relative; }

/* The number reads left-to-right, so it sits against the left edge of the
   field and the verdict badge takes the room left over on the right — which
   in this right-to-left page is the inline START of the wrapper, and the
   inline END of the left-to-right input inside it. */
.verify input { padding-inline-end: 40px; }

.verify-mark {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: transparent;
  transition: background .18s var(--ease);
}

.verify[data-state="valid"]   .verify-mark { background: var(--jade); }
.verify[data-state="warn"]    .verify-mark { background: var(--amber); }
.verify[data-state="invalid"] .verify-mark { background: var(--rose); }
.verify[data-state="unknown"] .verify-mark { background: var(--slate); }

.verify[data-state="loading"] .verify-mark {
  border: 2px solid var(--border-2);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}

.verify-msg { margin-top: 5px; color: var(--text-faint); }
.verify-msg[data-state="valid"]   { color: var(--jade); }
.verify-msg[data-state="warn"]    { color: var(--amber); }
.verify-msg[data-state="invalid"] { color: var(--rose); }

/* ---------- yes / no ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 99px;
}

.segmented label {
  margin: 0;
  position: relative;
  cursor: pointer;
}

.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }

.segmented span {
  display: grid;
  place-items: center;
  min-width: 68px;
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  transition: background .15s var(--ease), color .15s var(--ease);
}

.segmented input:checked + span {
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--sh-1);
}

.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- signature ---------- */

.sign {
  position: relative;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  height: 190px;
  overflow: hidden;
  transition: border-color .15s var(--ease);
}

.sign:hover { border-color: var(--primary); }
.sign canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.sign-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 14px;
  pointer-events: none;
}

.sign.inked .sign-hint { display: none; }

.sign > .btn-sm {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
}

.sign-existing { margin-bottom: 12px; }

.sign-existing img, .sign-saved {
  display: block;
  max-width: 260px;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

/* ============================================================
   Phones and tablets
   ============================================================ */

@media (min-width: 881px) {
  #menu-toggle { display: none; }
  .drawer-scrim { display: none; }
}

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    /* dvh, not vh: iOS Safari counts the URL bar in vh, so a 100vh drawer
       runs off the bottom of the screen. */
    height: 100dvh;
    transform: translateX(100%);
    transition: transform .22s var(--ease);
    z-index: 60;
    box-shadow: var(--sh-3);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar.open { transform: none; }

  /* Tapping outside the drawer closes it. */
  .drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(12, 9, 26, .45);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s var(--ease);
  }

  .drawer-scrim.open { opacity: 1; pointer-events: auto; }

  .search-trigger { width: auto; flex: 1; }
  .search-trigger .k { display: none; }

  .content {
    padding: 16px 12px calc(48px + env(safe-area-inset-bottom));
  }

  .topbar {
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  .page-head h2 { font-size: 19px; }

  /* Wide tables stay scrollable, but the first column stays put so you
     never lose track of which row you are reading. */
  .table-wrap table { min-width: 640px; }

  .table-wrap th:first-child,
  .table-wrap td:first-child {
    position: sticky;
    inset-inline-start: 0;
    background: var(--surface);
    z-index: 1;
  }

  .table-wrap th:first-child { background: var(--surface-2); }
  tbody tr:hover td:first-child { background: var(--surface-2); }

  th, td { padding: 10px 12px; }

  /* A modal on a phone should use the screen, not float in the middle. */
  .overlay { padding: 0; align-items: flex-end; }

  .modal, .modal.wide {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet .24s var(--ease);
  }

  .modal-foot {
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }

  .modal-foot button { flex: 1; justify-content: center; }

  .cmdk-overlay { padding: 0; align-items: flex-end; }
  .cmdk { width: 100%; max-height: 80dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }

  .stat-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat .n { font-size: 25px; }

  .board { grid-auto-columns: minmax(78vw, 1fr); }

  .toasts {
    inset-inline: 12px;
    inset-block-end: calc(14px + env(safe-area-inset-bottom));
  }

  .toast { max-width: none; }

  .pop {
    position: fixed;
    inset-inline: 10px;
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 70dvh;
  }

  .filters { gap: 7px; }
  .filters select,
  .filters input:not([type="checkbox"]):not([type="radio"]) { min-width: 0; flex: 1 1 44%; }

  .form-actions {
    inset-block-end: calc(6px + env(safe-area-inset-bottom));
    padding: 12px;
  }

  .form-actions .btn, .form-actions button { flex: 1; justify-content: center; }
  .form-actions .chip { flex-basis: 100%; }
  .sign { height: 155px; }
}

@keyframes sheet { from { transform: translateY(24px); opacity: 0; } }

/* ---------- touch devices, whatever the width ---------- */
@media (hover: none) and (pointer: coarse) {
  /* iOS Safari zooms the page whenever a focused field is under 16px.
     This is the single most annoying thing about forms on a phone. */
  input, select, textarea { font-size: 16px; }

  /* Comfortable finger targets. */
  button, .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-width: 42px; min-height: 42px; }
  .nav a { padding: 12px; }
  .tabs button { padding: 12px 15px; }
  .row-link { cursor: default; }

  /* Hover lifts are meaningless on touch and leave cards stuck mid-animation. */
  .stat:hover, .tcard:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
