* { box-sizing: border-box; }
:root { scrollbar-color: var(--crm-border-control) var(--crm-canvas); }
body { margin: 0; color: var(--crm-text); background: var(--crm-canvas); font: 400 16px/1.5 var(--crm-font-sans); }
::selection { color: var(--crm-brand); background: var(--crm-brand-soft); }
a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; color: var(--crm-disabled-fg); background: var(--crm-disabled-bg); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
input, textarea { caret-color: var(--crm-brand); }
input::placeholder, textarea::placeholder { color: var(--crm-text-muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--crm-brand); outline-offset: 3px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; flex-shrink: 0; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3, .customer-preview-card-head strong, .community-card-title > strong, .prop-card-title > strong, .avatar { font-family: var(--crm-font-display); }
h1 { font-size: 24px; line-height: 32px; font-weight: 700; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
img { max-width: 100%; display: block; }
button, a, input, textarea, select { transition: background-color var(--crm-duration-feedback) var(--crm-ease), border-color var(--crm-duration-feedback) var(--crm-ease); }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -60px; left: 16px; padding: 8px 16px; z-index: 100; background: var(--crm-surface); }
.skip-link:focus { top: 8px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 208px; padding: 24px 16px 16px; border-right: 1px solid var(--crm-border); background: var(--crm-sidebar); display: flex; flex-direction: column; z-index: 20; }
.brand { font-family: var(--crm-font-display); display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; line-height: 26px; margin-bottom: 32px; white-space: nowrap; }
.brand small { font-family: var(--crm-font-sans); display: block; font-size: 12px; font-weight: 400; color: var(--crm-text-muted); line-height: 20px; }
.brand-mark { position: relative; display: grid; place-items: center; width: 36px; height: 40px; background: var(--crm-brand); color: white; border-radius: var(--crm-radius-sm); }
.brand-mark::after { content: ""; position: absolute; inset: 3px; border: 1px solid rgb(255 250 241 / 55%); pointer-events: none; }
.brand-mark svg { width: 24px; height: 24px; }
.nav-link { font-family: var(--crm-font-display); font-size: 18px; display: flex; gap: 12px; align-items: center; min-height: 48px; padding: 8px 12px; margin-bottom: 4px; border-radius: var(--crm-radius-sm); font-weight: 600; }
.nav-link > svg { width: 22px; height: 22px; color: var(--nav-color,var(--crm-brand)); }
.nav-link.active { background: var(--crm-surface); color: var(--crm-brand); box-shadow: inset 0 0 0 1px var(--crm-border); }
.nav-link.active > svg { color: var(--crm-brand); }
.nav-divider { height: 1px; margin: 16px 12px; background: var(--crm-border); }
.badge { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; background: var(--crm-danger); color: white; border-radius: 999px; font-size: 12px; line-height: 16px; font-weight: 700; margin-left: auto; }
.sidebar-bottom { margin-top: auto; padding: 24px 4px 0; font-size: 12px; color: var(--crm-text-muted); }
.sidebar-bottom a { display: block; margin-top: 8px; text-decoration: underline; }
.preview-dot { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--crm-brand); }
.workspace { margin-left: 208px; }
.preview-bar { min-height: 36px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 24px; color: var(--crm-text-muted); background: var(--crm-surface-subtle); border-bottom: 1px solid var(--crm-border); font-size: 12px; }
.preview-bar a { text-decoration: underline; }
#view { max-width: 1440px; padding: 24px; margin: auto; min-height: calc(100dvh - 36px); outline: none; }
.mobile-nav { display: none; }
.muted, .meta, .counter { color: var(--crm-text-muted); }
.meta { font-size: 14px; line-height: 20px; }
.counter { font-size: 14px; font-variant-numeric: tabular-nums; }
.link { color: var(--crm-brand); text-decoration: underline; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .counter { margin-left: auto; }
.btn, .icon-btn, .text-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid transparent; border-radius: var(--crm-radius-sm); min-height: var(--crm-control-height); padding: 6px 12px; font-size: 16px; line-height: 24px; font-weight: 600; white-space: nowrap; }
.btn { background: var(--crm-brand); color: white; }
.btn.secondary { color: var(--crm-brand); background: var(--crm-brand-soft); }
.icon-btn { min-width: 44px; min-height: 44px; padding: 8px; background: transparent; color: var(--crm-text-muted); }
.text-btn { color: var(--crm-brand); background: transparent; padding: 4px 8px; min-height: 44px; }
.filters { display: inline-flex; align-items: center; gap: 8px; isolation: isolate; position: relative; }
.grade { display: inline-grid; place-items: center; width: 44px; min-height: 44px; padding: 8px 0; border: 2px solid transparent; border-radius: var(--crm-radius-sm); background: var(--crm-grade-sheen),var(--grade-color); color: white; font-size: 18px; font-weight: 700; line-height: 24px; box-shadow: var(--crm-grade-highlight); }
.a { --grade-color: var(--crm-grade-a); --grade-soft: var(--crm-grade-a-soft); }
.b { --grade-color: var(--crm-grade-b); --grade-soft: var(--crm-grade-b-soft); }
.c { --grade-color: var(--crm-grade-c); --grade-soft: var(--crm-grade-c-soft); }
.grade.all { width: 56px; background: var(--crm-brand-soft); color: var(--crm-brand); --grade-color: var(--crm-brand); }
.grade[aria-pressed=true] { box-shadow: var(--crm-focus-ring); }
.grade.all[aria-pressed=true] { background: var(--crm-brand); color: white; }
.grade:focus-visible { outline-offset: 6px; }
.filters.with-indicator .grade[aria-pressed=true] { box-shadow: var(--crm-grade-highlight); }
.grade-indicator { position: absolute; pointer-events: none; z-index: -1; border-radius: var(--crm-radius-sm); box-shadow: var(--crm-focus-ring); transform-origin: left center; }
.search-line { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; flex-wrap: wrap; }
.search { width: 280px; max-width: 100%; min-height: var(--crm-search-height); display: flex; align-items: center; gap: 8px; border: 1px solid var(--crm-border-control); border-radius: var(--crm-radius-sm); padding: 4px 12px; background: var(--crm-field); }
.search input { width: 100%; min-width: 0; border: 0; padding: 0; background: transparent; outline: 0; font-size: 16px; line-height: 24px; color: var(--crm-text); }
.search:focus-within { outline: 2px solid var(--crm-brand); outline-offset: 2px; }
.search svg { color: var(--crm-text-muted); }
.sort-select, .search-line select { border: 1px solid var(--crm-border); border-radius: var(--crm-radius-sm); background: var(--crm-field); color: var(--crm-text); padding: 4px 8px; min-height: var(--crm-search-height); font-size: 14px; max-width: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill,minmax(224px,1fr)); gap: 16px; align-items: start; }
.customer-card, .property-card { position: relative; display: block; min-width: 0; border: 1px solid var(--crm-border); border-radius: var(--crm-radius-md); background: var(--crm-surface); overflow: hidden; }
.customer-card { padding: 12px; }
.record-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: var(--crm-radius-sm); background: var(--crm-avatar-bg); color: var(--crm-text); font-size: 18px; font-weight: 600; overflow: hidden; border: none; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.detail-title { flex: 1; min-width: 0; }
.detail-title h1 { overflow-wrap: anywhere; }
.detail-header > .avatar { width: 56px; height: 56px; flex-basis: 56px; border-radius: var(--crm-radius-md); }
.section { padding: 16px; border: 1px solid var(--crm-border); background: var(--crm-surface); border-radius: var(--crm-radius-md); margin-bottom: 16px; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head .text-btn, .section-head .icon-btn { margin-block: -8px; }
.field-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px 16px; margin: 0; }
.field-grid > div, .field { display: flex; gap: 8px; min-width: 0; align-items: baseline; font-size: 14px; line-height: 20px; }
.field-grid dt { color: var(--crm-text-muted); white-space: nowrap; }
.field-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.field-grid .wide, .form-grid .wide { grid-column: 1 / -1; }
.price { color: var(--crm-price); font-weight: 700; font-size: 18px; line-height: 24px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { color: var(--crm-text-muted); padding: 24px 12px; text-align: center; font-size: 14px; border: 1px dashed var(--crm-border); border-radius: var(--crm-radius-sm); }
.media-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.media-thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; }
.followup-composer textarea, textarea { resize: vertical; }
.followup-composer textarea { display: block; width: 100%; min-height: 88px; padding: 8px 12px; border: 1px solid var(--crm-border-control); border-radius: var(--crm-radius-sm); background: var(--crm-field); color: var(--crm-text); }
.followup-list { display: grid; gap: 0; }
.followup-record { padding: 12px 0; border-bottom: 1px solid var(--crm-border); }
.followup-record:last-child { border-bottom: 0; }
.followup-record p { white-space: pre-wrap; overflow-wrap: anywhere; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
th { font-weight: 500; color: var(--crm-text-muted); background: var(--crm-surface-subtle); }
th,td { padding: 10px 12px; border-bottom: 1px solid var(--crm-border); white-space: nowrap; }
.chip { display: inline-flex; gap: 4px; align-items: center; min-height: 36px; padding: 4px 12px; border: 1px solid var(--crm-border); border-radius: 999px; color: var(--crm-text-muted); background: var(--crm-surface); font-size: 14px; }
button.chip { min-height: 40px; }
.chip[aria-pressed=true] { color: var(--crm-brand); border-color: var(--crm-brand); background: var(--crm-brand-soft); font-weight: 600; }
.agenda { max-width: 1000px; }
.today-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.today-date { display: flex; gap: 12px; align-items: baseline; }
.today-date span { font-size: 14px; color: var(--crm-text-muted); }
.quick-actions { display: flex; gap: 8px; }
.agenda-day { margin: 20px 0 8px; font-size: 14px; font-weight: 600; color: var(--crm-text-muted); }
.task-list { display: grid; gap: 8px; }
.task-wrap { position: relative; overflow: hidden; border-radius: var(--crm-radius-md); background: var(--crm-brand-soft); touch-action: pan-y; }
.task-body { position: relative; display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px; background: var(--grade-soft); transition: transform var(--crm-duration-panel) var(--crm-ease); }
.task-grade { color: var(--grade-color); font-size: 18px; font-weight: 700; min-width: 16px; }
.task-copy { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 16px; line-height: 24px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.task-title a:hover { text-decoration: underline; }
.task-copy p { font-size: 14px; line-height: 20px; color: var(--grade-color); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.task-time { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; gap: 2px; }
.due-label { color: var(--crm-danger); font-size: 12px; font-weight: 600; }
.task-more { min-width: 32px; width: 32px; padding: 4px; margin: -4px -4px -4px 0; color: var(--grade-color); }
.task-actions { position: absolute; inset: 0 0 0 auto; display: flex; width: 168px; }
.task-actions button { flex: 1; min-width: 44px; border: 0; background: var(--crm-brand-soft); color: var(--crm-brand); font-size: 14px; font-weight: 600; }
.task-actions button:last-child { background: var(--crm-brand); color: white; }
.task-wrap.actions-open .task-body { transform: translateX(-168px); }
.task-wrap.is-done .task-body { background: var(--crm-surface-subtle); }
.task-wrap.is-done .task-title { text-decoration: line-through; }
.complete-toggle { margin-top: 16px; }
.resource-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--crm-border); margin-bottom: 16px; overflow-x: auto; }
.resource-tabs a { font-family: var(--crm-font-display); min-height: 48px; padding: 8px 0 12px; font-size: 18px; font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.resource-tabs a.active { color: var(--crm-brand); border-bottom-color: var(--crm-brand); }
.resource-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.resource-toolbar { gap: 8px 12px; }
.resource-toolbar .resource-tabs { flex-shrink: 0; gap: 16px; margin: 0; border: 0; }
.resource-toolbar .resource-tabs a { font-family: var(--crm-font-display); min-height: 44px; padding: 8px 0; }
.resource-toolbar .search { flex: 0 1 220px; min-width: min(200px, 100%); }
.resource-toolbar .resource-tags { display: contents; }
.resource-list { display: grid; grid-template-columns: repeat(auto-fill,minmax(290px,1fr)); gap: 12px; }
.resource-card { text-align: left; display: flex; align-items: start; gap: 12px; border: 1px solid var(--crm-border); background: var(--crm-surface); padding: 16px; border-radius: var(--crm-radius-md); color: var(--crm-text); }
.resource-card > .resource-symbol { width: 40px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--crm-radius-sm); background: var(--crm-brand-soft); color: var(--crm-brand); }
.resource-card > div { min-width: 0; }
.resource-card h3 { margin-bottom: 4px; overflow-wrap: anywhere; }
.resource-card p { font-size: 14px; line-height: 20px; color: var(--crm-text-muted); }
.resource-card .resource-labels { margin-top: 12px; color: var(--crm-brand); font-size: 12px; }
.resource-detail { max-width: 900px; }
.resource-prose { white-space: pre-wrap; margin: 16px 0; line-height: 1.8; }
.resource-attachments { display: grid; gap: 12px; }
.resource-attachments img, .resource-attachments video { max-height: 500px; object-fit: contain; width: 100%; background: var(--crm-surface-subtle); border-radius: var(--crm-radius-sm); }
.form-dialog { padding: 0; border: 0; border-radius: var(--crm-radius-lg); width: min(620px,calc(100% - 32px)); max-height: calc(100dvh - 48px); color: var(--crm-text); box-shadow: var(--crm-shadow-dialog); background: var(--crm-surface); }
.form-dialog::backdrop { background: var(--crm-overlay); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--crm-border); }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; padding: 16px; }
.form-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 14px; }
.form-field > span { color: var(--crm-text-muted); }
.form-field input, .form-field textarea, .form-field select { min-width: 0; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--crm-border-control); border-radius: var(--crm-radius-sm); background: var(--crm-field); color: var(--crm-text); font-size: 16px; line-height: 24px; }
.form-field input[type=file] { padding: 8px; font-size: 14px; }
.form-field input[type=file]::file-selector-button { background: var(--crm-brand-soft); border: 0; border-radius: 4px; color: var(--crm-brand); padding: 4px 8px; margin-right: 8px; }
.required { color: var(--crm-danger); }
.form-error { margin: 0 16px 12px; color: var(--crm-danger); font-size: 14px; }
.dialog-footer { position: sticky; bottom: 0; padding: 12px 16px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; background: var(--crm-surface); border-top: 1px solid var(--crm-border); }
.dialog-footer > span { margin-right: auto; font-size: 12px; }
.toast { position: fixed; bottom: 24px; left: calc(50% + 104px); transform: translateX(-50%); z-index: 80; padding: 12px 16px; max-width: min(520px,calc(100% - 32px)); background: var(--crm-brand); color: white; border-radius: var(--crm-radius-sm); box-shadow: var(--crm-shadow-popover); font-size: 14px; }
@media (hover:hover) {
  .btn:not(:disabled):hover { background: var(--crm-brand-hover); color: white; }
  .btn:not(:disabled):active { background: var(--crm-brand-pressed); }
  .icon-btn:hover, .text-btn:hover, .nav-link:not(.active):hover { background: var(--crm-brand-soft); }
  .customer-card:hover, .property-card:hover, .resource-card:hover { border-color: var(--crm-border-control); }
}
@media (max-width: 1000px) { .field-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 767px) {
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .preview-bar { padding: 8px 12px; min-height: 32px; }
  #view { padding: 16px 12px calc(80px + env(safe-area-inset-bottom)); min-height: calc(100dvh - 32px); }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(6,1fr); inset: auto 0 0; background: var(--crm-surface); border-top: 1px solid var(--crm-border); padding: 4px 4px env(safe-area-inset-bottom); z-index: 30; }
  .mobile-nav a { font-family: var(--crm-font-display); position: relative; display: flex; align-items: center; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; border-radius: var(--crm-radius-sm); font-size: 12px; color: var(--crm-text-muted); }
  .mobile-nav a svg { width: 22px; height: 22px; }
  .mobile-nav a.active { color: var(--crm-brand); background: var(--crm-brand-soft); font-weight: 600; }
  .mobile-nav .badge { position: absolute; top: 0; left: calc(50% + 8px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 4px; }
  .toolbar { gap: 8px; margin-bottom: 12px; }
  .toolbar .counter { width: 100%; margin-top: 0; }
  .cards { grid-template-columns: repeat(auto-fill,minmax(min(100%,168px),1fr)); gap: 12px; }
  .search-line { flex-wrap: nowrap; gap: 8px; }
  .search { width: min(280px,100%); flex: 1; min-width: 0; }
  .search-line select { min-height: 44px; max-width: 134px; }
  .section { padding: 12px; }
  .detail-header { gap: 8px; }
  .field-grid { gap: 8px 12px; }
  .today-header { gap: 12px; margin-bottom: 16px; }
  .today-date { width: 100%; }
  .task-body { gap: 8px; padding: 10px 12px; min-height: 76px; }
  .task-time { font-size: 14px; }
  .task-time time { max-width: 88px; white-space: normal; text-align: right; }
  .task-more { min-width: 28px; width: 28px; }
  .resource-tabs { gap: 20px; }
  .resource-tabs a { font-size: 18px; }
  .resource-list { grid-template-columns: 1fr; }
  .resource-tags .chip { min-height: 44px; }
  .toast { left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .form-dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); }
  .form-grid { padding: 12px; gap: 12px 8px; }
  .dialog-footer > span { max-width: 7em; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior: auto !important; } }

/* Approved industrial workbench identity. */
.brand-mark:has(img){width:40px;height:40px;background:none;border:0;padding:0;box-shadow:none;flex-shrink:0;}
.brand-mark:has(img)::after{display:none;}
.brand-mark img{display:block;width:40px;height:40px;object-fit:contain;border-radius:9px;}
.workbench-preview-brand img{object-fit:contain;border-radius:5px;}
