/* web/css/styles.css — Ultimate BMS design system (light, blue-accent) */

:root {
  /* Colors */
  --primary: #000613;
  --primary-dim: #9ecaff;
  --accent: #0061a4;
  --accent-light: #33a0fd;
  --secondary: #64748B;
  --secondary-dim: #94a3b8;

  --background: #f7f9fb;
  --surface: #ffffff;
  --surface-alt: #f2f4f6;
  --surface-container: #eceef0;
  --surface-container-high: #e6e8ea;

  --outline: #94a3b8;
  --outline-variant: #E2E8F0;

  --success: #10B981;
  --success-bg: #d1fae5;
  --success-text: #047857;
  --warning: #F59E0B;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --error: #EF4444;
  --error-container: #fee2e2;
  --error-text: #b91c1c;
  --info-bg: #dbeafe;
  --purple: #8B5CF6;
  --purple-bg: #ede9fe;
  --purple-text: #6d28d9;
  --pink: #EC4899;
  --pink-bg: #fce7f3;
  --pink-text: #be185d;

  /* Dark mode */
  --dark-surface: #0f1720;
  --dark-surface-dim: #0a0e14;
  --dark-surface-container: #16202c;
  --dark-outline: #2c3a4d;
  --dark-text: #e5edf5;

  /* Radius */
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-pill: 999px;

  /* Spacing */
  --unit: 4px;
  --margin-desktop: 32px;
  --gutter: 16px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Courier New", monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--background);
  color: #1E293B;
  line-height: 1.5;
  font-size: 14px;
}

body.dark-mode {
  background: var(--dark-surface-dim);
  color: var(--dark-text);
}

/* Layout */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background: var(--surface-alt);
  border-right: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-header p,
.sidebar.collapsed .user-info {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar.collapsed .nav-item,
.sidebar.collapsed .sidebar-footer a {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

.sidebar.collapsed .user-card {
  justify-content: center;
}

.sidebar.collapsed .user-avatar {
  margin-right: 0;
}

.sidebar-collapse-btn {
  background: none;
  border: none;
  color: var(--secondary);
  cursor: pointer;
  padding: 4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-collapse-btn svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.dark-mode .sidebar {
  background: var(--dark-surface);
  border-right-color: var(--dark-outline);
}

.sidebar-header {
  padding: var(--margin-desktop);
  border-bottom: 1px solid var(--outline-variant);
}

.sidebar-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.dark-mode .sidebar-header h1 {
  color: var(--primary-dim);
}

.sidebar-header p {
  font-size: 12px;
  color: var(--secondary);
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-input);
  cursor: pointer;
  text-decoration: none;
  color: var(--secondary);
  font-size: 14px;
  border-left: 4px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
  background: var(--surface-container);
  color: var(--primary);
}

.nav-item.active {
  background: rgba(51, 160, 253, 0.16);
  color: var(--primary);
  border-left-color: var(--accent);
  font-weight: 600;
}

.dark-mode .nav-item {
  color: var(--secondary-dim);
}

.dark-mode .nav-item:hover,
.dark-mode .nav-item.active {
  background: var(--dark-surface-container);
  color: var(--primary-dim);
}

.nav-icon {
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.sidebar-footer {
  padding: var(--gutter);
  border-top: 1px solid var(--outline-variant);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  color: var(--secondary);
  text-decoration: none;
  font-size: 12px;
  border-radius: var(--radius-input);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-footer a .nav-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
}

.sidebar-footer a .nav-icon svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer a:hover {
  color: var(--primary);
  background: var(--surface-container);
}

.user-card {
  display: flex;
  align-items: center;
  padding: 12px;
  background: var(--surface-container);
  border-radius: var(--radius-input);
  margin-top: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
}

.user-avatar svg {
  width: 16px;
  height: 16px;
}

.dark-mode .user-card {
  background: var(--dark-surface-container);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #1E293B;
}

.dark-mode .user-name {
  color: var(--dark-text);
}

.user-role {
  font-size: 10px;
  color: var(--secondary);
  margin-top: 2px;
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--outline-variant);
  padding: 0 var(--margin-desktop);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 32px;
}

.dark-mode .header {
  background: var(--dark-surface);
  border-bottom-color: var(--dark-outline);
}

.header-title {
  font-size: clamp(1.125rem, 1rem + 1vw, 1.5rem);
  font-weight: 700;
  color: var(--primary);
}

.dark-mode .header-title {
  color: var(--primary-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--secondary);
  padding: 8px;
  margin-right: 8px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mobile-menu-btn svg {
  width: 22px;
  height: 22px;
}

.dark-mode .mobile-menu-btn {
  color: var(--secondary-dim);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 6, 19, 0.5);
  z-index: 900;
}

.sidebar-backdrop.active {
  display: block;
}

.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  background: var(--surface-container);
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 97, 164, 0.12);
}

.dark-mode .search-box input {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
  color: var(--dark-text);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--secondary);
  pointer-events: none;
  width: 16px;
  height: 16px;
  display: flex;
}

.search-icon svg {
  width: 16px;
  height: 16px;
}

/* ---- connection status ---- */
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-container);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-latency {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--secondary);
}

.conn-online .conn-dot,
.conn-degraded .conn-dot {
  animation: conn-pulse 1.6s ease-in-out infinite;
}

@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  .conn-dot {
    animation: none;
  }
}

.conn-online .conn-dot { background: var(--success); }
.conn-degraded .conn-dot { background: var(--warning); }
.conn-offline-api .conn-dot { background: var(--error); }
.conn-offline-device .conn-dot { background: var(--outline); }

.dark-mode .conn-status {
  background: var(--dark-surface-container);
}

.dark-mode .conn-latency {
  color: var(--secondary-dim);
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--secondary);
  transition: background-color 0.2s ease, color 0.2s ease;
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.icon-btn:hover {
  color: var(--accent);
  background: var(--surface-container);
}

.dark-mode .icon-btn:hover {
  background: var(--dark-surface-container);
  color: var(--primary-dim);
}

/* --secondary (#64748B) fails contrast on dark backgrounds; use --secondary-dim in dark mode */
.dark-mode .icon-btn,
.dark-mode .sidebar-collapse-btn,
.dark-mode .sidebar-header p,
.dark-mode .sidebar-footer a,
.dark-mode .search-icon,
.dark-mode .section-subtitle,
.dark-mode .kpi-label,
.dark-mode .kpi-change,
.dark-mode .text-muted {
  color: var(--secondary-dim);
}

/* Content Area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--margin-desktop);
  background: var(--background);
}

.dark-mode .content {
  background: var(--dark-surface-dim);
}

.content > * {
  margin-bottom: var(--gutter);
}

/* Sections */
.section {
  display: none;
}

.section.active {
  display: block;
}

.section-header {
  margin-bottom: var(--margin-desktop);
}

.section-title {
  font-size: clamp(1.375rem, 1.1rem + 1.4vw, 1.75rem);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.dark-mode .section-title {
  color: var(--primary-dim);
}

.section-subtitle {
  font-size: 14px;
  color: var(--secondary);
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: #1E293B;
}

.dark-mode label {
  color: var(--dark-text);
}

input,
textarea,
select {
  padding: 12px;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-input);
  font-family: var(--font-sans);
  font-size: 14px;
  background: white;
  color: #1E293B;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dark-mode input,
.dark-mode textarea,
.dark-mode select {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
  color: var(--dark-text);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 97, 164, 0.12);
}

.field-invalid {
  border-color: #DC2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

/* Buttons */
button {
  font-family: var(--font-sans);
  border: none;
  border-radius: var(--radius-input);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 12px 24px;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 6, 19, 0.2);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--outline-variant);
}

.btn-secondary:hover {
  background: var(--surface-container);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-small {
  padding: 8px 16px;
  font-size: 12px;
}

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-disabled:hover {
  background: var(--primary);
  box-shadow: none;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.dark-mode table {
  background: var(--dark-surface-container);
}

thead {
  background: var(--surface-container-high);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--secondary);
  font-family: var(--font-sans);
}

.dark-mode thead {
  background: var(--dark-surface);
  color: var(--secondary-dim);
}

th {
  padding: 12px 16px;
  text-align: left;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover {
  color: var(--primary);
}

.sort-indicator {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
}

.sort-indicator.active {
  opacity: 1;
}

th.filter-row {
  padding: 6px 16px;
  background: var(--surface);
}

.dark-mode th.filter-row {
  background: var(--dark-surface-container);
}

tbody tr {
  border-bottom: 1px solid var(--outline-variant);
}

.dark-mode tbody tr {
  border-bottom-color: var(--dark-outline);
}

tbody tr:hover {
  background: var(--surface-container);
}

.dark-mode tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

td {
  padding: 16px;
  font-size: 14px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

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

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-danger {
  background: var(--error-container);
  color: var(--error-text);
}

.badge-info {
  background: var(--info-bg);
  color: var(--accent);
}

.badge-neutral {
  background: var(--surface-container);
  color: var(--secondary);
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.dark-mode .card {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 97, 164, 0.08);
}

.card-header {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--outline-variant);
}

.dark-mode .card-header {
  color: var(--primary-dim);
  border-bottom-color: var(--dark-outline);
}

/* Grid */
.grid {
  display: grid;
  gap: var(--gutter);
  margin-bottom: var(--gutter);
}

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

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

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

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

/* KPI / Stat Cards */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dark-mode .kpi-card {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-input);
  background: rgba(0, 6, 19, 0.06);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.kpi-icon svg {
  width: 18px;
  height: 18px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-sans);
}

.dark-mode .kpi-value {
  color: var(--primary-dim);
}

.kpi-change {
  font-size: 11px;
  color: var(--secondary);
  margin-top: 8px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 6, 19, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--margin-desktop);
  /* Standard "medium" size: a fixed width rather than shrink-to-fit, so every
     small popup is the same width. See the .modal-sm/.modal-lg/.modal-full sizes. */
  width: min(640px, 94vw);
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

/* P5/§5.2 item 10: My Day quick-action forms slide up from the bottom on
   small screens instead of appearing as a centered dialog — no tables, one
   thing at a time, thumb-reachable. Falls back to a normal centered modal
   above the mobile breakpoint. */
.modal.bottom-sheet {
  align-items: flex-end;
}
@media (max-width: 640px) {
  .modal.bottom-sheet .modal-content {
    width: 100%;
    max-width: none;
    max-height: 85vh;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    margin: 0;
  }
}

.modal-content.modal-wide {
  max-width: 880px;
  width: min(880px, 94vw);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
  margin-bottom: var(--gutter);
}

.form-group-full {
  grid-column: 1 / -1;
}

.client-history {
  margin-top: var(--margin-desktop);
  padding-top: var(--gutter);
  border-top: 1px solid var(--outline-variant);
}

/* Client "View" modal */
.modal-content.client-view-modal-content {
  max-width: 1280px;
  width: 96vw;
  max-height: 92vh;
}

.client-view-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.client-view-title-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-input);
  background: var(--info-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.client-view-title-icon svg {
  width: 18px;
  height: 18px;
}

.client-view-summary {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: var(--gutter);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  margin-bottom: var(--gutter);
}

.dark-mode .client-view-summary {
  border-color: var(--dark-outline);
}

.client-view-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--info-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.client-view-summary-main {
  flex: 1;
  min-width: 0;
}

.client-view-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.client-view-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.client-view-summary-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--secondary);
  flex-shrink: 0;
}

.client-view-contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-view-contact-row svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.client-view-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gutter);
  align-items: start;
}

.client-view-details,
.client-view-history {
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
}

.dark-mode .client-view-details,
.dark-mode .client-view-history {
  border-color: var(--dark-outline);
}

.client-view-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: var(--gutter);
}

.client-view-section-title svg {
  width: 16px;
  height: 16px;
  color: var(--secondary);
}

.client-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 16px;
}

.client-detail-field {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.client-detail-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-input);
  background: var(--surface-container);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.client-detail-icon svg {
  width: 14px;
  height: 14px;
}

.client-detail-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--secondary);
  margin-bottom: 2px;
}

.client-detail-input-wrap {
  flex: 1;
  min-width: 0;
}

.client-detail-input-wrap input,
.client-detail-input-wrap select,
.client-detail-input-wrap textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
}

.client-detail-input-wrap textarea {
  resize: vertical;
}

.client-detail-value {
  font-size: 14px;
  font-weight: 500;
  word-break: break-word;
}

.client-view-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: var(--gutter);
}

.dark-mode .client-view-tabs {
  border-bottom-color: var(--dark-outline);
}

.client-view-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 4px;
  margin-right: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
}

.client-view-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.client-view-history-table {
  font-size: 13px;
}

.client-view-history-table th,
.client-view-history-table td {
  padding: 10px 8px;
}

.client-view-row-icon-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.client-view-row-icon {
  width: 14px;
  height: 14px;
  color: var(--secondary);
  flex-shrink: 0;
}

.client-view-empty {
  padding: 12px 0;
}

.client-view-see-all {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.client-view-see-all:hover {
  text-decoration: underline;
}

.client-view-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: var(--gutter);
  padding-top: var(--gutter);
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .client-view-footer {
  border-top-color: var(--dark-outline);
}

@media (max-width: 900px) {
  .client-view-columns {
    grid-template-columns: 1fr;
  }
  .client-view-summary {
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .modal-content.client-view-modal-content {
    width: 100%;
  }
  .client-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .modal-content.modal-wide {
    width: 100%;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Bottom-sheet treatment for every modal on phones: dock to the bottom edge,
   full width, rounded top only, internal scroll, and clear of the home
   indicator. */
@media (max-width: 680px) {
  .modal {
    align-items: flex-end;
  }

  .modal .modal-content {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  }

  /* Sticky coloured headers span the full sheet width without spilling past it
     (the content padding shrinks to --gutter on phones). */
  .modal-content .modal-header,
  .modal-content .quote-view-topbar {
    margin-left: calc(-1 * var(--gutter));
    margin-right: calc(-1 * var(--gutter));
    padding-left: var(--gutter);
    padding-right: var(--gutter);
    border-radius: 16px 16px 0 0;
  }
}

/* Quotation "View" modal */
.modal-content.quote-view-modal-content {
  max-width: 1280px;
  width: 96vw;
  max-height: 92vh;
  padding: 0 var(--margin-desktop) var(--margin-desktop);
}

.quote-view-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gutter);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--primary);
  color: #fff;
  margin: 0 calc(-1 * var(--margin-desktop)) var(--gutter);
  padding: 18px var(--margin-desktop);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.quote-view-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  min-width: 0;
  color: #fff;
}

.quote-view-title-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-input);
  background: var(--info-bg);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quote-view-title-icon svg {
  width: 18px;
  height: 18px;
}

#quotation-detail-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quote-view-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.65);
  padding: 4px;
  display: flex;
  flex-shrink: 0;
}

.quote-view-edit-btn svg {
  width: 16px;
  height: 16px;
}

.quote-view-edit-btn:hover {
  color: #fff;
}

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

.quote-view-topbar .btn-secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.quote-view-topbar .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

.quote-view-topbar .btn-primary {
  background: var(--accent);
}

.quote-view-topbar .btn-primary:hover {
  background: #0077c9;
}

.quote-view-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
  margin-bottom: var(--gutter);
}

.dark-mode .quote-view-stats {
  border-color: var(--dark-outline);
}

.quote-view-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--secondary);
  margin-bottom: 6px;
}

.quote-view-stat-value {
  font-size: 18px;
  font-weight: 700;
}

.quote-view-stat-value.quote-view-total {
  color: var(--success-text);
}

.quote-view-project-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--info-bg);
  color: var(--accent);
  border-radius: var(--radius-card);
  padding: 14px var(--gutter);
  margin-bottom: var(--gutter);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--accent-light);
}

.quote-view-project-banner:hover {
  background: #cfe6fb;
}

.quote-view-project-banner-text {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quote-view-project-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.quote-view-meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--secondary);
  margin: -4px 0 var(--gutter);
}

.quote-view-meta-line svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.quote-view-columns {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: var(--gutter);
  align-items: start;
}

.quote-view-card {
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
  margin-bottom: var(--gutter);
}

.dark-mode .quote-view-card {
  border-color: var(--dark-outline);
}

.quote-view-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: var(--gutter);
}

.quote-view-card-title svg {
  width: 16px;
  height: 16px;
  color: var(--secondary);
}

.quote-view-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
}

.quote-view-summary-row.quote-view-summary-total {
  border-top: 1px solid var(--outline-variant);
  margin-top: 4px;
  padding-top: 12px;
  font-weight: 700;
}

.dark-mode .quote-view-summary-row.quote-view-summary-total {
  border-top-color: var(--dark-outline);
}

.quote-view-summary-total .quote-view-summary-value {
  color: var(--success-text);
}

.quote-view-icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-input);
  background: var(--surface-container);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quote-view-icon-btn:hover {
  background: var(--surface-container-high);
}

.quote-view-icon-btn svg {
  width: 15px;
  height: 15px;
}

.quote-view-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quote-view-actions-grid .btn-primary svg,
.quote-view-actions-grid .btn-secondary svg,
.quote-view-actions-grid .btn-danger svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.quote-view-actions-grid .btn-primary,
.quote-view-actions-grid .btn-secondary,
.quote-view-actions-grid .btn-danger {
  width: 100%;
  justify-content: center;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quote-view-history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
}

.quote-view-history-item + .quote-view-history-item {
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .quote-view-history-item + .quote-view-history-item {
  border-top-color: var(--dark-outline);
}

.quote-view-history-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-container);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quote-view-history-icon svg {
  width: 13px;
  height: 13px;
}

.quote-view-history-label {
  font-weight: 600;
}

.quote-view-history-meta {
  color: var(--secondary);
  font-size: 12px;
}

.quote-view-history-more {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

@media (max-width: 900px) {
  .quote-view-columns {
    grid-template-columns: 1fr;
  }
  .quote-view-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .modal-content.quote-view-modal-content {
    width: 100%;
  }
  .quote-view-actions-grid {
    grid-template-columns: 1fr;
  }
}

.dark-mode .modal-content {
  background: var(--dark-surface-container);
}

.modal-content:has(> .modal-header) {
  padding-top: 0;
}

.modal-header {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--primary);
  margin: 0 calc(-1 * var(--margin-desktop)) var(--gutter);
  padding: 18px var(--margin-desktop);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.modal-header .lead-qu-subtitle {
  color: rgba(255, 255, 255, 0.65);
}

.modal-header .btn-secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.modal-header .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
}

/* Toasts */
/* Bottom-centre, so toasts never cover a window's close button or the header actions. */
#toast-container {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(480px, calc(100vw - 32px));
}

.toast {
  background: var(--surface);
  color: #1E293B;
  border-radius: var(--radius-input);
  padding: 14px 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border-left: 4px solid var(--outline);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-info { border-left-color: var(--accent); }

.dark-mode .toast {
  background: var(--dark-surface-container);
  color: var(--dark-text);
}

/* Confirm / prompt dialog */
.dialog-content {
  max-width: 440px;
  width: min(440px, 94vw);
}

#dialog-message {
  margin-bottom: var(--gutter);
  color: var(--secondary);
}

.dark-mode #dialog-message {
  color: var(--secondary-dim);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 24px;
  color: var(--error);
  padding: 0;
  width: 24px;
  height: 24px;
}

/* Asset form modal (Add/Edit Equipment, Add/Edit Vehicle) */
.modal-content.asset-form-content {
  max-width: 880px;
  width: min(880px, 94vw);
  padding: 0;
}

.af-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--outline-variant);
}

.dark-mode .af-header {
  border-color: var(--dark-outline);
}

.af-header-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-input);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.af-header-text {
  flex: 1;
  min-width: 0;
}

.af-header-text h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  color: #1E293B;
}

.dark-mode .af-header-text h3 {
  color: var(--dark-text);
}

.af-header-text p {
  margin: 0;
  font-size: 13px;
  color: var(--secondary);
}

.af-close {
  background: none;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-input);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--secondary);
  padding: 0;
}

.af-close:hover {
  background: var(--surface-container);
  color: #1E293B;
}

.dark-mode .af-close {
  border-color: var(--dark-outline);
  color: var(--dark-text);
}

.af-body {
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
}

.af-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.af-field-full {
  grid-column: 1 / -1;
}

.af-field label {
  font-size: 13px;
  font-weight: 600;
}

.af-field label .required {
  color: var(--error);
  margin-left: 2px;
}

.af-input-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.af-input-icon svg {
  position: absolute;
  left: 12px;
  color: var(--secondary);
  pointer-events: none;
}

.af-input-icon input,
.af-input-icon select,
.af-input-icon textarea {
  width: 100%;
  padding-left: 38px;
}

.af-input-icon select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.af-checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.af-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.af-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

.af-dropzone {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1.5px dashed var(--outline-variant);
  border-radius: var(--radius-card);
  padding: 20px;
  flex-wrap: wrap;
}

.dark-mode .af-dropzone {
  border-color: var(--dark-outline);
}

.af-dropzone-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.af-dropzone-icon {
  color: var(--secondary);
  flex-shrink: 0;
}

.af-dropzone-text strong {
  display: block;
  font-size: 14px;
  color: #1E293B;
}

.dark-mode .af-dropzone-text strong {
  color: var(--dark-text);
}

.af-dropzone-text span {
  font-size: 12px;
  color: var(--secondary);
}

.af-dropzone input[type="file"] {
  display: none;
}

.af-dropzone .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
}

.af-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 28px;
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .af-footer {
  border-color: var(--dark-outline);
}

/* ============================================================
   Project Detail — tabbed shell (header, KPI strip, tabs, timeline)
   ============================================================ */

.modal-content.modal-fullscreen {
  width: 96vw;
  max-width: 1280px;
  max-height: 92vh;
}

.pd-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pd-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-icon-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-input);
  flex-shrink: 0;
  vertical-align: middle;
}

.pd-icon-chip svg { display: block; }

.pd-icon-chip-sm { width: 28px; height: 28px; }
.pd-icon-chip-md { width: 36px; height: 36px; }

.pd-icon-chip-blue    { background: var(--info-bg);         color: var(--accent); }
.pd-icon-chip-green   { background: var(--success-bg);      color: var(--success-text); }
.pd-icon-chip-orange  { background: var(--warning-bg);      color: var(--warning-text); }
.pd-icon-chip-purple  { background: var(--purple-bg);       color: var(--purple-text); }
.pd-icon-chip-pink    { background: var(--pink-bg);         color: var(--pink-text); }
.pd-icon-chip-red     { background: var(--error-container); color: var(--error-text); }

.pd-header-info {
  flex: 1;
  min-width: 160px;
}

.pd-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.dark-mode .pd-header-title {
  color: var(--primary-dim);
}

.pd-header-subtitle {
  font-size: 13px;
  color: var(--secondary);
}

.pd-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pd-kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter);
  margin-bottom: 16px;
}

.pd-kpi-tile {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
}

.dark-mode .pd-kpi-tile {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.pd-kpi-tile-blue   { background: var(--info-bg); }
.pd-kpi-tile-green  { background: var(--success-bg); }
.pd-kpi-tile-orange { background: var(--warning-bg); }
.pd-kpi-tile-red    { background: var(--error-container); }

.pd-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  margin-bottom: 6px;
}

.pd-kpi-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.dark-mode .pd-kpi-value {
  color: var(--primary-dim);
}

.pd-info-boxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gutter);
  margin-bottom: 16px;
}

.pd-info-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: 12px var(--gutter);
}

.dark-mode .pd-info-box {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.pd-info-box-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-input);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pd-info-box-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
}

.pd-info-box-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.dark-mode .pd-info-box-value {
  color: var(--primary-dim);
}

.pd-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: 16px;
}

.assets-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: start;
}

.pd-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  cursor: pointer;
  white-space: nowrap;
}

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

.dark-mode .pd-tab:hover {
  color: var(--primary-dim);
}

.pd-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.pd-timeline {
  display: flex;
  gap: var(--gutter);
  align-items: flex-start;
}

.pd-phase-status-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.pd-phase-status-complete {
  color: var(--success);
}

.pd-phase-status-in_progress {
  color: var(--accent);
}

.pd-phase-status-not_started {
  color: var(--secondary-dim);
}

/* ---- Lead detail view ---- */

.modal-content.lead-view-modal-content {
  max-width: 1280px;
  width: 96vw;
  max-height: 92vh;
}

.lead-view-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lead-view-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px 76px;
}

.lead-view-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 6px;
  font-size: 13px;
  color: var(--primary);
}

.dark-mode .lead-view-chip {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
  color: var(--primary-dim);
}

.lead-view-overview-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 0.9fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 960px) {
  .lead-view-overview-grid { grid-template-columns: 1fr; }
  .lead-view-chips { margin-left: 0; }
}

.lead-view-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.lead-view-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.lead-view-field-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-input);
  background: var(--surface-container);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dark-mode .lead-view-field-icon {
  background: var(--dark-outline);
}

.lead-view-field-icon svg { width: 15px; height: 15px; }

.lead-view-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--secondary);
  margin-bottom: 2px;
}

.lead-view-field-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  word-break: break-word;
}

.dark-mode .lead-view-field-value {
  color: var(--primary-dim);
}

.lead-view-timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 18px;
}

.lead-view-timeline-item:last-child {
  padding-bottom: 0;
}

.lead-view-timeline-item::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--outline-variant);
}

.lead-view-timeline-item:last-child::before {
  display: none;
}

.dark-mode .lead-view-timeline-item::before {
  background: var(--dark-outline);
}

.lead-view-timeline-icon {
  flex-shrink: 0;
  z-index: 1;
}

.lead-view-timeline-title {
  font-weight: 700;
  color: var(--primary);
}

.dark-mode .lead-view-timeline-title {
  color: var(--primary-dim);
}

.lead-view-timeline-meta {
  font-size: 12px;
  color: var(--secondary);
  margin-bottom: 4px;
}

.lead-view-timeline-body {
  font-size: 13px;
  color: var(--primary);
}

.dark-mode .lead-view-timeline-body {
  color: var(--primary-dim);
}

.lead-view-timeline-body.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lead-view-timeline-body.clamped.expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.lead-view-note-toggle {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  margin-top: 2px;
  margin-bottom: 4px;
}

.dark-mode .lead-view-note-toggle {
  color: var(--primary-dim);
}

.lead-view-row-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.dark-mode .lead-view-row-link {
  color: var(--primary-dim);
}

.lead-view-row-link + .lead-view-row-link {
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .lead-view-row-link + .lead-view-row-link {
  border-top-color: var(--dark-outline);
}

.lead-view-row-link .lead-view-row-arrow {
  margin-left: auto;
  color: var(--secondary-dim);
}

.lead-view-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13px;
}

.lead-view-summary-row + .lead-view-summary-row {
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .lead-view-summary-row + .lead-view-summary-row {
  border-top-color: var(--dark-outline);
}

.lead-view-summary-label {
  color: var(--secondary);
}

.lead-view-summary-value {
  font-weight: 600;
  color: var(--primary);
}

.dark-mode .lead-view-summary-value {
  color: var(--primary-dim);
}

.lead-view-additional {
  margin-top: 16px;
}

.lead-view-additional-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}

.dark-mode .lead-view-additional-toggle {
  color: var(--primary-dim);
}

.lead-view-additional-toggle svg {
  transition: transform 0.15s ease;
}

.lead-view-additional.open .lead-view-additional-toggle svg {
  transform: rotate(180deg);
}

.lead-view-additional-body {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--outline-variant);
}

.dark-mode .lead-view-additional-body {
  border-top-color: var(--dark-outline);
}

.lead-view-additional.open .lead-view-additional-body {
  display: grid;
}

.pd-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--info-bg);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

/* ---- Maintenance: entitlement balance rows ---- */
.ma-entitlement-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--outline-variant);
}
.ma-entitlement-row:last-child {
  border-bottom: none;
}
.ma-entitlement-bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--outline-variant);
  margin-top: 6px;
  overflow: hidden;
}
.ma-entitlement-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

/* ---- Timeline tab: Gantt chart ---- */

.pd-gantt-card {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: var(--gutter);
}

.dark-mode .pd-gantt-card {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.pd-gantt-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
}

.pd-gantt-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.dark-mode .pd-gantt-nav-btn {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.pd-gantt-nav-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.pd-gantt-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--error, #c0392b);
  cursor: pointer;
}

.pd-gantt-remove-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.pd-gantt-body {
  display: flex;
  align-items: flex-start;
}

.pd-gantt-grid-fixed {
  flex-shrink: 0;
}

.pd-gantt-scroll {
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}

.pd-gantt-grid {
  display: grid;
  grid-auto-rows: 44px;
  position: relative;
}

.pd-gantt-cell {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--outline);
  border-right: 1px solid var(--outline-variant);
  font-size: 12px;
  padding: 0 8px;
}

.dark-mode .pd-gantt-cell {
  border-bottom-color: var(--dark-outline);
  border-right-color: var(--dark-outline);
}

.pd-gantt-fixed {
  background: var(--surface);
}

.dark-mode .pd-gantt-fixed {
  background: var(--dark-surface-container);
}

.pd-gantt-head {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--secondary);
  font-weight: 700;
  border-bottom: 2px solid var(--outline);
  align-items: flex-end;
  padding-bottom: 8px;
  z-index: 3;
}

.pd-gantt-name {
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}

.dark-mode .pd-gantt-name {
  color: var(--primary-dim);
}

.pd-gantt-name.selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

.pd-gantt-name svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.pd-gantt-muted {
  color: var(--secondary);
}

.pd-gantt-day-head {
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  padding-bottom: 8px;
  border-right: 1px solid var(--outline);
  font-weight: 600;
  color: var(--secondary);
}

.dark-mode .pd-gantt-day-head {
  border-color: var(--dark-outline);
}

.pd-gantt-day-head.is-today {
  color: var(--accent);
}

.pd-gantt-day-num {
  font-size: 12px;
}

.pd-gantt-day-name {
  font-size: 9px;
  text-transform: uppercase;
}

.pd-gantt-bar {
  align-self: center;
  height: 22px;
  margin: 0 2px;
  border-radius: 6px;
  z-index: 1;
}

.pd-gantt-bar-not_started {
  background: var(--outline);
  border: 1px solid var(--secondary);
}

.dark-mode .pd-gantt-bar-not_started {
  background: var(--dark-outline);
  border-color: var(--secondary);
}

.pd-gantt-bar-in_progress {
  background: var(--accent);
}

.pd-gantt-bar-complete {
  background: var(--success);
}

.pd-gantt-bar.selected {
  box-shadow: 0 0 0 2px var(--accent);
}

.pd-gantt-today-line {
  width: 0;
  border-left: 2px dashed var(--accent);
  justify-self: start;
  z-index: 1;
  pointer-events: none;
}

.pd-gantt-inline-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 12px;
  color: var(--primary);
  padding: 4px;
  border-radius: 4px;
}

.dark-mode .pd-gantt-inline-input {
  color: var(--primary-dim);
}

.pd-gantt-inline-input:hover,
.pd-gantt-inline-input:focus {
  border-color: var(--outline-variant);
  background: var(--surface-container);
}

.pd-gantt-deps {
  font-size: 12px;
  position: relative;
}
.pd-gantt-deps > summary {
  cursor: pointer;
  list-style: none;
  padding: 4px 6px;
  border: 1px solid var(--outline-variant);
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pd-gantt-deps > summary::-webkit-details-marker { display: none; }
.pd-gantt-dep-menu {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  min-width: 180px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  padding: 4px;
}
.pd-gantt-dep-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.pd-gantt-dep-item:hover { background: var(--surface-container); }

.dark-mode .pd-gantt-inline-input:hover,
.dark-mode .pd-gantt-inline-input:focus {
  background: var(--dark-outline);
}

.pd-gantt-inline-input-days {
  text-align: center;
}

.pd-gantt-add-phase {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pd-gantt-add-phase input {
  flex: 1;
  max-width: 260px;
}

/* ---- Overview tab ---- */

.pd-overview-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--gutter);
  align-items: start;
}

.pd-overview-main,
.pd-overview-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

.pd-overview-full {
  grid-column: 1 / -1;
}

.pd-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pd-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--primary);
}

.dark-mode .pd-checklist-item {
  color: var(--primary-dim);
}

.pd-progress-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 6px;
}

.pd-progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--outline-variant);
  overflow: hidden;
}

.dark-mode .pd-progress-bar {
  background: var(--dark-outline);
}

.pd-progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.pd-activity-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pd-activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.pd-activity-icon {
  display: flex;
  flex-shrink: 0;
}

.pd-activity-icon svg {
  width: 16px;
  height: 16px;
}

.pd-activity-text {
  flex: 1;
  color: var(--primary);
}

.dark-mode .pd-activity-text {
  color: var(--primary-dim);
}

.pd-activity-date {
  font-size: 11px;
  color: var(--secondary);
  flex-shrink: 0;
}

.pd-quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pd-quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-card);
  padding: 14px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-align: center;
}

.dark-mode .pd-quick-action {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
  color: var(--primary-dim);
}

.pd-quick-action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pd-quick-action svg {
  width: 20px;
  height: 20px;
}

/* ---- Team tab ---- */

.pd-team-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--gutter);
  align-items: start;
}

.pd-team-full {
  grid-column: 1 / -1;
}

.pd-role-breakdown {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.pd-donut {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--donut-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.pd-donut::before {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--surface);
}

.dark-mode .pd-donut::before {
  background: var(--dark-surface-container);
}

.pd-donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
}

.pd-donut-total {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.dark-mode .pd-donut-total {
  color: var(--primary-dim);
}

.pd-donut-label {
  font-size: 10px;
  color: var(--secondary);
  text-transform: uppercase;
}

.pd-role-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 140px;
}

.pd-role-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--primary);
}

.dark-mode .pd-role-legend-item {
  color: var(--primary-dim);
}

.pd-role-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pd-phase-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  background: var(--surface-container);
  font-size: 12px;
  color: var(--primary);
}

.dark-mode .pd-phase-chip {
  color: var(--primary-dim);
}

.pd-phase-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--error);
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.pd-phase-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.pd-phase-picker select {
  font-size: 12px;
  padding: 2px 4px;
}

.pd-form-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.pd-report-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-container, #f5f5f5);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dark-mode .pd-report-preview {
  background: var(--dark-surface-container);
}

/* Login View */
.login-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  background: var(--background);
  overflow: hidden;
}

.login-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(51, 160, 253, 0.10) 0%, rgba(247, 249, 251, 0) 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.login-glow.top {
  top: -220px;
  left: -220px;
}

.login-glow.bottom {
  bottom: -220px;
  right: -220px;
}

.login-brand {
  position: relative;
  z-index: 1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-input);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 6, 19, 0.25);
}

.login-icon-badge svg {
  width: 24px;
  height: 24px;
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.login-brand p {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 360px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0, 6, 19, 0.08);
}

.login-demo-box {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-alt);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-input);
  font-size: 12px;
  color: var(--secondary);
  line-height: 1.7;
}

.login-demo-box strong {
  color: var(--primary);
}

/* Utility Classes */
.text-center {
  text-align: center;
}

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

.mt-1 {
  margin-top: calc(var(--unit) * 1);
}

.mt-2 {
  margin-top: calc(var(--unit) * 2);
}

.mt-4 {
  margin-top: calc(var(--unit) * 4);
}

.mb-4 {
  margin-bottom: calc(var(--unit) * 4);
}

.p-4 {
  padding: calc(var(--unit) * 4);
}

.overflow-auto {
  overflow: auto;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.gap-2 {
  gap: calc(var(--unit) * 2);
}

.gap-4 {
  gap: calc(var(--unit) * 4);
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-container);
}

.dark-mode ::-webkit-scrollbar-track {
  background: var(--dark-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--secondary-dim);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* Mobile layout */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    /* Notch clearance in landscape, when the notch sits on the left edge. */
    padding-left: env(safe-area-inset-left);
  }

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

  .mobile-menu-btn {
    display: flex;
  }

  .header {
    padding: 0 var(--gutter);
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
    gap: 12px;
  }

  .header-actions {
    gap: 8px;
  }

  .conn-latency {
    display: none;
  }

  .search-box {
    width: 100%;
    max-width: 200px;
  }

  .content {
    padding: var(--gutter);
    padding-bottom: max(var(--gutter), env(safe-area-inset-bottom));
  }

  /* iOS Safari zooms the page in when a focused field's text is under 16px and
     never zooms back out. Force every control to 16px on phones. */
  input,
  textarea,
  select,
  .search-box input,
  .client-detail-input-wrap input,
  .client-detail-input-wrap select,
  .client-detail-input-wrap textarea {
    font-size: 16px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .card {
    overflow-x: auto;
  }

  table {
    min-width: 560px;
  }

  /* Wide tables stay horizontally scrollable on phones, but the first column
     (the row's name/identifier) freezes so you never lose your place while
     scrolling sideways. */
  .overflow-auto {
    -webkit-overflow-scrolling: touch;
  }

  .overflow-auto table th:first-child,
  .overflow-auto table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
  }

  .overflow-auto table tbody td:first-child {
    background: var(--surface);
  }

  .overflow-auto table thead th:first-child {
    background: var(--surface-container-high);
  }

  .dark-mode .overflow-auto table tbody td:first-child {
    background: var(--dark-surface-container);
  }

  .dark-mode .overflow-auto table thead th:first-child {
    background: var(--dark-surface);
  }

  .modal-content {
    width: 94vw;
    padding: var(--gutter);
  }

  .pd-kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .assets-layout {
    grid-template-columns: 1fr;
  }

  .pd-info-boxes {
    grid-template-columns: 1fr;
  }

  .pd-timeline {
    flex-direction: column;
  }

  .pd-gantt-nav-label {
    font-size: 12px;
  }

  .pd-overview-grid,
  .pd-team-layout {
    grid-template-columns: 1fr;
  }

  .pd-quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Bump small icon buttons up to a comfortable touch size on phones. */
  .pd-gantt-nav-btn,
  .pd-gantt-remove-btn,
  .af-close,
  .quote-view-icon-btn {
    width: 40px;
    height: 40px;
  }

  .modal-close {
    width: 40px;
    height: 40px;
    font-size: 28px;
  }
}

@media (max-width: 480px) {
  .pd-kpi-strip {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Dashboard — workflow pipeline layout.
   Scoped under #dashboard so no other view is affected.
   ============================================================ */

#dashboard {
  --stage-blue: #2563eb;
  --stage-green: #16a34a;
  --stage-amber: #f59e0b;
  --stage-violet: #7c3aed;
  --stage-teal: #0d9488;
}

.dash-greeting {
  font-size: 24px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.dark-mode .dash-greeting {
  color: var(--dark-text);
}

.dash-greeting-sub {
  font-size: 14px;
  color: var(--secondary);
}

/* Panel — flatter than .card, matching the calmer surfaces in the design */
.dash-panel {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dark-mode .dash-panel {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.dash-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #334155;
}

.dark-mode .dash-panel-title {
  color: var(--primary-dim);
}

.dash-panel-sub {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 2px;
}

.dash-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.dash-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--stage-blue, #2563eb);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.dash-link:hover {
  text-decoration: underline;
}

/* ---- Workflow pipeline rail ---- */
.pipeline {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipeline-stage {
  flex: 1 1 0;
  min-width: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: 0;
  padding: 4px;
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.pipeline-stage:hover {
  background: var(--surface-alt);
}

.dark-mode .pipeline-stage:hover {
  background: rgba(255, 255, 255, 0.04);
}

.pipeline-stage:disabled {
  cursor: default;
  opacity: 0.5;
}

.pipeline-stage:disabled:hover {
  background: none;
}

.pipeline-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.pipeline-icon svg {
  width: 26px;
  height: 26px;
}

.pipeline-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #334155;
  text-align: center;
}

.dark-mode .pipeline-name {
  color: var(--dark-text);
}

.pipeline-count {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1;
}

.dark-mode .pipeline-count {
  color: var(--dark-text);
}

.pipeline-state {
  font-size: 11px;
  color: var(--secondary);
}

.pipeline-underline {
  width: 22px;
  height: 3px;
  border-radius: 2px;
}

.pipeline-arrow {
  flex: 0 0 auto;
  margin-top: 26px;
  color: #cbd5e1;
}

.pipeline-arrow svg {
  width: 20px;
  height: 20px;
  display: block;
}

.dark-mode .pipeline-arrow {
  color: var(--dark-outline);
}

/* Stage colour variants */
.stage-blue .pipeline-icon { background: var(--stage-blue); }
.stage-blue .pipeline-underline { background: var(--stage-blue); }
.stage-blue .pipeline-state { color: var(--stage-blue); }
.stage-green .pipeline-icon { background: var(--stage-green); }
.stage-green .pipeline-underline { background: var(--stage-green); }
.stage-green .pipeline-state { color: var(--stage-green); }
.stage-amber .pipeline-icon { background: var(--stage-amber); }
.stage-amber .pipeline-underline { background: var(--stage-amber); }
.stage-amber .pipeline-state { color: #b45309; }
.stage-violet .pipeline-icon { background: var(--stage-violet); }
.stage-violet .pipeline-underline { background: var(--stage-violet); }
.stage-violet .pipeline-state { color: var(--stage-violet); }
.stage-teal .pipeline-icon { background: var(--stage-teal); }
.stage-teal .pipeline-underline { background: var(--stage-teal); }
.stage-teal .pipeline-state { color: var(--stage-teal); }

/* ---- KPI row (5 across) ---- */
.dash-kpi-grid {
  display: grid;
  /* minmax(0, …) so a long currency value cannot force a track wider than its share */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--gutter);
  margin-bottom: var(--gutter);
}

.dash-kpi {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  /* The icon is taken out of flow and pinned top-right, so the value gets the
     card's full width instead of being squeezed into a column beside it. */
  position: relative;
}

.dark-mode .dash-kpi {
  background: var(--dark-surface-container);
  border-color: var(--dark-outline);
}

.dash-kpi-body {
  min-width: 0;
}

.dash-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  margin-bottom: 10px;
  min-width: 0;
  /* Keeps the label clear of the absolutely-positioned icon */
  padding-right: 52px;
}

.dash-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.15;
  /* dashMoney() emits ordinary spaces, so a long amount wraps at its thousands
     separators. Never break inside a group of digits. */
  overflow-wrap: normal;
  min-width: 0;
}

.dark-mode .dash-kpi-value {
  color: var(--dark-text);
}

.dash-kpi-note {
  font-size: 12px;
  color: var(--secondary);
  margin-top: 10px;
}

.dash-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: absolute;
  top: 18px;
  right: 18px;
}

.dash-kpi-icon svg {
  width: 19px;
  height: 19px;
}

.tint-blue { background: #dbeafe; color: #2563eb; }
.tint-green { background: #dcfce7; color: #16a34a; }
.tint-amber { background: #fef3c7; color: #b45309; }
.tint-violet { background: #ede9fe; color: #7c3aed; }
.tint-red { background: #fee2e2; color: #dc2626; }

.dark-mode .tint-blue { background: rgba(37, 99, 235, 0.18); color: #93c5fd; }
.dark-mode .tint-green { background: rgba(22, 163, 74, 0.18); color: #86efac; }
.dark-mode .tint-amber { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.dark-mode .tint-violet { background: rgba(124, 58, 237, 0.2); color: #c4b5fd; }
.dark-mode .tint-red { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

/* ---- Three-column middle row ---- */
.dash-mid-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--gutter);
  margin-bottom: var(--gutter);
  align-items: start;
}

.donut-wrap {
  position: relative;
  height: 190px;
  margin-bottom: 12px;
}

.donut-centre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-centre-value {
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
  max-width: 78%;
  text-align: center;
  overflow-wrap: normal;
}

.dark-mode .donut-centre-value {
  color: var(--dark-text);
}

.donut-centre-label {
  font-size: 11px;
  color: var(--secondary);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.donut-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.donut-legend-name {
  color: #334155;
  flex: 1;
}

.dark-mode .donut-legend-name {
  color: var(--dark-text);
}

.donut-legend-value {
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
  text-align: right;
}

/* Recent projects table — lighter than the global table style */
.dash-table {
  width: 100%;
  border-collapse: collapse;
}

.dash-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  text-align: left;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--outline-variant);
  background: none;
}

.dash-table td {
  padding: 11px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--outline-variant);
  color: #334155;
}

.dark-mode .dash-table td {
  color: var(--dark-text);
  border-bottom-color: var(--dark-outline);
}

.dark-mode .dash-table th {
  border-bottom-color: var(--dark-outline);
}

.dash-table tr:last-child td {
  border-bottom: 0;
}

.dash-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dash-row-link {
  cursor: pointer;
}

.dash-row-link:hover td {
  background: var(--surface-alt);
}

.dark-mode .dash-row-link:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Soft stage pill used in the recent-projects table */
.stage-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.stage-pill.pill-blue { background: #dbeafe; color: #1d4ed8; }
.stage-pill.pill-green { background: #dcfce7; color: #15803d; }
.stage-pill.pill-amber { background: #fef3c7; color: #b45309; }
.stage-pill.pill-violet { background: #ede9fe; color: #6d28d9; }
.stage-pill.pill-teal { background: #ccfbf1; color: #0f766e; }
.stage-pill.pill-grey { background: var(--surface-container); color: #475569; }

/* ---- Needs attention list ---- */
.attention-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--outline-variant);
}

.dark-mode .attention-item {
  border-bottom-color: var(--dark-outline);
}

.attention-item:last-child {
  border-bottom: 0;
}

.attention-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.attention-body {
  flex: 1;
  min-width: 0;
}

.attention-text {
  font-size: 13px;
  color: #334155;
  line-height: 1.35;
}

.dark-mode .attention-text {
  color: var(--dark-text);
}

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

.attention-when {
  font-size: 11px;
  font-weight: 600;
  color: var(--error);
  white-space: nowrap;
}

/* ---- Ambient "needs action" outline: a faint pulsing red ring on the exact row/element
   flagged by a notification, so it's noticeable at rest without blocking the content. ---- */
@keyframes attn-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5); }
  50%      { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.05); }
}
.attn-pulse {
  /* Pulse a few times to catch the eye, then settle as a static ring. */
  animation: attn-pulse 2.8s ease-in-out 3;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.5);
}

/* ---- Due this week strip ---- */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.week-day {
  border: 1px solid var(--outline-variant);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  background: var(--surface);
}

.dark-mode .week-day {
  border-color: var(--dark-outline);
  background: var(--dark-surface-container);
}

.week-day.is-today {
  border-color: var(--stage-blue);
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px var(--stage-blue);
}

.dark-mode .week-day.is-today {
  background: rgba(37, 99, 235, 0.14);
}

.week-dow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
}

.week-date {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 4px 0 8px;
}

.dark-mode .week-date {
  color: var(--dark-text);
}

.week-count {
  font-size: 12px;
  color: var(--stage-blue);
  font-weight: 600;
}

.week-count.is-empty {
  color: var(--secondary);
  font-weight: 400;
}

.dash-empty {
  font-size: 13px;
  color: var(--secondary);
  text-align: center;
  padding: 28px 12px;
}

/* ---- Responsive ---- */
@media (max-width: 1280px) {
  .dash-mid-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .dash-mid-grid > :nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1100px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dash-mid-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .dash-mid-grid > :nth-child(3) {
    grid-column: auto;
  }
  .week-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---- Phones ----
   The pipeline becomes a wrapping grid instead of a horizontal scroller (7
   stages in a 60px-circle rail only showed two at a time), the KPI cards
   become single-column rows so long currency values fit on one line, and the
   recent-projects table drops its client column so nothing is cut off. */
@media (max-width: 640px) {
  .dash-panel {
    padding: var(--gutter);
  }

  .dash-greeting {
    font-size: 20px;
  }

  .dash-panel-head {
    margin-bottom: 14px;
  }

  .pipeline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow-x: visible;
  }

  /* icon spans both rows, with the stage name above its count */
  .pipeline-stage {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "icon name"
      "icon count";
    align-items: center;
    gap: 1px 10px;
    text-align: left;
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--outline-variant);
  }

  .dark-mode .pipeline-stage {
    border-color: var(--dark-outline);
  }

  .pipeline-icon {
    grid-area: icon;
    width: 38px;
    height: 38px;
  }

  .pipeline-icon svg {
    width: 18px;
    height: 18px;
  }

  .pipeline-name {
    grid-area: name;
    font-size: 10px;
    text-align: left;
  }

  /* The step number would push longer names onto a second line */
  .pipeline-num {
    display: none;
  }

  .pipeline-count {
    grid-area: count;
    font-size: 20px;
    text-align: left;
  }

  .pipeline-state,
  .pipeline-underline,
  .pipeline-arrow {
    display: none;
  }

  .dash-kpi-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  /* Icon moves to the left of the text so each card is a short row */
  .dash-kpi {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--gutter);
  }

  .dash-kpi-icon {
    position: static;
    width: 36px;
    height: 36px;
  }

  .dash-kpi-body {
    flex: 1;
    min-width: 0;
  }

  .dash-kpi-label {
    margin-bottom: 3px;
    padding-right: 0;
  }

  .dash-kpi-value {
    font-size: 21px;
  }

  .dash-kpi-note {
    margin-top: 3px;
  }

  .donut-wrap {
    height: 160px;
  }

  /* Client is the least useful column on a narrow screen and the one that
     forces the table to scroll — drop it rather than clip Stage and Value. */
  .dash-table th:nth-child(2),
  .dash-table td:nth-child(2) {
    display: none;
  }

  /* Overrides the global mobile `table { min-width: 560px }`, which would keep
     this table scrolling sideways even with the client column hidden. */
  .dash-table {
    min-width: 0;
  }

  .dash-table th,
  .dash-table td {
    padding-left: 6px;
    padding-right: 6px;
  }

  .week-strip {
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 8px;
  }

  .week-day {
    padding: 9px 4px;
  }

  .week-date {
    font-size: 13px;
    margin: 3px 0 5px;
  }

  .week-count {
    font-size: 11px;
  }
}

/* Narrow phones (iPhone SE and similar): two pipeline tiles per row leaves too
   little room for the longer stage names, so go single column. */
@media (max-width: 380px) {
  .pipeline {
    grid-template-columns: minmax(0, 1fr);
  }

  .dash-table th,
  .dash-table td {
    padding-left: 4px;
    padding-right: 4px;
  }

  .week-strip {
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  }
}

/* ---- Leads: row actions + Quick Update dialog ---- */
.lead-actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-content.lead-qu-modal {
  max-width: 640px;
  width: min(640px, 94vw);
  padding: 0 32px 28px;
}

.lead-qu-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: var(--secondary);
  margin-top: 4px;
}

.lead-qu-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: 24px;
}

.lead-qu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.lead-qu-field {
  margin: 0;
}

.lead-qu-form textarea {
  resize: vertical;
  min-height: 90px;
  font: inherit;
}

.lead-qu-file-drop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1.5px dashed var(--outline);
  border-radius: var(--radius-input);
  cursor: pointer;
  color: var(--secondary);
  font-size: 13px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lead-qu-file-drop:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.lead-qu-file-drop-active {
  border-style: solid;
  border-color: var(--accent);
  color: var(--primary);
}

.dark-mode .lead-qu-file-drop-active {
  color: var(--dark-text);
}

.lead-qu-file-icon {
  display: flex;
  flex-shrink: 0;
}

.lead-qu-submit {
  align-self: flex-start;
  padding: 12px 28px;
}

.lead-qu-timeline-header {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.lead-qu-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 340px;
  overflow-y: auto;
}

.lead-qu-timeline-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 4px 16px;
  padding: 14px 16px;
  border-radius: var(--radius-input);
  background: var(--surface-alt);
}

.dark-mode .lead-qu-timeline-item {
  background: rgba(255, 255, 255, 0.04);
}

.lead-qu-timeline-type {
  font-weight: 700;
  font-size: 13px;
}

.lead-qu-timeline-body {
  font-size: 13px;
  line-height: 1.5;
}

.lead-qu-timeline-due {
  margin-top: 4px;
  font-size: 12px;
  color: var(--secondary);
}

.lead-qu-timeline-meta {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--secondary);
}

.lead-qu-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--stage-blue, #2563eb);
  cursor: pointer;
}

.lead-qu-attachment:hover {
  text-decoration: underline;
}

.lead-qu-voice {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border: 1.5px dashed var(--outline);
  border-radius: var(--radius-input);
  color: var(--secondary);
  font-size: 13px;
}

.lead-qu-voice.lead-qu-file-drop-active {
  border-style: solid;
}

.lead-qu-voice-main {
  flex: 1;
  min-width: 0;
}

.lead-qu-voice-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.lead-qu-voice-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
}

.lead-qu-voice-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lead-qu-voice-btn {
  padding: 6px 14px;
  font-size: 12px;
  position: relative;
}

.lead-qu-voice-btn.is-recording::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  margin-right: 6px;
  animation: voicePulse 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .lead-qu-voice-btn.is-recording::before {
    animation: none;
  }
}

@keyframes voicePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .25; }
}

.lead-qu-voice-upload {
  font-size: 12px;
  font-weight: 600;
  color: var(--stage-blue, #2563eb);
  cursor: pointer;
}

.lead-qu-voice-upload-primary {
  flex-basis: 100%;
  justify-content: center;
  display: flex;
  padding: 10px;
  border: 1.5px dashed var(--outline);
  border-radius: var(--radius-input);
}

.lead-qu-voice-remove {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--secondary);
  cursor: pointer;
  padding: 0;
}

.lead-qu-voice-remove:hover {
  text-decoration: underline;
}

.lead-qu-voice-audio {
  flex-basis: 100%;
  max-width: 320px;
  height: 36px;
}

.lead-qu-voice-hint {
  font-size: 12px;
  color: var(--secondary);
  margin: 6px 0 0;
}

.lead-qu-voice-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.lead-qu-transcribe-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.lead-qu-transcribe-btn:hover {
  border-color: var(--accent);
}

.lead-qu-transcribe-btn:disabled {
  opacity: .55;
  cursor: default;
}

.lead-qu-voice-duration,
.lead-qu-voice-meta {
  font-size: 11px;
  color: var(--secondary);
}

.lead-qu-mood-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--primary);
  font-weight: 600;
}

.dark-mode .lead-qu-mood-tag {
  background: rgba(255, 255, 255, 0.08);
  color: var(--dark-text);
}

.lead-qu-voice-summary {
  font-size: 12px;
  color: var(--secondary);
  font-style: italic;
  margin-top: 4px;
}

@media (max-width: 680px) {
  .modal-content.lead-qu-modal {
    width: 100%;
    max-height: 92vh;
    padding: 0 16px 20px;
    border-radius: 16px 16px 0 0;
  }

  .modal-content.lead-qu-modal .modal-header {
    margin: 0 -16px var(--gutter);
    padding: 16px;
    border-radius: 16px 16px 0 0;
  }

  .lead-qu-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .lead-qu-timeline-item {
    grid-template-columns: 1fr;
  }

  .lead-qu-submit {
    align-self: stretch;
    width: 100%;
  }

  .lead-qu-voice {
    gap: 8px;
  }

  .lead-qu-voice-actions {
    flex-basis: 100%;
    display: flex;
    gap: 12px;
  }

  .lead-qu-voice-audio {
    max-width: 100%;
  }
}

/* ---- AI Assistant widget ---- */
#assistant-widget {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 1500;
}

.assistant-bubble {
  width: 88px;
  height: 120px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.assistant-bubble:hover {
  transform: translateY(-2px);
}

.assistant-mascot {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 6, 19, 0.35));
  transition: transform 0.15s ease;
}

/* Only bob while hovered - a mascot that never stops moving pulls the eye off the work. */
.assistant-bubble:hover .assistant-mascot {
  animation: assistant-idle-bob 2.6s ease-in-out infinite;
}

.assistant-bubble-thinking .assistant-mascot {
  animation: assistant-thinking-wobble 0.6s ease-in-out infinite;
}

@keyframes assistant-idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes assistant-thinking-wobble {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.assistant-panel {
  position: absolute;
  right: 0;
  bottom: 124px;
  width: 340px;
  max-width: calc(100vw - 48px);
  height: 460px;
  max-height: calc(100dvh - 140px);
  background: var(--surface);
  border: 1px solid var(--outline-variant);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 6, 19, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.assistant-panel.assistant-panel-open {
  display: flex;
}

.assistant-header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}

.assistant-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
}

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.assistant-msg-bot {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--primary);
}

.assistant-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.assistant-msg-thinking {
  opacity: 0.6;
  font-style: italic;
}

.assistant-msg .assistant-line {
  margin: 0 0 6px;
}

.assistant-msg .assistant-line:last-child,
.assistant-msg .assistant-list:last-child {
  margin-bottom: 0;
}

.assistant-msg .assistant-list {
  margin: 0 0 6px;
  padding-left: 18px;
}

.assistant-msg .assistant-list li {
  margin-bottom: 2px;
}

.assistant-msg .assistant-highlight {
  color: var(--accent);
  font-weight: 600;
}

.assistant-msg-user .assistant-highlight {
  color: #fff;
}

.assistant-input-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--outline-variant);
}

.assistant-input-row input {
  flex: 1;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.assistant-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.assistant-icon-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  padding: 4px;
  border-radius: 6px;
}

.assistant-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.assistant-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assistant-history[hidden] {
  display: none;
}

.assistant-history:not([hidden]) + .assistant-messages {
  display: none;
}

.assistant-history-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--primary);
}

.assistant-history-item:hover,
.assistant-history-current {
  border-color: var(--accent);
}

.assistant-history-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.assistant-history-date,
.assistant-history-empty {
  font-size: 12px;
  color: var(--secondary);
}

.assistant-history-empty {
  padding: 12px;
  text-align: center;
}

.assistant-choices {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.assistant-choice {
  text-align: left;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

.assistant-choice:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.assistant-choice:disabled {
  cursor: default;
  opacity: 0.55;
}

.assistant-choice.assistant-choice-picked {
  opacity: 1;
  background: var(--accent);
  color: #fff;
}

.assistant-proposal {
  margin-top: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--outline-variant);
  background: var(--surface);
  font-size: 12px;
}

.assistant-proposal ul {
  margin: 2px 0 6px;
  padding-left: 18px;
}

.assistant-proposal-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.assistant-proposal-section {
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.assistant-proposal-sku {
  color: var(--secondary);
}

.assistant-proposal-note {
  color: var(--secondary);
  font-size: 11px;
  margin: 4px 0 8px;
}

.assistant-proposal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.assistant-proposal-done {
  color: var(--success-text);
  font-weight: 600;
}

.assistant-proposal-error {
  width: 100%;
  color: var(--error-text);
}

.assistant-mic-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

.assistant-mic-btn svg,
.assistant-icon-btn svg {
  flex-shrink: 0;
}

.assistant-mic-btn.assistant-mic-active {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

.assistant-voice-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--outline-variant);
  font-size: 12px;
  color: var(--primary);
}

.assistant-voice-bar[hidden] {
  display: none;
}

.assistant-voice-bar span:nth-child(2) {
  flex: 1;
}

.assistant-voice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--secondary);
}

.assistant-voice-dot.assistant-voice-listening {
  background: var(--error);
  animation: assistant-voice-pulse 1.2s ease-in-out infinite;
}

.assistant-voice-dot.assistant-voice-speaking {
  background: var(--success);
  animation: assistant-voice-pulse 0.8s ease-in-out infinite;
}

.assistant-voice-dot.assistant-voice-transcribing,
.assistant-voice-dot.assistant-voice-thinking {
  background: var(--warning);
}

@keyframes assistant-voice-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
  .assistant-voice-dot { animation: none !important; }
}

@media (max-width: 640px) {
  .assistant-panel {
    width: calc(100vw - 32px);
    right: -8px;
  }

  /* Keep the chat input at 16px so iOS Safari doesn't zoom the page on focus. */
  .assistant-input-row input {
    font-size: 16px;
  }
}

/* Command palette (Ctrl/Cmd+K) + notification centre — roadmap §5.2/WP-10, P1 */
.cmdk-group {
  margin-bottom: 8px;
}
.cmdk-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #888);
  padding: 6px 4px 2px;
}
.cmdk-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.cmdk-item:hover {
  background: var(--surface-variant, rgba(0,0,0,0.05));
}
.cmdk-empty {
  padding: 16px 4px;
  text-align: center;
}
.notif-item {
  padding: 10px 4px;
  border-bottom: 1px solid var(--outline-variant);
  cursor: pointer;
  font-size: 14px;
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item:hover {
  background: var(--surface-variant, rgba(0,0,0,0.05));
}
.notif-critical {
  border-left: 3px solid var(--error);
  padding-left: 8px;
}
.notif-warning {
  border-left: 3px solid #d97706;
  padding-left: 8px;
}

/* ---- Payroll (plans/payroll-module.md §14.9) ---- */
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--radius-pill); background: var(--error); color: #fff;
  font-size: .7rem; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center;
}
.nav-badge[hidden] { display: none; }
.pii-masked { font-family: var(--font-mono); letter-spacing: .05em; color: var(--secondary); }
.pii-revealed { font-family: var(--font-mono); letter-spacing: .05em; color: var(--error-text); font-weight: 600; }
.payroll-banner {
  border-left: 3px solid var(--accent); background: var(--surface);
  border-radius: var(--radius-card); padding: 12px 16px; margin-bottom: 12px;
}
.payroll-banner-danger  { border-left-color: var(--error);   background: var(--error-container); }
.payroll-banner-warning { border-left-color: var(--warning); background: var(--warning-bg); }
.payroll-input-grid td { padding: 2px 4px; }
.payroll-input-grid input { width: 84px; text-align: right; }
.dark-mode .payroll-banner { background: var(--dark-surface-container); }
.dark-mode .payroll-banner-danger  { background: #3a1a1a; }
.dark-mode .payroll-banner-warning { background: #3a2f16; }
.dark-mode .pii-masked { color: var(--secondary-dim); }

/* ---- CoffeeBot training tour (web/js/training.js) ---- */
#training-root {
  display: none;
}

#training-root.tr-active {
  display: block;
}

.tr-blocker {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.tr-spot {
  position: fixed;
  z-index: 10001;
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(0, 6, 19, 0.72);
}

.tr-spot.tr-spot-glide {
  transition: left 0.45s ease, top 0.45s ease, width 0.45s ease, height 0.45s ease;
}

.tr-spot.tr-spot-on {
  box-shadow: 0 0 0 200vmax rgba(0, 6, 19, 0.72), 0 0 0 3px var(--accent-light), 0 0 26px 6px rgba(51, 160, 253, 0.55);
  animation: tr-pulse 1.6s ease-in-out infinite;
}

@keyframes tr-pulse {
  0%, 100% { outline: 0 solid rgba(51, 160, 253, 0.45); outline-offset: 0; }
  50% { outline: 6px solid rgba(51, 160, 253, 0); outline-offset: 6px; }
}

.tr-spot.tr-spot-on.tr-spot-group {
  box-shadow: 0 0 0 200vmax rgba(0, 6, 19, 0.72);
  animation: none;
}

.tr-ring {
  position: fixed;
  z-index: 10001;
  border-radius: 10px;
  pointer-events: none;
  box-shadow: 0 0 0 3px var(--accent-light), 0 0 18px 4px rgba(51, 160, 253, 0.5);
  animation: tr-pulse 1.6s ease-in-out infinite;
}

.tr-coach {
  position: fixed;
  z-index: 10002;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  max-width: calc(100vw - 16px);
  transition: left 0.7s ease-in-out, top 0.7s ease-in-out;
}

.tr-coach.tr-no-anim {
  transition: none;
}

.tr-bot {
  width: 104px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.45));
  animation: assistant-idle-bob 2.6s ease-in-out infinite;
  user-select: none;
  pointer-events: none;
}

.tr-bot.tr-bot-flip {
  transform: scaleX(-1);
  animation: none;
}

.tr-speech {
  position: relative;
  width: 340px;
  max-width: calc(100vw - 132px);
  margin-bottom: 30px;
  padding: 14px 16px 12px;
  background: #ffffff;
  color: #0f1720;
  border: 3px solid #0f1720;
  border-radius: 18px;
  box-shadow: 0 6px 0 #0f1720, 0 14px 36px rgba(0, 0, 0, 0.35);
  font-family: var(--font-sans);
  animation: tr-pop 0.25s ease-out;
}

/* speech tail pointing at CoffeeBot */
.tr-speech::before {
  content: '';
  position: absolute;
  left: -16px;
  bottom: 22px;
  border-width: 10px 16px 10px 0;
  border-style: solid;
  border-color: transparent #0f1720 transparent transparent;
}

.tr-speech::after {
  content: '';
  position: absolute;
  left: -10px;
  bottom: 24px;
  border-width: 8px 12px 8px 0;
  border-style: solid;
  border-color: transparent #ffffff transparent transparent;
}

@keyframes tr-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tr-speech-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.tr-chapter {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.tr-voice {
  width: 28px;
  height: 28px;
  padding: 4px;
  border: none;
  border-radius: 50%;
  background: var(--surface-alt);
  color: #0f1720;
  cursor: pointer;
}

.tr-voice svg {
  width: 100%;
  height: 100%;
}

.tr-text {
  font-size: 15px;
  line-height: 1.5;
  min-height: 46px;
  cursor: default;
}

.tr-text strong {
  color: var(--accent);
}

.tr-progress {
  height: 4px;
  margin: 12px 0 10px;
  border-radius: 2px;
  background: var(--surface-container);
  overflow: hidden;
}

.tr-progress span {
  display: block;
  height: 100%;
  background: var(--accent-light);
  transition: width 0.3s ease;
}

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

.tr-gap {
  flex: 1;
}

.tr-actions button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.tr-later,
.tr-skip {
  background: none;
  border: none;
  color: var(--secondary);
  padding-left: 0 !important;
  padding-right: 6px !important;
  text-decoration: underline;
}

.tr-back {
  background: var(--surface-alt);
  border: 1px solid var(--outline-variant);
  color: #0f1720;
}

.tr-back:disabled {
  opacity: 0.4;
  cursor: default;
}

.tr-next {
  min-width: 72px;
}

@media (max-width: 480px) {
  .tr-bot {
    width: 72px;
  }

  .tr-speech {
    max-width: calc(100vw - 96px);
  }
}

/* ==========================================================================
   UX pass (2026-09): dark-mode contrast, popup sizes, motion
   ========================================================================== */

/* ---- Dark-mode contrast. Several components colour their text with
   var(--primary) (near-black), which disappears on the dark surfaces. ---- */
.dark-mode .btn-primary {
  background: var(--accent);
  color: #fff;
}
.dark-mode .btn-primary:hover {
  background: var(--accent-light);
}
.dark-mode .btn-secondary {
  color: var(--dark-text);
  border-color: var(--dark-outline);
}
.dark-mode .btn-secondary:hover {
  background: var(--dark-surface-container);
  border-color: var(--accent-light);
}
.dark-mode th,
.dark-mode th.sortable {
  color: var(--secondary-dim);
}
.dark-mode .content a:not([class]),
.dark-mode .modal a:not([class]) {
  color: var(--accent-light);
}
.dark-mode .pd-tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent-light);
}
.dark-mode .planner-resource-avatar {
  color: var(--dark-text);
}
.dark-mode .modal {
  background: rgba(0, 0, 0, 0.72);
}
/* The login page is always light, so undo the dark-mode label/input colours there. */
.dark-mode #login label {
  color: #1E293B;
}
.dark-mode #login input {
  background: #fff;
  color: #1E293B;
  border-color: var(--outline-variant);
}

/* ---- Popup sizes: small / medium (default) / large / full ---- */
.modal-content.modal-sm { width: min(440px, 94vw); max-width: 440px; }
.modal-content.modal-lg { width: min(880px, 94vw); max-width: 880px; }
.modal-content.modal-full { width: 96vw; max-width: 1280px; max-height: 92vh; }

/* Keep a long form's submit button in view: it sticks to the bottom of the
   scrolling popup instead of hiding below the fold. The shadow "halo" paints
   the popup background behind it so scrolled content doesn't show through. */
.modal-content > form > button[type="submit"]:last-child,
.modal-content > form > .form-actions:last-child {
  position: sticky;
  bottom: calc(-1 * var(--margin-desktop) + 12px);
  z-index: 2;
  box-shadow: 0 0 0 12px var(--surface);
}
.dark-mode .modal-content > form > button[type="submit"]:last-child,
.dark-mode .modal-content > form > .form-actions:last-child {
  box-shadow: 0 0 0 12px var(--dark-surface-container);
}

/* ---- Popup open animation ---- */
@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-content-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.modal.active {
  animation: modal-backdrop-in 0.15s ease-out;
}
.modal.active > .modal-content {
  animation: modal-content-in 0.18s ease-out;
}

/* ---- Clickable list rows ---- */
tr.row-link {
  cursor: pointer;
}
tr.row-link:hover td {
  background: var(--surface-alt);
}
.dark-mode tr.row-link:hover td {
  background: var(--dark-surface-container);
}
.lead-actions-cell {
  white-space: nowrap;
  flex-wrap: nowrap;
}

/* ---- Record links inside text (invoice -> project, project -> client, ...) ---- */
.record-link {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.record-link:hover {
  text-decoration: underline;
}
.dark-mode .record-link {
  color: var(--accent-light);
}

/* ---- Respect "reduce motion" everywhere, not just a few components ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Compact KPI tiles on list pages: icon beside the number, so the
   list itself starts higher up the page. ---- */
.kpi-card {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  padding: 12px 16px;
}
.kpi-card .kpi-icon {
  grid-row: 1 / span 2;
  margin-bottom: 0;
}
.kpi-card .kpi-label {
  margin-bottom: 2px;
}
.dark-mode .kpi-icon {
  background: rgba(255, 255, 255, 0.06);
  color: var(--primary-dim);
}
.dark-mode .kpi-value {
  color: var(--primary-dim);
}

@media (max-width: 640px) {
  /* Three small tiles in one row instead of three full-width cards. */
  .grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .kpi-card {
    display: block;
    padding: 10px;
  }
  .kpi-card .kpi-icon {
    display: none;
  }
  .kpi-card .kpi-label {
    font-size: 10px;
  }
  .kpi-card .kpi-value {
    font-size: 16px;
    overflow-wrap: anywhere;
  }
}

/* ---- Phone layout for lists: each row becomes a card of "label: value"
   lines instead of a table that scrolls sideways. ---- */
@media (max-width: 640px) {
  table.sft-table,
  table.sft-table tbody,
  table.sft-table tr,
  table.sft-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  table.sft-table td {
    overflow-wrap: anywhere;
  }
  table.sft-table thead tr:first-child {
    display: none;
  }
  table.sft-table thead tr.filter-row,
  table.sft-table thead tr:nth-child(2) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
  }
  table.sft-table thead th:empty {
    display: none;
  }
  table.sft-table tbody tr {
    border: 1px solid var(--outline-variant);
    border-radius: var(--radius-card);
    padding: 8px 12px;
    margin-bottom: 10px;
    background: var(--surface);
  }
  .dark-mode table.sft-table tbody tr {
    border-color: var(--dark-outline);
    background: var(--dark-surface-container);
  }
  table.sft-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    border: none;
    text-align: right;
  }
  table.sft-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--secondary);
    text-align: left;
  }
  table.sft-table tbody td[data-label="Action"]::before,
  table.sft-table tbody td:not([data-label])::before {
    content: none;
  }
  table.sft-table tbody td[data-label="Action"] {
    justify-content: flex-end;
  }
}

/* Record windows use the whole screen on a phone. */
@media (max-width: 640px) {
  .modal-content.modal-fullscreen,
  .modal-content.modal-full,
  .modal-content.lead-view-modal-content,
  .modal-content.client-view-modal-content,
  .modal-content.quote-view-modal-content {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* ---- Sidebar group headings (Sales / Delivery / Finance / ...) ---- */
.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary-dim);
  padding: 14px 16px 4px;
}
.sidebar.collapsed .sidebar-nav .nav-group-label {
  display: block;
  height: 1px;
  padding: 0;
  margin: 8px 12px;
  background: var(--outline-variant);
  font-size: 0;
}
.dark-mode .sidebar.collapsed .sidebar-nav .nav-group-label {
  background: var(--dark-outline);
}
.sidebar-nav .nav-item {
  padding-top: 9px;
  padding-bottom: 9px;
}

/* ---- Lead -> Client -> Quote -> Project -> Invoiced -> Paid stepper ---- */
.flow-stepper {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 16px;
  font-size: 12px;
  font-weight: 600;
}
.flow-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  color: var(--secondary);
  background: var(--surface-alt);
}
.flow-step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--surface-container-high);
}
.flow-step-done { color: var(--success-text); background: var(--success-bg); }
.flow-step-done .flow-step-dot { background: var(--success); color: #fff; }
.flow-step-current { color: #fff; background: var(--accent); }
.flow-step-current .flow-step-dot { background: rgba(255, 255, 255, 0.25); color: #fff; }
.flow-step-link { cursor: pointer; }
.flow-step-link:hover { text-decoration: underline; }
.flow-step-sep {
  width: 14px;
  height: 2px;
  background: var(--outline-variant);
}
.dark-mode .flow-step { background: var(--dark-surface-container); color: var(--secondary-dim); }
.dark-mode .flow-step-dot { background: var(--dark-outline); }
.dark-mode .flow-step-done { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.dark-mode .flow-step-current { background: var(--accent); color: #fff; }
.dark-mode .flow-step-sep { background: var(--dark-outline); }

/* The top bar already names the page; don't repeat it as a big heading. */
.section-header .section-title {
  display: none;
}

/* Row-level delete buttons: quiet outline instead of a solid red block on every line. */
td .btn-small.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.45);
}
td .btn-small.btn-danger:hover {
  background: var(--error);
  color: #fff;
}

/* Loading placeholders: grey bars instead of "Loading..." text. */
.skeleton-bar {
  display: block;
  height: 12px;
  margin: 10px auto;
  width: 70%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-container) 25%, var(--surface-container-high) 50%, var(--surface-container) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-bar + .skeleton-bar { width: 55%; }
.skeleton-bar + .skeleton-bar + .skeleton-bar { width: 40%; }
.dark-mode .skeleton-bar {
  background: linear-gradient(90deg, var(--dark-surface-container) 25%, var(--dark-outline) 50%, var(--dark-surface-container) 75%);
  background-size: 200% 100%;
}
@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Room under the last list row so the floating assistant never covers its buttons. */
.content {
  padding-bottom: 140px;
}
@media (max-width: 640px) {
  .assistant-bubble {
    width: 60px;
    height: 82px;
  }
  .assistant-panel {
    bottom: 88px;
  }
}
