/* ==========================================================================
   Admin dashboard — design system v2 ("clean corporate")
   Loaded LAST on /admin/: it redefines the shared tokens (so every page and
   every inline `var(--color-…)` picks them up), styles the new shell
   (sidebar grouped by department + top bar), the home / department
   workspaces, and normalises the shared components used by all pages.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  --font-ui: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-family-primary: var(--font-ui);
  --font-family-secondary: var(--font-ui);

  --app-bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #eff2ee;
  --border: #e2e7e1;
  --border-strong: #cdd5cb;
  --text: #15201a;
  --text-2: #55625a;
  --text-3: #626d66; /* ≥4.5:1 on surface, surface-2, app-bg and surface-3 */

  --brand: #0f5c41;
  --brand-hover: #0b4a34;
  --brand-soft: #e6f1ea;
  --brand-ink: #0b4a34;
  --accent: #8bc53f;
  --ring: 0 0 0 3px rgba(15, 92, 65, 0.18);

  --sidebar-w: 268px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 60px;
  --sb-bg: #0b2f25;
  --sb-bg-2: #0e382c;
  --sb-text: rgba(232, 242, 236, 0.7);
  --sb-text-strong: #f3f8f5;
  --sb-muted: rgba(232, 242, 236, 0.6); /* ~5.5:1 on --sb-bg (0.42 was ~3.5:1) */
  --sb-hover: rgba(255, 255, 255, 0.06);
  --sb-active: rgba(139, 197, 63, 0.16);
  --sb-border: rgba(255, 255, 255, 0.07);

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --sh-1: 0 1px 2px rgba(16, 24, 20, 0.05);
  --sh-2: 0 1px 3px rgba(16, 24, 20, 0.06), 0 4px 12px rgba(16, 24, 20, 0.05);
  --sh-3: 0 12px 32px rgba(16, 24, 20, 0.14);

  --ok: #15803d;
  --ok-soft: #e8f5ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #b91c1c;
  --bad-soft: #fdecec;
  --info: #1d4ed8;
  --info-soft: #e9effd;

  /* Legacy tokens used across pages and inline styles. */
  --color-primary: var(--brand);
  --color-primary-dark: var(--brand-hover);
  --color-primary-light: var(--brand-soft);
  --color-secondary: var(--brand);
  --color-secondary-dark: var(--brand-hover);
  --color-background: var(--surface);
  --color-background-alt: var(--app-bg);
  --color-surface: var(--surface);
  --color-surface-hover: var(--surface-3);
  --color-surface-active: #e6ebe5;
  --color-text-primary: var(--text);
  --color-text-secondary: var(--text-2);
  --color-text-muted: var(--text-3);
  --color-border: var(--border);
  --color-border-dark: var(--border-strong);
  --color-gray-50: var(--surface-2);
  --color-gray-100: var(--surface-3);
  --sc-card-bg: var(--surface);
  --sc-card-shadow: var(--sh-1);
  --sc-card-shadow-hover: var(--sh-2);
  --modal-bg: var(--surface);
  --input-bg: var(--surface);
  --input-border: var(--border-strong);
  --input-text: var(--text);
  --input-placeholder: var(--text-3);
  --table-header-bg: var(--surface-2);
  --table-row-hover: #f3f6f2;
  --table-border: var(--border);
  --table-stripe: var(--surface-2);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --shadow-sm: var(--sh-1);
  --shadow-md: var(--sh-2);
  --shadow-lg: var(--sh-3);
}

:root[data-theme='dark'] {
  --app-bg: #0c1210;
  --surface: #131b18;
  --surface-2: #17211d;
  --surface-3: #1c2722;
  --border: #243029;
  --border-strong: #324038;
  --text: #e4ebe7;
  --text-2: #a1aea7;
  --text-3: #818e87;
  --brand: #2a8a5d;
  --brand-hover: #33a06d;
  --brand-soft: rgba(63, 168, 119, 0.14);
  --brand-ink: #86d6ab;
  --ring: 0 0 0 3px rgba(63, 168, 119, 0.28);
  --sb-bg: #08130f;
  --sb-bg-2: #0c1a15;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-2: 0 1px 3px rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.25);
  --sh-3: 0 16px 40px rgba(0, 0, 0, 0.5);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --info: #7aa2ff;
  --info-soft: rgba(122, 162, 255, 0.12);
  --color-surface-active: #24302a;
  --table-row-hover: #1a2420;
  --color-gray-200: #26322c;
  --color-gray-300: #34423a;
  --color-gray-400: #6f7c75;
  --color-gray-500: #8a968f;
  --color-gray-600: #a9b5ae;
  --color-gray-700: #c6d0ca;
  --color-gray-800: #dbe3de;
  --color-gray-900: #eef3f0;
  --color-text-inverse: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --app-bg: #0c1210;
    --surface: #131b18;
    --surface-2: #17211d;
    --surface-3: #1c2722;
    --border: #243029;
    --border-strong: #324038;
    --text: #e4ebe7;
    --text-2: #a1aea7;
    --text-3: #818e87;
    --brand: #2a8a5d;
    --brand-hover: #33a06d;
    --brand-soft: rgba(63, 168, 119, 0.14);
    --brand-ink: #86d6ab;
    --sb-bg: #08130f;
    --sb-bg-2: #0c1a15;
  }
}

/* ---------- 2. Base ------------------------------------------------------ */
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  padding: 0 !important; /* the legacy fixed header reserved 80px here */
  background: var(--app-bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body,
button,
input,
select,
textarea {
  font-family: var(--font-ui);
}
.ic {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
::selection {
  background: rgba(15, 92, 65, 0.18);
}
.num,
.data-table td,
.stat-card__value {
  font-variant-numeric: tabular-nums;
}
.skip-to-content:focus {
  top: 0 !important;
}

/* ---------- 3. Shell ----------------------------------------------------- */
.app-shell {
  min-height: 100vh;
  padding-inline-start: var(--sidebar-w);
  transition: padding 0.2s ease;
}
.app-shell.is-collapsed {
  padding-inline-start: var(--sidebar-w-collapsed);
}
.app-main {
  padding: 24px 32px 48px;
  max-width: 1480px;
  margin: 0 auto;
  min-width: 0;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  transition:
    width 0.2s ease,
    transform 0.25s ease;
  border-inline-end: 1px solid var(--sb-border);
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--sb-border);
  flex: none;
  cursor: pointer;
  text-decoration: none;
}
.sb-brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 9px;
  padding: 3px;
}
.sb-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.sb-brand__name {
  color: var(--sb-text-strong);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.sb-brand__sub {
  color: var(--sb-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.sb-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.sb-label {
  color: var(--sb-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 16px 10px 6px;
  white-space: nowrap;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--sb-text);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.sb-item:hover {
  background: var(--sb-hover);
  color: var(--sb-text-strong);
}
.sb-item.active {
  background: var(--sb-active);
  color: var(--sb-text-strong);
}
.sb-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sb-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-item__badge {
  font-size: 0.68rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--sb-text-strong);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 18px;
}
.sb-group {
  margin-top: 2px;
}
.sb-group__head .sb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dept, var(--accent));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dept, var(--accent)) 25%, transparent);
  flex: none;
  margin-inline: 4px 2px;
}
.sb-group__head .sb-chev {
  transition: transform 0.2s;
  opacity: 0.6;
}
.sb-group.open .sb-group__head .sb-chev {
  transform: rotate(-90deg);
}
.sb-group__items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}
.sb-group.open .sb-group__items {
  grid-template-rows: 1fr;
}
.sb-group:not(.open) .sb-group__inner {
  visibility: hidden;
  transition: visibility 0s 0.22s;
}
.sb-group__inner {
  overflow: hidden;
  padding-inline-start: 22px;
  position: relative;
}
.sb-group__inner::before {
  content: '';
  position: absolute;
  inset-inline-start: 15px;
  top: 4px;
  bottom: 6px;
  width: 1px;
  background: var(--sb-border);
}
.sb-group__inner .sb-item {
  min-height: 34px;
  font-size: 0.83rem;
  padding-block: 6px;
}
.sb-group__inner .sb-item.active::before {
  inset-inline-start: -7px;
}
.sb-footer {
  flex: none;
  border-top: 1px solid var(--sb-border);
  padding: 8px 10px;
}
.app-shell.is-collapsed .app-sidebar {
  width: var(--sidebar-w-collapsed);
}
.app-shell.is-collapsed .sb-brand__text,
.app-shell.is-collapsed .sb-item__label,
.app-shell.is-collapsed .sb-item__badge,
.app-shell.is-collapsed .sb-chev,
.app-shell.is-collapsed .sb-label,
.app-shell.is-collapsed .sb-group__items,
.app-shell.is-collapsed .sb-dot {
  display: none;
}
.app-shell.is-collapsed .sb-item {
  justify-content: center;
  padding-inline: 0;
}
.app-shell.is-collapsed .sb-brand {
  justify-content: center;
  padding: 0;
}
.app-shell.is-collapsed .sb-footer .sb-item .ic {
  transform: scaleX(-1);
}
.app-shell.is-collapsed .sb-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  inset-inline-start: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #101814;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: var(--sh-3);
  z-index: 10;
  pointer-events: none;
}

/* Top bar */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.tb-crumbs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
}
.tb-crumbs a,
.tb-crumbs button {
  color: var(--text-2);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.tb-crumbs a:hover,
.tb-crumbs button:hover {
  color: var(--text);
}
.tb-crumbs .tb-crumbs__current {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-crumbs .tb-dept-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dept, var(--brand));
  display: inline-block;
}
.tb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tb-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 220px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.tb-search:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}
.tb-search kbd {
  margin-inline-start: auto;
  font-family: inherit;
  font-size: 0.7rem;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  background: var(--surface);
  direction: ltr;
}
.tb-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.tb-icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.tb-year {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tb-year:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.tb-year .tb-year__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.tb-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  z-index: 1100;
  overflow: hidden;
}
#yearDropdown {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--sh-3) !important;
  inset-inline-end: auto !important;
  inset-inline-start: 0;
}
.tb-user {
  position: relative;
}
.tb-user__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tb-user__btn:hover {
  background: var(--surface-3);
}
.tb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 700;
  font-size: 0.85rem;
  flex: none;
}
.tb-user__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-align: start;
  max-width: 180px;
}
.tb-user__meta .user-name {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-user__meta .user-role {
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-menu {
  padding: 6px;
}
.tb-menu__head {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin: -6px -6px 6px;
  background: var(--surface-2);
}
.tb-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  text-align: start;
}
.tb-menu__item:hover {
  background: var(--surface-3);
}
.tb-menu__item--danger {
  color: var(--bad);
}
.tb-menu__sep {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.app-topbar .notification-badge {
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border: 2px solid var(--surface);
  box-sizing: content-box;
}
.notification-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  /* admin-components.css also sets inset-inline-start: 0; with both set, RTL drops
     the end side and the panel opened off the left edge of the screen. */
  inset-inline-start: auto;
  inset-inline-end: 0;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  z-index: 1100;
  text-align: start;
  color: var(--text);
}
.notification-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
}
.notification-item:hover {
  background: var(--surface-2);
}
.notification-item.unread {
  background: var(--brand-soft);
}
.notification-item__time {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-top: 2px;
}
.ws-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-3);
  margin-inline: 4px;
}
.ws-status-connected {
  background: var(--ok);
}
.ws-status-reconnecting {
  background: var(--warn);
}
.ws-status-disconnected {
  background: var(--bad);
}
.tb-menu-toggle {
  display: none;
}
/* Shell controls size themselves; the legacy mobile touch-target rule pads every button. */
.app-topbar .tb-icon-btn {
  padding: 0 !important;
  min-width: 36px;
}
.app-topbar .tb-user__btn {
  padding: 0 6px 0 10px !important;
}
.app-sidebar .sb-item {
  min-width: 0;
}
.app-shell .sidebar-overlay {
  display: none;
}

/* ---------- 4. Page frame ------------------------------------------------ */
.admin-page {
  display: none;
  animation: v2-in 0.22s ease both;
}
.admin-page.active {
  display: block;
}
@keyframes v2-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .admin-page,
  .sb-group__items,
  .app-shell,
  .app-sidebar {
    animation: none;
    transition: none;
  }
}
.admin-main .page-header,
.app-main .page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 4px 16px;
  margin: 0 0 20px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  text-align: start;
}
.app-main .page-header > h2,
.app-main .page-header .page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-basis: 100%;
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.005em;
}
.app-main .page-header > p,
.app-main .page-header .page-description {
  margin: 0;
  flex-basis: 100%;
  color: var(--text-2);
  font-size: 0.9rem;
}
.app-main .page-header .back-button {
  order: -1;
}
.app-main .page-header .page-header__text {
  flex: 1;
  min-width: min(100%, 280px);
}
.app-main .page-header .page-header__text > * + * {
  margin-top: 4px;
}
.app-main .page-header .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  flex-basis: 100%;
  margin-bottom: 2px;
}
.page-eyebrow .tb-dept-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dept, var(--brand));
}
#adminBreadcrumb {
  display: none !important;
}

/* ---------- 5. Components ------------------------------------------------ */
/* Cards */
.app-main .content-card,
.app-main .card,
.app-main .hub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 20px;
  margin-bottom: 16px;
}
.app-main .hub-card {
  padding: 0;
}
.app-main .hub-card:hover {
  box-shadow: var(--sh-1);
  transform: none;
}
.app-main .card {
  padding: 0;
}
.app-main .card-header,
.app-main .hub-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.92rem;
  background: transparent;
  color: var(--text);
}
.app-main .card-body,
.app-main .hub-card-body {
  padding: 16px 18px;
}

/* Headings inside cards: page code uses h2/h3 at page-title size */
.app-main .content-card h2,
.app-main .hub-card h2,
.app-main .card h2,
.app-main .content-card .card-title,
.app-main .content-card .section-title {
  font-size: 1.08rem !important;
  font-weight: 700 !important;
  line-height: 1.4;
  color: var(--text);
  letter-spacing: 0;
}
.app-main .content-card h3,
.app-main .hub-card h3,
.app-main .card h3 {
  font-size: 0.98rem !important;
  font-weight: 700 !important;
  line-height: 1.4;
  color: var(--text);
}
.app-main .content-card h4,
.app-main .hub-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
}
.ic-inline {
  vertical-align: -3px;
  margin-inline-end: 2px;
}
button .ic-inline,
.btn .ic-inline,
.hub-btn .ic-inline {
  margin: 0;
}

/* Buttons — .btn*, .hub-btn* and legacy action buttons share one look */
.app-main .btn,
.modal .btn,
.hub-btn,
.app-main .action-button,
.students-toolbar__btn,
.app-main .back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: none;
  transform: none;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
.app-main .btn:hover:not(:disabled),
.modal .btn:hover:not(:disabled),
.hub-btn:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
}
.app-main .btn:active:not(:disabled),
.hub-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn-primary,
.hub-btn--primary,
.btn--primary,
.hub-btn.primary,
.btn.primary {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
}
.btn-primary:hover:not(:disabled),
.hub-btn--primary:hover:not(:disabled),
.btn--primary:hover:not(:disabled) {
  background: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
}
.btn-green,
.hub-btn--green {
  background: var(--brand) !important;
  border-color: var(--brand) !important;
  color: #fff !important;
}
.btn-outline,
.hub-btn--outline,
.btn--secondary,
.btn-secondary,
.app-main .back-button,
.students-toolbar__btn {
  background: var(--surface) !important;
  border-color: var(--border-strong) !important;
  color: var(--text) !important;
}
.btn-outline:hover:not(:disabled),
.hub-btn--outline:hover:not(:disabled),
.btn--secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.app-main .back-button:hover,
.students-toolbar__btn:hover {
  background: var(--surface-3) !important;
}
.btn-danger,
.hub-btn--danger,
.hub-btn.danger {
  background: var(--surface) !important;
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border)) !important;
  color: var(--bad) !important;
}
.btn-danger:hover:not(:disabled),
.hub-btn--danger:hover:not(:disabled) {
  background: var(--bad-soft) !important;
}
.btn-blue,
.hub-btn--blue {
  background: var(--surface) !important;
  border-color: var(--border-strong) !important;
  color: var(--info) !important;
}
.btn-purple,
.btn-orange,
.hub-btn--orange {
  background: var(--surface) !important;
  border-color: var(--border-strong) !important;
  color: var(--text) !important;
}
.btn-ghost {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text-2) !important;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
.btn-sm,
.hub-btn--sm,
.hub-btn.sm {
  min-height: 30px !important;
  padding: 0 10px !important;
  font-size: 0.8rem !important;
}
.btn-xs {
  min-height: 26px !important;
  padding: 0 8px !important;
  font-size: 0.75rem !important;
  border-radius: var(--r-sm) !important;
}
.btn-lg {
  min-height: 42px;
  padding: 0 18px;
}
.btn-icon,
.app-main .action-button {
  min-width: 32px;
  min-height: 32px;
  padding: 0 8px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.app-main .action-button:hover,
.btn-icon:hover {
  background: var(--surface-3);
  color: var(--text);
}
.app-main .action-button.delete {
  color: var(--bad);
}
.btn:disabled,
.hub-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */
.app-main input[type='text'],
.app-main input[type='search'],
.app-main input[type='email'],
.app-main input[type='tel'],
.app-main input[type='number'],
.app-main input[type='password'],
.app-main input[type='date'],
.app-main input[type='time'],
.app-main input[type='datetime-local'],
.app-main input[type='url'],
.app-main select,
.app-main textarea,
.modal input[type='text'],
.modal input[type='email'],
.modal input[type='tel'],
.modal input[type='number'],
.modal input[type='password'],
.modal input[type='date'],
.modal input[type='time'],
.modal input[type='datetime-local'],
.modal input[type='url'],
.modal select,
.modal textarea,
.form-control,
.form-input {
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  min-height: 36px;
  font: inherit;
  font-size: 0.875rem;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.app-main textarea,
.modal textarea {
  min-height: 72px;
}
.app-main input:focus,
.app-main select:focus,
.app-main textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus,
.form-control:focus,
.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.app-main input::placeholder,
.modal input::placeholder,
.app-main textarea::placeholder {
  color: var(--text-3);
}
.app-main input[type='checkbox'],
.app-main input[type='radio'],
.modal input[type='checkbox'],
.modal input[type='radio'] {
  accent-color: var(--brand);
}
.form-label,
.app-main label.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
}

/* Tabs — hub tabs, program tabs, config tabs: one underline style */
.hub-tabs,
.program-tabs,
.app-main .config-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border) !important;
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
.hub-tab,
.program-tab,
.app-main .config-tab {
  position: relative;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 10px 14px !important;
  margin: 0 !important;
  color: var(--text-2) !important;
  font: inherit;
  font-size: 0.87rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: none !important;
  transform: none !important;
}
.hub-tab:hover,
.program-tab:hover,
.app-main .config-tab:hover {
  color: var(--text) !important;
  background: transparent !important;
}
.hub-tab.active,
.program-tab.active,
.app-main .config-tab.active {
  color: var(--brand-ink) !important;
  font-weight: 600 !important;
}
.hub-tab.active::after,
.program-tab.active::after,
.app-main .config-tab.active::after {
  content: '';
  position: absolute;
  inset-inline: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand);
}

/* Tables */
.app-main .data-table,
.app-main table.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  font-size: 0.86rem;
  border: 0;
  box-shadow: none;
}
.app-main .data-table thead th,
.app-main .data-table th,
.app-main .fr-th {
  background: var(--surface-2) !important;
  color: var(--text-2) !important;
  font-weight: 600;
  font-size: 0.78rem;
  text-align: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.app-main .data-table td,
.app-main .fr-td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.app-main .data-table tbody tr:hover td {
  background: var(--table-row-hover);
}
.app-main .data-table tbody tr:last-child td {
  border-bottom: 0;
}
.app-main .table-wrapper,
.app-main .data-table-wrapper,
.app-main .table-container {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  background: var(--surface);
  box-shadow: none;
}

/* Table row actions: quiet icon buttons, colour only on the glyph */
.app-main .btn-row-action {
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md);
  background: var(--surface) !important;
  color: var(--text-2) !important;
  box-shadow: none;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
}
.app-main .btn-row-action:hover {
  background: var(--surface-3) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
  transform: none;
}
.app-main .btn-row-action.btn-view {
  color: var(--brand-ink) !important;
}
.app-main .btn-row-action.btn-delete {
  color: var(--bad) !important;
}
.app-main .btn-row-action.btn-status {
  color: var(--ok) !important;
}
.app-main .actions-cell,
.app-main td:last-child {
  white-space: nowrap;
}
.app-main [id$='ResetButtonContainer'] {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.app-main [id$='ResetButtonContainer'] .btn {
  margin: 0 !important;
}

/* Badges + status chips */
.badge,
.status-chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  border: 0;
}
.badge-success,
.status-active,
.status-chip--accepted,
.status-chip--eligible {
  background: var(--ok-soft) !important;
  color: var(--ok) !important;
}
.badge-danger,
.status-inactive,
.status-chip--rejected,
.status-chip--ineligible,
.status-chip--withdrawn {
  background: var(--bad-soft) !important;
  color: var(--bad) !important;
}
.badge-warning,
.status-chip--waitlist,
.status-chip--in_interview {
  background: var(--warn-soft) !important;
  color: var(--warn) !important;
}
.badge-info,
.badge-primary,
.status-chip--interview_set,
.status-chip--scheduled,
.status-chip--interview_done {
  background: var(--info-soft) !important;
  color: var(--info) !important;
}
.badge-gray,
.badge-secondary {
  background: var(--surface-3) !important;
  color: var(--text-2) !important;
}
.badge-purple {
  background: color-mix(in srgb, #7c3aed 12%, transparent) !important;
  color: #7c3aed !important;
}
:root[data-theme='dark'] .badge-purple {
  color: #b79cff !important;
}

/* Stat cards (pages) */
.app-main .stat-card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--sh-1) !important;
  padding: 16px 18px !important;
  text-align: start !important;
  transform: none !important;
  border-top-width: 1px !important;
}
.app-main .stat-card:hover {
  box-shadow: var(--sh-2) !important;
}
.app-main .stat-card__value {
  font-size: 1.6rem !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  color: var(--text) !important;
}
.app-main .stat-card__label {
  font-size: 0.8rem !important;
  color: var(--text-2) !important;
  font-weight: 500 !important;
}

.app-main .stat-card--active {
  border-color: var(--brand) !important;
  box-shadow: var(--ring) !important;
}
.app-main .stat-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* Empty states / loading */
.hub-empty,
.empty-state {
  color: var(--text-3);
  text-align: center;
  padding: 36px 16px;
  font-size: 0.9rem;
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-md);
}

/* Modals */
.modal-overlay {
  background: rgba(10, 18, 14, 0.46) !important;
  backdrop-filter: blur(2px);
}
.modal-content {
  background: var(--surface) !important;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) !important;
  box-shadow: var(--sh-3) !important;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px !important;
  border-bottom: 1px solid var(--border) !important;
  background: transparent !important;
  color: var(--text) !important;
}
.modal-header h2,
.modal-header h3,
.modal-title {
  margin: 0;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
  color: var(--text) !important;
}
.modal-close,
.modal .close {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0 !important;
  border-radius: var(--r-md) !important;
  background: transparent !important;
  color: var(--text-2) !important;
  font-size: 1.3rem !important;
  cursor: pointer;
}
.modal-close:hover,
.modal .close:hover {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}
.modal-footer {
  border-top: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
  padding: 12px 20px !important;
}

/* Toasts */
.toast {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-inline-start: 3px solid var(--brand) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--sh-3) !important;
  font-size: 0.86rem;
}
.toast-error {
  border-inline-start-color: var(--bad) !important;
}
.toast-warning {
  border-inline-start-color: var(--warn) !important;
}
.toast-info {
  border-inline-start-color: var(--info) !important;
}

/* ---------- 6. Home + department workspaces ------------------------------ */
.v2-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 22px;
}
.v2-hero__title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
.v2-hero__sub {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 0.9rem;
}
.v2-hero__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.v2-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}
.v2-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.v2-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  text-align: start;
  font: inherit;
  color: inherit;
  cursor: default;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}
button.v2-kpi {
  cursor: pointer;
}
button.v2-kpi:hover {
  box-shadow: var(--sh-2);
  border-color: var(--border-strong);
}
.v2-kpi.is-active {
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.v2-kpis--compact {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.v2-kpis--compact .v2-kpi {
  padding: 12px 14px;
}
.v2-kpis--compact .v2-kpi__value {
  font-size: 1.4rem;
}
.v2-kpi__icon {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--tint, var(--brand-soft));
  color: var(--tone, var(--brand-ink));
}
.v2-kpi__label {
  font-size: 0.8rem;
  color: var(--text-2);
  font-weight: 500;
  padding-inline-end: 40px;
}
.v2-kpi__value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.v2-kpi__hint {
  font-size: 0.74rem;
  color: var(--text-3);
}
.v2-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}
.v2-section-title h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.v2-section-title span {
  color: var(--text-3);
  font-size: 0.8rem;
}
.v2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 14px;
}
.v2-dept {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}
.v2-dept:hover {
  box-shadow: var(--sh-2);
  border-color: var(--border-strong);
}
.v2-dept__head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 12px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  width: 100%;
}
.v2-dept__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: color-mix(in srgb, var(--dept) 12%, transparent);
  color: var(--dept);
}
:root[data-theme='dark'] .v2-dept__icon {
  background: color-mix(in srgb, var(--dept) 22%, transparent);
  color: color-mix(in srgb, var(--dept) 55%, white);
}
.v2-dept__name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
}
.v2-dept__desc {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.v2-dept__go {
  margin-inline-start: auto;
  color: var(--text-3);
}
.v2-dept__stats {
  display: flex;
  gap: 16px;
  padding: 0 16px 12px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.v2-dept__stats b {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  margin-inline-end: 3px;
  font-variant-numeric: tabular-nums;
}
.v2-dept__links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: auto;
}
.v2-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.v2-link-chip:hover {
  border-color: color-mix(in srgb, var(--dept, var(--brand)) 50%, var(--border));
  color: var(--dept-ink, var(--brand-ink));
}
.v2-link-chip .ic {
  color: var(--text-3);
}
.v2-empty-line {
  font-size: 0.78rem;
  color: var(--text-3);
}
.v2-columns {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 8px;
}
.v2-panel {
  padding: 0; /* legacy layout.css pads every <section> */
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  min-width: 0;
}
.v2-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.v2-panel__head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.v2-panel__body {
  padding: 8px 16px 14px;
}
.v2-feed {
  list-style: none;
  margin: 0;
  padding: 0;
}
.v2-feed li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}
.v2-feed li:last-child {
  border-bottom: 0;
}
.v2-feed .tb-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}
.v2-feed__who {
  font-weight: 600;
}
.v2-feed__what {
  color: var(--text-2);
}
.v2-feed__when {
  font-size: 0.72rem;
  color: var(--text-3);
  margin-inline-start: auto;
  white-space: nowrap;
}
.v2-funnel {
  display: grid;
  gap: 10px;
  padding-top: 8px;
}
.v2-funnel__row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}
.v2-funnel__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.v2-funnel__bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}
.v2-funnel__num {
  text-align: end;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.v2-health {
  display: grid;
  gap: 2px;
}
.v2-health__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.84rem;
}
.v2-health__row:last-child {
  border-bottom: 0;
}
.v2-health__row .ic {
  color: var(--text-3);
}
.v2-health__val {
  margin-inline-start: auto;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.v2-meter {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 4px;
}
.v2-meter span {
  display: block;
  height: 100%;
  background: var(--ok);
}
.v2-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
}

/* Department workspace */
.v2-dept-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.v2-dept-hero::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--dept);
}
.v2-dept-hero .v2-dept__icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}
.v2-dept-hero h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
}
.v2-dept-hero p {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 0.88rem;
}
.v2-avatars {
  display: flex;
  margin-inline-start: auto;
  align-items: center;
}
.v2-avatars .tb-avatar {
  border: 2px solid var(--surface);
  margin-inline-start: -8px;
}
.v2-avatars .tb-avatar:first-child {
  margin-inline-start: 0;
}
.v2-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}
.v2-tile {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: start;
  transition:
    box-shadow 0.15s,
    border-color 0.15s;
}
.v2-tile:hover {
  box-shadow: var(--sh-2);
  border-color: color-mix(in srgb, var(--dept, var(--brand)) 45%, var(--border));
}
.v2-tile__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-3);
  color: var(--text-2);
}
.v2-tile:hover .v2-tile__icon {
  background: color-mix(in srgb, var(--dept, var(--brand)) 12%, transparent);
  color: var(--dept, var(--brand));
}
.v2-tile__title {
  font-weight: 600;
  font-size: 0.92rem;
}
.v2-tile__desc {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 2px;
}
.v2-members {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 10px;
}
.v2-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.84rem;
}
.v2-member small {
  display: block;
  color: var(--text-3);
  font-size: 0.74rem;
}
.v2-role {
  margin-inline-start: auto;
}
.v2-placeholder {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 0.86rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

/* Pipeline stepper (acceptance) */
.v2-stepper {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding: 2px;
}
.v2-step {
  flex: 1 0 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.v2-step:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
}
.v2-step__count {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.v2-step__label {
  font-size: 0.76rem;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}
.v2-step--ok .v2-step__count {
  color: var(--ok);
}
.v2-step--bad .v2-step__count {
  color: var(--bad);
}
.v2-step--muted {
  background: var(--surface-2);
  border-style: dashed;
}
.v2-step__arrow,
.v2-step__sep {
  align-self: center;
  color: var(--text-3);
  flex: none;
}
.v2-step__sep {
  width: 1px;
  height: 36px;
  background: var(--border-strong);
  margin: 0 4px;
}

/* Legacy home blocks no longer used */
#main-nav .nav-grid,
#section-nav .nav-grid {
  display: none;
}

/* ---------- 7. Responsive ------------------------------------------------ */
@media (max-width: 1100px) {
  .v2-columns {
    grid-template-columns: 1fr;
  }
  .tb-search {
    min-width: 0;
  }
  .tb-search .tb-search__text,
  .tb-search kbd {
    display: none;
  }
  .tb-search {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
}
@media (max-width: 860px) {
  .app-shell,
  .app-shell.is-collapsed {
    padding-inline-start: 0;
  }
  .app-sidebar,
  .app-shell.is-collapsed .app-sidebar {
    width: min(86vw, 300px);
    transform: translateX(100%);
    box-shadow: var(--sh-3);
  }
  .app-sidebar.mobile-open {
    transform: none;
  }
  .app-shell.is-collapsed .sb-brand__text,
  .app-shell.is-collapsed .sb-item__label,
  .app-shell.is-collapsed .sb-chev,
  .app-shell.is-collapsed .sb-label,
  .app-shell.is-collapsed .sb-dot {
    display: initial;
  }
  .app-shell.is-collapsed .sb-group__items {
    display: grid;
  }
  .app-shell.is-collapsed .sb-item {
    justify-content: flex-start;
    padding-inline: 10px;
  }
  .sb-footer {
    display: none;
  }
  .app-shell .sidebar-overlay.active {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 14, 0.45);
    z-index: 1025;
  }
  .tb-menu-toggle {
    display: inline-grid;
  }
  .app-topbar {
    padding: 0 12px;
    gap: 6px;
  }
  .tb-user__meta,
  .tb-user__btn .sb-chev {
    display: none;
  }
  .tb-year {
    display: none;
  }
  .app-main {
    padding: 16px 16px 40px;
  }
  .v2-hero__title {
    font-size: 1.3rem;
  }
  .app-main .page-header > h2,
  .app-main .page-header .page-title {
    font-size: 1.25rem;
  }
  .v2-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .v2-kpi__value {
    font-size: 1.4rem;
  }
  .v2-dept-hero {
    padding: 18px 16px;
  }
  .v2-avatars {
    margin-inline-start: 0;
  }
  .tb-crumbs .tb-crumbs__trail {
    display: none;
  }
  /* Wide tables scroll inside their card instead of breaking words letter by letter */
  .app-main .table-wrapper,
  .app-main .data-table-wrapper,
  .app-main .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .app-main .table-wrapper .data-table {
    min-width: 680px !important;
  }
  .app-main .data-table th,
  .app-main .data-table td {
    white-space: nowrap !important;
    word-break: normal !important;
  }
}

/* ---------- Work system (admin-work.js): projects, milestones, tasks ------ */
.wk-muted {
  color: var(--text-2);
  font-size: 0.84rem;
}
.wk-bad,
.wk-bad .num {
  color: var(--bad) !important;
}
.wk-warn-text {
  color: var(--warn);
}
.wk-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 8px 0 6px;
}
.wk-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: start;
}
.wk-link:hover {
  text-decoration: underline;
}
.wk-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 700;
}
.wk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0;
}
.wk-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.wk-filters .form-control {
  width: auto;
  min-width: 140px;
  height: 36px;
  padding-block: 0;
}
.wk-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.86rem;
  cursor: pointer;
  margin: 6px 0;
}
.wk-check input,
.wk-radio input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

/* chips, badges, progress */
.wk-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
.wk-st--in_progress,
.wk-ps--active {
  background: var(--info-soft) !important;
  color: var(--info) !important;
}
.wk-st--blocked,
.wk-ps--paused {
  background: var(--bad-soft) !important;
  color: var(--bad) !important;
}
.wk-st--in_review,
.wk-ps--planned {
  background: var(--warn-soft) !important;
  color: var(--warn) !important;
}
.wk-st--done,
.wk-ps--done {
  background: var(--ok-soft) !important;
  color: var(--ok) !important;
}
.wk-st--cancelled,
.wk-ps--cancelled {
  text-decoration: line-through;
}
.wk-health {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--text-2);
  white-space: nowrap;
}
.wk-health span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.wk-health--on_track span {
  background: var(--ok);
}
.wk-health--at_risk span {
  background: var(--warn);
}
.wk-health--off_track span {
  background: var(--bad);
}
.wk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-2);
  white-space: nowrap;
}
.wk-badge--warn,
.wk-pri--high {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: var(--warn-soft);
}
.wk-pri--urgent {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  background: var(--bad-soft);
}
.wk-progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 90px;
}
.wk-progress__bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.wk-progress__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 0.4s ease;
}
.wk-progress__pct {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-2);
  min-width: 34px;
  text-align: end;
}
.wk-progress--big .wk-progress__bar {
  height: 10px;
}
.wk-progress--big .wk-progress__pct {
  font-size: 1rem;
  color: var(--text);
}
.wk-avatars {
  display: inline-flex;
  flex-direction: row-reverse;
}
.wk-avatars .tb-avatar {
  width: 26px;
  height: 26px;
  font-size: 0.72rem;
  border: 2px solid var(--surface);
  margin-inline-start: -6px;
}
.wk-unassigned {
  font-size: 0.76rem;
  color: var(--text-3);
  white-space: nowrap;
}
.wk-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-2);
  white-space: nowrap;
}
.wk-due.is-overdue {
  color: var(--bad);
  font-weight: 700;
}

/* task rows */
.wk-group {
  margin-bottom: 14px;
}
.wk-group--bad .v2-panel__head h3 {
  color: var(--bad);
}
.wk-group--warn .v2-panel__head h3 {
  color: var(--warn);
}
.wk-group--info .v2-panel__head h3 {
  color: var(--info);
}
.wk-collapsible > summary {
  cursor: pointer;
  list-style: none;
}
.wk-collapsible > summary::-webkit-details-marker {
  display: none;
}
.wk-list {
  display: flex;
  flex-direction: column;
}
.wk-task {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-inline-start: calc(16px + var(--depth, 0) * 22px);
  border-bottom: 1px solid var(--border);
}
.wk-task:last-child {
  border-bottom: 0;
}
.wk-task:hover {
  background: var(--surface-2);
}
.wk-task--sub {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.wk-task.is-done .wk-task__title {
  color: var(--text-3);
  text-decoration: line-through;
}
.wk-task__main {
  min-width: 0;
}
.wk-task__title {
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-align: start;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wk-task__title:hover {
  color: var(--brand);
}
.wk-task__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-2);
}
.wk-task__meta > span:not(.wk-badge) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wk-task__side {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wk-status-select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  border: 0;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
}

/* project tree */
.wk-tree {
  overflow: hidden;
}
.wk-tree__head,
.wk-prow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 170px 90px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
}
.wk-tree__head {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-3);
}
.wk-prow {
  border-bottom: 1px solid var(--border);
}
.wk-prow:last-child {
  border-bottom: 0;
}
.wk-prow:hover {
  background: var(--surface-2);
}
.wk-prow.is-archived {
  opacity: 0.6;
}
.wk-prow__name-cell {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding-inline-start: calc(var(--depth, 0) * 24px);
}
.wk-caret {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  padding: 0 !important;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.wk-caret:hover {
  background: var(--surface-3);
}
.wk-caret svg {
  transition: transform 0.2s ease;
}
.wk-caret.is-open svg {
  transform: rotate(-90deg);
}
.wk-caret--empty {
  cursor: default;
}
.wk-pdot {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--pc, var(--brand));
}
.wk-prow__main {
  min-width: 0;
}
.wk-prow__name {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  text-align: start;
}
.wk-prow__name:hover {
  color: var(--brand);
}
.wk-prow__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-2);
}
.wk-prow__meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wk-ms-tag {
  color: var(--brand-ink);
}
.wk-prow__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.wk-prow__counts {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-2);
}
.wk-prow__counts > span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* project header */
.wk-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.84rem;
  color: var(--text-3);
}
.wk-phero {
  position: relative;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.wk-phero::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--pc, var(--brand));
}
.wk-phero__top {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}
.wk-phero__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}
.wk-phero__desc {
  margin: 6px 0 0;
  color: var(--text-2);
  max-width: 75ch;
  white-space: pre-wrap;
}
.wk-phero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.wk-phero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wk-phero__stats {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(80px, 1fr));
  gap: 16px;
  align-items: end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.wk-phero__progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wk-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wk-stat .num {
  font-size: 1.3rem;
  font-weight: 700;
}
.wk-stat small {
  color: var(--text-2);
  font-size: 0.76rem;
}
.wk-tabs {
  margin: 16px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wk-tabs .hub-tab {
  white-space: nowrap;
}
.wk-phero__meta .v2-chip {
  white-space: normal;
  max-width: 100%;
}
#work-projects > .page-header[hidden] {
  display: none !important;
}

/* board */
.wk-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(190px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.wk-col {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.wk-col.is-over {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.wk-col__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
}
.wk-col__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px 12px;
}
.wk-col__empty {
  text-align: center;
  color: var(--text-3);
  padding: 16px 0;
}
.wk-card {
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--sh-1);
  cursor: grab;
}
.wk-card:hover,
.wk-card:focus-visible {
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
  outline: none;
}
.wk-card.is-overdue {
  border-inline-start: 3px solid var(--bad);
}
.wk-card__title {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.5;
}
.wk-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.wk-card__badges:empty {
  display: none;
}
.wk-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.wk-hint {
  margin-top: 8px;
}

/* milestones */
.wk-ms-list {
  overflow: hidden;
}
.wk-ms {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 170px auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.wk-ms:last-child {
  border-bottom: 0;
}
.wk-ms.is-inherited {
  background: var(--surface-2);
}
.wk-ms__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
}
.wk-ms.is-done .wk-ms__icon {
  background: var(--ok-soft);
  color: var(--ok);
}
.wk-ms__name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.wk-ms__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.wk-ms__meta > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wk-ms__progress {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wk-ms__actions {
  display: flex;
  gap: 2px;
}
.wk-warn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.8rem;
}

/* project cards */
.wk-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 12px;
}
.wk-pcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-1);
  font: inherit;
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition:
    box-shadow 0.15s,
    border-color 0.15s,
    transform 0.15s;
}
.wk-pcard:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-2);
  transform: translateY(-1px);
}
.wk-pcard__head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wk-pcard__head .wk-pdot {
  margin-top: 0;
}
.wk-pcard__name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
}
.wk-pcard__meta,
.wk-pcard__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 0.76rem;
  color: var(--text-2);
}
.wk-pcard__foot > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wk-queue-note {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 12px;
  font: inherit;
  cursor: pointer;
}

/* forms */
.wk-modal-body {
  padding: 16px;
}
.wk-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wk-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.wk-field > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-2);
}
.wk-grid2,
.wk-grid3 {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wk-grid3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.wk-color {
  height: 40px;
  padding: 4px !important;
}
.wk-fieldset {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.wk-fieldset legend {
  padding: 0 6px;
  font-size: 0.82rem;
  font-weight: 700;
}
.wk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.wk-chip-check {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}
.wk-chip-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.wk-chip-check span {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.wk-chip-check input:checked + span {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 600;
}
.wk-chip-check input:focus-visible + span {
  box-shadow: var(--ring);
}
.wk-chip-check--sm span {
  height: 26px;
  padding: 0 9px;
  font-size: 0.74rem;
}
.wk-radios {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 8px;
}
.wk-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}
.wk-picker {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.wk-picker > .form-control {
  width: 100%;
  margin: 0;
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
}
.wk-picker__list {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.wk-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.84rem;
  cursor: pointer;
}
.wk-pick:hover {
  background: var(--surface-2);
}
.wk-pick input {
  accent-color: var(--brand);
}
.wk-sub-details {
  margin-top: 10px;
}
.wk-sub-details > summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-2);
  margin-bottom: 8px;
}
.wk-settings {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
}
.wk-settings__title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border);
}
.wk-settings-section {
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.wk-settings-section:last-child {
  border-bottom: 0;
}
.wk-settings-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}
.wk-settings-section[open] {
  padding-bottom: 12px;
}
.wk-rem {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}
.wk-rem .form-control {
  width: auto;
  height: 34px;
  padding-block: 0;
}
.wk-rem__before,
.wk-rem__at,
.wk-rem__to {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.wk-rem__before[hidden],
.wk-rem__at[hidden] {
  display: none;
}
.wk-rem__before input {
  width: 72px !important;
}
.wk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.wk-actions--sticky {
  position: sticky;
  bottom: -16px;
  margin: 0 -16px -16px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 2;
}
.wk-actions--bar {
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* task drawer */
.modal.wk-drawer-modal {
  justify-content: flex-end;
  align-items: stretch;
  padding: 0 !important;
}
.modal .modal-content.wk-drawer {
  width: min(720px, 100vw);
  max-width: none;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  animation: wk-slide 0.22s ease;
}
@keyframes wk-slide {
  from {
    transform: translateX(-24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
.wk-drawer .modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.wk-tsum {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
}
.wk-tsum__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.wk-tsum__row > span:not(.wk-chip):not(.wk-badge):not(.v2-chip) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.wk-note {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 0.86rem;
  white-space: pre-wrap;
}
.wk-dsec {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.wk-dsec:last-of-type {
  border-bottom: 0;
}
.wk-dsec__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: default;
}
details.wk-dsec > summary.wk-dsec__title {
  cursor: pointer;
}
.wk-desc {
  white-space: pre-wrap;
  margin: 0 0 8px;
}
.wk-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 0.86rem;
}
.wk-dl dt {
  color: var(--text-2);
}
.wk-dl dd {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wk-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}
.wk-cl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
}
.wk-cl-item:hover {
  background: var(--surface-2);
}
.wk-cl-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.88rem;
}
.wk-cl-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.wk-cl-item.is-done span {
  color: var(--text-3);
  text-decoration: line-through;
}
.wk-inline-add {
  display: flex;
  gap: 8px;
}
.wk-inline-add .form-control {
  flex: 1;
  height: 36px;
}
.wk-dep {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.wk-comments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.wk-comment {
  display: flex;
  gap: 10px;
}
.wk-comment .tb-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  font-size: 0.78rem;
}
.wk-comment__body {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.wk-comment--rejection .wk-comment__body {
  background: var(--bad-soft);
}
.wk-comment--completion .wk-comment__body {
  background: var(--ok-soft);
}
.wk-comment__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.wk-comment__text {
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.88rem;
}
.wk-comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.wk-comment-form textarea {
  flex: 1;
}
.wk-feed li {
  align-items: center;
}

/* home panel */
.wk-home {
  margin-bottom: 8px;
}
.wk-home__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 8px 0;
  font-size: 0.86rem;
  color: var(--text-2);
}
.wk-home__stats b {
  font-size: 1.15rem;
  color: var(--text);
  margin-inline-end: 4px;
}
.wk-home__stats .wk-bad b,
.wk-home__stats .wk-warn-text b {
  color: inherit;
}
.wk-home__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wk-home__list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
}
.wk-home__list li small {
  color: var(--text-3);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .wk-tree__head {
    display: none;
  }
  .wk-prow {
    grid-template-columns: minmax(0, 1fr) 150px;
    grid-template-areas: 'name name' 'status progress' 'counts counts';
    row-gap: 8px;
  }
  .wk-prow__name-cell {
    grid-area: name;
  }
  .wk-prow__status {
    grid-area: status;
    padding-inline-start: calc(var(--depth, 0) * 24px + 50px);
  }
  .wk-prow__progress {
    grid-area: progress;
  }
  .wk-prow__counts {
    grid-area: counts;
    padding-inline-start: calc(var(--depth, 0) * 24px + 50px);
  }
  .wk-phero__stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .wk-phero__progress {
    grid-column: 1 / -1;
  }
}
@media (max-width: 860px) {
  .wk-task {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .wk-task__status {
    max-width: 160px;
  }
  .wk-task__side {
    flex-wrap: wrap;
  }
  .wk-task__title {
    white-space: normal;
  }
  .wk-prow {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'name' 'status' 'progress' 'counts';
  }
  .wk-prow__progress {
    padding-inline-start: calc(var(--depth, 0) * 16px + 50px);
  }
  .wk-prow__name-cell {
    padding-inline-start: calc(var(--depth, 0) * 16px);
  }
  .wk-prow__status,
  .wk-prow__counts {
    padding-inline-start: calc(var(--depth, 0) * 16px + 50px);
  }
  .wk-board {
    grid-template-columns: repeat(5, 78vw);
    scroll-snap-type: x mandatory;
  }
  .wk-col {
    scroll-snap-align: start;
  }
  .wk-ms {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  .wk-ms__progress,
  .wk-ms__actions {
    grid-column: 2;
  }
  .wk-grid2,
  .wk-grid3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .wk-phero {
    padding: 16px;
  }
  .wk-phero__top {
    flex-direction: column;
  }
  .wk-phero__title {
    font-size: 1.15rem;
  }
  .wk-phero__stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .wk-filters .form-control {
    min-width: 0;
    flex: 1 1 140px;
  }
  .wk-filters {
    width: 100%;
  }
  .modal .modal-content.wk-drawer {
    width: 100vw;
  }
}

/* ---------- Work system 2B: portfolio, timeline, impact, templates -------- */
.wk-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wk-stale {
  display: inline-flex;
  color: var(--warn);
}
.v2-chip.wk-stale-chip {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

/* health picker */
.wk-health-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wk-health-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
}
.wk-health-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.wk-health-opt > span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-3);
}
.wk-health-opt.wk-health--on_track > span {
  background: var(--ok);
}
.wk-health-opt.wk-health--at_risk > span {
  background: var(--warn);
}
.wk-health-opt.wk-health--off_track > span {
  background: var(--bad);
}
.wk-health-opt:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.wk-health-opt:has(input:focus-visible) {
  box-shadow: var(--ring);
}

/* overview */
.wk-ov {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
  margin-top: 14px;
}
.wk-ov__main,
.wk-ov__side {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.wk-ov__composer {
  padding: 12px 16px 16px;
}
.wk-pf {
  overflow: hidden;
}
.wk-pf__head,
.wk-pf-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 130px 150px minmax(0, 1fr) 76px;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
}
.wk-pf__head {
  background: var(--surface-2);
  border-block: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-3);
}
.wk-pf-row {
  border-bottom: 1px solid var(--border);
}
.wk-pf-row:last-child {
  border-bottom: 0;
}
.wk-pf-row:hover {
  background: var(--surface-2);
}
.wk-pf__name {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  padding-inline-start: calc(var(--depth, 0) * 22px);
}
.wk-pf__name .wk-pdot {
  margin-top: 7px;
}
.wk-pf__health {
  display: grid;
  gap: 3px;
  justify-items: start;
}
.wk-pf__health small {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
}
.wk-pf__ms {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-width: 0;
  font-size: 0.84rem;
  color: var(--text-2);
}
.wk-pf__ms-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wk-msc-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 14px 16px 16px;
}
.wk-msc {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: start;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.wk-msc:hover {
  border-color: var(--border-strong);
  box-shadow: var(--sh-1);
}
.wk-msc.is-inherited {
  border-style: dashed;
}
.wk-msc.is-late {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}
.wk-msc.is-done {
  opacity: 0.7;
}
.wk-msc__head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--brand);
}
.wk-msc.is-late .wk-msc__head {
  color: var(--bad);
}
.wk-msc__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.wk-msc small {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.wk-updates {
  list-style: none;
  margin: 0;
  padding: 4px 16px 12px;
}
.wk-update {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.wk-update:last-child {
  border-bottom: 0;
}
.wk-update__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.84rem;
}
.wk-update__head .v2-feed__when {
  margin-inline-start: auto;
}
.wk-update__body {
  margin: 6px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
}

/* segmented control */
.wk-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--surface-3);
}
.wk-seg button {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
.wk-seg button.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-1);
}

/* timeline (RTL: time flows right → left; positions use inset-inline-start) */
.wk-tl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.wk-tl-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wk-tl-legend i {
  display: inline-block;
  width: 18px;
  height: 8px;
  border-radius: 4px;
}
.wk-tl-legend .lg-project {
  background: var(--brand);
}
.wk-tl-legend .lg-task {
  background: color-mix(in srgb, var(--info) 62%, var(--surface));
}
.wk-tl-legend .lg-overdue {
  background: var(--bad);
}
.wk-tl-legend .lg-done {
  background: var(--border-strong);
}
.wk-tl-legend .lg-ms {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--warn);
  transform: rotate(45deg);
}
.wk-tl-legend .lg-today {
  width: 2px;
  height: 14px;
  border-radius: 0;
  background: var(--bad);
}
.wk-tl {
  --tl-label: 230px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.wk-tl__scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}
.wk-tl__scroll:focus-visible {
  outline: none;
  box-shadow: inset var(--ring);
}
.wk-tl__canvas {
  position: relative;
}
.wk-tl__head,
.wk-tl__lane,
.wk-tl__row {
  display: flex;
}
.wk-tl__label {
  position: sticky;
  inset-inline-start: 0;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  width: var(--tl-label);
  min-width: 0;
  padding-inline: calc(12px + var(--d, 0) * 14px) 10px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
}
.wk-tl__corner {
  padding-inline: 12px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-3);
}
.wk-tl__head {
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.wk-tl__head .wk-tl__label {
  background: var(--surface-2);
}
.wk-tl.is-months .wk-tl__head {
  height: 34px;
}
.wk-tl__scale {
  position: relative;
  flex: none;
}
.wk-tl__months,
.wk-tl__weeks {
  position: relative;
  height: 26px;
}
.wk-tl.is-months .wk-tl__months {
  height: 34px;
}
.wk-tl__weeks {
  border-top: 1px solid var(--border);
}
.wk-tl__mcell,
.wk-tl__wcell {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding-inline: 8px;
  border-inline-start: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-2);
}
.wk-tl__wcell {
  font-weight: 500;
  color: var(--text-3);
}
.wk-tl__today-tag {
  position: absolute;
  bottom: 2px;
  z-index: 2;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bad);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 16px;
  transform: translateX(50%);
}
.wk-tl__lane {
  height: 58px;
  border-bottom: 1px solid var(--border);
}
.wk-tl__lane .wk-tl__track,
.wk-tl__row .wk-tl__track {
  position: relative;
  flex: none;
}
.wk-tl__row .wk-tl__track {
  width: calc(100% - var(--tl-label));
}
.wk-tl__body {
  position: relative;
}
.wk-tl__lines {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: var(--tl-label);
  z-index: 0;
  pointer-events: none;
}
.wk-tl__line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-inline-start: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.wk-tl__line.is-month {
  border-inline-start-color: var(--border-strong);
}
.wk-tl__line.is-ms {
  border-inline-start: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent);
}
.wk-tl__line.is-today {
  z-index: 1;
  border-inline-start: 2px solid var(--bad);
}
.wk-tl__deps {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}
.wk-tl__deps path {
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.4;
}
.wk-tl__deps marker path {
  fill: var(--text-3);
  stroke: none;
}
.wk-tl__deps path.is-bad {
  stroke: var(--bad);
}
.wk-tl__deps marker path.is-bad {
  fill: var(--bad);
}
.wk-tl__row {
  height: var(--tl-row, 34px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.wk-tl__row.is-project {
  background: color-mix(in srgb, var(--pc, var(--brand)) 5%, transparent);
}
.wk-tl__row.is-project .wk-tl__label {
  background: color-mix(in srgb, var(--pc, var(--brand)) 6%, var(--surface));
}
.wk-tl__row:hover .wk-tl__label {
  background: var(--surface-2);
}
.wk-tl__name {
  flex: 0 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
}
.wk-tl__row.is-project .wk-tl__name {
  font-size: 0.86rem;
  font-weight: 700;
}
b.wk-tl__name {
  cursor: default;
}
.wk-tl__row.is-done .wk-tl__name {
  color: var(--text-3);
  text-decoration: line-through;
}
.wk-tl__label .wk-pdot {
  flex: none;
}
.wk-tl__hd {
  display: inline-flex;
  flex: none;
}
.wk-tl__hd span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}
.wk-tl__hd.wk-health--on_track span {
  background: var(--ok);
}
.wk-tl__hd.wk-health--at_risk span {
  background: var(--warn);
}
.wk-tl__hd.wk-health--off_track span {
  background: var(--bad);
}
.wk-tl__bar {
  position: absolute;
  top: 50%;
  z-index: 2;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  transform: translateY(-50%);
}
.wk-tl__bar:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.wk-tl__bar--project {
  height: 20px;
  border: 1px solid color-mix(in srgb, var(--pc, var(--brand)) 55%, transparent);
  background: color-mix(in srgb, var(--pc, var(--brand)) 22%, var(--surface));
}
.wk-tl__fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  background: color-mix(in srgb, var(--pc, var(--brand)) 70%, var(--surface));
}
.wk-tl__pct {
  position: relative;
  display: block;
  padding-inline: 6px;
  text-align: start;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 18px;
  color: var(--text);
}
.wk-tl__bar--task {
  background: color-mix(in srgb, var(--info) 62%, var(--surface));
}
.wk-tl__bar--task.wk-st-in_progress {
  background: var(--info);
}
.wk-tl__bar--task.wk-st-in_review {
  background: var(--warn);
}
.wk-tl__bar--task.wk-st-blocked {
  background: repeating-linear-gradient(
    -45deg,
    var(--bad) 0 5px,
    color-mix(in srgb, var(--bad) 55%, var(--surface)) 5px 10px
  );
}
.wk-tl__bar--task.wk-st-done,
.wk-tl__bar--task.wk-st-cancelled {
  background: var(--border-strong);
}
.wk-tl__bar--task.is-overdue {
  background: var(--bad);
}
.wk-tl__bar.is-point {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
}
.wk-tl__nodate {
  position: absolute;
  top: 50%;
  inset-inline-start: 10px;
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--text-3);
  transform: translateY(-50%);
}
.wk-tl__ms {
  position: absolute;
  top: 32%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  /* the diamond (first item, at the inline start) sits on the date */
  transform: translate(6px, -50%);
}
.wk-tl__ms i {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--surface);
  transform: rotate(45deg);
}
.wk-tl__ms.is-inherited i {
  border: 2px dashed var(--warn);
  background: var(--surface);
}
.wk-tl__ms.is-done i {
  background: var(--ok);
}
.wk-tl__ms.is-late i {
  background: var(--bad);
}
.wk-tl__ms span {
  padding-inline: 2px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-2);
}
.wk-tl__ms.is-low {
  top: 70%;
}
.wk-tl__ms:hover span,
.wk-tl__ms:focus-visible span {
  color: var(--text);
}

/* date-change impact */
.wk-impact__lead {
  margin: 0 0 10px;
  line-height: 1.8;
}
.wk-impact__list {
  display: grid;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.wk-impact__item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.wk-impact__item:last-child {
  border-bottom: 0;
}
.wk-impact__item.is-static {
  cursor: default;
}
.wk-impact__item:hover {
  background: var(--surface-2);
}
.wk-impact__item input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.wk-impact__icon {
  display: inline-flex;
  color: var(--text-3);
}
.wk-impact__main {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.wk-impact__title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.wk-impact__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.wk-impact__dates {
  white-space: nowrap;
  font-size: 0.84rem;
  color: var(--text-2);
}
.wk-impact__dates b {
  color: var(--text);
}
.wk-issue--moves_with {
  background: var(--info-soft);
  color: var(--info);
}
.wk-issue--dependent_before_blocker,
.wk-issue--after_milestone,
.wk-issue--contributor_late,
.wk-issue--after_parent_milestone,
.wk-issue--after_project_end {
  background: var(--warn-soft);
  color: var(--warn);
}

/* templates */
.wk-tpl-list {
  display: grid;
  gap: 10px;
}
.wk-tpl {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.wk-tpl--picked {
  margin-bottom: 14px;
  background: var(--surface-2);
}
.wk-tpl__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
}
.wk-tpl__main {
  flex: 1;
  display: grid;
  gap: 4px;
  min-width: 0;
}
.wk-tpl__name {
  font-weight: 700;
}
.wk-tpl__actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 1100px) {
  .wk-ov {
    grid-template-columns: minmax(0, 1fr);
  }
  .wk-pf__head {
    display: none;
  }
  .wk-pf-row {
    grid-template-columns: minmax(0, 1fr) 150px;
    grid-template-areas: 'name name' 'health progress' 'ms counts';
    row-gap: 8px;
  }
  .wk-pf__name {
    grid-area: name;
  }
  .wk-pf__health {
    grid-area: health;
    padding-inline-start: calc(var(--depth, 0) * 22px + 18px);
  }
  .wk-pf__progress {
    grid-area: progress;
  }
  .wk-pf__ms {
    grid-area: ms;
    padding-inline-start: calc(var(--depth, 0) * 22px + 18px);
  }
  .wk-pf-row .wk-prow__counts {
    grid-area: counts;
  }
}
@media (max-width: 860px) {
  .wk-tl {
    --tl-label: 132px;
  }
  .wk-tl__label {
    padding-inline: calc(8px + var(--d, 0) * 8px) 6px;
  }
  .wk-tl__corner span {
    display: none;
  }
  .wk-pf-row {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'name' 'health' 'progress' 'ms' 'counts';
  }
  .wk-pf__name {
    padding-inline-start: calc(var(--depth, 0) * 14px);
  }
  .wk-pf__health,
  .wk-pf__progress,
  .wk-pf__ms,
  .wk-pf-row .wk-prow__counts {
    padding-inline-start: calc(var(--depth, 0) * 14px + 18px);
  }
  .wk-impact__item {
    grid-template-columns: 22px minmax(0, 1fr);
  }
  .wk-impact__dates {
    grid-column: 2;
    white-space: normal;
  }
  .wk-tpl {
    flex-wrap: wrap;
  }
  .wk-tpl__actions {
    justify-content: flex-end;
    width: 100%;
  }
}

/* ---------- Work system 2C: reports, record links, morning digest -------- */
.wk-toolbar__end {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* switch (ملخص صباحي) */
.wk-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.wk-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.wk-switch__track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.wk-switch__track::after {
  content: '';
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--sh-1);
  transition: inset-inline-start 0.15s ease;
}
.wk-switch input:checked + .wk-switch__track {
  background: var(--brand);
}
.wk-switch input:checked + .wk-switch__track::after {
  inset-inline-start: 18px;
}
.wk-switch input:focus-visible + .wk-switch__track {
  box-shadow: var(--ring);
}

/* record links in the task drawer */
.wk-recs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wk-rec {
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.wk-rec__main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text);
  text-align: start;
  cursor: pointer;
  border-radius: var(--r-md);
}
.wk-rec__main:hover:not(:disabled) {
  background: var(--surface-2);
}
.wk-rec__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
}
.wk-rec__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.wk-rec__text b,
.wk-rec__text small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wk-rec__text small {
  color: var(--text-3);
  font-size: 0.76rem;
}
.wk-rec__kind {
  flex: none;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  border-radius: 999px;
  padding: 2px 8px;
}
.wk-rec.is-stale {
  opacity: 0.55;
  border-style: dashed;
}
.wk-rec.is-stale .wk-rec__main {
  cursor: not-allowed;
}
.wk-link-details {
  margin-top: 8px;
}
.wk-link-details > summary {
  list-style: none;
  display: inline-flex;
}
.wk-link-details > summary::-webkit-details-marker {
  display: none;
}
.wk-link-add {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.wk-link-add .wk-filters .form-control {
  min-width: 0;
}
.wk-link-q {
  flex: 1 1 180px;
}
.wk-link-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.wk-link-results:empty {
  display: none;
}
.wk-link-res {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}
.wk-link-res span {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.wk-link-res small {
  color: var(--text-3);
  font-size: 0.76rem;
}
.wk-link-res:hover,
.wk-link-res:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
  outline: none;
}
.wk-link-err {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--bad);
  font-size: 0.84rem;
}

/* reports page */
.wk-rep-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.wk-rep-filters .form-control {
  width: auto;
  min-width: 150px;
  height: 36px;
  padding-block: 0;
}
.wk-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-2);
}
.wk-inline-field .form-control {
  min-width: 140px;
}
.wk-scope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  font-size: 0.8rem;
  color: var(--text-3);
}
.wk-rep-panel {
  margin-top: 16px;
}
.wk-rep-panel .v2-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.wk-rep-body {
  padding: 12px 16px 16px;
}
.wk-rep-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 580px), 1fr));
  gap: 0 16px;
}

/* weekly trend (inline SVG; the drawing itself puts week 1 on the right) */
.wk-trend {
  overflow-x: auto;
  direction: ltr;
}
.wk-trend svg {
  display: block;
  width: 100%;
  min-width: 560px;
  height: auto;
}
/* the drawer scrolls under its header: keep the header opaque */
.wk-drawer .modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface) !important;
}
.wk-trend__grid {
  stroke: var(--border);
  stroke-dasharray: 3 4;
}
.wk-trend__axis,
.wk-trend__label {
  fill: var(--text-3);
  font-size: 11px;
  font-family: var(--font-ui);
}
.wk-trend__created {
  fill: var(--border-strong);
}
.wk-trend__done {
  fill: var(--brand);
}
.wk-trend-legend {
  display: inline-flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.wk-trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wk-trend-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.wk-trend-legend i.wk-trend__done {
  background: var(--brand);
}
.wk-trend-legend i.wk-trend__created {
  background: var(--border-strong);
}

/* report tables */
.wk-table-wrap {
  overflow-x: auto;
  margin: -4px -16px -8px;
  padding: 0 16px;
}
.wk-rtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.wk-rtable th,
.wk-rtable td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  white-space: nowrap;
  vertical-align: middle;
}
.wk-rtable thead th {
  background: var(--surface-2);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-3);
}
.wk-rtable tbody tr:hover {
  background: var(--surface-2);
}
.wk-rtable tbody tr:last-child td {
  border-bottom: 0;
}
.wk-th {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.wk-th:hover,
.wk-th:focus-visible {
  color: var(--text);
}
.wk-rtable__bar {
  min-width: 140px;
}
.wk-rtable__bar .wk-progress {
  min-width: 140px;
}
.wk-person {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.wk-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.wk-load {
  display: flex;
  height: 8px;
  width: 100%;
  min-width: 120px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}
.wk-load__ok {
  background: var(--brand);
}
.wk-load__bad {
  background: var(--bad);
}
.wk-pct {
  display: inline-block;
  min-width: 46px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}
.wk-pct--ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.wk-pct--warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.wk-pct--bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.wk-late {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .wk-rep-filters .form-control,
  .wk-inline-field .form-control {
    min-width: 0;
    flex: 1 1 140px;
  }
  .wk-rep-filters > select.form-control {
    width: 100%;
  }
  .wk-inline-field {
    flex: 1 1 150px;
  }
  .wk-scope {
    margin-inline-start: 0;
    width: 100%;
  }
  .wk-rep-body {
    padding: 10px 12px 14px;
  }
  .wk-table-wrap {
    margin-inline: -12px;
    padding-inline: 12px;
  }
  .wk-toolbar__end {
    width: 100%;
    justify-content: space-between;
  }
  /* linked record: kind badge drops under the name so the name isn't truncated */
  .wk-rec__main {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .wk-rec__text {
    flex-basis: calc(100% - 40px);
  }
  .wk-rec__kind {
    margin-inline-start: 40px;
  }
}

/* ==========================================================================
   Phase 2 — global program scope, record drawer, attention-first home
   ========================================================================== */

/* Program scope in the top bar (admin/core/scope.js). Each page's own program
   tab row stays in the DOM (its logic is driven from here) but is hidden. */
.app-main .is-scoped {
  display: none !important;
}
.tb-scope {
  display: flex;
  align-items: center;
  flex: none;
}
.tb-scope[hidden] {
  display: none;
}
.tb-scope__seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-3);
}
.tb-scope__seg button {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tb-scope__seg button:hover {
  color: var(--text);
}
.tb-scope__seg button.is-on {
  background: var(--surface);
  color: var(--brand-ink);
  font-weight: 600;
  box-shadow: var(--sh-1);
}
.tb-scope__seg button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.tb-scope__single {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 0.8rem;
  font-weight: 600;
}
@media (max-width: 860px) {
  /* Second row under the top bar so the control keeps full-size targets. */
  body.has-scope .app-topbar {
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    padding-top: 6px;
    padding-bottom: 8px;
  }
  body.has-scope .tb-scope {
    order: 10;
    flex-basis: 100%;
  }
  .tb-scope__seg {
    width: 100%;
  }
  .tb-scope__seg button {
    flex: 1;
    min-height: 36px;
  }
}

/* Record drawer: a modal that slides in from the inline-end edge and keeps the
   list visible beside it. Add `modal--drawer` to a record-view modal. */
.modal.modal--drawer {
  padding: 0;
  justify-content: flex-end;
  align-items: stretch;
}
.modal--drawer .modal-content {
  width: min(680px, 100vw) !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border-block: 0;
  border-inline-end: 0;
  animation: v2-drawer-in 0.2s ease-out;
}
.modal--drawer .modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface) !important;
}
.modal--drawer .modal-footer {
  position: sticky;
  bottom: 0;
}
@keyframes v2-drawer-in {
  from {
    transform: translateX(-32px);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .modal--drawer .modal-content {
    animation: none;
  }
}

/* Home: attention list first, own work + departments beside it */
.v2-home__main,
.v2-home__side {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}
.v2-home {
  margin-top: 4px;
}
.v2-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 700;
}
.v2-count[hidden] {
  display: none;
}
.v2-panel__meta {
  font-size: 0.78rem;
  color: var(--text-3);
}
.v2-attn {
  list-style: none;
  margin: 0;
  padding: 0;
}
.v2-attn__item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.v2-attn__item:first-child {
  border-top: 0;
}
.v2-attn__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--tint, var(--surface-3));
  color: var(--tone, var(--text-2));
}
.v2-attn__text {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.v2-attn__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.v2-attn__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: var(--text-3);
}
.v2-attn__prog {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  border: 0;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}
.v2-attn__prog:hover {
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.v2-attn__prog:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.v2-attn-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 16px;
  color: var(--ok);
  font-size: 0.9rem;
  font-weight: 500;
}
.v2-deptlist {
  display: grid;
}
.v2-deptrow {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto 16px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 8px 16px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.v2-deptrow:first-child {
  border-top: 0;
}
.v2-deptrow:hover {
  background: var(--surface-2);
}
.v2-deptrow:focus-visible {
  outline: none;
  box-shadow: inset var(--ring);
}
.v2-deptrow__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dept, var(--brand));
}
.v2-deptrow__text {
  display: grid;
  min-width: 0;
}
.v2-deptrow__name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-deptrow__sub {
  font-size: 0.75rem;
  color: var(--text-3);
}
.v2-deptrow__metric {
  font-size: 0.76rem;
  color: var(--text-2);
  white-space: nowrap;
}
.v2-deptrow__go {
  color: var(--text-3);
}
@media (max-width: 860px) {
  .v2-attn__item {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 12px;
  }
  .v2-attn__icon {
    width: 36px;
    height: 36px;
  }
  .v2-attn__item > .btn {
    grid-column: 2;
    justify-self: start;
  }
  .v2-attn__prog {
    min-height: 36px;
    padding: 0 12px;
  }
}

/* ==========================================================================
   Phase 3 — shared page components (admin/core/ui.js)
   ========================================================================== */

/* One status badge; tone carried by a dot + text, not colour alone. */
.v2-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--text-2);
}
.v2-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.v2-status--info {
  background: var(--info-soft);
  color: var(--info);
}
.v2-status--ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.v2-status--warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.v2-status--bad {
  background: var(--bad-soft);
  color: var(--bad);
}

/* «المزيد» overflow menu */
.v2-more {
  position: relative;
  display: inline-flex;
}
.v2-more__btn {
  width: 38px;
  padding: 0 !important;
  justify-content: center;
}
.v2-more__menu {
  /* placed by toggleMoreMenu() from the button rect (never clipped by a scrolling table) */
  position: fixed;
  z-index: 1060;
  min-width: 220px;
  max-height: min(360px, 70vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  display: grid;
  gap: 2px;
}
.v2-more__menu[hidden] {
  display: none;
}
.v2-more__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  text-align: start;
  cursor: pointer;
}
.v2-more__item:hover,
.v2-more__item:focus-visible {
  background: var(--surface-3);
  outline: none;
}
.v2-more__item .ic {
  color: var(--text-2);
}
.v2-more__item.is-danger,
.v2-more__item.is-danger .ic {
  color: var(--bad);
}
.v2-more__item.is-danger:hover {
  background: var(--bad-soft);
}

/* List toolbar: search, filters, then trailing controls */
.v2-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
.v2-toolbar__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: 380px;
  margin: 0;
}
.v2-toolbar__search .ic {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.v2-toolbar__search input {
  width: 100%;
  height: 38px;
  padding-inline: 38px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}
.v2-toolbar__search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.v2-toolbar select {
  height: 38px;
  min-width: 140px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
}
.v2-toolbar__end {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Collapsible secondary panel (e.g. conversion funnel above a list) */
.v2-disclosure {
  margin: 0 0 16px;
}
.v2-disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}
.v2-disclosure > summary::-webkit-details-marker {
  display: none;
}
.v2-disclosure > summary .ic {
  transition: transform 0.15s;
}
.v2-disclosure[open] > summary .ic {
  transform: rotate(180deg);
}
.v2-disclosure > .v2-panel {
  margin-top: 8px;
}

/* Acceptance stepper doubles as the tab row: the selected stage is marked. */
.v2-step.is-active {
  border-color: var(--brand) !important;
  box-shadow: inset 0 0 0 1px var(--brand);
}

@media (max-width: 860px) {
  .v2-toolbar__search {
    max-width: none;
    flex-basis: 100%;
  }
  .v2-toolbar select {
    flex: 1 1 140px;
  }
  .v2-toolbar__end {
    margin-inline-start: 0;
  }
}

/* Row actions: the stage's main action + a compact «المزيد» */
.v2-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.v2-row-actions .v2-more__btn {
  width: 32px;
  height: 32px;
  min-height: 32px;
}

@media (max-width: 860px) {
  /* Header actions: one row under the title (legacy mobile CSS stacks them full width). */
  .app-main .page-header .page-actions {
    flex-basis: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .app-main .page-header .page-actions .btn {
    width: auto;
  }
  .app-main .page-header .page-actions .btn-primary {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* Installed app: «فعّل إشعارات هذا الجهاز» prompt + bell dropdown status row (admin/core/push.js) */
.push-prompt {
  position: fixed;
  inset-inline: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  margin-inline: auto;
  max-width: 480px;
  z-index: 1060;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  color: var(--text);
}
.push-prompt__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
}
.push-prompt__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  line-height: 1.5;
}
.push-prompt__text span {
  color: var(--text-2);
}
.push-prompt__actions {
  flex: none;
  display: flex;
  gap: 6px;
}
@media (max-width: 480px) {
  .push-prompt {
    flex-wrap: wrap;
  }
  .push-prompt__actions {
    width: 100%;
    justify-content: flex-end;
  }
}
.push-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}
.push-row .btn {
  width: 100%;
  justify-content: center;
}
@media (max-width: 600px) {
  /* Phones: the bell sits near the edge, so pin the panel under the topbar instead. */
  .notification-dropdown {
    position: fixed;
    top: calc(var(--topbar-h) + 6px);
    inset-inline: 12px;
    width: auto;
    max-width: none;
  }
}
