.crm-nav{display:flex;gap:6px;padding:5px;background:#f3f3f3;border-radius:16px;width:max-content;margin:12px 0 26px}.crm-nav button{border:0;background:transparent;color:#707070;padding:11px 24px;border-radius:12px;font:inherit;font-weight:600;cursor:pointer}.crm-nav button[aria-current=page],.crm-nav button.active{background:#fff;color:#161616;box-shadow:0 2px 8px #0000000a}.crm-toolbar{display:flex;justify-content:space-between;gap:16px;align-items:center;margin-bottom:24px}.crm-toolbar input,.crm-toolbar select{max-width:340px;margin:0}.crm-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(285px,1fr));gap:14px}.client-card{display:flex;align-items:flex-start;gap:14px;padding:22px;border:1px solid #e9e9e9;border-radius:20px;background:white;text-align:left;font:inherit;color:inherit;cursor:pointer;min-width:0}.client-card:hover,.task-body:hover{background:#fafafa}.client-card>div:last-child{min-width:0;flex:1}.client-card h3{font-size:16px;margin:0 0 5px;overflow-wrap:anywhere}.client-card .person-handle{font-size:13px}.crm-preview{font-size:13px;color:#707070;line-height:1.6;margin:12px 0 0;white-space:pre-wrap;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.crm-badge{display:inline-block;padding:4px 8px;border-radius:7px;background:#f1f1f1;color:#555;font-size:11px;margin-top:12px}.crm-subtitle{font-size:15px;color:#707070;font-weight:500;margin:28px 0 12px}.crm-list{border:1px solid #e9e9e9;border-radius:20px;overflow:hidden}.crm-list:empty{border:0}.task-row{display:flex;gap:14px;align-items:center;padding:6px 18px;background:white;border-bottom:1px solid #efefef}.task-row:last-child{border:0}.task-body{flex:1;min-width:0;border:0;border-radius:10px;background:transparent;color:inherit;text-align:left;font:inherit;cursor:pointer;padding:14px 0}.task-body strong{display:block;font-weight:600;overflow-wrap:anywhere}.task-meta{display:block;font-size:12px;color:#707070;margin-top:7px;line-height:1.6}.task-overdue{color:#161616;font-weight:700}.task-toggle{width:23px;height:23px;flex:none;accent-color:#161616;cursor:pointer}.crm-empty{color:#707070;padding:24px;text-align:center;font-size:14px}.crm-dialog{width:min(560px,calc(100vw - 24px));max-height:90dvh}.crm-dialog .dialog-content{overflow:auto;max-height:calc(90dvh - 80px)}.crm-dialog label{display:block;margin-bottom:16px}.crm-dialog .check{display:flex}.crm-dialog .button-row{flex-wrap:wrap}.crm-identity{display:flex;gap:14px;align-items:center;margin-bottom:20px}.task-photos{display:flex;gap:10px;flex-wrap:wrap;margin:12px 0}.task-photo{position:relative;width:85px;height:85px}.task-photo img{width:100%;height:100%;object-fit:cover;border-radius:12px}.task-photo button:first-child{border:0;background:transparent;padding:0;width:100%;height:100%;cursor:zoom-in}.task-photo .photo-remove{position:absolute;right:-5px;top:-5px;border-radius:50%;width:24px;height:24px;border:1px solid #ddd;background:white;font-size:18px;cursor:pointer}.login-roles{display:flex;gap:6px;background:#f3f3f3;border-radius:12px;padding:5px;margin:0 0 22px}.login-roles button{flex:1;border:0;padding:10px;background:transparent;border-radius:8px;font:inherit;color:#707070;cursor:pointer}.login-roles button.active{background:white;color:#161616}.crm-dialog :disabled{cursor:wait}.crm-nav button:focus-visible,.client-card:focus-visible,.task-body:focus-visible{outline:2px solid #161616;outline-offset:3px}@media(max-width:600px){.crm-toolbar{flex-wrap:wrap;gap:12px}.crm-toolbar input,.crm-toolbar select{max-width:none;width:100%}.crm-nav{width:100%;box-sizing:border-box}.crm-nav button{flex:1;padding:11px 12px}.crm-grid{grid-template-columns:1fr}.client-card{padding:18px}.task-row{padding:6px 12px}.crm-dialog .dialog-content{padding:18px}.crm-dialog .button-row .button{flex:1}.topbar{gap:12px}}
.crm-toolbar input,.crm-toolbar select{padding:12px 16px;border:1px solid #e4e4e4;border-radius:12px;background:#fff;color:#161616;font-size:14px;min-height:44px;box-sizing:border-box}.crm-toolbar input{width:340px}.crm-toolbar select{width:180px}.crm-dialog label textarea{display:block;width:100%;box-sizing:border-box;padding:12px 14px;margin-top:8px;resize:vertical;border:1px solid #dedede;border-radius:12px;background:#fff;color:#161616;font:inherit;line-height:1.6}.crm-dialog label input:not([type=checkbox]),.crm-dialog label select{padding:12px 14px;border-radius:12px;font-size:15px}.crm-dialog label{font-size:13px}.crm-toolbar input:focus-visible,.crm-toolbar select:focus-visible,.crm-dialog textarea:focus-visible{outline:2px solid #161616;outline-offset:2px}.crm-dialog label textarea::placeholder{color:#999}@media(max-width:600px){.crm-toolbar input,.crm-toolbar select{width:100%;font-size:16px}.crm-dialog label input:not([type=checkbox]),.crm-dialog label select,.crm-dialog label textarea{font-size:16px}}

/* Chat filters share the main CRM segmented control. */
.filters.chat-filters {
  align-items: center;
  gap: 6px;
  min-height: 0;
  max-width: 100%;
  margin: 12px 0;
  overflow-x: auto;
}

/* ALARI workspace. The same API and access rules serve owner and manager. */
:root {
  --sidebar-width: 216px;
  --canvas: #fff;
  --quiet: #f6f6f6;
  --ink: #171717;
  --muted: #737373;
  --line: #ebebeb;
}
.crm-app { background: var(--canvas); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 6;
  display: flex; flex-direction: column; width: var(--sidebar-width);
  padding: 32px 16px 20px; border-right: 1px solid var(--line); background: #fafafa;
}
.alari-brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font-size: 25px; font-weight: 600; letter-spacing: 3px; }
.sidebar .alari-brand { padding: 0 12px; height: 28px; margin-bottom: 56px; }
.alari-brand > span { padding: 4px 5px; border: 1px solid #dcdcdc; border-radius: 4px; font-size: 9px; font-weight: 500; letter-spacing: 1px; }
.sidebar-caption { padding: 0 12px; color: #777; font-size: 10px; margin-bottom: 14px; }
.workspace-nav.crm-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 0; padding: 0; border-radius: 0; background: transparent; }
.workspace-nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 14px; border-radius: 10px; color: #656565; font-size: 13px; font-weight: 500; text-align: left; }
.workspace-nav button:hover { background: #efefef; color: var(--ink); }
.workspace-nav button[aria-current=page] { background: var(--ink); color: #fff; box-shadow: none; }
.workspace-nav svg, .sidebar-action svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav-count { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .7; }
.workspace-nav button[aria-current=page] .nav-count { padding: 3px 6px; border-radius: 5px; background: #ffffff20; opacity: 1; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 6px; margin-top: auto; }
.sidebar-action { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: #666; font-size: 12px; text-align: left; }
.sidebar-action:hover { background: #efefef; color: var(--ink); }
.sidebar-signature { display: flex; gap: 6px; padding: 20px 14px 0; margin-top: 12px; border-top: 1px solid var(--line); color: #7b7b7b; font-size: 10px; }
.sidebar-signature span { color: #b5b5b5; }
.crm-app .topbar { height: 80px; margin-left: var(--sidebar-width); padding: 0 40px; }
.workspace-breadcrumb { display: flex; align-items: center; gap: 14px; font-size: 12px; color: #444; }
.desktop-crumb { display: flex; gap: 14px; color: var(--muted); }
.desktop-crumb > span { color: #ccc; }
.mobile-brand { display: none; }
.workspace-account { display: flex; align-items: center; gap: 10px; font-size: 12px; white-space: nowrap; }
.account-mark { display: grid; place-items: center; height: 32px; width: 32px; border: 1px solid #e2e2e2; border-radius: 50%; background: #f8f8f8; font-size: 12px; font-weight: 550; }
.crm-app .top-actions { gap: 28px; }
.crm-app .connection { font-size: 11px; }
.crm-app main { width: calc(100% - var(--sidebar-width)); max-width: 1600px; min-width: 0; margin: 0 0 0 var(--sidebar-width); padding: 40px; }
.page-eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.crm-app h1 { font-size: 32px; line-height: 1.25; font-weight: 550; letter-spacing: -1px; }
.crm-app .intro { align-items: center; flex-direction: row; gap: 16px; }
.crm-app .button { min-height: 42px; padding: 0 16px; border-radius: 10px; font-size: 12px; }
.crm-app .button.primary { box-shadow: none; }
.crm-app .button.secondary { border-color: #e4e4e4; }
.crm-app .summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin: 32px 0; }
.crm-app .metric { min-width: 0; margin: 0; padding: 22px 24px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.crm-app .metric:first-child { background: #f8f8f8; border-color: #e8e8e8; }
.crm-app .metric > span { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-size: 11px; }
.crm-app .metric > strong { font-size: 32px; font-weight: 500; letter-spacing: -1px; }
.metric-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.crm-app .workspace { border-radius: 14px; overflow: visible; }
.crm-app .toolbar { padding: 12px 20px; gap: 12px; flex-wrap: wrap; }
.crm-app .chat-filters.crm-nav { gap: 4px; margin: 0; padding: 4px; border-radius: 10px; background: var(--quiet); }
.crm-app .chat-filters .filter { gap: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 7px; font-size: 11px; font-weight: 500; }
.crm-app .chat-filters .filter.active { color: var(--ink); background: white; box-shadow: 0 1px 4px #0000000a; }
.crm-app .filter span { padding: 3px 5px; min-width: 18px; background: #e9e9e9; font-size: 10px; }
.crm-app .search { flex: 1 1 180px; max-width: 264px; min-height: 40px; margin: 0; border-radius: 9px; }
.crm-app .search input { font-size: 12px; }
.crm-app label.search input { min-height: 0; margin: 0; padding: 8px 0; border: 0; border-radius: 0; background: transparent; }
.crm-app table { min-width: 720px; }
.crm-app th { padding: 14px 20px; background: #fafafa; font-size: 10px; }
.crm-app th:first-child { width: 25%; }
.crm-app th:nth-child(2) { width: 32%; }
.crm-app td { padding: 20px; }
.crm-app .person-name { font-size: 13px; }
.crm-app .person-handle { color: #808080; font-size: 11px; }
.crm-app .preview { max-width: 320px; font-size: 12px; }
.crm-app .date { font-size: 10px; }
.crm-app .reply-source { font-size: 10px; }
.crm-app .status { padding: 6px 8px; border-radius: 6px; font-size: 10px; }
.crm-app .wait { font-size: 12px; }
.crm-app .row-actions { gap: 12px; }
.crm-app .open-chat { font-size: 11px; }
.crm-app .row-actions > .open-chat { display: inline-flex; align-items: center; min-height: 40px; }
.crm-app .table-footer { min-height: 48px; padding: 12px 20px; font-size: 10px; }
.crm-app .table-wrap { position: relative; border-radius: 0 0 14px 14px; }
.crm-app .table-wrap:has(.action-menu[open]) { padding-bottom: 120px; margin-bottom: -120px; }
.section-count { display: inline-flex; padding: 5px 9px; margin-left: 8px; background: #f3f3f3; border-radius: 8px; color: #777; font-size: 16px; vertical-align: 4px; font-weight: 400; letter-spacing: 0; }
.clients-surface { margin-top: 32px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.client-toolbar.crm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.client-toolbar input { width: 220px; max-width: 260px; min-height: 40px; padding: 10px 12px; border-radius: 9px; font-size: 12px; }
.client-stage-filters { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.client-stage-filters button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 10px; min-height: 36px; border: 0; border-radius: 7px; background: transparent; color: #737373; font-size: 11px; white-space: nowrap; }
.client-stage-filters button:hover { background: #f7f7f7; color: var(--ink); }
.client-stage-filters button.active { background: var(--ink); color: #fff; }
.client-stage-filters button span { font-size: 10px; opacity: .7; }
.crm-grid { display: block; }
.client-table-head, .client-card { display: grid; grid-template-columns: minmax(160px,1.2fr) minmax(100px,.65fr) minmax(140px,1.3fr) 20px; gap: 20px; align-items: center; }
.client-table-head { padding: 14px 24px; color: #7b7b7b; background: #fafafa; font-size: 10px; }
.client-card { width: 100%; min-height: 92px; padding: 20px 24px; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: white; text-align: left; font: inherit; color: inherit; }
.client-card:hover { background: #fcfcfc; }
.client-card:focus-visible { outline-offset: -3px; }
.client-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.client-names { min-width: 0; }
.client-stage { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.crm-badge { padding: 5px 8px; margin: 0; border: 1px solid #e9e9e9; border-radius: 6px; background: #fff; color: #666; font-size: 10px; white-space: nowrap; }
.crm-badge.stage-working { background: var(--ink); border-color: var(--ink); color: white; }
.crm-badge.stage-done { background: #f4f4f4; border-color: #f4f4f4; }
.client-attention { font-size: 10px; font-weight: 550; }
.client-detail { min-width: 0; }
.client-detail .crm-preview { display: -webkit-box; margin: 0; -webkit-line-clamp: 1; font-size: 12px; color: #555; }
.client-detail .task-meta { font-size: 10px; margin-top: 6px; }
.client-arrow { width: 20px; color: #aaa; font-size: 17px; text-align: right; }
.client-card:hover .client-arrow { color: var(--ink); }
.crm-toolbar { margin-top: 28px; margin-bottom: 0; }
.crm-toolbar input { font-size: 12px; border-radius: 9px; }
#tasks-workspace > .crm-toolbar { padding-bottom: 24px; border-bottom: 1px solid var(--line); }
#tasks-workspace .filters { align-items: center; gap: 4px; min-height: 0; width: auto; padding: 4px; border-radius: 10px; background: #f5f5f5; }
#tasks-workspace .filter { padding: 10px 16px; margin: 0; min-height: 36px; border: 0; border-radius: 7px; font-size: 12px; }
#tasks-workspace .filter.active { background: white; box-shadow: 0 1px 4px #0000000a; }
.task-columns { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); gap: 24px; }
.task-columns:has(#automatic-tasks.hidden) { grid-template-columns: 1fr; }
.task-column { min-width: 0; }
.crm-subtitle { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 14px; color: #404040; font-size: 12px; font-weight: 550; }
.column-count { color: #888; font-size: 11px; font-weight: 400; font-variant-numeric: tabular-nums; }
.crm-list { border-radius: 12px; }
.task-row { align-items: flex-start; gap: 12px; padding: 4px 18px; }
.task-row > .avatar { width: 32px; height: 32px; margin-top: 17px; font-size: 11px; }
.task-toggle { width: 18px; height: 18px; margin: 18px 0 0; }
.task-body { padding: 16px 0; }
.task-body strong { font-size: 13px; line-height: 1.45; font-weight: 500; }
.task-body .crm-preview { margin-top: 6px; font-size: 11px; line-height: 1.6; }
.task-body .task-meta { margin-top: 8px; font-size: 10px; }
.task-row:has(.task-toggle:checked) .task-body strong { text-decoration: line-through; color: var(--muted); }
.crm-empty { padding: 40px 20px; margin: 0; font-size: 12px; }
.crm-dialog { border-radius: 16px; }
.crm-dialog .dialog-head { padding: 24px; }
.crm-dialog .dialog-content { padding: 24px; }
.crm-dialog label { font-size: 12px; }
.crm-dialog input:not([type=checkbox]), .crm-dialog textarea, .crm-dialog select { min-height: 44px; font-size: 14px; }
.crm-dialog .icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fafafa; color: #555; }
.crm-identity { padding-bottom: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.crm-dialog .button-row { padding-top: 8px; }
.crm-dialog .button-row .primary { flex: 1; }
#client-dialog { width: min(480px,100%); height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border: 0; border-left: 1px solid var(--line); border-radius: 0; }
#client-dialog .dialog-content { max-height: calc(100dvh - 88px); }
#client-dialog .button-row { display: grid; grid-template-columns: 1fr 1fr; }
#client-dialog #client-save { grid-column: 1 / -1; }
.login-page { background: #fafafa; }
.login-panel .login-brand { margin-bottom: 40px; }
.login-panel h1 { font-size: 24px; font-weight: 500; margin-bottom: 28px; }
.login-panel .button { min-height: 46px; border-radius: 10px; }
.login-panel label { font-size: 12px; }
.login-panel label input { padding: 12px 14px; border-radius: 9px; }
.login-roles { margin-bottom: 28px; }
.login-roles button { min-height: 40px; font-size: 12px; }
.login-panel { box-shadow: 0 12px 44px #00000003; }
@media (min-width: 1600px) { .crm-app main { padding: 48px 56px; } .crm-app .topbar { padding: 0 56px; } }
@media (max-width: 1200px) {
  :root { --sidebar-width: 188px; }
  .crm-app .topbar { padding: 0 28px; }
  .crm-app main { padding: 32px 28px; }
  .crm-app .toolbar { padding: 12px 16px; }
  .crm-app .chat-filters .filter { padding: 0 10px; }
  .crm-app td, .crm-app th { padding-left: 16px; padding-right: 16px; }
  .client-table-head, .client-card { gap: 16px; grid-template-columns: minmax(140px,1.2fr) minmax(90px,.65fr) minmax(120px,1fr) 16px; }
}
@media (max-width: 900px) {
  :root { --sidebar-width: 176px; }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .sidebar .alari-brand { font-size: 21px; gap: 8px; }
  .sidebar-caption { font-size: 9px; }
  .workspace-nav button { padding: 0 12px; gap: 10px; }
  .crm-app .topbar { padding: 0 24px; }
  .crm-app main { padding: 32px 24px; }
  .crm-app .summary { gap: 10px; }
  .crm-app .metric { padding: 20px 16px; }
  .crm-app .table-wrap { overflow-x: auto; }
  .crm-app .search { max-width: none; }
  .task-columns { grid-template-columns: 1fr; gap: 0; }
  .client-table-head, .client-card { grid-template-columns: minmax(140px,1fr) minmax(90px,.6fr) 16px; }
  .client-table-head span:nth-child(3), .client-detail { display: none; }
  .client-toolbar input { width: 100%; max-width: none; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  .crm-app table, .crm-app tbody { display: block; min-width: 0; width: 100%; }
  .crm-app thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .crm-app tbody tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px 12px; padding: 20px; border-top: 1px solid var(--line); }
  .crm-app tbody tr:first-child { border-top: 0; }
  .crm-app td { padding: 0; border: 0; box-shadow: none !important; }
  .crm-app td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .crm-app td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .crm-app td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .crm-app td:nth-child(4) { grid-column: 2; grid-row: 3; justify-self: end; }
  .crm-app td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .crm-app .preview { max-width: none; }
}
@media (max-width: 700px) {
  .crm-app main { width: 100%; margin: 0; padding: 28px 20px calc(108px + env(safe-area-inset-bottom)); }
  .crm-app .topbar { height: 68px; padding: 0 20px; margin: 0; }
  .desktop-crumb, .sidebar-caption, .sidebar > .alari-brand, .sidebar-signature, .account-mark { display: none; }
  .mobile-brand { display: block; font-size: 20px; letter-spacing: 2px; text-decoration: none; font-weight: 600; }
  #workspace-label { display: none; }
  .workspace-account { font-size: 11px; }
  .crm-app .top-actions { gap: 12px; }
  .sidebar { inset: auto 0 0; width: 100%; height: auto; padding: 0; border: 0; background: transparent; }
  .workspace-nav.crm-nav { flex-direction: row; gap: 0; min-height: 76px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid #e8e8e8; background: #fffffff5; backdrop-filter: blur(16px); }
  .workspace-nav button { flex: 1; min-width: 0; min-height: 52px; flex-direction: column; justify-content: center; gap: 5px; padding: 7px 8px; border-radius: 10px; font-size: 10px; }
  .workspace-nav button svg { width: 20px; height: 20px; }
  .workspace-nav .nav-count { display: none; }
  .sidebar-bottom { position: fixed; top: 14px; right: 20px; flex-direction: row; gap: 6px; margin: 0; }
  .sidebar-action { width: 36px; min-height: 36px; padding: 0; justify-content: center; overflow: hidden; font-size: 0; background: #f5f5f5; }
  .sidebar-action svg { width: 17px; height: 17px; }
  .top-actions:has(#workspace-role) { margin-right: 88px; }
  .crm-app:has(#settings-open.hidden) .top-actions { margin-right: 44px; }
  .crm-app .intro { align-items: center; }
  .crm-app h1 { font-size: 28px; }
  .page-eyebrow { font-size: 10px; margin-bottom: 8px; }
  .crm-app .intro-actions .button { min-height: 40px; padding: 0 12px; }
  .crm-app .intro-actions a[download] { display: none; }
  .crm-app .summary { gap: 8px; margin: 24px 0; }
  .crm-app .metric { padding: 18px 12px; border-radius: 12px; }
  .crm-app .metric > span { font-size: 10px; margin-bottom: 14px; }
  .crm-app .metric > strong { font-size: 28px; }
  .metric-dot { display: none; }
  .crm-app .toolbar { padding: 12px; gap: 12px; }
  .crm-app .chat-filters.crm-nav { width: 100%; }
  .crm-app .chat-filters .filter { flex: 1; padding: 0 6px; justify-content: center; min-height: 38px; font-size: 10px; }
  .crm-app .search { width: 100%; max-width: none; min-height: 42px; }
  .crm-app .search input { font-size: 16px; }
  .crm-app .table-wrap { overflow: visible; }
  .crm-app table, .crm-app tbody { display: block; min-width: 0; width: 100%; }
  .crm-app thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .crm-app tbody tr { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px 8px; padding: 20px 16px; border-top: 1px solid var(--line); }
  .crm-app tbody tr:first-child { border-top: 0; }
  .crm-app td { padding: 0; border: 0; }
  .crm-app td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .crm-app td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .crm-app td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .crm-app td:nth-child(4) { grid-column: 2; grid-row: 3; }
  .crm-app td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .crm-app .preview { max-width: none; font-size: 13px; }
  .crm-app .table-footer { padding: 14px 16px; }
  .clients-surface { margin-top: 24px; }
  .client-toolbar.crm-toolbar { padding: 12px; gap: 12px; }
  .client-stage-filters { flex-wrap: nowrap; width: 100%; overflow-x: auto; }
  .client-stage-filters button { min-height: 40px; padding: 9px 10px; font-size: 11px; }
  .client-stage-filters button span { display: none; }
  .client-toolbar input { font-size: 16px; }
  .client-table-head { display: none; }
  .client-card { grid-template-columns: minmax(0,1fr) auto; gap: 16px 12px; padding: 20px 16px; }
  .client-card .client-detail { display: block; grid-column: 1 / -1; }
  .client-arrow { display: none; }
  .client-stage { align-items: flex-end; }
  .client-detail .crm-preview { -webkit-line-clamp: 2; font-size: 12px; }
  .section-count { font-size: 13px; padding: 4px 8px; vertical-align: 3px; }
  #tasks-workspace .intro .button { padding: 0 12px; font-size: 11px; }
  #tasks-workspace > .crm-toolbar { margin-top: 24px; gap: 12px; }
  #tasks-workspace .filters { width: 100%; }
  #tasks-workspace .filter { flex: 1; justify-content: center; }
  #tasks-workspace > .crm-toolbar input { width: 100%; max-width: none; font-size: 16px; }
  .crm-dialog .dialog-head, .crm-dialog .dialog-content { padding: 20px; }
  .crm-dialog label input:not([type=checkbox]), .crm-dialog label select, .crm-dialog label textarea { font-size: 16px; }
  .crm-app .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .crm-dialog .button { min-height: 44px; }
}
@media (max-width: 360px) {
  .crm-app main { padding-left: 12px; padding-right: 12px; }
  .crm-app .topbar { padding-left: 16px; padding-right: 16px; }
  .sidebar-bottom { right: 16px; }
  .crm-app .metric { padding: 16px 10px; }
  .crm-app .metric > span { font-size: 9px; }
  .crm-app .chat-filters .filter { padding: 0 4px; font-size: 9px; }
  .crm-app .filter span { font-size: 9px; min-width: 14px; }
  .client-stage-filters button { padding: 8px; font-size: 10px; }
  .crm-app .person-name { max-width: 150px; }
}

/* Team task workflow and owner reporting. */
.task-toolbar.crm-toolbar { flex-direction: column; align-items: stretch; }
.task-search-tools { display: flex; align-items: center; gap: 12px; }
.task-search-tools select { width: 220px; max-width: 100%; min-height: 44px; }
.task-search-tools input { flex: 1; max-width: none; }
#tasks-workspace .task-filters { width: max-content; max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
#tasks-workspace .task-filters .filter { flex: none; white-space: nowrap; }
.task-columns { grid-template-columns: minmax(0,1.7fr) minmax(240px,1fr); }
.workflow-task { display: grid; grid-template-columns: 18px minmax(0,1fr) 108px; gap: 12px; }
.task-assignee-label { display: inline-flex; margin-top: 10px; padding: 4px 7px; border-radius: 5px; background: #f3f3f3; color: #666; font-size: 10px; }
.quick-task-status { width: 108px; min-height: 38px; margin-top: 14px; padding: 8px; border: 1px solid #e5e5e5; border-radius: 8px; background: white; color: #555; font-size: 11px; cursor: pointer; }
.quick-task-status.status-doing { background: #171717; color: white; border-color: #171717; }
.quick-task-status.status-waiting { background: #f4f4f4; }
.statistics-controls { display: flex; gap: 10px; }
.statistics-controls select { min-height: 42px; padding: 10px 14px; max-width: 220px; border: 1px solid #e5e5e5; border-radius: 10px; background: white; color: var(--ink); font-size: 12px; }
.statistics-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 16px; margin-top: 32px; }
.crm-app .statistics-summary .metric { padding: 22px 20px; }
.crm-app .statistics-summary .metric strong { font-size: 26px; letter-spacing: -.7px; }
.statistics-definition { margin: 16px 0 24px; color: #777; font-size: 11px; line-height: 1.7; }
.statistics-panel { min-width: 0; margin-top: 24px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.statistics-panel h2 { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 20px; font-size: 13px; font-weight: 550; }
.statistics-table-wrap { overflow-x: auto; }
.crm-app .statistics-table { display: table; width: 100%; min-width: 720px; }
.crm-app .statistics-table thead { position: static; display: table-header-group; width: auto; height: auto; clip: auto; overflow: visible; }
.crm-app .statistics-table tbody { display: table-row-group; }
.crm-app .statistics-table tr { display: table-row; }
.crm-app .statistics-table th,.crm-app .statistics-table td { display: table-cell; width: auto; padding: 16px 20px; border-top: 1px solid var(--line); font-size: 11px; white-space: nowrap; }
.crm-app .statistics-table td:first-child { font-weight: 550; }
.statistics-muted { color: #999; }
.statistics-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.statistics-breakdown { padding: 0 20px 8px; }
.statistics-breakdown-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line); font-size: 12px; color: #666; }
.statistics-breakdown-row strong { font-weight: 500; color: var(--ink); }
.statistics-waiting-client { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 52px; padding: 14px 20px; border: 0; border-top: 1px solid var(--line); background: #fff; color: #333; text-align: left; font-size: 12px; }
.statistics-waiting-client:hover { background: #fafafa; }
.statistics-waiting-client span:last-child { color: #777; font-size: 11px; white-space: nowrap; }
@media(max-width:1100px) { .task-columns { grid-template-columns: 1fr; gap: 0; } .statistics-summary { grid-template-columns: 1fr 1fr; } .statistics-controls { flex-wrap: wrap; justify-content: flex-end; } }
@media(max-width:700px) {
  .task-search-tools { flex-direction: column; align-items: stretch; }
  .task-search-tools select { width: 100%; font-size: 16px; }
  .task-search-tools input { width: 100%; }
  #tasks-workspace .task-filters { width: 100%; }
  #tasks-workspace .task-filters .filter { padding: 10px 12px; font-size: 11px; }
  .workflow-task { grid-template-columns: 18px minmax(0,1fr); padding: 4px 14px; gap: 0 12px; }
  .workflow-task .task-body { padding-bottom: 8px; }
  .quick-task-status { grid-column: 2; margin: 0 0 14px; min-height: 44px; width: 100%; font-size: 14px; }
  .crm-app #statistics-workspace .intro { align-items: stretch; flex-direction: column; }
  .statistics-controls { justify-content: flex-start; flex-wrap: nowrap; }
  .statistics-controls select { min-width: 0; flex: 1; width: 50%; max-width: 100%; font-size: 14px; }
  .statistics-summary { gap: 10px; margin-top: 24px; }
  .crm-app .statistics-summary .metric { padding: 18px 14px; }
  .crm-app .statistics-summary .metric > strong { font-size: 24px; }
  .statistics-columns { grid-template-columns: 1fr; gap: 0; }
  .statistics-panel { margin-top: 20px; }
}
.chat-filters .filter {
  margin-bottom: 0;
  min-height: 44px;
}
@media (max-width: 600px) {
  .filters.chat-filters { width: 100%; gap: 4px; }
  .chat-filters .filter {
    flex: 1;
    gap: 5px;
    padding: 11px 4px;
    font-size: 11px;
  }
  .chat-filters .filter span {
    min-width: 16px;
    padding: 3px 4px;
    font-size: 9px;
  }
}

/* The header switches channels, the sidebar switches Telegram tools. */
.crm-app .sidebar { top: var(--alari-header); padding-top: 19px; }
.crm-app .workspace-nav button { min-height: 40px; }
.crm-app .workspace-nav button[aria-current=page] {
  background: #efefef;
  color: #1a1a1a;
}
.crm-app .workspace-nav button[aria-current=page] .nav-count { background: #fff; }
.crm-app .sidebar-signature { display: none; }
.crm-app main { padding: 26px 28px; }
.crm-app h1 { font-weight: 650; }
.crm-app .summary { margin-block: 22px; }
.crm-app .metric { padding: 14px 18px; }
.crm-app .metric > span { margin-bottom: 8px; }
.crm-app .metric > strong { font-size: 26px; }
.crm-app .alari-header .connection { white-space: nowrap; }

@media (max-width: 700px) {
  .crm-app .sidebar { top: auto; padding-top: 0; z-index: 13; }
  .crm-app .sidebar-bottom { top: 8px; z-index: 14; right: 14px; }
  .crm-app .alari-header-actions { margin-right: 84px; }
  .crm-app:has(#settings-open.hidden) .alari-header-actions { margin-right: 42px; }
  .crm-app .alari-header .connection { display: none; }
  .crm-app .alari-header .workspace-account { font-size: 11px; }
  .crm-app main { padding: 18px 14px calc(89px + env(safe-area-inset-bottom)); }
  .crm-app .summary { margin-block: 16px; }
  .crm-app .metric { padding: 12px 9px; }
  .crm-app .chat-filters.crm-nav { flex-wrap: wrap; }
  .crm-app .chat-filters .filter { flex: 1 0 auto; padding-inline: 6px; }
  .crm-app .workspace-nav button { min-height: 48px; }
}
