/* ============================================================================
   MAR IT SOLUTION CRM — Design System (Pure CSS3, Zero Frameworks)
   ----------------------------------------------------------------------------
   A single, consistent visual language for every module:
   tokens -> base -> shell -> navigation -> topbar -> page header -> buttons
   -> stats -> panels -> tables -> forms -> feedback -> lists -> detail views
   -> kanban -> calendar -> responsive.
   Every class name used by the existing PHP templates is preserved.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. Design tokens
   ---------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg-canvas: #f7f8fa;
  --bg-surface: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-hover: #f3f4f6;
  --bg-sidebar: #ffffff;
  --bg-sidebar-active: #eef2ff;
  --bg-sidebar-hover: #f5f6f8;

  /* Borders */
  --border-subtle: #e7e9ee;
  --border-strong: #d3d7de;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;
  --text-inverse: #ffffff;

  /* Brand */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ring: rgba(79, 70, 229, 0.18);

  /* Semantic */
  --status-green: #067647;
  --status-green-bg: #ecfdf3;
  --status-amber: #b54708;
  --status-amber-bg: #fffaeb;
  --status-red: #b42318;
  --status-red-bg: #fef3f2;
  --status-blue: #175cd3;
  --status-blue-bg: #eff8ff;
  --status-slate: #344054;
  --status-slate-bg: #f2f4f7;
  --status-muted: #6b7280;
  --status-muted-bg: #f9fafb;

  /* Layout */
  --sidebar-width: 264px;
  --sidebar-width-collapsed: 76px;
  --topbar-height: 64px;
  --page-padding: 28px;

  /* Radii */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, 0.12), 0 4px 8px -4px rgba(16, 24, 40, 0.06);

  /* Type */
  --font-sans: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* ----------------------------------------------------------------------------
   2. Base
   ---------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.017em;
  line-height: 1.3;
}

h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }

p { margin: 0; }

ul { margin: 0; padding: 0; list-style: none; }

.mono,
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.94em;
}

.muted { color: var(--text-muted); }

.inline-form { display: inline; margin: 0; }

::selection { background: var(--accent-ring); }

/* ----------------------------------------------------------------------------
   3. App shell
   ---------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-column {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

.content-viewport {
  flex: 1 1 auto;
  padding: var(--page-padding);
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px var(--page-padding);
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12.5px;
  background: var(--bg-surface);
}

/* Collapsed desktop sidebar */
body.is-sidebar-collapsed { --sidebar-width: var(--sidebar-width-collapsed); }

body.is-sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
body.is-sidebar-collapsed .brand-wordmark,
body.is-sidebar-collapsed .brand-text,
body.is-sidebar-collapsed .nav-label,
body.is-sidebar-collapsed .nav-section-label,
body.is-sidebar-collapsed .sidebar-user-meta,
body.is-sidebar-collapsed .sidebar-domain { display: none; }
body.is-sidebar-collapsed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
body.is-sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
body.is-sidebar-collapsed .sidebar-user { justify-content: center; }
body.is-sidebar-collapsed .sidebar-footer { padding: 12px 8px; }
body.is-sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

/* ----------------------------------------------------------------------------
   4. Sidebar
   ---------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 60;
  border-right: 1px solid var(--border-subtle);
  transition: width 0.2s ease, transform 0.22s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-wordmark {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-wordmark:hover { color: var(--text-primary); }

.brand-sub {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-collapse-btn svg { transition: transform 0.2s ease; }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.nav-section-label {
  padding: 14px 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-primary);
}

.nav-link .nav-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  transition: color 0.15s ease;
}

.nav-link:hover .nav-icon { color: var(--text-secondary); }

.nav-link.is-active {
  background: var(--bg-sidebar-active);
  color: var(--accent);
  font-weight: 600;
}

.nav-link.is-active .nav-icon { color: var(--accent); }

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Tooltip for collapsed state */
body.is-sidebar-collapsed .nav-link { position: relative; }
body.is-sidebar-collapsed .nav-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 70;
  box-shadow: var(--shadow-md);
}

body.is-sidebar-collapsed .nav-link:hover::after { opacity: 1; }

.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  padding: 12px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-user-meta { min-width: 0; flex: 1 1 auto; }

.sidebar-account-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-account-email {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-domain {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.sidebar-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-logout:hover { background: var(--status-red-bg); color: var(--status-red); border-color: #fecdca; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  z-index: 55;
  backdrop-filter: blur(1px);
}

.sidebar-backdrop.is-open { display: block; }

/* ----------------------------------------------------------------------------
   5. Topbar
   ---------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--page-padding);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
}

.breadcrumb-root {
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.03em;
  font-size: 11.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.breadcrumb-sep { color: var(--border-strong); }

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-topbar-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.notif-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--status-red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
}

/* Inline count chip used inside toolbar buttons (e.g. Duplicates) */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
}

.badge-count.is-empty { opacity: 0.55; }

/* Profile menu */
.user-menu { position: relative; }

.user-profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  max-width: 240px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.user-profile-chip:hover { background: var(--bg-subtle); color: var(--text-primary); box-shadow: var(--shadow-xs); }

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar-img { object-fit: cover; background: var(--bg-hover); }

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 232px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 80;
  display: none;
}

.user-menu-panel.is-open { display: block; }

.user-menu-head {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}

.user-menu-head strong { display: block; font-size: 13px; color: var(--text-primary); }
.user-menu-head span { display: block; font-size: 11.5px; color: var(--text-muted); word-break: break-all; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.menu-item.is-danger { color: var(--status-red); }
.menu-item.is-danger:hover { background: var(--status-red-bg); }
.menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ----------------------------------------------------------------------------
   6. Page header & toolbar
   ---------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 72ch;
}

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------------------
   7. Buttons
   ---------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 15px; height: 15px; }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: var(--radius-xs); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-secondary);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: #b9bfc9;
  color: var(--text-primary);
}

.btn-danger {
  background: var(--status-red);
  border-color: var(--status-red);
  color: #fff;
}

.btn-danger:hover { background: #912018; border-color: #912018; color: #fff; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }

.btn-block { width: 100%; }

.btn[disabled],
.btn.is-disabled { opacity: 0.55; pointer-events: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease;
}

.icon-btn:hover { background: var(--bg-hover); }

.hamburger,
.hamburger::before,
.hamburger::after {
  display: block;
  width: 16px;
  height: 1.6px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  position: relative;
}

.hamburger::before { position: absolute; top: -5px; }
.hamburger::after { position: absolute; top: 5px; }

.mobile-only { display: none !important; }

/* ----------------------------------------------------------------------------
   8. Stat / KPI cards
   ---------------------------------------------------------------------------- */
.kpi-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid-4,
.stat-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid-7 {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card,
.stat-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 17px;
  box-shadow: var(--shadow-xs);
  min-width: 0;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover,
.stat-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }

.kpi-grid-7 .kpi-card { padding: 13px 14px; }
.kpi-grid-7 .kpi-value { font-size: 22px; }

.kpi-top,
.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-label,
.stat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-transform: uppercase;
  line-height: 1.3;
}

.kpi-value,
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-sub,
.stat-foot {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.stat-icon,
.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.stat-icon svg,
.kpi-icon svg { width: 16px; height: 16px; }

.stat-icon.tone-green { background: var(--status-green-bg); color: var(--status-green); }
.stat-icon.tone-amber { background: var(--status-amber-bg); color: var(--status-amber); }
.stat-icon.tone-red { background: var(--status-red-bg); color: var(--status-red); }
.stat-icon.tone-blue { background: var(--status-blue-bg); color: var(--status-blue); }
.stat-icon.tone-slate { background: var(--status-slate-bg); color: var(--status-slate); }

.stat-card.is-accent { background: linear-gradient(180deg, #fbfbff 0%, #ffffff 60%); }

.task-metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 18px;
}

.task-metric-item {
  background: var(--bg-surface);
  padding: 13px 16px;
  min-width: 0;
}

.task-metric-item .kpi-label { margin-bottom: 4px; }

/* ----------------------------------------------------------------------------
   9. Welcome banner & quick actions
   ---------------------------------------------------------------------------- */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.welcome-banner h1 {
  font-size: 21px;
  letter-spacing: -0.02em;
}

.welcome-banner p {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 78ch;
}

.welcome-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.date-chip,
.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.date-chip svg,
.info-chip svg { width: 13px; height: 13px; color: var(--text-muted); }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.quick-action:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.quick-action svg { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.quick-action span { display: block; }

/* ----------------------------------------------------------------------------
   10. Panels & layout grids
   ---------------------------------------------------------------------------- */
.two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.two-col-grid > div { min-width: 0; }
.two-col-grid > div > .panel + .panel { margin-top: 18px; }

.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.overview-grid > * { min-width: 0; }

.span-2 { grid-column: span 2; }

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel + .panel { margin-top: 18px; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title svg { width: 16px; height: 16px; color: var(--text-muted); }

.panel-subtitle {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.panel-body { padding: 18px; }

.panel-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-gap { margin-top: 18px; }

/* ----------------------------------------------------------------------------
   11. Tables
   ---------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 880px;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f2f5;
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: #fafbfc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table td a { color: var(--text-primary); font-weight: 500; }
.data-table td a:hover { color: var(--accent); }

.col-right { text-align: right; }
.col-center { text-align: center; }

.col-actions { width: 1%; white-space: nowrap; text-align: right; }

.cell-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.cell-secondary {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------------------
   12. Status / badges
   ---------------------------------------------------------------------------- */
.status-green,
.status-amber,
.status-red,
.status-blue,
.status-slate,
.status-muted {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-green { color: var(--status-green); background: var(--status-green-bg); border-color: #abefc6; }
.status-amber { color: var(--status-amber); background: var(--status-amber-bg); border-color: #fedf89; }
.status-red   { color: var(--status-red);   background: var(--status-red-bg);   border-color: #fecdca; }
.status-blue  { color: var(--status-blue);  background: var(--status-blue-bg);  border-color: #b2ddff; }
.status-slate { color: var(--status-slate); background: var(--status-slate-bg); border-color: #e4e7ec; }
.status-muted { color: var(--status-muted); background: var(--status-muted-bg); border-color: #e4e7ec; }

.code-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.priority-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   13. Progress
   ---------------------------------------------------------------------------- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 120px;
}

.progress-track {
  flex: 1 1 auto;
  height: 6px;
  border-radius: var(--radius-pill);
  background: #eceef2;
  overflow: hidden;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-fill.is-complete { background: var(--status-green); }

.progress-pct {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   14. Forms
   ---------------------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full-span { grid-column: 1 / -1; }

.form-label,
label.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-label .req { color: var(--status-red); margin-left: 2px; }

.form-hint,
.form-field small,
.field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

.form-input,
.form-select,
input[type="text"].form-input,
input[type="email"].form-input,
input[type="password"].form-input,
input[type="date"].form-input,
input[type="time"].form-input,
input[type="number"].form-input,
input[type="url"].form-input,
input[type="search"],
select.form-select,
textarea,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  appearance: none;
}

.form-select,
select.form-select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover { border-color: #b9bfc9; }

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
textarea:focus,
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-faint); }

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled,
input:disabled {
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-textarea,
textarea { min-height: 92px; resize: vertical; }

.form-section {
  padding: 20px 0;
  border-top: 1px solid var(--border-subtle);
}

.form-section:first-child { padding-top: 0; border-top: none; }

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}

.form-error {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  background: var(--status-red-bg);
  border: 1px solid #fecdca;
  color: var(--status-red);
  font-size: 12.5px;
  font-weight: 500;
}

.form-error ul { margin: 6px 0 0; padding-left: 18px; list-style: disc; }
.form-error li { margin: 2px 0; }

.search-input {
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface)
    url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E")
    no-repeat 11px center;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  min-width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.password-wrap { position: relative; }
.password-wrap .form-input { padding-right: 62px; }

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.password-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.radio-card:hover { border-color: var(--border-strong); background: var(--bg-subtle); }
.radio-card input[type="radio"] { margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.password-mode-grid,
.credential-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.conversion-mode-bar {
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.member-picker-grid,
.service-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.member-picker-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.member-check-item,
.service-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--bg-surface);
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.member-check-item:hover,
.service-check-item:hover { border-color: var(--accent); }
.member-check-item input[type="checkbox"],
.service-check-item input[type="checkbox"] { accent-color: var(--accent); flex-shrink: 0; }
.member-check-item:has(input:checked),
.service-check-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.service-catalogue-box {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
}

.service-cat-group { border-top: 1px solid var(--border-subtle); padding: 14px; }
.service-cat-group:first-child { border-top: none; }

.service-cat-header,
.settings-cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ----------------------------------------------------------------------------
   15. Alerts & empty states
   ---------------------------------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}

.alert-success { background: var(--status-green-bg); border-color: #abefc6; color: var(--status-green); }
.alert-error   { background: var(--status-red-bg);   border-color: #fecdca; color: var(--status-red); }
.alert-info    { background: var(--status-blue-bg);  border-color: #b2ddff; color: var(--status-blue); }
.alert-warning { background: var(--status-amber-bg); border-color: #fedf89; color: var(--status-amber); }

.alert-close {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.alert-close:hover { opacity: 1; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 44px 24px;
}

.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-faint);
  margin-bottom: 12px;
}

.empty-state-icon svg { width: 20px; height: 20px; }

.empty-state-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 48ch;
  line-height: 1.55;
}

/* ----------------------------------------------------------------------------
   16. Auth screens
   ---------------------------------------------------------------------------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background:
    radial-gradient(1200px 600px at 100% 0%, #eef2ff 0%, transparent 55%),
    var(--bg-canvas);
}

.auth-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 30;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 430px);
  gap: 48px;
  align-items: center;
  width: 100%;
  max-width: 1020px;
}

.auth-brand { max-width: 460px; }

.auth-brand-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.auth-brand-sub {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  width: 100%;
}

.auth-card h1 {
  font-size: 21px;
  letter-spacing: -0.02em;
  margin-bottom: 5px;
}

.auth-card > p { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.auth-card .form-field { margin-bottom: 15px; }

.auth-footer-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ----------------------------------------------------------------------------
   17. Tabs, filters, pagination
   ---------------------------------------------------------------------------- */
.tabs-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-bar::-webkit-scrollbar { display: none; }

.tab-link {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-link:hover { color: var(--text-primary); }

.tab-link.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.filter-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.filter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.pagination-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.page-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.page-btn.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.page-btn.is-disabled { opacity: 0.45; pointer-events: none; }

/* ----------------------------------------------------------------------------
   18. Activity lists, notes, related rows
   ---------------------------------------------------------------------------- */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 18px;
  border-bottom: 1px solid #f1f2f5;
}

.activity-item:last-child { border-bottom: none; }

.activity-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.activity-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.activity-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: break-word;
}

.activity-desc strong { color: var(--text-secondary); font-weight: 600; }

/* Timeline variant for activity logs */
.timeline { display: flex; flex-direction: column; }

.timeline-item {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 14px 18px;
}

.timeline-item + .timeline-item { border-top: 1px solid #f1f2f5; }

.timeline-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.note-list { display: flex; flex-direction: column; }

.note-item {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.note-item:last-child { border-bottom: none; }

.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.note-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.note-meta { font-size: 11.5px; color: var(--text-muted); }
.note-body { font-size: 12.5px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; }

.private-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--radius-xs);
  background: var(--status-amber-bg);
  border: 1px solid #fedf89;
  color: var(--status-amber);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.followup-flag { font-size: 12px; font-weight: 600; }

.lead-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid #d9defb;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Generic overview row used by dashboard lists */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid #f1f2f5;
  min-width: 0;
}

.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #fafbfc; }

.row-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
}

.row-icon svg { width: 15px; height: 15px; }

.row-main { flex: 1 1 auto; min-width: 0; }

.row-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-title:hover { color: var(--accent); }

.row-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.row-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Task status distribution strip */
.status-dist { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }

.status-dist-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.status-dist-bar {
  height: 7px;
  border-radius: var(--radius-pill);
  background: #eceef2;
  overflow: hidden;
}

.status-dist-bar > span { display: block; height: 100%; border-radius: var(--radius-pill); }

.status-dist-count {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.bar-green { background: var(--status-green); }
.bar-amber { background: #dc6803; }
.bar-red { background: var(--status-red); }
.bar-blue { background: var(--accent); }
.bar-slate { background: #667085; }

.task-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 4px;
}

.task-tile {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: var(--bg-subtle);
}

.task-tile-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.task-tile-label { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ----------------------------------------------------------------------------
   19. Detail views, avatars, profile
   ---------------------------------------------------------------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px 20px;
  padding: 18px;
}

.detail-item-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.detail-item-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}

.notes-box {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
}

.team-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.team-avatar-initials { display: inline-flex; }

.avatar-xs { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

.team-avatar img,
.avatar-img-rounded { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.user-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-cell-text { display: flex; flex-direction: column; min-width: 0; }

.profile-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
}

.profile-hero h1 { font-size: 20px; letter-spacing: -0.02em; }
.profile-hero p { color: var(--text-muted); font-size: 13px; margin-top: 3px; }

.credential-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--status-green-bg);
  border: 1px solid #abefc6;
  color: var(--status-green);
  font-size: 13px;
  margin-bottom: 16px;
}

.credential-item {
  padding: 12px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  min-width: 0;
}

.credential-item span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 3px; }
.credential-item strong { display: block; font-size: 13px; word-break: break-all; }

.team-group { padding: 16px 18px; border-top: 1px solid var(--border-subtle); }
.team-group:first-child { border-top: none; }

.assigned-list { display: flex; flex-direction: column; gap: 6px; }
.assigned-list a { font-size: 12.5px; }

.skills-row { display: flex; flex-wrap: wrap; gap: 6px; }

.skill-chip {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
}

.role-empty-notice,
.empty-role-notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--status-amber-bg);
  border: 1px solid #fedf89;
  color: var(--status-amber);
  font-size: 13px;
}

.role-empty-notice a,
.empty-role-notice a { color: inherit; text-decoration: underline; font-weight: 600; }

/* ----------------------------------------------------------------------------
   20. Kanban (tasks)
   ---------------------------------------------------------------------------- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  align-items: start;
}

.kanban-column {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 160px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.kanban-column.is-drag-over { border-color: var(--accent); background: var(--accent-soft); }

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.kanban-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  flex: 1 1 auto;
}

.kanban-empty {
  padding: 16px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  box-shadow: var(--shadow-xs);
}

.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card[draggable="true"]:active { cursor: grabbing; }
.kanban-card.is-dragging { opacity: 0.5; }
.kanban-card.is-overdue { border-left: 3px solid var(--status-red); }

.kanban-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.kanban-card-title:hover { color: var(--accent); }

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 11px;
  color: var(--text-muted);
}

.kanban-move-form { margin-top: 8px; }

.kanban-status-select {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--bg-subtle);
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.review-box {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-size: 12.5px;
}

.review-box-approve { background: var(--status-green-bg); border-color: #abefc6; color: var(--status-green); }
.review-box-revise { background: var(--status-amber-bg); border-color: #fedf89; color: var(--status-amber); }

.attachment-list { display: flex; flex-direction: column; }

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f2f5;
  font-size: 12.5px;
  flex-wrap: wrap;
}

.attachment-item:last-child { border-bottom: none; }

/* ----------------------------------------------------------------------------
   21. Meetings & calendar
   ---------------------------------------------------------------------------- */
.mtg-type-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.mtg-type-client     { background: var(--status-blue-bg);  color: var(--status-blue);  border-color: #b2ddff; }
.mtg-type-project    { background: var(--accent-soft);     color: var(--accent);       border-color: #d9defb; }
.mtg-type-internal   { background: var(--status-slate-bg); color: var(--status-slate); border-color: #e4e7ec; }
.mtg-type-freelancer { background: var(--status-amber-bg); color: var(--status-amber); border-color: #fedf89; }
.mtg-type-general    { background: var(--bg-subtle);       color: var(--text-muted);   border-color: var(--border-subtle); }

.cal-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.cal-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }

.cal-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.cal-month-weekdays > div {
  padding: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  border-right: 1px solid var(--border-subtle);
}

.cal-month-weekdays > div:last-child { border-right: none; }

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-day-cell {
  min-height: 108px;
  padding: 7px;
  border-right: 1px solid #f1f2f5;
  border-bottom: 1px solid #f1f2f5;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.cal-day-cell:nth-child(7n) { border-right: none; }
.cal-day-cell.is-outside { background: #fbfcfd; }
.cal-day-cell.is-today { background: var(--accent-soft); }

.cal-day-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; }

.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cal-day-cell.is-today .cal-day-num { color: var(--accent); font-weight: 700; }

.cal-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  opacity: 0;
}

.cal-day-cell:hover .cal-add-btn { opacity: 1; }
.cal-add-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.cal-day-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }

.cal-event-chip {
  display: block;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event-chip:hover { background: #e3e8fd; color: var(--text-primary); }
.cal-event-chip.is-cancelled { background: var(--status-red-bg); border-left-color: var(--status-red); color: var(--status-red); text-decoration: line-through; }

.cal-week-grid { display: grid; grid-template-columns: repeat(7, minmax(180px, 1fr)); gap: 10px; overflow-x: auto; }

.cal-week-col {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 200px;
}

.cal-week-col.is-today { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.cal-event-card {
  display: block;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.cal-event-card:last-child { margin-bottom: 0; }
.cal-event-card:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ----------------------------------------------------------------------------
   22. Notifications
   ---------------------------------------------------------------------------- */
.notif-unread { background: #fbfcff; }
.notif-unread .notif-dot { display: inline-block; }

.notif-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   23. Responsive
   ---------------------------------------------------------------------------- */
@media (max-width: 1400px) {
  .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid-7 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
  :root { --page-padding: 22px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid-7 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col-grid { grid-template-columns: minmax(0, 1fr); }
  .kanban-board { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
  .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); max-width: 460px; gap: 0; }
  .auth-brand { display: none; }
  .task-metrics-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid-7 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Tablet / mobile: off-canvas sidebar */
@media (max-width: 860px) {
  :root { --page-padding: 16px; --topbar-height: 58px; }

  body { --sidebar-width: 0px; }
  body.is-sidebar-collapsed { --sidebar-width: 0px; }

  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border-subtle);
  }

  .sidebar.is-open { transform: translateX(0); }

  /* Mobile drawer always shows full labels */
  body.is-sidebar-collapsed .brand-wordmark,
  body.is-sidebar-collapsed .brand-text,
  body.is-sidebar-collapsed .nav-label,
  body.is-sidebar-collapsed .nav-section-label,
  body.is-sidebar-collapsed .sidebar-user-meta,
  body.is-sidebar-collapsed .sidebar-domain { display: block; }
  body.is-sidebar-collapsed .nav-link { justify-content: flex-start; padding: 9px 10px; }
  body.is-sidebar-collapsed .sidebar-brand { justify-content: space-between; padding: 0 12px 0 18px; }
  body.is-sidebar-collapsed .nav-link::after { display: none; }

  .main-column { margin-left: 0; }

  .mobile-only { display: inline-flex !important; }
  .sidebar-collapse-btn { display: none; }
  .sidebar-close-btn { display: inline-flex; }

  .topbar { padding: 0 14px; gap: 10px; }
  .user-meta { display: none; }
  .user-profile-chip { padding: 4px; border: 0; background: transparent; box-shadow: none; }
  .notif-topbar-btn span:first-child { display: none; }
  .notif-topbar-btn { padding: 6px 9px; }

  .content-viewport { padding: 16px 14px; }

  .welcome-banner { padding: 18px; }
  .welcome-banner h1 { font-size: 18px; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 19px; }

  .form-grid,
  .form-grid-3 { grid-template-columns: minmax(0, 1fr); }

  .filter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

  .panel-header { padding: 14px; }
  .panel-body { padding: 14px; }
  .list-row { padding: 10px 14px; }
  .activity-item { padding: 11px 14px; }

  .data-table th { padding: 9px 12px; }
  .data-table td { padding: 10px 12px; }

  .detail-grid { padding: 14px; gap: 14px 16px; }

  .cal-day-cell { min-height: 78px; padding: 5px; }
  .cal-day-num { font-size: 11px; }
  .cal-event-chip { font-size: 9.5px; }

  .kanban-board { grid-template-columns: repeat(4, minmax(240px, 1fr)); }

  .app-footer { padding: 14px; font-size: 11.5px; }

  .row-side .status-green,
  .row-side .status-amber,
  .row-side .status-red,
  .row-side .status-blue,
  .row-side .status-slate,
  .row-side .status-muted { font-size: 10.5px; padding: 2px 7px; }
}

@media (max-width: 560px) {
  .kpi-grid,
  .kpi-grid-7 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  .stat-card,
  .kpi-card { padding: 13px; }
  .kpi-value,
  .stat-value { font-size: 22px; }
  .kpi-label,
  .stat-label { font-size: 10.5px; letter-spacing: 0.01em; }
  .kpi-sub,
  .stat-foot { font-size: 11px; }

  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick-action { padding: 11px; font-size: 12px; }

  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filter-footer .toolbar-group { width: 100%; }
  .filter-footer .toolbar-group .btn { flex: 1 1 auto; }

  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .toolbar-group { width: 100%; }
  .page-header .toolbar-group .btn { flex: 1 1 auto; }

  .breadcrumb-root,
  .breadcrumb-sep { display: none; }

  .tabs-bar { gap: 0; }
  .tab-link { padding: 9px 11px; font-size: 12.5px; }

  .form-actions .btn { flex: 1 1 auto; }

  .pagination-bar { flex-direction: column; align-items: flex-start; gap: 10px; }

  .task-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .status-dist-row { grid-template-columns: 80px minmax(0, 1fr) 30px; }

  .profile-hero { padding: 16px; gap: 14px; }

  .cal-month-weekdays > div { padding: 6px 2px; font-size: 9px; letter-spacing: 0; }
  .cal-day-cell { min-height: 66px; padding: 4px; gap: 3px; }
  .cal-add-btn { display: none; }
  .cal-event-chip { padding: 1px 4px; font-size: 9px; }

  .auth-card { padding: 22px; }

  .app-footer { justify-content: center; text-align: center; }
}

/* Touch-friendly spacing on coarse pointers */
@media (hover: none) and (pointer: coarse) {
  .nav-link { padding-top: 11px; padding-bottom: 11px; }
  .btn { padding-top: 9px; padding-bottom: 9px; }
  .btn-sm { padding-top: 7px; padding-bottom: 7px; }
  .cal-add-btn { opacity: 1; }
}

/* ----------------------------------------------------------------------------
   24. Motion / accessibility preferences
   ---------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------------------------
   25. Lead Import — upload, progress & wizard
   ---------------------------------------------------------------------------- */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 34px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.upload-zone:hover,
.upload-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--accent);
  margin-bottom: 4px;
}

.upload-zone-icon svg { width: 20px; height: 20px; }

.upload-zone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-zone-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.upload-file-card {
  margin-top: 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.upload-file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.upload-progress { padding: 0 14px 14px; }

.upload-progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: #eceef2;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width 0.2s ease;
}

.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-muted);
}

.import-steps {
  list-style: none;
  counter-reset: importstep;
  padding: 16px 18px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-steps li {
  position: relative;
  padding-left: 34px;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  counter-increment: importstep;
}

.import-steps li::before {
  content: counter(importstep);
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.import-steps strong { color: var(--text-primary); }

@media (max-width: 860px) {
  .upload-zone { padding: 26px 14px; }
  .import-steps { padding: 14px; }
}

/* Lead import — small phone refinements (iPhone SE / Android compact) */
@media (max-width: 560px) {
  .upload-zone { padding: 22px 12px; }
  .upload-zone-title { font-size: 14px; }
  .upload-zone-sub { font-size: 12px; }
  .upload-zone-icon { width: 42px; height: 42px; }
  .upload-progress { padding: 0 12px 12px; }
  .import-steps { padding: 12px; gap: 10px; }
  .import-steps li { font-size: 12px; padding-left: 30px; }
  [data-import-runner] .form-actions { flex-direction: column; align-items: stretch; }
  [data-import-runner] .form-actions .btn { width: 100%; justify-content: center; }
}

/* ============================================================================
   30. Dark theme (data-theme="dark")
   Only design tokens are redefined; every component inherits them. A few
   hard-coded light surfaces are overridden explicitly at the end.
   ============================================================================ */
html[data-theme="dark"] {
  --bg-canvas: #0b0f17;
  --bg-surface: #111827;
  --bg-subtle: #0f172a;
  --bg-hover: #1a2333;
  --bg-sidebar: #0d1420;
  --bg-sidebar-active: #1b2340;
  --bg-sidebar-hover: #16203a;

  --border-subtle: #1f2a3a;
  --border-strong: #2c3a4f;

  --text-primary: #e8ecf4;
  --text-secondary: #b3bccb;
  --text-muted: #8d98a8;
  --text-faint: #6b7686;
  --text-inverse: #0b0f17;

  --accent: #6d6af8;
  --accent-hover: #8b88ff;
  --accent-soft: #1c2140;
  --accent-ring: rgba(109, 106, 248, 0.3);

  --status-green: #4ade80;
  --status-green-bg: #0f2a1d;
  --status-amber: #fbbf24;
  --status-amber-bg: #2c2210;
  --status-red: #f87171;
  --status-red-bg: #2c1414;
  --status-blue: #60a5fa;
  --status-blue-bg: #10233d;
  --status-slate: #cbd5e1;
  --status-slate-bg: #1c2430;
  --status-muted: #94a3b8;
  --status-muted-bg: #161d29;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 14px -4px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 18px 36px -12px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
}

html[data-theme="dark"] body { background-color: var(--bg-canvas); }

html[data-theme="dark"] .auth-body {
  background:
    radial-gradient(1200px 600px at 100% 0%, rgba(59, 96, 168, 0.18) 0%, transparent 55%),
    var(--bg-canvas);
}

/* Hard-coded light surfaces inside otherwise token-driven components */
html[data-theme="dark"] .data-table tbody tr:hover { background: var(--bg-hover); }
html[data-theme="dark"] .data-table th { background: var(--bg-subtle); color: var(--text-secondary); }
html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] textarea {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
html[data-theme="dark"] .form-input::placeholder,
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: var(--text-faint); }
html[data-theme="dark"] .form-select option { background: var(--bg-surface); color: var(--text-primary); }

html[data-theme="dark"] .btn-secondary { background: var(--bg-surface); border-color: var(--border-strong); color: var(--text-primary); }
html[data-theme="dark"] .btn-secondary:hover { background: var(--bg-hover); }
html[data-theme="dark"] .btn-primary { color: #fff; }
html[data-theme="dark"] .btn-link { color: var(--accent); }

html[data-theme="dark"] .topbar { background: rgba(13, 20, 32, 0.92); border-bottom-color: var(--border-subtle); }
html[data-theme="dark"] .user-menu-panel { background: var(--bg-surface); border-color: var(--border-strong); }
html[data-theme="dark"] .sidebar { border-right-color: var(--border-subtle); }
html[data-theme="dark"] .brand-mark { color: #fff; }
html[data-theme="dark"] .alert-info { background: #10233d; color: #bfdbfe; border-color: #1e3a5f; }
html[data-theme="dark"] .alert-success { background: #0f2a1d; color: #bbf7d0; border-color: #14532d; }
html[data-theme="dark"] .alert-error { background: #2c1414; color: #fecaca; border-color: #7f1d1d; }
html[data-theme="dark"] .tab-link.is-active { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .upload-zone { background: var(--bg-subtle); border-color: var(--border-strong); }
html[data-theme="dark"] .code-tag { background: var(--bg-hover); color: var(--text-secondary); }
html[data-theme="dark"] .notif-count-badge { color: #fff; }
html[data-theme="dark"] img { opacity: 0.95; }

/* Theme toggle button */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; }
.theme-toggle:hover { color: var(--accent); }
html[data-theme="dark"] .theme-toggle { border-color: var(--border-strong); }

/* ---------------------------------------------------------------------------
   31. Role chips, icon buttons & organisation widgets
   --------------------------------------------------------------------------- */
.btn-with-icon { display: inline-flex; align-items: center; gap: 7px; }
.check-chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--bg-surface); color: var(--text-secondary);
  font-size: 12.5px; cursor: pointer; transition: all 0.14s ease;
}
.check-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.check-chip input { accent-color: var(--accent); margin: 0; }
.check-chip.is-checked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.check-chip.is-disabled { opacity: 0.55; cursor: not-allowed; }
.role-chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.role-chip.is-muted { background: var(--status-muted-bg); color: var(--status-muted); }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.dept-card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-xs); }
.dept-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.dept-card h3 { font-size: 14px; margin: 0; }
.dept-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.avatar-stack { display: flex; }
.avatar-stack .user-avatar { width: 26px; height: 26px; font-size: 10px; margin-left: -6px; border: 2px solid var(--bg-surface); }
.avatar-stack .user-avatar:first-child { margin-left: 0; }
@media (max-width: 640px) {
  .dept-grid { grid-template-columns: 1fr; }
}
