/* Phase 18: shared, text-first visual refinement for CRM workspaces. */
:root {
  --crm-ink: #19324d;
  --crm-muted: #68798a;
  --crm-line: #dfe5e9;
  --crm-paper: #fff;
  --crm-canvas: #f3f5f6;
  --crm-primary: #254a6d;
  --crm-radius: 12px;
  --crm-shadow: 0 2px 8px rgba(23, 46, 68, .045);
}

/* 01. Calm, neutral page canvas */
body[data-page-mode="standalone"] { color:var(--crm-ink); background:var(--crm-canvas); }
/* 02. Consistent content width and page gutters */
body[data-page-mode="standalone"] .main-content { width:min(100%, 1680px); margin-inline:auto; padding:16px clamp(12px, 1.7vw, 24px) 36px; }
/* Let short pages end with their content instead of stretching to a full viewport. */
body[data-page-mode="standalone"] .app-shell { min-height: 0; }
/* 03. Predictable vertical rhythm */
body[data-page-mode="standalone"] .main-content { gap:14px; }
/* 04. Simple, aligned page headers */
body[data-page-mode="standalone"] .topbar { min-height:58px; padding:11px 16px; border:1px solid var(--crm-line); border-radius:var(--crm-radius); background:var(--crm-paper); box-shadow:var(--crm-shadow); }
/* 05. Consistent title hierarchy */
body[data-page-mode="standalone"] :is(.topbar h2,.panel h3,.hero-card h3,.panel-head h2,.panel-head h3) { color:var(--crm-ink); line-height:1.45; }
body[data-page-mode="standalone"] .topbar h2 { font-size:1.12rem; font-weight:750; }
/* 06. Standardize content cards, retaining all existing cards */
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card,.table-card,.section-card) { min-width:0; border:1px solid var(--crm-line); border-radius:var(--crm-radius); background:var(--crm-paper); box-shadow:var(--crm-shadow); }
/* 07. Normalize card padding */
body[data-page-mode="standalone"] :is(.panel,.hero-card) { padding:16px; }
/* 08. Give section headers a consistent divider and spacing */
body[data-page-mode="standalone"] :is(.panel-head,.section-head) { min-width:0; gap:10px; margin-bottom:12px; padding-bottom:9px; border-bottom:1px solid #e9edf0; }
/* 09. Improve supporting text contrast and line height */
body[data-page-mode="standalone"] :is(.subtle,.eyebrow,small,.hint) { color:var(--crm-muted); line-height:1.6; }
/* 10. Make all grids tolerate long Arabic labels and values */
body[data-page-mode="standalone"] :is(.dashboard-grid,.split-grid,.stats-grid,.form-grid,.content-grid) > * { min-width:0; }
body[data-page-mode="standalone"] :is(.panel,.stat-card,.category-card) { overflow-wrap:anywhere; }
/* 11. Normalize form spacing */
body[data-page-mode="standalone"] :is(.form-grid,.form-row,.filters-row) { gap:10px; }
/* 12. Make inputs consistent and readable */
body[data-page-mode="standalone"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select,textarea) { min-width:0; max-width:100%; border:1px solid #d6dfe5; border-radius:8px; background:#fff; color:var(--crm-ink); box-shadow:none; }
body[data-page-mode="standalone"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select) { min-height:40px; }
/* 13. Clear keyboard focus without decorative effects */
body[data-page-mode="standalone"] :is(input,select,textarea,button,a,[tabindex]):focus-visible { outline:2px solid #50789b; outline-offset:2px; box-shadow:none; }
/* 14. Consistent action sizing */
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn) { min-height:36px; border-radius:8px; font-weight:700; box-shadow:none; }
body[data-page-mode="standalone"] .primary-btn { background:var(--crm-primary); border-color:var(--crm-primary); }
body[data-page-mode="standalone"] .ghost-btn { border-color:#d6dfe5; background:#fff; }
/* 15. Remove ornamental button movement */
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn):hover { transform:none; box-shadow:none; }
/* 16. Present tables as readable, stable work surfaces */
body[data-page-mode="standalone"] .table-wrap { min-width:0; max-width:100%; overflow:auto; border:1px solid var(--crm-line); border-radius:10px; background:#fff; }
body[data-page-mode="standalone"] .data-table { border-collapse:collapse; }
body[data-page-mode="standalone"] .data-table th { background:#f2f5f7; color:var(--crm-ink); font-weight:750; }
body[data-page-mode="standalone"] .data-table :is(th,td) { padding:10px 11px; border-bottom:1px solid #e8ecef; vertical-align:middle; }
/* 17. Keep row hover restrained and non-animated */
body[data-page-mode="standalone"] .data-table tbody tr:hover { background:#f7f9fa; }
/* 18. Keep badges textual, compact, and consistent */
body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip) { max-width:100%; border-radius:6px; box-shadow:none; }
/* 19. Quiet decorative metric symbols while retaining logos and property photography */
body[data-page-mode="standalone"] :is(.dashboard-shortcut-icon,.metric-icon,.target-metric-icon,.projects-overview-icon,.history-mark) { display:none !important; }
/* 20. Keep cards still and visually simple */
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card)::before,
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card)::after { animation:none !important; }
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card) { animation:none !important; transition:none !important; }
/* 21. Keep charts and property photography intact while removing ornamental page backgrounds. */
body[data-page-mode="standalone"] { background-image:none; }
body[data-page-mode="standalone"] :is(.overview-hero,.analytics-hero,.targets-hero,.projects-premium-hero) { box-shadow:none; }
@media (max-width:760px) {
  body[data-page-mode="standalone"] .main-content { padding-inline:12px; }
  body[data-page-mode="standalone"] :is(.dashboard-grid,.split-grid,.stats-grid) { grid-template-columns:minmax(0,1fr); }
  body[data-page-mode="standalone"] :is(.panel,.hero-card) { padding:13px; }
  body[data-page-mode="standalone"] .panel-head { align-items:flex-start; flex-wrap:wrap; }
}
@media (prefers-reduced-motion:reduce) {
  body[data-page-mode="standalone"] *, body[data-page-mode="standalone"] *::before, body[data-page-mode="standalone"] *::after { scroll-behavior:auto !important; animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}

/* Phase 19: another 20 restrained refinements for everyday CRM screens. */
/* 22. Align header content and actions consistently */
body[data-page-mode="standalone"] .topbar { display:flex; align-items:center; justify-content:space-between; gap:12px; }
/* 23. Keep header action groups readable when they wrap */
body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions,.row-actions) { display:flex; flex-wrap:wrap; align-items:center; gap:7px; min-width:0; }
/* 24. Make form labels easier to scan */
body[data-page-mode="standalone"] :is(.form-grid label,.form-row label,.filters-row label) { min-width:0; color:var(--crm-muted); font-size:.8rem; font-weight:650; line-height:1.5; }
/* 25. Keep input text and placeholders legible */
body[data-page-mode="standalone"] :is(input,select,textarea)::placeholder { color:#8795a2; opacity:1; }
body[data-page-mode="standalone"] :is(input,select,textarea):disabled { color:#75818c; background:#f0f2f3; cursor:not-allowed; }
/* 26. Make validation states clear without decoration */
body[data-page-mode="standalone"] :is(input,select,textarea)[aria-invalid="true"],
body[data-page-mode="standalone"] :is(input,select,textarea).is-invalid { border-color:#b84747; }
/* 27. Give checkboxes and radio controls a consistent accent */
body[data-page-mode="standalone"] :is(input[type="checkbox"],input[type="radio"]) { accent-color:var(--crm-primary); }
/* 28. Keep numeric values aligned */
body[data-page-mode="standalone"] :is(.data-table,.stat-card,.metric-value) { font-variant-numeric:tabular-nums; }
/* 29. Prevent long table values from stretching the whole page */
body[data-page-mode="standalone"] .data-table :is(th,td) { max-width:360px; overflow-wrap:anywhere; }
/* 30. Separate table headers from data with a quiet fixed header */
body[data-page-mode="standalone"] .data-table thead th { position:sticky; top:0; z-index:2; }
/* 31. Make table action columns compact */
body[data-page-mode="standalone"] .data-table td :is(.row-actions,.table-actions) { justify-content:flex-start; gap:5px; }
/* 32. Standardize status labels without adding symbols */
body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip) { display:inline-flex; align-items:center; min-height:24px; padding:3px 8px; border:1px solid var(--crm-line); background:#f5f7f8; color:var(--crm-ink); font-size:.72rem; font-weight:700; line-height:1.35; }
/* 33. Give empty states a clear text-first frame */
body[data-page-mode="standalone"] :is(.empty-state,.empty-row,.no-data) { border:1px dashed #ccd6dd; border-radius:10px; background:#fafbfc; color:var(--crm-muted); line-height:1.7; }
/* 34. Normalize modal and drawer surfaces */
body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel,.client-drawer,.workspace-page-modal-panel) { border:1px solid var(--crm-line); border-radius:14px; background:var(--crm-paper); color:var(--crm-ink); box-shadow:0 12px 32px rgba(23,46,68,.12); }
/* 35. Keep modal headings and body content spaced */
body[data-page-mode="standalone"] :is(.modal-header,.drawer-header,.dialog-header) { gap:10px; padding-bottom:10px; border-bottom:1px solid var(--crm-line); }
body[data-page-mode="standalone"] :is(.modal-body,.drawer-body,.dialog-body) { line-height:1.65; }
/* 36. Keep inline notices readable and text-led */
body[data-page-mode="standalone"] :is(.notice,.alert,.callout,.form-message) { border-radius:8px; box-shadow:none; line-height:1.6; }
/* 37. Prevent long Arabic content from overflowing cards */
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card,.modal-content) :is(p,small,strong,span) { min-width:0; overflow-wrap:anywhere; }
/* 38. Make section separators consistent */
body[data-page-mode="standalone"] hr { height:1px; border:0; background:var(--crm-line); }
/* 39. Keep pagination and tab controls compact */
body[data-page-mode="standalone"] :is(.pagination,.tabs,.tab-list) { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
/* 40. Use the same quiet canvas in print while preserving real data visuals */
@media print {
  body[data-page-mode="standalone"] { background:#fff !important; color:#111 !important; }
  body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card,.table-card) { box-shadow:none !important; break-inside:avoid; }
  body[data-page-mode="standalone"] .data-table :is(th,td) { color:#111 !important; border-color:#999 !important; }
}
/* 41. Respect the existing dark theme with the same restrained hierarchy. */
html[data-theme="dark"] {
  --crm-ink:#e2eaf1;
  --crm-muted:#a9b7c4;
  --crm-line:#354454;
  --crm-paper:#172330;
  --crm-canvas:#111a23;
  --crm-primary:#85b1d3;
  --crm-shadow:0 2px 8px rgba(0,0,0,.14);
}
html[data-theme="dark"] body[data-page-mode="standalone"] { background:var(--crm-canvas); color:var(--crm-ink); }
html[data-theme="dark"] body[data-page-mode="standalone"] :is(.topbar,.panel,.hero-card,.stat-card,.category-card,.table-card,.section-card,.modal-content,.modal-panel,.drawer-panel,.client-drawer,.workspace-page-modal-panel) { background:var(--crm-paper); border-color:var(--crm-line); color:var(--crm-ink); }
html[data-theme="dark"] body[data-page-mode="standalone"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),select,textarea) { background:#111a23; border-color:var(--crm-line); color:var(--crm-ink); }
html[data-theme="dark"] body[data-page-mode="standalone"] .data-table th { background:#223140; color:var(--crm-ink); }
html[data-theme="dark"] body[data-page-mode="standalone"] .data-table td { background:var(--crm-paper); color:var(--crm-ink); border-color:var(--crm-line); }
html[data-theme="dark"] body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip,.empty-state,.empty-row,.no-data) { background:#202d39; border-color:var(--crm-line); color:var(--crm-ink); }

/* Phase 20: 20 additional layout and readability refinements. */
/* 42. Normalize table row vertical alignment */
body[data-page-mode="standalone"] .data-table tbody tr > td { vertical-align:middle; }
/* 43. Keep table row heights steady */
body[data-page-mode="standalone"] .data-table tbody tr { height:46px; }
/* 44. Center short state and stage values */
body[data-page-mode="standalone"] .data-table td[data-label="المرحلة"],
body[data-page-mode="standalone"] .data-table td[data-label="Stage"] { text-align:center; }
/* 45. Reduce visual weight on secondary table labels */
body[data-page-mode="standalone"] .data-table td small { color:var(--crm-muted); font-size:.74rem; }
/* 46. Keep linked text visible without default underlines */
body[data-page-mode="standalone"] :is(.panel,.table-wrap) a:not(.button):not(.primary-btn):not(.ghost-btn) { color:var(--crm-primary); text-decoration-thickness:1px; text-underline-offset:2px; }
/* 47. Preserve visible keyboard focus on rows */
body[data-page-mode="standalone"] .data-table tbody tr:focus-within { outline:2px solid #7f9bb3; outline-offset:-2px; }
/* 48. Let table footers wrap without squeezing their controls */
body[data-page-mode="standalone"] :is(.table-footer,.clients-table-footer,.table-pagination) { display:flex; align-items:center; flex-wrap:wrap; gap:9px; }
/* 49. Keep filter groups aligned across pages */
body[data-page-mode="standalone"] :is(.filters-row,.filter-actions,.clients-toolbar-actions) { align-items:center; }
/* 50. Match filter control heights */
body[data-page-mode="standalone"] :is(.filters-row,.clients-toolbar-actions) :is(input,select,button) { min-height:38px; }
/* 51. Make active tabs use a restrained solid fill */
body[data-page-mode="standalone"] :is(.tab-btn,.clients-view-btn,[role="tab"]).active { border-color:var(--crm-primary); color:#fff; background:var(--crm-primary); }
/* 52. Keep inactive tabs clear */
body[data-page-mode="standalone"] :is(.tab-btn,.clients-view-btn,[role="tab"]):not(.active) { border:1px solid var(--crm-line); background:var(--crm-paper); }
/* 53. Provide clear pressed states without movement */
body[data-page-mode="standalone"] :is(button,.button):active { filter:brightness(.96); transform:none; }
/* 54. Make destructive actions clear through text color */
body[data-page-mode="standalone"] :is(button,a).danger,
body[data-page-mode="standalone"] .danger-text-btn { color:#a6383f; }
/* 55. Keep selection controls centered in their cells */
body[data-page-mode="standalone"] .data-table td:has(> input[type="checkbox"]),
body[data-page-mode="standalone"] .data-table th:has(> input[type="checkbox"]) { text-align:center; }
/* 56. Give textareas room for multi-line notes */
body[data-page-mode="standalone"] textarea { min-height:88px; line-height:1.6; resize:vertical; }
/* 57. Keep long notes contained inside the existing column */
body[data-page-mode="standalone"] :is(.client-last-comment-text,.client-comment-cell-content) { min-width:0; overflow:hidden; text-overflow:ellipsis; }
/* 58. Clarify disabled states while preserving contrast */
body[data-page-mode="standalone"] :is(button,.button,[role="button"]):disabled { opacity:.58; cursor:not-allowed; }
/* 59. Align modal footer actions */
body[data-page-mode="standalone"] :is(.modal-footer,.dialog-footer) { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; padding-top:10px; border-top:1px solid var(--crm-line); }
/* 60. Avoid splitting table headers during printing */
@media print { body[data-page-mode="standalone"] .data-table thead { display:table-header-group; } }
/* 61. Apply the same calmer, compact spacing on small screens */
@media (max-width:560px) {
  body[data-page-mode="standalone"] .data-table :is(th,td) { padding:8px 7px; }
  body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions) { width:100%; }
  body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions) > * { max-width:100%; }
}

/* Requested client stage control: one full-width centered cell with clipped text. */
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(1) { width:3% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(2) { width:7% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(3) { width:17% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(4) { width:9% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(5) { width:8% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(6) { width:12% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:14% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(8) { width:8% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:22% !important; }
body[data-page-section="clients"] table.clients-table tbody tr > td:nth-child(6) { padding-inline:5px !important; text-align:center !important; }
body[data-page-section="clients"] .table-stage-badge {
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:6px;
  width:100% !important;
  min-width:0 !important;
  max-width:100% !important;
  min-height:32px;
  padding:4px 7px !important;
  position:relative;
  overflow:hidden;
  border-radius:7px !important;
  text-align:center;
  white-space:nowrap;
  cursor:help;
}
body[data-page-section="clients"] .table-stage-badge .lamp { position:absolute; inset-inline-start:7px; flex:0 0 9px; width:9px; height:9px; margin:0; }
body[data-page-section="clients"] .table-stage-badge .stage-badge-text { display:block; width:100%; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:center; }
body[data-page-section="clients"] .table-stage-badge:focus-visible { outline:2px solid #50789b; outline-offset:2px; }
@media (max-width:760px) {
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(6) { width:15% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:16% !important; }
  body[data-page-section="clients"] .table-stage-badge { min-height:30px; gap:4px; padding-inline:4px !important; }
  body[data-page-section="clients"] .table-stage-badge .lamp { inset-inline-start:4px; }
}

/* Screenshot follow-up: keep row actions compact so they do not stretch rows. */
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(1) { width:3% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(2) { width:7% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(3) { width:17% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(4) { width:9% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(5) { width:8% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(6) { width:12% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:14% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(8) { width:8% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:22% !important; }
body[data-page-section="clients"] table.clients-table td:nth-child(9) { overflow:visible !important; }
body[data-page-section="clients"] .row-action-wrap {
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  flex-wrap:nowrap !important;
  gap:4px !important;
  width:100% !important;
  min-width:0 !important;
  white-space:nowrap !important;
}
body[data-page-section="clients"] .row-action-wrap > button { flex:0 1 auto !important; min-width:0 !important; max-width:100%; margin:0 !important; padding-inline:7px !important; white-space:nowrap !important; }
body[data-page-section="clients"] .row-action-wrap > .mobile-client-feedback-btn { min-width:76px !important; padding-inline:9px !important; }
body[data-page-section="clients"] .row-action-wrap > .tiny-icon-btn { flex:0 0 30px !important; width:30px !important; min-width:30px !important; height:30px !important; min-height:30px !important; padding:0 !important; }
@media (max-width:760px) {
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:auto !important; }
  body[data-page-section="clients"] table.clients-table td:nth-child(9) .row-action-wrap { justify-content:flex-start !important; flex-wrap:wrap !important; }
}
body[data-page-section="clients"] table.clients-table { width:100% !important; min-width:100% !important; table-layout:fixed !important; }
/* Keep contact actions visible and give comments a practical share of the row. */
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:18% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(8) { width:12% !important; }
body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:14% !important; }
body[data-page-section="clients"] table.clients-table td.phone-actions-cell { display:table-cell !important; overflow:visible !important; white-space:nowrap !important; }
body[data-page-section="clients"] table.clients-table td.phone-actions-cell > .video-call-wrap { display:inline-flex !important; visibility:visible !important; opacity:1 !important; position:relative !important; vertical-align:middle !important; }
body[data-page-section="clients"] table.clients-table td.phone-actions-cell .video-trigger { display:inline-flex !important; visibility:visible !important; opacity:1 !important; align-items:center !important; justify-content:center !important; }
body[data-page-section="clients"] table.clients-table td.phone-actions-cell .video-trigger-icon,
body[data-page-section="clients"] table.clients-table td.phone-actions-cell .video-trigger-icon svg { display:block !important; visibility:visible !important; opacity:1 !important; }
body[data-page-section="clients"] .row-action-wrap > .mobile-client-feedback-btn { display:none !important; }
@media (max-width:760px) {
  body[data-page-section="clients"] table.clients-table { width:max-content !important; min-width:100% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(1) { width:36px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(2) { width:60px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(3) { width:180px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(4) { width:135px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(5) { width:125px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(6) { width:135px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:200px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(8) { width:130px !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:220px !important; }
}

/* Phase 21: another 20 restrained visual refinements across CRM pages. */
/* 62. Keep dashboard columns balanced */
body[data-page-section="overview"] .dashboard-grid { align-items:stretch; }
/* 63. Align card headers across dashboard panels */
body[data-page-mode="standalone"] :is(.panel-head,.section-head) { align-items:center; }
/* 64. Let long Arabic headings wrap cleanly */
body[data-page-mode="standalone"] :is(h1,h2,h3,h4,.panel-head strong) { min-width:0; overflow-wrap:anywhere; }
/* 65. Keep KPI values readable and aligned */
body[data-page-mode="standalone"] :is(.stat-card,.overview-metric-card,.analytics-stat-card) strong { display:block; line-height:1.3; font-variant-numeric:tabular-nums; }
/* 66. Normalize KPI label spacing */
body[data-page-mode="standalone"] :is(.stat-card,.overview-metric-card,.analytics-stat-card) .eyebrow { margin:0 0 5px; }
/* 67. Keep card descriptions easy to scan */
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card) p { line-height:1.65; }
/* 68. Make panel content grids align at the top */
body[data-page-mode="standalone"] :is(.dashboard-grid,.split-grid,.content-grid) { align-items:start; }
/* 69. Prevent forms from forcing cards wider than the viewport */
body[data-page-mode="standalone"] :is(.form-grid,.form-row,.filters-row) > * { min-width:0; max-width:100%; }
/* 70. Give form captions consistent spacing */
body[data-page-mode="standalone"] :is(.form-grid label,.form-row label) > span { margin-bottom:5px; line-height:1.5; }
/* 71. Keep search and filter bars from overflowing */
body[data-page-mode="standalone"] :is(.toolbar,.clients-toolbar,.clients-table-toolbar,.filters-row) { min-width:0; max-width:100%; }
/* 72. Align compact filter controls */
body[data-page-mode="standalone"] :is(.toolbar,.clients-toolbar,.filters-row) :is(input,select,button) { vertical-align:middle; }
/* 73. Make cards with actions keep a stable header layout */
body[data-page-mode="standalone"] :is(.panel-head,.section-head) > :first-child { flex:1 1 180px; }
body[data-page-mode="standalone"] :is(.panel-head,.section-head) > :last-child { flex:0 1 auto; }
/* 74. Keep text-only links visually distinct */
body[data-page-mode="standalone"] a:not([class]) { color:var(--crm-primary); text-underline-offset:2px; }
/* 75. Use restrained separators in stacked records */
body[data-page-mode="standalone"] :is(.stack-list,.timeline-list) > :is(article,li) + :is(article,li) { border-top:1px solid var(--crm-line); }
/* 76. Keep status text legible beside existing state colors */
body[data-page-mode="standalone"] :is(.status-text,.status-label,.performance-hit-badge) { font-weight:700; line-height:1.4; }
/* 77. Keep empty panels from collapsing */
body[data-page-mode="standalone"] :is(.empty-state,.empty-row,.no-data) { min-height:72px; padding:14px; text-align:center; }
/* 78. Keep dialog content within the visible screen */
body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel,.client-drawer,.workspace-page-modal-panel) { max-height:calc(100dvh - 28px); overflow:auto; }
/* 79. Keep page-level action groups readable on medium screens */
@media (max-width:980px) {
  body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions,.clients-toolbar-actions) { flex-wrap:wrap; }
  body[data-page-mode="standalone"] :is(.dashboard-grid,.split-grid) { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
/* 80. Give compact screens a clean single-column flow */
@media (max-width:620px) {
  body[data-page-mode="standalone"] :is(.dashboard-grid,.split-grid,.content-grid) { grid-template-columns:minmax(0,1fr); }
  body[data-page-mode="standalone"] :is(.topbar,.panel-head,.section-head) { align-items:flex-start; }
  body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions,.clients-toolbar-actions) { width:100%; }
}
/* 81. Keep printed records clean and readable */
@media print {
  body[data-page-mode="standalone"] :is(.topbar,.panel-head,.section-head) { color:#111 !important; background:#fff !important; }
  body[data-page-mode="standalone"] .data-table tbody tr { height:auto; }
}

/* Phase 22: 20 page-specific refinements for projects, analytics, overview, and targets. */
/* 82. Give the project catalog consistent card gaps */
body[data-page-section="projects"] .projects-cards-wrap .data-table tbody.projects-card-grid { gap:12px !important; }
/* 83. Keep project cards aligned to the same edge radius */
body[data-page-section="projects"] .project-list-card { border-radius:14px !important; box-shadow:var(--crm-shadow) !important; }
/* 84. Preserve property photography while standardizing its crop */
body[data-page-section="projects"] .project-list-card-cover { overflow:hidden; background-color:#e9edf0; }
body[data-page-section="projects"] .project-list-card-cover > img { width:100%; height:100%; object-fit:cover; }
/* 85. Normalize project card content padding */
body[data-page-section="projects"] .project-list-card-body { min-width:0; padding:14px !important; gap:9px !important; }
/* 86. Keep project card headings legible */
body[data-page-section="projects"] .project-list-card-heading h4 { line-height:1.45; overflow-wrap:anywhere; }
/* 87. Let project metadata wrap instead of widening cards */
body[data-page-section="projects"] :is(.project-list-card-meta,.project-list-card-footer) { min-width:0; flex-wrap:wrap; gap:7px; }
/* 88. Give project directories consistent section spacing */
body[data-page-section="projects"] :is(.projects-directory-panel,.directory-section) { margin-block:12px; }
/* 89. Keep developer project records aligned and text-first */
body[data-page-section="developer-detail"] .developer-linked-project-grid { align-items:stretch; gap:12px; }
/* 90. Match analytics panel spacing */
body[data-page-section="analytics"] :is(.analytics-main-grid,.analytics-money-grid,.analytics-insight-grid) { gap:12px; }
/* 91. Keep analytics filters aligned at the field baseline */
body[data-page-section="analytics"] .analytics-filter-grid { align-items:end; gap:9px; }
/* 92. Keep analytics charts within their panels */
body[data-page-section="analytics"] :is(.analytics-chart-panel,.analytics-progress-panel) { min-width:0; overflow:hidden; }
/* 93. Preserve readable chart proportions */
body[data-page-section="analytics"] :is(#analyticsChart,.analytics-chart-panel canvas) { display:block; max-width:100%; }
/* 94. Align analytics insight cards */
body[data-page-section="analytics"] .analytics-insight-grid > * { min-width:0; height:100%; line-height:1.6; }
/* 95. Keep overview KPI cards on a stable responsive grid */
body[data-page-section="overview"] #overviewStats { grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr)); align-items:stretch; }
/* 96. Give overview analysis cards consistent internal spacing */
body[data-page-section="overview"] .overview-work-analysis-grid > * { min-width:0; padding:12px; }
/* 97. Keep overview meeting rows readable */
body[data-page-section="overview"] .overview-meeting-table td { line-height:1.5; }
/* 98. Keep target metrics aligned without decorative movement */
body[data-page-section="targets"] .target-metric-grid > * { min-height:92px; padding:12px; animation:none !important; transform:none !important; }
/* 99. Align target history and log content */
body[data-page-section="targets"] .target-history-grid { align-items:start; gap:12px; }
/* 100. Keep target filters usable in narrow panels */
body[data-page-section="targets"] .target-filters > * { min-width:0; }
/* 101. Retain all columns and records on small project and analytics screens */
@media (max-width:760px) {
  body[data-page-section="projects"] .projects-cards-wrap .data-table tbody.projects-card-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:10px !important; }
  body[data-page-section="analytics"] :is(.analytics-main-grid,.analytics-money-grid) { grid-template-columns:minmax(0,1fr); }
}

/* Phase 23: 20 more practical visual refinements for daily CRM work. */
/* 102. Match form-control typography to the surrounding interface */
body[data-page-mode="standalone"] :is(input,select,textarea,button) { font-family:inherit; }
/* 103. Keep text fields readable at common zoom levels */
body[data-page-mode="standalone"] :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) { font-size:.88rem; line-height:1.45; }
/* 104. Keep multiline notes aligned to the top */
body[data-page-mode="standalone"] textarea { vertical-align:top; }
/* 105. Distinguish helper text from field values */
body[data-page-mode="standalone"] :is(.form-hint,.field-hint,.help-text) { display:block; margin-top:4px; color:var(--crm-muted); font-size:.73rem; line-height:1.55; }
/* 106. Keep grouped form sections clearly separated */
body[data-page-mode="standalone"] fieldset { min-width:0; border:1px solid var(--crm-line); border-radius:10px; }
/* 107. Keep fieldset captions aligned with form labels */
body[data-page-mode="standalone"] fieldset > legend { padding-inline:5px; color:var(--crm-muted); font-size:.78rem; font-weight:700; }
/* 108. Keep compact buttons from clipping localized labels */
body[data-page-mode="standalone"] :is(.tiny-btn,.ghost-btn,.primary-btn) { line-height:1.35; }
/* 109. Align button labels consistently */
body[data-page-mode="standalone"] button { text-align:center; }
/* 110. Keep grouped actions on consistent baselines */
body[data-page-mode="standalone"] :is(.row-actions,.toolbar-actions,.panel-actions) > * { flex:0 0 auto; }
/* 111. Let action groups wrap before they force horizontal page overflow */
body[data-page-mode="standalone"] :is(.row-actions,.toolbar-actions,.panel-actions) { max-width:100%; flex-wrap:wrap; }
/* 112. Keep compact tags from splitting across lines */
body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip) { white-space:nowrap; }
/* 113. Use stable row separators in text lists */
body[data-page-mode="standalone"] :is(.stack-list,.timeline-list) > :is(article,li) { min-width:0; padding-block:9px; }
/* 114. Preserve readable spacing in detail field groups */
body[data-page-mode="standalone"] :is(.detail-grid,.detail-fields,.record-details) { gap:9px; }
/* 115. Keep detail labels secondary and values prominent */
body[data-page-mode="standalone"] :is(.detail-field-card,.detail-field) > :first-child { color:var(--crm-muted); font-size:.76rem; }
body[data-page-mode="standalone"] :is(.detail-field-card,.detail-field) > :last-child { color:var(--crm-ink); line-height:1.5; }
/* 116. Keep long record identifiers from breaking the layout */
body[data-page-mode="standalone"] :is(.record-id,.client-code,.project-code) { overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
/* 117. Keep secondary data columns visually quiet */
body[data-page-mode="standalone"] .data-table td[data-secondary="true"] { color:var(--crm-muted); }
/* 118. Keep table content within its own cell */
body[data-page-mode="standalone"] .data-table td > :is(div,span,p) { min-width:0; max-width:100%; }
/* 119. Keep compact table action controls centered */
body[data-page-mode="standalone"] .data-table td :is(.row-action-wrap,.table-actions) { align-items:center; }
/* 120. Make table footers separate from the final record */
body[data-page-mode="standalone"] :is(.table-footer,.clients-table-footer) { border-top:1px solid var(--crm-line); }
/* 121. Simplify cards and controls further on small screens */
@media (max-width:560px) {
  body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip) { font-size:.68rem; }
  body[data-page-mode="standalone"] :is(.detail-grid,.detail-fields,.record-details) { grid-template-columns:minmax(0,1fr); }
  body[data-page-mode="standalone"] :is(.table-footer,.clients-table-footer) { align-items:flex-start; }
}

/* Final client table balance: 100% total across all nine columns. */
@media (min-width:761px) {
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(1) { width:3% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(2) { width:7% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(3) { width:17% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(4) { width:9% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(5) { width:8% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(6) { width:12% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(7) { width:18% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(8) { width:12% !important; }
  body[data-page-section="clients"] table.clients-table :is(th,td):nth-child(9) { width:14% !important; }
}

/* Keep the user's requested feedback action out of regular client rows. */
body[data-page-section="clients"] .row-action-wrap > .mobile-client-feedback-btn { display:none !important; }

/* Phase 24: 20 clean, text-first visual refinements. */
/* 122. Keep client contact actions on one visible line. */
body[data-page-section="clients"] .phone-actions-cell { white-space:nowrap !important; overflow:visible !important; }
/* 123. Keep the video call control available beside call and messaging. */
body[data-page-section="clients"] .phone-actions-cell .video-call-wrap,
body[data-page-section="clients"] .phone-actions-cell .video-trigger { display:inline-flex !important; visibility:visible !important; opacity:1 !important; }
/* 124. Keep feedback text inside its existing cell without narrowing comments. */
body[data-page-section="clients"] .client-last-comment { min-width:0; }
/* 125. Let comment copy use the available width. */
body[data-page-section="clients"] .client-comment-cell-content { min-width:0; width:100%; }
/* 126. Keep comments readable while containing long text. */
body[data-page-section="clients"] .client-last-comment-text { min-width:0; overflow:hidden; text-overflow:ellipsis; }
/* 127. Keep table headers aligned with their column content. */
body[data-page-mode="standalone"] .data-table thead th { vertical-align:middle; line-height:1.4; }
/* 128. Make table rows easier to scan. */
body[data-page-mode="standalone"] .data-table tbody tr > td { line-height:1.45; }
/* 129. Maintain consistent spacing between card sections. */
body[data-page-mode="standalone"] :is(.panel,.hero-card,.table-card) + :is(.panel,.hero-card,.table-card) { margin-top:0; }
/* 130. Keep card headings from colliding with adjacent actions. */
body[data-page-mode="standalone"] :is(.panel-head,.section-head) > :first-child { min-width:0; flex:1 1 auto; }
/* 131. Align form control text vertically. */
body[data-page-mode="standalone"] :is(input,select) { line-height:1.4; }
/* 132. Keep validation messages readable below their fields. */
body[data-page-mode="standalone"] :is(.error-message,.validation-message) { display:block; margin-top:4px; line-height:1.5; }
/* 133. Keep secondary buttons visually distinct from primary actions. */
body[data-page-mode="standalone"] .ghost-btn { color:var(--crm-ink); }
/* 134. Keep primary action labels legible. */
body[data-page-mode="standalone"] .primary-btn { color:#fff; }
/* 135. Preserve readable contrast for muted text. */
body[data-page-mode="standalone"] :is(.subtle,.eyebrow,small,.hint) { opacity:1; }
/* 136. Keep long navigation labels from widening the sidebar. */
body[data-page-mode="standalone"] :is(.sidebar,.side-nav) :is(a,button) { min-width:0; overflow-wrap:anywhere; }
/* 137. Keep horizontal filter bars usable on smaller screens. */
@media (max-width:760px) { body[data-page-mode="standalone"] :is(.filters-row,.filter-actions) { flex-wrap:wrap; } }
/* 138. Keep modal content within the viewport. */
body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel) { max-width:calc(100vw - 24px); }
/* 139. Keep long modal titles within their header. */
body[data-page-mode="standalone"] :is(.modal-header,.drawer-header) > :first-child { min-width:0; overflow-wrap:anywhere; }
/* 140. Align empty-state text within the existing content area. */
body[data-page-mode="standalone"] :is(.empty-state,.empty-row,.no-data) { text-align:center; padding:16px; }
/* 141. Keep printable card surfaces simple. */
@media print { body[data-page-mode="standalone"] :is(.panel,.hero-card,.table-card) { border-radius:0 !important; } }

/* Dynamic system phase 1: live connection and save status, using text only. */
body[data-page-mode="standalone"] .crm-live-system-status {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:32px;
  padding:5px 10px;
  border:1px solid var(--crm-line);
  border-radius:7px;
  background:var(--crm-paper);
  color:var(--crm-muted);
  font-size:.74rem;
  font-weight:700;
  line-height:1.35;
  white-space:nowrap;
}
body[data-page-mode="standalone"] .crm-live-system-status[data-state="connected"] { color:#27664d; border-color:#b8d5c6; background:#f3faf6; }
body[data-page-mode="standalone"] .crm-live-system-status[data-state="saving"],
body[data-page-mode="standalone"] .crm-live-system-status[data-state="connecting"] { color:#315e83; border-color:#bfd1df; background:#f3f8fb; }
body[data-page-mode="standalone"] .crm-live-system-status[data-state="offline"],
body[data-page-mode="standalone"] .crm-live-system-status[data-state="error"] { color:#98434a; border-color:#dfc0c2; background:#fff7f7; }
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-live-system-status { background:var(--crm-paper); border-color:var(--crm-line); }
@media (max-width:560px) { body[data-page-mode="standalone"] .crm-live-system-status { min-height:29px; padding:4px 7px; font-size:.68rem; } }

/* Dynamic system phase 2: keyboard-first search across CRM records. */
body[data-page-mode="standalone"] .crm-global-search-trigger { display:inline-flex; align-items:center; gap:8px; }
body[data-page-mode="standalone"] .crm-global-search-trigger kbd { padding:2px 5px; border:1px solid var(--crm-line); border-radius:4px; color:var(--crm-muted); font-size:.65rem; font-weight:600; }
body[data-page-mode="standalone"] .crm-global-search-overlay { position:fixed; inset:0; z-index:5000; display:grid; place-items:start center; overflow:auto; padding:10vh 16px 24px; background:rgba(18,37,62,.42); }
body[data-page-mode="standalone"] .crm-global-search-overlay[hidden] { display:none !important; }
body[data-page-mode="standalone"] .crm-global-search-dialog { width:min(640px,100%); max-height:80vh; overflow:hidden; display:flex; flex-direction:column; gap:12px; padding:18px; border:1px solid var(--crm-line); border-radius:12px; background:var(--crm-paper); color:var(--crm-ink); }
body[data-page-mode="standalone"] .crm-global-search-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
body[data-page-mode="standalone"] .crm-global-search-head h2 { margin:0; font-size:1rem; }
body[data-page-mode="standalone"] .crm-global-search-head p { margin:4px 0 0; color:var(--crm-muted); font-size:.78rem; }
body[data-page-mode="standalone"] .crm-global-search-field input { width:100%; min-height:44px; padding:9px 12px; }
body[data-page-mode="standalone"] .crm-global-search-results { min-height:90px; overflow:auto; display:flex; flex-direction:column; gap:5px; }
body[data-page-mode="standalone"] .crm-global-search-result { display:grid; grid-template-columns:76px minmax(0,1fr); align-items:center; gap:2px 10px; width:100%; min-height:54px; padding:8px 10px; border:1px solid transparent; border-radius:7px; background:transparent; color:var(--crm-ink); text-align:start; }
body[data-page-mode="standalone"] .crm-global-search-result:hover,
body[data-page-mode="standalone"] .crm-global-search-result[aria-selected="true"] { border-color:var(--crm-line); background:#f3f6f8; }
body[data-page-mode="standalone"] .crm-global-search-result-type { grid-row:span 2; color:var(--crm-muted); font-size:.72rem; }
body[data-page-mode="standalone"] .crm-global-search-result strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:.82rem; }
body[data-page-mode="standalone"] .crm-global-search-result small { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--crm-muted); font-size:.7rem; }
body[data-page-mode="standalone"] .crm-global-search-empty { margin:0; padding:16px 10px; color:var(--crm-muted); text-align:center; font-size:.82rem; }
body.crm-global-search-open { overflow:hidden; }
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-global-search-result:hover,
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-global-search-result[aria-selected="true"] { background:#202d39; }
@media (max-width:560px) {
  body[data-page-mode="standalone"] .crm-global-search-overlay { padding:7vh 10px 14px; }
  body[data-page-mode="standalone"] .crm-global-search-dialog { padding:13px; }
  body[data-page-mode="standalone"] .crm-global-search-result { grid-template-columns:58px minmax(0,1fr); padding:8px 6px; }
  body[data-page-mode="standalone"] .crm-global-search-trigger kbd { display:none; }
}

/* Shared interaction and accessibility refinement. */
body[data-page-mode="standalone"] {
  --crm-focus-ring: color-mix(in srgb, var(--primary) 68%, var(--surface));
  --crm-ink: var(--text);
  --crm-muted: var(--muted);
  --crm-line: var(--line);
  --crm-paper: var(--surface);
  --crm-canvas: var(--bg);
  --crm-primary: var(--primary);
  color-scheme: light;
}
html[data-theme="dark"] body[data-page-mode="standalone"] { color-scheme: dark; }
body[data-page-mode="standalone"] :is(a,button,input,select,textarea,[role="button"],[tabindex]):focus-visible {
  outline:3px solid var(--crm-focus-ring) !important;
  outline-offset:3px !important;
  box-shadow:0 0 0 5px color-mix(in srgb, var(--primary) 14%, transparent) !important;
}
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn,a.ghost-btn) {
  transition:background-color .16s ease,border-color .16s ease,color .16s ease,box-shadow .16s ease,translate .16s ease;
}
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn,a.ghost-btn):hover {
    translate:0 -1px;
    box-shadow:0 4px 12px color-mix(in srgb, var(--primary) 12%, transparent);
  }
  body[data-page-mode="standalone"] .data-table tbody tr { transition:background-color .14s ease; }
}
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn):active { translate:0 0; }
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn):disabled,
body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn)[aria-disabled="true"] {
  translate:none;
  box-shadow:none;
  cursor:not-allowed;
}
body[data-page-mode="standalone"] .data-table thead th { background:var(--surface-alt); }
body[data-page-mode="standalone"] .data-table thead th { position:static; }
body[data-page-mode="standalone"] .data-table tbody tr:nth-child(even) > td { background:color-mix(in srgb, var(--surface-alt) 48%, var(--surface)); }
body[data-page-mode="standalone"] .table-wrap { scrollbar-width:thin; scrollbar-color:color-mix(in srgb, var(--muted) 36%, transparent) transparent; }
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card,.table-card) {
  transition:border-color .18s ease,box-shadow .18s ease;
}
body[data-page-mode="standalone"] :is(.panel,.hero-card,.stat-card,.category-card,.table-card):hover {
  border-color:color-mix(in srgb, var(--primary) 18%, var(--line));
}
html[data-theme="dark"] body[data-page-mode="standalone"] .data-table tbody tr:nth-child(even) > td { background:color-mix(in srgb, var(--surface-alt) 55%, var(--surface)); }
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-live-system-status[data-state="connected"] { color:#a6e2be; border-color:#47765d; background:#1b382a; }
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-live-system-status:is([data-state="saving"],[data-state="connecting"]) { color:#f0d394; border-color:#78643c; background:#39311f; }
html[data-theme="dark"] body[data-page-mode="standalone"] .crm-live-system-status:is([data-state="offline"],[data-state="error"]) { color:#f2b3ae; border-color:#80504e; background:#412727; }
@media (max-width:640px) {
  body[data-page-mode="standalone"] :is(.filters-row,.filter-actions,.toolbar-actions,.panel-actions) > :is(button,a,select,input) { flex:1 1 auto; }
  body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel,.crm-global-search-dialog) { max-height:calc(100dvh - 24px); overflow:auto; overscroll-behavior:contain; }
  body[data-page-mode="standalone"] .data-table :is(th,td) { padding:9px 8px; }
}
@media (prefers-reduced-motion:reduce) {
  body[data-page-mode="standalone"] :is(button,.button,.primary-btn,.ghost-btn,.tiny-btn,.panel,.hero-card,.stat-card,.category-card,.table-card),
  body[data-page-mode="standalone"] .data-table tbody tr { transition:none !important; translate:none !important; }
}

/* Phase 2: clearer hierarchy, resilient layouts, and status feedback. */
body[data-page-mode="standalone"] :is(.panel-head,.section-head,.modal-header,.drawer-header) :is(h1,h2,h3,h4) {
  text-wrap:balance;
  letter-spacing:-.012em;
}
body[data-page-mode="standalone"] :is(.eyebrow,.panel-head .eyebrow,.section-head .eyebrow) {
  font-size:.72rem;
  font-weight:750;
  letter-spacing:.025em;
}
body[data-page-mode="standalone"] :is(.subtle,.hint,.helper-text,.form-hint) { max-width:74ch; text-wrap:pretty; }
body[data-page-mode="standalone"] :is(.data-table,.table-wrap table) { font-variant-numeric:tabular-nums; }
body[data-page-mode="standalone"] :is(.data-table,.table-wrap table) :is(th,td) { text-align:start; }
body[data-page-mode="standalone"] .data-table tbody tr:last-child > td { border-bottom-color:transparent; }
body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip) { display:inline-flex; align-items:center; justify-content:center; gap:5px; min-height:24px; padding:3px 9px; line-height:1.35; }
body[data-page-mode="standalone"] :is(.empty-state,.empty-row,.no-data,[data-empty-state="true"]) {
  border-color:color-mix(in srgb,var(--line) 78%,var(--muted));
  background:color-mix(in srgb,var(--surface-alt) 45%,var(--surface));
}
body[data-page-mode="standalone"] :is([aria-busy="true"],.is-loading,.loading-state) { cursor:progress; }
body[data-page-mode="standalone"] :is([aria-busy="true"],.is-loading,.loading-state) :is(button,input,select,textarea) { pointer-events:none; }
body[data-page-mode="standalone"] :is(.error-message,.validation-message,[role="alert"]) { color:var(--danger); }
body[data-page-mode="standalone"] :is(.success-message,.success-banner,[role="status"]) { overflow-wrap:anywhere; }
body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions,.row-actions) > :is(button,a) { flex:0 0 auto; }
body[data-page-mode="standalone"] :is(.topbar-actions,.panel-actions,.toolbar-actions,.row-actions) { min-height:36px; }
body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel,.client-drawer,.workspace-page-modal-panel) { overscroll-behavior:contain; scrollbar-gutter:stable; }
body[data-page-mode="standalone"] :is(input,select,textarea) { accent-color:var(--primary); }
body[data-page-mode="standalone"] select { text-overflow:ellipsis; }
body[data-page-mode="standalone"] :is(input[type="date"],input[type="time"],input[type="datetime-local"]) { min-height:42px; }
body[data-page-mode="standalone"] :is(a,button) { touch-action:manipulation; }
body[data-page-mode="standalone"] :is(.table-wrap,.client-table-wrap,.target-table-wrap,.resale-match-table-wrap) { overscroll-behavior-inline:contain; }
body[data-page-mode="standalone"] :is(.table-wrap,.client-table-wrap,.target-table-wrap,.resale-match-table-wrap):focus-visible { outline-offset:2px; }
body[data-page-mode="standalone"] :is(.data-table,.table-wrap table) :is(th,td) { overflow-wrap:anywhere; }
@media (min-width:761px) {
  body[data-page-mode="standalone"] :is(.filters-row,.filter-actions,.toolbar-actions) { align-items:end; }
  body[data-page-mode="standalone"] :is(.modal-content,.modal-panel,.drawer-panel,.workspace-page-modal-panel) { scrollbar-gutter:stable; }
}
@media (max-width:640px) {
  body[data-page-mode="standalone"] .topbar { align-items:flex-start; flex-wrap:wrap; }
  body[data-page-mode="standalone"] .topbar-actions { width:100%; }
  body[data-page-mode="standalone"] .topbar-actions > :is(button,a) { flex:1 1 auto; }
  body[data-page-mode="standalone"] :is(.filters-row,.filter-actions,.toolbar-actions,.panel-actions) { align-items:stretch; }
  body[data-page-mode="standalone"] :is(.filters-row,.filter-actions,.toolbar-actions,.panel-actions) > :is(button,a,select,input) { min-height:42px; }
  body[data-page-mode="standalone"] :is(.panel-head,.section-head) { align-items:flex-start; }
  body[data-page-mode="standalone"] :is(.panel-head,.section-head) > :is(button,a) { flex:0 0 auto; }
  body[data-page-mode="standalone"] :is(.empty-state,.empty-row,.no-data) { min-height:64px; padding:14px 10px; }
}
@media (forced-colors:active) {
  body[data-page-mode="standalone"] :is(a,button,input,select,textarea,[role="button"]):focus-visible { outline:2px solid Highlight !important; }
  body[data-page-mode="standalone"] :is(.badge,.status-badge,.tag,.chip,.crm-live-system-status) { border:1px solid currentColor; }
}
