/* ===========================================================================
   Next Automation — visual identity
   Palette: deep indigo #15156B · emerald #05D89C · lavender-white #F5F5FF
   Light UI. Works identically in LTR and RTL (logical properties only).
   =========================================================================== */

:root {
  /* Brand — adaptive: these shift between light and dark mode */
  --indigo: #15156b;
  --indigo-hi: #232399;
  --indigo-press: #0f0f4f;
  --emerald: #05d89c;
  --emerald-hi: #2ce7b1;
  --emerald-press: #04b482;
  --emerald-glow: rgba(5, 216, 156, 0.28);

  /* Surfaces */
  --bg: #f5f5ff;
  --bg-tint: #ececfb;
  --surface: #ffffff;
  --surface-2: #f7f7fe;
  --line: rgba(21, 21, 107, 0.1);
  --line-strong: rgba(21, 21, 107, 0.18);

  /* Text */
  --text: #15156b;          /* headings */
  --text-body: #3b3b5c;     /* body copy */
  --text-dim: #6f6f92;
  --text-faint: #9a9ab5;

  /* Fixed brand marks — deliberately constant in both themes: the login hero
     panel and the logo's light backing chip are a fixed identity, not UI chrome. */
  --brand-panel: #15156b;
  --on-indigo: #eef0ff;     /* text on the brand panel */
  --logo-chip: #ffffff;

  /* Priority scale — distinct from both brand hues, same in both themes */
  --p-low: #3b82f6;   /* blue  */
  --p-med: #f59e0b;   /* amber */
  --p-high: #ef4444;  /* red   */

  /* Board column accents */
  --st-pending: #8888a8;
  --st-progress: #f59e0b;
  --st-done: var(--emerald);

  /* Due-date signals */
  --due-soon: #f59e0b;
  --due-over: #ef4444;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(21, 21, 107, 0.06), 0 2px 8px rgba(21, 21, 107, 0.05);
  --shadow: 0 12px 32px -10px rgba(21, 21, 107, 0.18);
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Dark mode: follows the OS by default (unstamped root), or the explicit
   choice made with the theme toggle (data-theme attribute wins either way). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --indigo: #8385f5;
    --indigo-hi: #a0a2ff;
    --indigo-press: #6668d6;
    --emerald: #1de9ab;
    --emerald-hi: #5ff5c8;
    --emerald-press: #14c496;
    --emerald-glow: rgba(29, 233, 171, 0.25);

    --bg: #23264a;
    --bg-tint: #2d3059;
    --surface: #2a2d56;
    --surface-2: #363968;
    --line: rgba(190, 194, 255, 0.18);
    --line-strong: rgba(190, 194, 255, 0.32);

    --text: #eef0ff;
    --text-body: #c7c9ec;
    --text-dim: #9698c4;
    --text-faint: #6c6e9c;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --indigo: #8385f5;
  --indigo-hi: #a0a2ff;
  --indigo-press: #6668d6;
  --emerald: #1de9ab;
  --emerald-hi: #5ff5c8;
  --emerald-press: #14c496;
  --emerald-glow: rgba(29, 233, 171, 0.25);

  --bg: #23264a;
  --bg-tint: #2d3059;
  --surface: #2a2d56;
  --surface-2: #363968;
  --line: rgba(190, 194, 255, 0.18);
  --line-strong: rgba(190, 194, 255, 0.32);

  --text: #eef0ff;
  --text-body: #c7c9ec;
  --text-dim: #9698c4;
  --text-faint: #6c6e9c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
  --shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text-body);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--emerald-press); }

/* --- Corner controls: language + theme toggles (sit over the light form
   panel in both directions, adapt their own chrome to the active theme) -- */
.corner-controls {
  position: fixed;
  inset-block-start: 18px;
  inset-inline-end: 18px;
  z-index: 50;
  display: flex;
  gap: 8px;
}
.corner-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.corner-btn:hover { color: var(--indigo); border-color: var(--indigo); transform: translateY(-1px); }
.corner-btn svg { width: 15px; height: 15px; opacity: 0.75; }
.theme-toggle__moon[hidden] { display: none; }

/* --- Auth screen --------------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

/* Left: indigo brand panel with an emerald horizon */
.auth__brand {
  position: relative;
  overflow: hidden;
  padding: clamp(2rem, 5vw, 4.5rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--on-indigo);
  background:
    radial-gradient(120% 85% at 100% 0%, rgba(5, 216, 156, 0.28), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgba(90, 90, 200, 0.35), transparent 60%),
    var(--brand-panel);
}
.auth__brand::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(80% 60% at 30% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}
.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
}
/* Logo mark: a light chip behind the two-tone icon so it reads on both the
   dark brand panel and light surfaces without the indigo shapes disappearing
   into an indigo background. */
.brand-icon {
  width: 32px;
  height: 32px;
  padding: 5px;
  border-radius: 9px;
  background: var(--logo-chip);
  box-shadow: 0 1px 2px rgba(21, 21, 107, 0.1), 0 6px 16px -6px rgba(21, 21, 107, 0.25);
  flex: none;
  display: block;
}
.auth__headline {
  position: relative;
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  max-width: 15ch;
  color: #fff;
}
.auth__headline em { font-style: normal; color: var(--emerald-hi); }
.auth__note { position: relative; color: rgba(238, 240, 255, 0.72); font-size: 0.92rem; }

/* Right: the form */
.auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  background: var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.75rem, 4.5vw, 2.75rem);
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 8px; color: var(--text); }
.auth-card .sub { color: var(--text-dim); margin: 0 0 28px; font-size: 0.92rem; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus {
  border-color: var(--emerald);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--emerald-glow);
}
.field .hint { margin-top: 6px; font-size: 0.76rem; color: var(--text-faint); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: var(--indigo);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.06s, box-shadow 0.15s;
  box-shadow: 0 10px 24px -12px rgba(21, 21, 107, 0.5);
}
.btn:hover { background: var(--indigo-hi); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn--sm {
  width: auto;
  padding: 9px 15px;
  font-size: 0.88rem;
  white-space: nowrap;
  box-shadow: 0 8px 18px -12px rgba(21, 21, 107, 0.5);
}

.btn--emerald { background: var(--emerald-press); }
.btn--emerald:hover { background: var(--emerald); }

.auth-switch {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--text-dim);
  text-align: center;
}
.auth-switch button {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--emerald-press);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-inline-start: 6px;
}
.auth-switch button:hover { text-decoration: underline; }
.auth-switch--quiet { font-size: 0.82rem; color: var(--text-faint); }

.form-error {
  display: none;
  margin-bottom: 16px;
  padding: 10px 13px;
  font-size: 0.86rem;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: var(--radius-sm);
}
.form-error.show { display: block; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth__brand { min-height: 200px; }
}

/* ===========================================================================
   App shell — sidebar + content, mirrors automatically in RTL
   =========================================================================== */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
  grid-template-rows: minmax(100vh, auto);
  background: var(--bg);
  transition: grid-template-columns 0.18s ease;
}

/* --- Collapsed sidebar: icon-only rail --- */
.app.sidebar-collapsed { grid-template-columns: 76px 1fr; }
.app.sidebar-collapsed .sidebar { padding-inline: 16px; }
.app.sidebar-collapsed .sidebar__brand { justify-content: center; position: relative; }
.app.sidebar-collapsed .sidebar__brand span { display: none; }
.app.sidebar-collapsed .sidebar__collapse {
  position: absolute;
  inset-block-start: 100%;
  margin-block-start: 14px;
}
.app.sidebar-collapsed .sidebar__collapse svg { transform: rotate(180deg); }
.app.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .nav-item__chev { display: none; }
.app.sidebar-collapsed .nav-dropdown { display: none !important; }
.app.sidebar-collapsed .side-user__id { display: none; }
.app.sidebar-collapsed .side-user__actions { flex-direction: column; }
.app.sidebar-collapsed .side-user__actions .ghost-btn { width: 100%; }

/* --- Sidebar ----------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 20px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 4px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.sidebar__brand .brand-icon { width: 28px; height: 28px; padding: 4px; box-shadow: none; }
.sidebar__brand span { flex: 1; overflow: hidden; white-space: nowrap; }
.sidebar__collapse {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.sidebar__collapse:hover { background: var(--bg-tint); color: var(--indigo); }
.sidebar__collapse svg { width: 16px; height: 16px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  text-align: start;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-tint); color: var(--text); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item.is-active {
  color: var(--indigo);
  background: var(--bg-tint);
}

.nav-item--dropdown .nav-item__chev { margin-inline-start: auto; transition: transform 0.15s; }
.nav-item--dropdown[aria-expanded="true"] .nav-item__chev { transform: rotate(180deg); }
.nav-item--dropdown[aria-expanded="true"] { color: var(--indigo); }

.nav-dropdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 10px 16px;
  margin: 2px 2px 6px;
  border-inline-start: 2px solid var(--line);
  padding-inline-start: 16px;
}
.nav-dropdown__label {
  display: flex;
  align-items: center;
  padding-inline: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}
.nav-dropdown__label--row { justify-content: space-between; }
.nav-dropdown .chip-row { padding-inline: 4px; }
.nav-dropdown .cat-list { margin-inline: -2px; gap: 3px; }

/* --- Empty / placeholder view (e.g. Leads) --- */
.empty-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  text-align: center;
  color: var(--text-dim);
}
.empty-view svg { width: 46px; height: 46px; color: var(--text-faint); }
.empty-view h2 { margin: 0; color: var(--text); font-size: 1.2rem; }
.empty-view p { margin: 0; max-width: 32ch; font-size: 0.9rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-tint); color: var(--indigo); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn--bordered {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.icon-btn--bordered svg { width: 18px; height: 18px; }

.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 0.9rem;
  color: var(--text-body);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: start;
  font-family: var(--font);
}
.cat-item:hover { background: var(--bg-tint); }
.cat-item.is-active { background: var(--bg-tint); color: var(--indigo); font-weight: 600; }
.cat-item__swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.cat-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item__count { font-size: 0.78rem; color: var(--text-faint); }
.cat-item__del {
  opacity: 0;
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.cat-item:hover .cat-item__del { opacity: 1; }
.cat-item__del:hover { color: var(--p-high); }
.cat-item__del svg { width: 14px; height: 14px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 7px; padding-inline: 6px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--indigo); color: var(--indigo); }
.chip.is-active { background: var(--indigo); border-color: var(--indigo); color: #fff; }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }

.ghost-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ghost-btn:hover { background: var(--bg-tint); border-color: var(--indigo); color: var(--indigo); }
.ghost-btn svg { width: 16px; height: 16px; flex: none; }
.ghost-btn--sm { padding: 7px 10px; font-size: 0.8rem; }
.ghost-btn.is-on { color: var(--emerald-press); border-color: var(--emerald); background: rgba(5, 216, 156, 0.08); }
.ghost-btn[disabled] { opacity: 0.6; cursor: default; }

.side-user {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-user__id {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-align: start;
  font-family: var(--font);
}
.side-user__id:hover { background: var(--bg-tint); }
.side-user__id:hover svg { opacity: 1; color: var(--indigo); }
.side-user__id-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.side-user__id strong { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.side-user__id span { font-size: 0.78rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user__id > svg { width: 15px; height: 15px; flex: none; color: var(--text-faint); opacity: 0.7; }
.side-user__actions { display: flex; gap: 8px; }
.side-user__actions .ghost-btn { flex: 1; justify-content: center; }
.side-user__actions .ghost-btn--icon { flex: none; width: 38px; padding-inline: 0; justify-content: center; }
.side-user__actions .ghost-btn--icon > span:not(.theme-toggle__sun):not(.theme-toggle__moon) { display: none; }

/* --- Content --------------------------------------------------------- */
.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  padding: 30px clamp(20px, 3.5vw, 40px) 40px;
  gap: 24px;
}

/* The board/leads panes are swapped by JS but must keep the same vertical
   rhythm as .content itself — display:block here would collapse every gap
   between the topbar, filters, stats and board to zero. */
#boardView {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar__title { font-size: 1.6rem; font-weight: 700; color: var(--text); margin: 0; }
.topbar__tools { display: flex; align-items: center; gap: 10px; }

.board-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: -10px;
}
.board-filter__label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.board-filter .chip-row { padding-inline: 0; }
.board-filter__sep { width: 1px; height: 18px; background: var(--line-strong); }

/* Priority chips pick up the priority's own colour once selected, tying the
   filter back to the badge colours it controls. */
#priorityFilter .chip[data-priority="high"].is-active { background: var(--p-high); border-color: var(--p-high); }
#priorityFilter .chip[data-priority="medium"].is-active { background: var(--p-med); border-color: var(--p-med); }
#priorityFilter .chip[data-priority="low"].is-active { background: var(--p-low); border-color: var(--p-low); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-faint);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-glow); }
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  width: clamp(140px, 22vw, 240px);
}

.reminders { position: relative; }
.reminders__badge {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-end: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--p-high);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.reminders__panel {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  width: 300px;
  max-height: 380px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 30;
}
.reminders__head {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.notify-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.83rem;
  color: var(--text-body);
  cursor: pointer;
  background: var(--surface-2);
}
.notify-row[data-disabled] { color: var(--text-faint); cursor: not-allowed; }

.switch { position: relative; display: inline-block; width: 36px; height: 21px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute;
  inset: 0;
  background: var(--line-strong);
  border-radius: 999px;
  transition: background 0.15s;
}
.switch__thumb {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked + .switch__track { background: var(--emerald-press); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(15px); }
[dir="rtl"] .switch input:checked + .switch__track .switch__thumb { transform: translateX(-15px); }
.switch input:disabled + .switch__track { opacity: 0.5; cursor: not-allowed; }
.reminder-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.reminder-row:hover { background: var(--bg-tint); }
.reminder-row:last-child { border-bottom: none; }
.reminder-row__title { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.reminder-row__time { font-size: 0.76rem; color: var(--text-faint); }
.reminder-row.is-due .reminder-row__time { color: var(--p-high); font-weight: 700; }
.reminders__empty { padding: 18px 14px; font-size: 0.85rem; color: var(--text-faint); text-align: center; }

/* --- Stats ---------------------------------------------------------- */
.stats__head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.stats__toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.stats__toggle:hover { border-color: var(--indigo); color: var(--indigo); background: var(--bg-tint); }
.stats.is-collapsed .stats__head { margin-bottom: 0; }
.stats.is-collapsed .stats__grid { display: none; }

.stats__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 1.3fr;
  gap: 14px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card__label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.stat-card__value { font-size: 1.7rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card--warn .stat-card__value { color: var(--p-high); }
.stat-card--ok .stat-card__value { color: var(--emerald-press); }

.stat-card--donut { gap: 10px; }
.donut-wrap { display: flex; align-items: center; gap: 14px; }
.donut { width: 74px; height: 74px; flex: none; transform: rotate(-90deg); }
.donut__hole { fill: var(--surface); }
.donut__ring { fill: transparent; stroke: var(--bg-tint); stroke-width: 4; }
.donut__seg { fill: transparent; stroke-width: 4; stroke-linecap: butt; transition: stroke-dasharray 0.4s ease; }
#segPending { stroke: var(--st-pending); }
#segProgress { stroke: var(--st-progress); }
#segDone { stroke: var(--emerald); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.donut-legend li { display: flex; align-items: center; gap: 7px; font-size: 0.78rem; color: var(--text-dim); }
.donut-legend .k { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.donut-legend b { color: var(--text); margin-inline-start: 2px; }

/* --- Board -------------------------------------------------------- */
.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  align-items: start;
  flex: 1;
}
.column {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
}
.column__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 17px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.column__dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }
.column__dot[data-status="pending"] { background: var(--st-pending); }
.column__dot[data-status="in_progress"] { background: var(--st-progress); }
.column__dot[data-status="done"] { background: var(--emerald); }
.column__count {
  margin-inline-start: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-tint);
  color: var(--text-dim);
  font-size: 0.76rem;
  display: grid;
  place-items: center;
}
.column__body {
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  overflow-y: auto;
  min-height: 90px;
}
.column__body.is-drop-target {
  background: rgba(5, 216, 156, 0.07);
  outline: 2px dashed var(--emerald);
  outline-offset: -6px;
  border-radius: 10px;
}
.column__empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 0.83rem;
  color: var(--text-faint);
}

/* --- Task card -------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--card-accent, var(--line-strong));
  border-radius: 12px;
  padding: 14px 15px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s, transform 0.05s, border-color 0.15s;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card:active { cursor: grabbing; }
.card.is-dragging { opacity: 0.45; }
.card.is-done .card__title { text-decoration: line-through; color: var(--text-faint); }

.card__title { font-size: 0.9rem; font-weight: 600; color: var(--text); line-height: 1.4; }
.card__desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
}
.badge--priority { color: #fff; }
.badge--priority[data-p="low"] { background: var(--p-low); }
.badge--priority[data-p="medium"] { background: var(--p-med); }
.badge--priority[data-p="high"] { background: var(--p-high); }
.badge--cat { background: var(--bg-tint); color: var(--text-body); }
.badge--cat .k { width: 7px; height: 7px; border-radius: 2px; }
.badge--due { background: var(--bg-tint); color: var(--text-dim); }
.badge--due.is-soon { background: #fef3e2; color: #b45309; }
.badge--due.is-over { background: #fef2f2; color: #b91c1c; }
.badge--reminder { background: var(--bg-tint); color: var(--text-dim); }
.badge svg { width: 11px; height: 11px; }

/* --- Dialogs --------------------------------------------------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--text-body);
  box-shadow: 0 30px 70px -20px rgba(21, 21, 107, 0.4);
}
.dialog::backdrop { background: rgba(21, 21, 107, 0.32); backdrop-filter: blur(2px); }
.dialog {
  max-block-size: calc(100vh - 32px);
  overflow: hidden;
}
.dialog form {
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 17px;
  max-block-size: calc(100vh - 32px);
  overflow-y: auto;
}
.dialog h2 { margin: 0 0 2px; font-size: 1.15rem; color: var(--text); }
.dialog__error {
  margin: 0;
  padding: 10px 13px;
  border-radius: 9px;
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: #b42318;
  font-size: 0.83rem;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog .field { margin: 0; }
.dialog label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 7px;
}
.dialog input,
.dialog textarea,
.dialog select {
  width: 100%;
  padding: 10px 13px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
}
.dialog textarea { resize: vertical; }
.dialog input:focus,
.dialog textarea:focus,
.dialog select:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px var(--emerald-glow);
}
.dialog__actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.dialog__actions .spacer { flex: 1; }
.dialog input:disabled,
.dialog textarea:disabled,
.dialog select:disabled { opacity: 0.6; cursor: not-allowed; }

.dialog__note {
  margin: 0;
  padding: 10px 13px;
  border-radius: 9px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #1e40af;
  font-size: 0.83rem;
}

/* --- Dialog subsections (steps, assignment) --- */
.subsection {
  border-top: 1px solid var(--line);
  padding-top: 17px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.subsection__head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-body);
}
.subsection__count {
  margin-inline-start: auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-faint);
}

.step-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-tint);
  overflow: hidden;
}
.step-progress > span {
  display: block;
  block-size: 100%;
  inline-size: 0%;
  background: var(--emerald);
  border-radius: 999px;
  transition: inline-size 0.3s ease;
}
.step-progress--sm { height: 5px; }

.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
}
.step-item:hover { background: var(--surface-2); }
.step-check {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-body);
  cursor: pointer;
}
.step-check input { width: auto; accent-color: var(--emerald-press); }
.step-item.is-done .step-check span { text-decoration: line-through; color: var(--text-faint); }
.step-del {
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 2px;
}
.step-del:hover { color: var(--p-high); }
.step-del svg { width: 14px; height: 14px; }

.step-add { display: flex; gap: 8px; }
.step-add input { flex: 1; }

.assign-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--text-body);
}
.assign-current span:nth-child(2) { flex: 1; }
.assign-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--indigo);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex: none;
}
.assign-avatar--xs { width: 18px; height: 18px; font-size: 0.58rem; }

/* --- Card extras (steps, assignee) --- */
.card__steps { display: flex; align-items: center; gap: 8px; }
.card__steps .step-progress { flex: 1; }
.card__steps-count { font-size: 0.72rem; font-weight: 600; color: var(--text-faint); }
.card__assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-dim);
  border-top: 1px dashed var(--line);
  padding-top: 7px;
}

.text-btn {
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px 6px;
}
.text-btn:hover { color: var(--text); }
.text-btn--danger { color: var(--p-high); }
.text-btn--danger:hover { color: #b91c1c; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatches button.is-selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

/* --- Toasts -------------------------------------------------- */
.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  padding: 14px 17px;
  border-radius: 11px;
  background: var(--indigo);
  color: #fff;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.25s ease;
}
.toast--reminder { background: var(--emerald-press); }
.toast strong { display: block; font-weight: 700; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Admin: activity log ------------------------------------- */
.admin {
  max-width: 1000px;
  margin: 0 auto;
  padding: 34px clamp(20px, 4vw, 44px) 64px;
}
.admin__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.admin__head .brand-mark { color: var(--text); }
.admin__title { font-size: 1.6rem; color: var(--text); margin: 0 0 4px; }
.admin__sub { color: var(--text-dim); margin: 0 0 22px; font-size: 0.92rem; }

.admin__forbidden {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.admin-tab {
  padding: 10px 4px;
  margin-inline-end: 22px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.is-active { color: var(--indigo); border-bottom-color: var(--emerald); }

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.role-pill--admin { background: rgba(21, 21, 107, 0.1); color: var(--indigo); }
.role-pill--user { background: var(--bg-tint); color: var(--text-dim); }
.role-pill .you { color: var(--text-faint); font-weight: 500; }

.admin__filter { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.admin__filter select {
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 0.86rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
}
.admin__filter select:focus { border-color: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-glow); }
.admin__total {
  font-size: 0.82rem;
  color: var(--text-faint);
  background: var(--bg-tint);
  padding: 4px 10px;
  border-radius: 999px;
}

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.admin-table th {
  text-align: start;
  padding: 14px 18px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.admin-table td { padding: 13px 18px; border-bottom: 1px solid var(--line); color: var(--text-body); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--surface-2); }
.admin-table__time { color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.admin-table__details { color: var(--text-dim); }

.admin-actor { display: inline-flex; align-items: center; gap: 8px; }
.admin-action {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--bg-tint);
  color: var(--text-body);
}
.admin-action[data-a="task"] { background: rgba(96, 165, 250, 0.16); color: #1d4ed8; }
.admin-action[data-a="step"] { background: rgba(5, 216, 156, 0.16); color: var(--emerald-press); }
.admin-action[data-a="category"] { background: rgba(139, 92, 246, 0.16); color: #6d28d9; }
.admin-action[data-a="auth"] { background: rgba(245, 158, 11, 0.16); color: #b45309; }

.admin__empty { padding: 40px 16px; text-align: center; color: var(--text-faint); font-size: 0.9rem; }

/* --- Responsive ------------------------------------------------ */
@media (max-width: 1080px) {
  .stats__grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card--donut { grid-column: span 2; }
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto; min-height: 0; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
  }
  .sidebar__foot { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-user { border-top: none; padding-top: 0; }
  .content { min-height: 0; }
  .board { grid-template-columns: 1fr; }
  .column { max-height: none; }
}
@media (max-width: 620px) {
  .stats__grid { grid-template-columns: 1fr; }
  .stat-card--donut { grid-column: span 1; }
  .field-row { grid-template-columns: 1fr; }
  .topbar__tools { width: 100%; flex-wrap: wrap; }
  .search input { width: 100%; }
  .search { flex: 1; }
  .admin-table__details { display: none; }
}
