/* Workspace design system. Loaded after the original functional stylesheet. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  font-size: 15px;
  color: #182b43;
  background: #f4f7fa;
  --ink: #182b43;
  --muted: #68798d;
  --teal: #087f87;
  --teal-soft: #e6f3f2;
  --line: #e3e9ef;
  --surface: #fff;
  --header-height: 72px;
  --nav-height: 0px;
  --app-height: 100dvh;
  --app-offset-top: 0px;
  --radius: 18px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html { min-width: 0; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body { color: var(--ink); background: #f4f7fa; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { min-width: 0; min-height: 44px; padding: 10px 15px; border-radius: 11px; font-size: 13px; font-weight: 600; line-height: 1.35; transition: background .16s ease, border-color .16s ease, box-shadow .16s ease; }
button:hover { background: #f1f7f7; border-color: #b8d7d7; }
button:active { background: #e6f1f1; }
button:disabled { cursor: not-allowed; opacity: .5; }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: 0 2px 3px #06494f0a; }
button.primary:hover { background: #066c74; border-color: #066c74; }
button.small { min-height: 44px; padding: 9px 12px; font-size: 12px; }
button.link { min-height: 44px; padding: 7px 3px; font-size: 12px; }
button.danger { color: #ae3b4a; }
input, select, textarea { min-width: 0; padding: 11px 13px; background: #fff; border: 1px solid #dce4eb; border-radius: 11px; color: var(--ink); font-size: 16px; }
input, select { min-height: 46px; }
input::placeholder, textarea::placeholder { color: #8290a1; opacity: 1; }
input[type="checkbox"], input[type="radio"] { min-height: 20px; width: 20px; height: 20px; flex: 0 0 auto; }
label { color: #53677e; font-size: 13px; }
svg { width: 20px; height: 20px; flex-shrink: 0; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { font-size: 30px; font-weight: 720; letter-spacing: -.9px; line-height: 1.18; }
h2 { font-size: 18px; font-weight: 680; line-height: 1.4; letter-spacing: -.35px; margin-bottom: 18px; }
h3 { font-size: 15px; font-weight: 650; line-height: 1.4; }
p { line-height: 1.55; }
small, .muted { color: var(--muted); }
small { line-height: 1.45; }
a { text-underline-offset: 3px; }
hr { border-color: var(--line); }
:focus-visible { outline: 3px solid #4caeb5; outline-offset: 3px; }
[hidden] { display: none !important; }
.grow, .workspace, .panel, .row, .task, .page-title > *, .home-grid > *, .quick-stats > * { min-width: 0; }
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; padding: 0; }

/* A quiet, permanent desktop navigation rail. */
.sidebar { position: sticky; top: 0; bottom: auto; height: 100dvh; width: auto; padding: 30px 16px 20px; background: #142b3e; border: 0; color: #d6e4eb; box-shadow: none; }
.sidebar > .brand { display: flex; gap: 12px; padding: 0 12px 35px; color: #f5fbff; font-size: 19px; font-weight: 680; letter-spacing: -.5px; }
.sidebar .brand svg { color: #73d4cf; width: 29px; height: 29px; }
.sidebar .brand span { display: inline; }
.sidebar .brand small { display: block; margin-top: 6px; color: #7299ac; font-size: 7px; line-height: 1.3; letter-spacing: 1.4px; font-weight: 550; }
.nav-caption { color: #608398; font-size: 8px; letter-spacing: 1.2px; font-weight: 650; padding: 0 14px 15px; }
.sidebar .nav { display: grid; align-content: start; justify-content: stretch; gap: 5px; height: auto; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #416174 transparent; }
.sidebar .nav button { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 13px; width: 100%; margin: 0; min-width: 0; min-height: 47px; padding: 12px 14px; border: 1px solid transparent; border-radius: 11px; color: #b6cad7; background: transparent; font-size: 13px; text-align: left; font-weight: 520; }
.sidebar .nav button span { display: inline; font-size: inherit; line-height: 1.4; }
.sidebar .nav button svg { width: 20px; height: 20px; color: #89a7b9; }
.sidebar .nav button .nav-icon { position: relative; display: inline-flex; align-items: center; flex: 0 0 20px; height: 20px; }
.sidebar .nav button .nav-badge { position: absolute; right: -8px; top: -7px; display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 14px; padding: 0 3px; border-radius: 4px; background: #a8d9cc; color: #24564e; font-size: 7px; line-height: 1; font-weight: 750; }
.sidebar .nav button:hover { background: #ffffff09; color: #fff; }
.sidebar .nav button.active { color: #f3fffd; background: #2b666c; border-color: #74c1b917; box-shadow: 0 3px 10px #08232d15; }
.sidebar .nav button.active svg { color: #a1eee2; }
.sidebar .side-bottom { display: block; margin-top: auto; padding: 24px 12px 0; }
.sidebar .side-bottom .status { padding-top: 18px; border-top: 1px solid #ffffff13; font-size: 11px; color: #9cb5c4; }
.sidebar .side-bottom .status span { display: inline; }
.sidebar .identity { display: flex; gap: 10px; margin: 18px 0 0; }
.sidebar button.identity { width: 100%; padding: 5px 0; border: 0; background: transparent; text-align: left; }
.sidebar button.identity:hover { background: #ffffff06; }
.sidebar .identity .grow { display: block; }
.sidebar .identity small { display: block; margin-top: 3px; }
.sidebar .identity > svg { width: 17px; height: 17px; color: #85a2b4; }
.sidebar .identity strong { color: #e7f0f6; font-size: 13px; font-weight: 600; }
.sidebar .identity small { color: #92acbd; font-size: 11px; }
.sidebar .identity .avatar { width: 36px; height: 36px; background: #314d62; color: #dceaf2; font-size: 12px; }
.dot { width: 6px; height: 6px; background: #c79245; }
.dot.live { background: #72c5aa; box-shadow: 0 0 0 3px #72c5aa12; }
.mobile-nav, .mobile-brand { display: none; }

/* App bar and common page framing. */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--header-height); padding: 0 32px; display: flex; align-items: center; justify-content: flex-end; gap: 15px; border-bottom: 1px solid #e3e9efa6; background: #ffffffed; backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.topbar .search { display: flex; align-items: center; gap: 10px; flex: 1; margin-right: auto; max-width: 430px; min-width: 0; min-height: 41px; padding: 9px 13px; background: #f4f7f9; border: 1px solid #edf1f4; border-radius: 10px; font-weight: 400; color: #718194; text-align: left; }
.topbar .search:hover { background: #ecf3f5; border-color: #d5e4e8; }
.topbar .search svg { width: 19px; height: 19px; }
.search-symbol { display: inline-flex; align-items: center; justify-content: center; width: 21px; margin: 0; font-size: 22px; line-height: 1; }
.search-copy { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .search kbd { flex-shrink: 0; margin-left: auto; padding: 2px 5px; border: 1px solid #e1e7ec; border-radius: 4px; background: #fff; color: #95a1ac; font-family: inherit; font-size: 9px; white-space: nowrap; }
.topbar-context { color: #92a0ad; font-size: 11px; white-space: nowrap; }
.profile-button { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 0 0 auto; min-width: 44px; min-height: 44px; border: 0; background: transparent; padding: 3px; border-radius: 50%; }
.profile-button .avatar { width: 36px; height: 36px; border: 3px solid #fff; box-shadow: 0 0 0 1px #dce6eb; font-size: 12px; background: #e7eaf6; color: #526186; }
.team { display: flex; gap: 0; padding-right: 5px; }
.team > * + * { margin-left: -7px; }
.team .avatar { border: 2px solid #fff; width: 29px; height: 29px; font-size: 10px; }
main { max-width: 1600px; margin: 0 auto; padding: 30px 32px 38px; }
.page-title { margin-bottom: 25px; gap: 18px; align-items: center; }
.eyebrow { font-size: 10px; line-height: 1.3; letter-spacing: 1.4px; font-weight: 650; color: #748b9c; margin: 0 0 8px; }
.subtitle { margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 620px; }
.panel { padding: 22px; border: 1px solid #e2e9ef; border-radius: var(--radius); background: #fff; box-shadow: 0 3px 15px #1b364703; }
.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.avatar { width: 39px; height: 39px; font-size: 12px; font-weight: 650; background: #e9eaf6; color: #5c6386; }
.avatar.green { color: #177b70; background: #e2f3ed; }
.badge { padding: 5px 9px; font-size: 10px; font-weight: 600; border-radius: 7px; background: #e9f5ef; color: #26765b; }
.badge.warn { background: #fff3df; color: #9a6d27; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; max-width: 65px; min-height: 21px; padding: 3px 6px; border-radius: 7px; background: var(--teal); color: #fff; font-size: 10px; font-weight: 650; line-height: 1.2; white-space: nowrap; }
.network-banner { padding: 11px 24px; background: #fff5e5; border-bottom: 1px solid #f0dfbf; color: #886227; font-size: 12px; line-height: 1.5; text-align: center; }
.network-banner button { margin-left: 8px; min-height: 32px; padding: 4px 9px; font-size: 11px; background: #ffffffb3; border-color: #ead7b8; color: inherit; }
.setup-banner { margin-bottom: 22px; padding: 20px 24px; border: 1px solid #cfe4e4; border-radius: 16px; background: linear-gradient(115deg, #eaf6f4, #f6fafc); }
.setup-banner h3 { font-size: 16px; }
.setup-banner p { font-size: 13px; }

/* The first screen prioritises work, with compact actionable metrics. */
.home-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 26px; }
.home-heading h1 { font-size: 31px; }
.greeting-dot { color: #24a7a1; }
.home-heading .subtitle { font-size: 13px; margin-top: 8px; }
.today-date { flex: 0 0 auto; font-size: 12px; color: #748597; padding: 8px 0 8px 14px; text-align: right; }
.quick-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 25px; }
.metric { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 36px; grid-template-areas: "label label" "value icon" "note note"; align-items: center; gap: 5px 10px; width: 100%; min-height: 126px; padding: 17px 19px; border: 1px solid #dfe8ed; border-radius: 16px; background: #fff; color: var(--ink); text-align: left; box-shadow: 0 3px 12px #17324902; }
.metric:hover { border-color: #94c6c7; background: #fbfefd; box-shadow: 0 5px 17px #1b5b6208; }
.metric-label { grid-area: label; color: #61758b; font-size: 12px; font-weight: 550; line-height: 1.35; }
.metric-value { grid-area: value; color: #18354b; font-size: 32px; font-weight: 710; letter-spacing: -1.3px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-icon { grid-area: icon; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 11px; color: #34858b; background: #edf7f6; }
.metric-icon svg { width: 18px; height: 18px; }
.metric-note { grid-area: note; color: #82909f; font-size: 10px; font-weight: 400; line-height: 1.35; }
.metric:first-child { border-color: #c9e0de; background: #f7fcfb; }
.metric:first-child .metric-value { color: #087d7f; }
.metric-warning .metric-value { color: #ae7640; }
.metric-warning .metric-icon { background: #fbf4e9; color: #b58950; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.home-grid > .panel { padding: 21px 22px 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 16px; letter-spacing: -.25px; }
.section-head .text-action { flex: 0 0 auto; }
.text-action { display: inline-flex; justify-content: center; align-items: center; gap: 3px; border: 0; background: transparent; color: var(--teal); font-size: 11px; padding: 7px 0 7px 8px; min-height: 38px; font-weight: 600; }
.text-action svg { width: 13px; height: 13px; }
.section-description { margin: 0 0 9px; color: #8c9aa7; font-size: 11px; line-height: 1.5; }
.text-action:hover { background: transparent; color: #055c66; text-decoration: underline; text-underline-offset: 3px; }
.conversation-row, .task-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 15px 0; min-height: 82px; border: 0; border-bottom: 1px solid #edf1f4; border-radius: 0; background: transparent; text-align: left; }
.conversation-row:last-child, .task-row:last-child { border-bottom: 0; }
.conversation-row:hover, .task-row:hover { background: #f8fbfc; border-color: #edf1f4; }
.conversation-row .grow strong, .task-row .grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 620; line-height: 1.5; color: #223a50; }
.conversation-row .grow p, .task-row .grow p { margin: 4px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 400; line-height: 1.4; color: #7b8a9b; }
.row-meta { display: flex; flex: 0 0 auto; align-items: flex-end; justify-content: center; flex-direction: column; gap: 7px; padding-left: 3px; }
.row-meta time, .row-meta small { color: #8796a3; font-size: 10px; font-weight: 400; white-space: nowrap; }
.row-meta > svg { width: 15px; height: 15px; color: #a0b2bf; }
.task-marker { display: inline-flex; justify-content: center; align-items: center; width: 20px; height: 20px; flex: 0 0 20px; border: 1.5px solid #cbd8df; border-radius: 6px; background: #fafcfd; color: #5c9a9d; }
.task-marker svg { width: 13px; height: 13px; }
.task-marker.overdue { border-color: #e6bd98; background: #fff8ee; color: #bd8144; }
.task-marker.doing { color: #248f8a; background: #e6f5f0; border-color: #a3d5c8; }
.task-row .grow p.overdue { color: #ac7854; }
.add-task { width: 100%; min-height: 44px; margin: 12px 0 13px; border: 1px dashed #d1e3e4; background: #f9fcfc; color: #5d9395; font-size: 12px; }
.team-panel > .install-card { margin-bottom: 13px; }
.row-chevron { width: 17px; flex: 0 0 17px; color: #9aacb8; font-size: 20px; font-weight: 400; }
.row-chevron svg { width: 16px; height: 16px; }
.followup-panel > p { margin: -1px 0 8px; font-size: 12px; line-height: 1.55; }
.home-grid .empty { padding: 24px 12px 30px; }
.home-grid .empty svg { width: 30px; height: 30px; margin-bottom: 10px; color: #80a5aa; }
.home-grid .empty h3 { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.home-grid .empty p { margin: 5px 0; font-size: 12px; }
.row { padding: 14px 0; gap: 11px; }
.row strong { font-size: 13px; font-weight: 600; }
.row p { font-size: 12px; }
.empty { color: #7c8b9b; }
.empty h3 { color: #4a657b; }
.empty p { font-size: 13px; }

/* Conversations keep their history and composer in independent regions. */
main[data-view="chat"], main:has(.inbox) { display: flex; flex-direction: column; height: calc(var(--app-height) - var(--header-height) - var(--nav-height)); min-height: 0; max-width: none; padding: 20px; overflow: hidden; }
main[data-view="chat"] > .page-title, main:has(.inbox) > .page-title { display: none; }
.inbox { display: grid; grid-template-columns: clamp(210px, 31%, 340px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1; gap: 0; height: auto; min-height: 0; }
.inbox .chat-list { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 20px 10px 10px; overflow: hidden; border-right: 0; border-radius: 16px 0 0 16px; }
.chat-list h3 { display: flex; gap: 8px; align-items: center; margin: 0 10px 16px; font-size: 16px; letter-spacing: -.3px; }
.chat-list h3 small { background: #eef3f6; border-radius: 6px; padding: 2px 6px; color: #7b8b9b; font-size: 10px; font-weight: 500; }
.chat-list .filter { margin: 0 7px 12px; }
.chat-list .filter input { padding: 10px 12px; border-color: #e6edf1; background: #f7f9fb; min-height: 42px; font-size: 13px; }
.chat-filters, .task-filters { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 18px; }
.chat-filters { margin: 0 7px 10px; gap: 5px; }
.filter-chip { min-height: 38px; padding: 7px 12px; border: 1px solid #e2e9ef; border-radius: 9px; background: #fff; color: #6c7e91; font-size: 12px; font-weight: 550; }
.filter-chip.active, .filter-chip[aria-pressed="true"] { color: #087c81; background: #e8f5f3; border-color: #c8e5e2; }
.chat-filters .filter-chip { padding: 6px 10px; font-size: 11px; }
.inbox #chat-items { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #d4dee6 transparent; }
.chat-item { display: flex; width: 100%; min-height: 79px; padding: 13px 10px; margin: 2px 0; gap: 10px; border: 0; border-radius: 10px; align-items: center; }
.chat-item:hover { background: #f4f8f9; }
.chat-item.active { background: #eaf5f4; }
.chat-item .avatar { width: 38px; height: 38px; font-size: 11px; }
.chat-item strong { font-size: 13px; font-weight: 620; }
.chat-item p { margin-top: 4px; font-size: 11px; line-height: 1.45; color: #7c8c9c; }
.inbox .conversation { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 0; border-radius: 0 16px 16px 0; overflow: hidden; }
.inbox .chat-head { display: flex; align-items: center; min-height: 71px; padding: 13px 20px; gap: 12px; border-bottom: 1px solid #e6ecf1; background: #fff; flex-shrink: 0; }
.inbox .chat-head h3 { margin: 0 0 3px; font-size: 14px; line-height: 1.35; font-weight: 650; -webkit-line-clamp: 2; }
.inbox .chat-head small { font-size: 11px; }
.chat-head > button.small { min-width: 44px; font-size: 22px; padding: 4px 10px; border: 0; background: #f6f8fa; }
.inbox .messages { min-height: 0; flex: 1 1 0; padding: 20px 24px; background: #f5f8fa; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; scrollbar-width: thin; scrollbar-color: #cbd8e1 transparent; }
.inbox .message { max-width: 85%; margin-bottom: 18px; }
.message .bubble { border: 1px solid #e8edf1; border-radius: 3px 14px 14px 14px; background: #fff; padding: 11px 14px; font-size: 14px; line-height: 1.6; box-shadow: 0 2px 4px #24415502; }
.message.out .bubble { border-color: #d2e9e4; border-radius: 14px 3px 14px 14px; background: #e2f2ed; color: #234e4b; }
.message.note .bubble { border-color: #f0e3ba; background: #fff8e6; color: #776138; }
.message small { color: #81909f; font-size: 10px; margin-bottom: 5px; }
.message-actions { gap: 9px; }
.message-actions .info-button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; border: 0; background: transparent; font-size: 17px; line-height: 42px; color: #4b8d93; }
.message-actions button.link { min-height: 44px; padding: 8px 2px; font-size: 11px; }
.inbox .composer { flex: 0 0 auto; padding: 9px 16px 12px; background: #fff; border-top: 1px solid #e2e9ee; box-shadow: none; }
.inbox .composer .tabs { display: flex; gap: 20px; margin: 0 0 6px; }
.inbox .composer .tabs button { min-height: 35px; font-size: 12px; font-weight: 550; padding: 5px 0; }
.tabs button.active { border-bottom-color: var(--teal); color: #087b83; }
.inbox .composer textarea { display: block; min-width: 0; width: 100%; height: 55px; min-height: 55px; max-height: 120px; padding: 12px 13px; border-radius: 11px; border-color: #dfe7ed; background: #fbfcfd; font-size: 15px; line-height: 1.45; resize: none; }
.inbox .composer-tools { display: flex; flex-wrap: nowrap; gap: 8px; margin-top: 8px; align-items: center; }
.inbox .composer-tools select { min-width: 0; flex: 0 1 170px; width: 170px; max-width: 170px; min-height: 42px; padding: 7px 8px; font-size: 12px; }
.inbox .composer-tools button { min-height: 42px; font-size: 12px; padding: 9px 12px; }
.inbox .composer-tools > .primary { min-width: 0; margin-left: auto; white-space: normal; }
.inbox .status-line { margin-top: 7px; font-size: 10px; color: #8b98a5; line-height: 1.4; }
.reply-label { color: #50828a; font-size: 11px; }
.reply-label:empty { display: none; }
.inbox .chat-detail { display: none; }
.mobile-back { display: none; }

/* The remaining work surfaces use the same visual and spacing system. */
.toolbar { flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar input { flex: 1 1 200px; max-width: 420px; }
.contact-table { font-size: 13px; }
.contact-table th { padding: 12px 14px 17px; font-size: 10px; font-weight: 600; letter-spacing: .4px; color: #8292a2; }
.contact-table td { padding: 17px 14px; border-bottom-color: #edf1f4; }
.contact-table tr:last-child td { border-bottom: 0; }
.contact-name { gap: 11px; }
.contact-name strong { font-size: 13px; font-weight: 620; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.column { min-width: 0; min-height: 230px; padding: 16px; background: #eaf0f5; border: 1px solid #e2e9f0; border-radius: 16px; }
.column h3 { margin: 0 0 17px; font-size: 13px; font-weight: 650; }
.column h3 .badge { background: #ffffffbd; color: #72859a; }
.task { padding: 17px; margin-bottom: 11px; border-color: #dfe7ee; border-radius: 12px; box-shadow: 0 2px 4px #18364b02; }
.task strong { display: block; font-size: 13px; line-height: 1.55; font-weight: 620; }
.task p { margin: 9px 0 13px; font-size: 12px; line-height: 1.5; }
.task footer { gap: 8px; font-size: 11px; flex-wrap: wrap; }
.task footer .avatar { width: 28px; height: 28px; font-size: 10px; }
.task hr { margin: 13px 0; }
.task .small { width: 100%; color: #678093; background: #fafcfd; border-color: #e8eef2; min-height: 38px; font-size: 11px; }
.overdue { color: #ae6943; }
.settings { max-width: 1040px; gap: 20px; }
.settings .panel { padding: 25px 27px; }
.settings .panel > .muted { font-size: 13px; }
.settings .form { max-width: 620px; }
.form { gap: 18px; }
.form .two { gap: 15px; }
.form label { font-size: 12px; }
.notice, .inline-error { line-height: 1.55; }
.notice { border: 1px solid #eee3c7; border-radius: 10px; background: #fff9ed; }
.setup-help { border-color: #dce9e9; background: #f3f9f8; font-size: 12px; }
.setup-help summary { min-height: 38px; }
.check-row { padding: 13px 8px; font-size: 13px; }
.check-row input { min-height: 20px; }
.ops-filters { gap: 10px; }
.ops-filters > * { min-width: min(150px, 100%); }
.ops-card { margin: 14px 0; }
.ops-card-head { gap: 14px; }
.ops-card-head h3 { font-size: 15px; }
.ops-preview, .journal-entry p, .summary-body { font-size: 13px; line-height: 1.65; }
.ops-counts { font-size: 12px; }
.ledger-grid { gap: 16px; }
.dossier-toolbar { gap: 9px; }
.dossier-chips { gap: 5px; }
.chip-check { min-height: 38px; gap: 6px; padding: 6px 10px; font-size: 12px; }
.chip-check input { width: 17px; height: 17px; min-height: 17px; }
.chip-check:has(input:checked) { background: #e7f4f2; color: #157e80; border-color: #b9ddd8; }
.chip-set { border-radius: 11px; }
.summary-report { margin-top: 18px; }
.summary-person summary { font-size: 13px; }
.permission-person, .journal-entry { font-size: 13px; }

/* Native dialogs: desktop cards and a reachable phone menu. */
dialog { width: min(620px, calc(100vw - 32px)); max-height: min(88dvh, calc(var(--app-height) - 32px)); padding: 30px; border: 1px solid #e1e9ef; border-radius: 22px; color: var(--ink); background: #fff; box-shadow: 0 30px 90px #112b3c2b; overscroll-behavior: contain; }
dialog::backdrop { background: #10263663; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
dialog h2 { font-size: 21px; padding-right: 38px; margin-bottom: 21px; }
dialog .close { display: flex; align-items: center; justify-content: center; top: 12px; right: 12px; min-height: 44px; min-width: 44px; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; color: #7b8b9b; background: #f4f7f9; font-size: 23px; }
dialog .close:hover { background: #e9f0f3; }
.preview-text { padding: 17px; border: 1px solid #d6eae6; border-radius: 12px; background: #eff8f5; font-size: 14px; }
.search-results { max-height: 56dvh; }
.search-hit { min-width: 0; padding: 14px; border-color: #e2eaf0; }
.search-hit p { font-size: 12px; }
dialog.workspace-menu, dialog:has(.workspace-menu) { width: min(440px, calc(100vw - 32px)); padding: 28px; }
.workspace-menu { width: auto; padding: 0; }
.workspace-menu h2 { margin-bottom: 20px; font-size: 21px; }
.menu-profile { display: flex; align-items: center; gap: 13px; padding: 0 0 21px; border-bottom: 1px solid #e7edf2; margin-bottom: 18px; }
.menu-profile .avatar { width: 46px; height: 46px; font-size: 15px; background: #e4f1ef; color: #29837c; }
.menu-profile strong { display: block; font-size: 15px; font-weight: 650; }
.menu-profile small, .menu-profile p { display: block; font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 21px; }
.menu-grid button { display: flex; align-items: center; gap: 10px; min-height: 57px; padding: 12px; border-color: #e6edf1; background: #f8fafb; color: #38546b; text-align: left; font-size: 12px; font-weight: 550; }
.menu-grid button:hover { background: #edf6f5; border-color: #cde3df; }
.menu-grid button svg { width: 20px; height: 20px; color: #53868e; }
.menu-grid button svg:last-child { width: 14px; height: 14px; margin-left: auto; color: #96aab5; }
.menu-grid button span { min-width: 0; }
.menu-settings { padding-top: 18px; border-top: 1px solid #e7edf2; }
.menu-settings label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; }
.menu-settings select, .menu-settings .ui-language { flex: 0 0 112px; width: 112px; padding: 8px 10px; min-height: 44px; border-color: #e1e9ee; background: #f8fafb; color: #3b5c72; font-size: 14px; }
.install-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 66px; margin-top: 17px; padding: 14px; border: 1px solid #d3e8e4; background: #f0f9f6; color: #247a74; border-radius: 13px; text-align: left; }
.install-card svg { width: 24px; height: 24px; }
.install-card > span { flex: 1; min-width: 0; }
.install-card > svg:last-child { width: 15px; height: 15px; margin-left: auto; color: #79a6a0; }
.install-card span, .install-card strong { display: block; font-size: 12px; font-weight: 600; }
.install-card small { display: block; font-size: 11px; font-weight: 400; margin-top: 3px; color: #6c9990; }
.menu-footer { margin-top: 20px; padding-top: 14px; border-top: 1px solid #e7edf2; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-footer button { display: inline-flex; gap: 7px; align-items: center; min-height: 44px; padding: 8px 0; border: 0; background: transparent; color: #a45861; font-size: 12px; }
.menu-footer button svg { width: 16px; height: 16px; }
.menu-footer > span { color: #92a0ac; font-size: 11px; }
.menu-footer small { color: #92a0ac; font-size: 10px; }
.pwa-update { position: fixed; z-index: 80; right: 24px; bottom: 24px; display: flex; align-items: center; gap: 16px; width: min(460px, calc(100vw - 32px)); padding: 16px 18px; border: 1px solid #d1e0e4; border-radius: 16px; background: #fff; box-shadow: 0 12px 45px #193a5126; }
.pwa-update-copy { flex: 1; min-width: 0; font-size: 12px; color: #6e8293; line-height: 1.45; }
.pwa-update-copy strong { display: block; color: #28465a; font-size: 13px; font-weight: 650; margin-bottom: 4px; }
.pwa-update-copy p { margin: 0; }
.pwa-update-actions { display: flex; align-items: center; gap: 7px; }
.pwa-update-actions button { font-size: 11px; min-height: 44px; padding: 8px 10px; }
.pwa-install-dialog { width: min(430px, calc(100vw - 32px)); }
.pwa-install-dialog p, .pwa-install-dialog li { font-size: 14px; line-height: 1.65; color: #62788b; }
.pwa-install-dialog ol { padding-left: 23px; }
.pwa-install-dialog li { padding-left: 5px; margin-bottom: 12px; }
.pwa-install-dialog .primary { width: 100%; margin-top: 8px; }
#toast { z-index: 1100; top: calc(16px + env(safe-area-inset-top)); bottom: auto; max-width: min(520px, calc(100vw - 32px)); padding: 13px 18px; border: 1px solid #ffffff17; border-radius: 13px; background: #203d50; box-shadow: 0 8px 30px #1d394127; font-size: 13px; }

.login-page { min-height: var(--app-height); padding: 30px 20px; background: radial-gradient(ellipse at 25% 15%, #e0f1ee, transparent 48%), radial-gradient(ellipse at 80% 90%, #e8edf5, transparent 45%), #f5f8fa; }
.login-card { max-width: 430px; padding: 73px 34px 33px; border-color: #e0e9ee; border-radius: 24px; box-shadow: 0 20px 70px #2141540b; }
.login-card .brand { display: flex; padding: 0 0 26px; font-size: 20px; letter-spacing: -.5px; }
.login-card .brand span { display: inline; }
.login-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -.8px; }
.login-card p { font-size: 13px; line-height: 1.6; }
.login-card button.primary { min-height: 48px; }
.login-language { top: 19px; right: 22px; }

@media (min-width: 1600px) {
  main { padding-left: 44px; padding-right: 44px; }
  .topbar { padding-left: 44px; padding-right: 44px; }
  .home-grid { gap: 24px; }
  .inbox { grid-template-columns: 350px minmax(0, 1fr); }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .shell { grid-template-columns: 208px minmax(0, 1fr); }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .sidebar > .brand { font-size: 17px; gap: 9px; }
  .sidebar .nav button { padding-left: 12px; padding-right: 9px; gap: 11px; font-size: 12px; }
  .topbar { padding: 0 24px; }
  .topbar-context { display: none; }
  main { padding: 26px 24px; }
  .home-heading h1 { font-size: 27px; }
  .today-date { display: none; }
  .quick-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .metric { min-height: 111px; }
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .column { min-height: 0; }
  .task footer { flex-wrap: nowrap; }
  .inbox { grid-template-columns: minmax(170px, 40%) minmax(0, 1fr); }
  main[data-view="chat"], main:has(.inbox) { padding: 10px; }
  .inbox .chat-list { padding-left: 5px; padding-right: 5px; }
  .chat-list h3 { font-size: 14px; }
  .chat-item { padding: 12px 6px; gap: 7px; }
  .chat-item .avatar { width: 30px; height: 30px; font-size: 10px; }
  .chat-item strong { font-size: 12px; }
  .chat-item p { font-size: 10px; }
  .inbox .chat-head { padding: 10px 12px; }
  .inbox .chat-head .avatar { display: none; }
  .inbox .messages { padding: 16px 12px; }
  .inbox .composer { padding-left: 10px; padding-right: 10px; }
  .inbox .composer-tools { flex-wrap: wrap; }
  .inbox .composer-tools select { flex: 1; width: auto; max-width: none; }
  .inbox .composer-tools > .primary { flex-basis: 100%; margin-left: 0; }
}

@media (max-width: 700px) {
  :root { --header-height: calc(60px + env(safe-area-inset-top)); --nav-height: calc(66px + env(safe-area-inset-bottom)); --radius: 16px; }
  html { scroll-padding-top: var(--header-height); }
  body { background: #f4f7fa; }
  .shell { display: block; min-height: 100dvh; padding-bottom: var(--nav-height); }
  .shell:has(.inbox) { padding-bottom: var(--nav-height); }
  .sidebar { display: none; }
  .topbar { position: sticky; top: 0; z-index: 40; height: var(--header-height); padding: env(safe-area-inset-top) 16px 0; gap: 8px; background: #ffffffed; border-bottom-color: #e3eaf0cc; }
  .mobile-brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: #223d52; font-size: 16px; font-weight: 700; letter-spacing: -.5px; line-height: 1.2; }
  .mobile-brand svg { width: 27px; height: 27px; color: #16898d; }
  .mobile-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-brand .brand-mark { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 10px; background: #eaf5f2; }
  .mobile-brand small { display: block; margin-top: 3px; color: #8b9eaa; font-size: 9px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; }
  .topbar .search { display: flex; justify-content: center; align-items: center; flex: 0 0 44px; min-height: 44px; width: 44px; max-width: 44px; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 50%; color: #627e91; }
  .topbar .search svg { width: 21px; height: 21px; }
  .search-symbol { font-size: 24px; width: auto; }
  .search-copy, .topbar .search kbd, .topbar-context { display: none; }
  .profile-button { min-width: 44px; min-height: 44px; width: 44px; padding: 4px; }
  .profile-button .avatar { width: 33px; height: 33px; border-width: 2px; font-size: 11px; }
  .topbar .team { display: none; }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); left: 0; right: 0; bottom: 0; z-index: 50; gap: 0; width: 100%; height: var(--nav-height); padding: 5px 8px env(safe-area-inset-bottom); border-top: 1px solid #dfe8eec9; background: #ffffffed; backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); box-shadow: 0 -5px 25px #173b5004; overflow: visible; }
  .mobile-nav button, .mobile-nav.nav button { display: flex; flex: initial; flex-direction: column; justify-content: center; align-items: center; min-width: 0; width: 100%; min-height: 55px; height: 55px; margin: 0; padding: 3px 0 4px; gap: 3px; border: 0; border-radius: 11px; background: transparent; color: #8092a3; font-weight: 550; font-size: 10px; text-align: center; overflow: visible; }
  .mobile-nav button:hover { background: #f4f8f9; }
  .mobile-nav button.active { color: #087e86; background: transparent; }
  .mobile-nav .nav-icon { position: relative; display: inline-flex; justify-content: center; align-items: center; width: 43px; height: 28px; border-radius: 9px; }
  .mobile-nav button.active .nav-icon { background: #e2f2ef; }
  .mobile-nav button svg { width: 21px; height: 21px; }
  .mobile-nav .nav-label, .mobile-nav.nav button .nav-label { display: block; min-width: 0; max-width: 100%; font-size: 10px; line-height: 1.25; letter-spacing: -.15px; font-weight: 600; white-space: nowrap; }
  .mobile-nav .nav-badge { position: absolute; top: -2px; right: -5px; display: flex; align-items: center; justify-content: center; min-width: 16px; height: 15px; padding: 1px 4px; border: 2px solid #fff; border-radius: 6px; background: #168a90; color: #fff; font-size: 8px; font-weight: 700; line-height: 1; }
  main { max-width: none; padding: 23px 16px 27px; }
  .page-title { align-items: flex-start; margin-bottom: 20px; gap: 12px; }
  h1, .page-title h1 { font-size: 25px; line-height: 1.2; letter-spacing: -.7px; }
  h2 { font-size: 17px; }
  .eyebrow { margin-bottom: 7px; font-size: 9px; letter-spacing: 1.15px; }
  .subtitle { font-size: 12px; margin-top: 7px; line-height: 1.5; }
  .page-title > .primary { max-width: 131px; min-height: 44px; padding: 10px 12px; font-size: 12px; flex-shrink: 0; }
  .panel { padding: 18px; border-radius: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .home-heading { gap: 12px; margin-bottom: 19px; align-items: flex-start; }
  .home-heading h1 { font-size: 25px; line-height: 1.2; }
  .home-heading .eyebrow { font-size: 9px; margin-bottom: 6px; }
  .home-heading .subtitle { font-size: 12px; margin-top: 7px; }
  .today-date { display: none; }
  .quick-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 20px; }
  .metric { min-height: 83px; padding: 10px 12px; grid-template-columns: minmax(0, 1fr) 27px; grid-template-rows: auto 27px auto; gap: 2px 7px; border-radius: 13px; }
  .metric-label { font-size: 11px; line-height: 1.3; font-weight: 550; }
  .metric-value { font-size: 26px; letter-spacing: -.8px; line-height: 1; }
  .metric-icon { width: 26px; height: 26px; border-radius: 8px; }
  .metric-icon svg { width: 15px; height: 15px; }
  .metric-note { font-size: 9px; line-height: 1.35; }
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .home-grid > .panel { padding: 15px 15px 4px; }
  .section-head { gap: 8px; margin-bottom: 4px; min-height: 36px; }
  .section-head h2 { font-size: 16px; }
  .section-description { font-size: 10px; margin-bottom: 5px; }
  .text-action { min-height: 44px; padding: 7px 0 7px 6px; font-size: 11px; }
  .conversation-row, .task-row { gap: 10px; min-height: 77px; padding: 13px 0; }
  .conversation-row .avatar { width: 35px; height: 35px; font-size: 11px; }
  .conversation-row .grow strong, .task-row .grow strong { font-size: 13px; line-height: 1.5; }
  .conversation-row .grow p, .task-row .grow p { font-size: 12px; margin-top: 3px; }
  .row-meta { gap: 6px; padding-left: 0; }
  .row-meta time, .row-meta small { font-size: 9px; }
  .count { min-width: 21px; min-height: 20px; padding: 3px 5px; font-size: 9px; }
  .task-marker { width: 17px; height: 17px; flex-basis: 17px; border-radius: 5px; }
  .followup-panel > p { margin: 4px 0 6px; font-size: 11px; }
  .home-grid .empty { padding: 20px 10px 26px; }
  .network-banner { padding: 9px 15px; font-size: 11px; }
  .setup-banner { display: block; padding: 19px; margin-bottom: 18px; }
  .setup-banner h3 { font-size: 16px; }
  .setup-banner p { font-size: 12px; }
  .setup-banner button { width: 100%; min-height: 44px; margin-top: 10px; }
  .row { gap: 10px; align-items: center; }
  .row strong { font-size: 13px; }
  .row p { font-size: 11px; }
  .row > button { flex-shrink: 0; }
  button.small, button.link { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  .toolbar { gap: 9px; }
  .toolbar input { max-width: none; width: 100%; }
  .toolbar button { min-height: 44px; }
  .settings { gap: 15px; }
  .settings .panel { padding: 22px 18px; }
  .settings h2 { font-size: 18px; }
  .settings .form { max-width: none; }
  .settings .form > .primary { width: 100%; }
  .form .two { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .form label { font-size: 12px; }
  .check-row { padding: 13px 3px; gap: 11px; font-size: 13px; line-height: 1.5; }
  .dialog-list { max-height: 50dvh; }
  .scroll-table { padding: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .contact-table, .contact-table tbody { display: block; width: 100%; }
  .contact-table thead { display: none; }
  .contact-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 15px; margin-bottom: 12px; padding: 17px; border: 1px solid #e1e9ee; border-radius: 15px; background: #fff; }
  .contact-table td { display: flex; min-width: 0; flex-direction: column; gap: 6px; padding: 0; border: 0; font-size: 13px; overflow-wrap: anywhere; }
  .contact-table td:first-child { grid-column: 1 / -1; padding-bottom: 13px; border-bottom: 1px solid #edf1f4; }
  .contact-table td:last-child { justify-content: end; }
  .contact-table td[data-label]::before { content: attr(data-label); font-size: 10px; color: #8494a3; }
  .contact-name .avatar { width: 38px; height: 38px; }
  .contact-name strong { font-size: 13px; }
  .kanban { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; overflow: visible; scroll-snap-type: none; padding-bottom: 0; }
  .column { min-width: 0; min-height: 0; padding: 15px; border-radius: 15px; }
  .column h3 { font-size: 13px; margin: 1px 0 15px; }
  .task { padding: 16px; border-radius: 12px; }
  .task:last-child { margin-bottom: 0; }
  .task strong { font-size: 14px; }
  .task p { font-size: 12px; }
  .task footer { flex-wrap: nowrap; }
  .task .small { min-height: 44px; font-size: 12px; }
  .task-filters { gap: 7px; margin-bottom: 17px; }
  .filter-chip { min-height: 44px; font-size: 12px; padding: 8px 12px; }
  .ops-filters > * { min-width: 100%; width: 100%; }
  .ops-card-head { flex-wrap: wrap; }
  .ops-card .controls > *, .ledger-grid .controls > * { flex: 1; min-width: 110px; }
  .ledger-grid { grid-template-columns: minmax(0, 1fr); }
  .dossier-toolbar > input { min-width: 0; width: 100%; flex-basis: 100%; }
  .chip-check { min-height: 44px; }

  /* Lists fill the available screen; an open conversation owns the viewport. */
  main[data-view="chat"], main:has(.inbox) { height: calc(var(--app-height) - var(--header-height) - var(--nav-height)); min-height: 0; padding: 0; }
  .inbox { display: block; flex: 1; min-height: 0; height: 100%; }
  .inbox .chat-list { height: 100%; min-height: 0; padding: 20px 12px 8px; border: 0; border-radius: 0; background: #fff; }
  .chat-list h3 { margin: 0 8px 15px; font-size: 23px; letter-spacing: -.65px; }
  .chat-list h3 small { font-size: 11px; padding: 3px 7px; }
  .chat-list .filter { margin: 0 5px 10px; }
  .chat-list .filter input { min-height: 45px; padding: 10px 12px; font-size: 16px; }
  .chat-filters { gap: 6px; margin: 0 5px 8px; }
  .chat-filters .filter-chip { min-height: 44px; font-size: 11px; padding: 7px 11px; }
  .chat-item { min-height: 84px; padding: 14px 8px; gap: 12px; border-radius: 11px; }
  .chat-item .avatar { width: 43px; height: 43px; font-size: 12px; }
  .chat-item strong { font-size: 14px; }
  .chat-item p { font-size: 12px; margin-top: 5px; }
  .chat-item .count { min-width: 23px; min-height: 21px; font-size: 10px; }
  .inbox .conversation { display: none; min-height: 0; height: 100%; border: 0; border-radius: 0; padding: 0; }
  .inbox.has-chat .chat-list { display: none; }
  .inbox.has-chat .conversation { display: flex; }
  .conversation-open .topbar, .conversation-open .mobile-nav { display: none; }
  html.conversation-viewport { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body.conversation-open { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  .conversation-open #app { height: 100%; min-height: 0; }
  /* One fixed viewport owner; no separate keyboard rule may reset its top. */
  .conversation-open .shell { position: fixed; top: var(--app-offset-top); right: 0; bottom: auto; left: 0; width: 100%; height: var(--app-height); min-height: 0; padding: 0; overflow: hidden; }
  .conversation-open .workspace { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .conversation-open .network-banner { flex: 0 0 auto; }
  .conversation-open main[data-view="chat"], .conversation-open main:has(.inbox.has-chat), .keyboard-open.conversation-open main:has(.inbox.has-chat) { flex: 1 1 0; height: 100%; min-height: 0; padding: 0; }
  .inbox .chat-head, .keyboard-open .inbox .chat-head { min-height: calc(64px + env(safe-area-inset-top)); padding: calc(8px + env(safe-area-inset-top)) 12px 8px 7px; gap: 9px; }
  .inbox .chat-head h3 { font-size: 14px; line-height: 1.35; margin-bottom: 3px; }
  .inbox .chat-head small { font-size: 10px; }
  .inbox .chat-head .avatar { display: flex; width: 33px; height: 33px; font-size: 10px; }
  .mobile-back { display: flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: #347285; font-size: 32px; font-weight: 400; line-height: 1; }
  .mobile-back svg { width: 22px; height: 22px; }
  .inbox .chat-head > button.small { width: 44px; min-width: 44px; min-height: 44px; padding: 0; background: transparent; font-size: 24px; }
  .inbox .messages { padding: 17px 13px; }
  .inbox .message { max-width: 91%; margin-bottom: 16px; }
  .message .bubble { padding: 11px 13px; font-size: 15px; line-height: 1.55; }
  .message small { font-size: 10px; }
  .message small button { min-height: 44px; }
  .messages > .controls { display: flex; flex-wrap: wrap; gap: 7px; }
  .messages > .controls button { flex: 1 1 110px; min-height: 44px; padding: 8px 10px; font-size: 11px; }
  .message-actions .info-button { min-width: 44px; min-height: 44px; width: 44px; height: 44px; }
  .inbox .composer, .keyboard-open .inbox .composer { padding: 7px 12px calc(10px + env(safe-area-inset-bottom)); }
  .inbox .composer .tabs, .keyboard-open .inbox .composer .tabs { gap: 20px; margin: 0 0 6px; }
  .inbox .composer .tabs button, .keyboard-open .inbox .composer .tabs button { min-height: 44px; font-size: 12px; padding: 4px 0; }
  .inbox .composer textarea, .keyboard-open .inbox .composer textarea { min-height: 48px; height: 48px; max-height: 112px; padding: 11px 12px; font-size: 16px; }
  .inbox .composer-tools, .keyboard-open .inbox .composer-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.7fr); gap: 6px; margin-top: 7px; }
  .inbox .composer-tools select, .keyboard-open .inbox .composer-tools select { min-height: 44px; min-width: 0; width: 100%; max-width: none; padding: 7px 5px; font-size: 16px; }
  .inbox .composer-tools button, .keyboard-open .inbox .composer-tools button { min-height: 44px; min-width: 0; padding: 7px 8px; font-size: 11px; line-height: 1.3; }
  .inbox .composer-tools > .primary, .keyboard-open .inbox .composer-tools > .primary { grid-column: auto; margin-left: 0; min-height: 44px; font-size: 11px; }
  .inbox .composer-tools > .primary:only-child, .keyboard-open .inbox .composer-tools > .primary:only-child { grid-column: 1 / -1; }
  .inbox .status-line { display: block; margin-top: 6px; font-size: 9px; line-height: 1.35; }
  .keyboard-open .inbox .composer { padding-bottom: 9px; }
  .keyboard-open .inbox .chat-head { min-height: calc(52px + env(safe-area-inset-top)); padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .keyboard-open .inbox .status-line, .keyboard-open .inbox .chat-head small { display: none; }

  dialog { width: calc(100vw - 24px); max-height: calc(var(--app-height) - 24px - env(safe-area-inset-top)); padding: 28px 20px 22px; border-radius: 20px; }
  dialog h2 { font-size: 21px; }
  dialog .close { top: 10px; right: 10px; }
  .preview-text { font-size: 14px; padding: 15px; }
  dialog.workspace-menu, dialog:has(.workspace-menu) { inset: auto 0 0; width: 100%; max-width: none; max-height: calc(var(--app-height) - 24px - env(safe-area-inset-top)); margin: auto 0 0; padding: 27px 20px calc(19px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; border-bottom: 0; }
  .workspace-menu { width: auto; padding: 0; }
  dialog:has(.workspace-menu)::before, dialog.workspace-menu::before { content: ""; position: absolute; top: 9px; left: calc(50% - 17px); width: 34px; height: 4px; border-radius: 4px; background: #d7e1e8; }
  .workspace-menu h2 { font-size: 21px; margin-bottom: 18px; }
  .menu-profile { padding-bottom: 17px; margin-bottom: 15px; }
  .menu-grid { gap: 8px; margin-bottom: 17px; }
  .menu-grid button { min-height: 57px; padding: 11px; font-size: 12px; }
  .menu-settings { padding-top: 15px; }
  .menu-settings select, .menu-settings .ui-language { font-size: 16px; }
  .menu-footer { margin-top: 17px; padding-top: 11px; }
  .install-card { margin-top: 15px; }
  .pwa-update { left: 12px; right: 12px; bottom: calc(var(--nav-height) + 10px); width: auto; max-width: none; padding: 13px 14px; gap: 10px; border-radius: 15px; }
  .pwa-update-copy { font-size: 11px; }
  .pwa-update-copy strong { font-size: 12px; }
  .pwa-update-actions { gap: 5px; flex-shrink: 0; }
  .pwa-update-actions button { padding: 7px 9px; font-size: 10px; }
  .conversation-open .pwa-update { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .pwa-install-dialog { padding: 29px 22px 22px; }
  .login-page { padding: 22px 16px; }
  .login-card { padding: 72px 26px 29px; }
  .login-card h1 { font-size: 28px; }
  .login-card .brand { padding-bottom: 25px; font-size: 20px; }
  #toast { top: calc(10px + env(safe-area-inset-top)); font-size: 12px; }
}

@media (max-width: 360px) {
  .topbar { padding-left: 13px; padding-right: 11px; gap: 4px; }
  .mobile-brand { gap: 7px; font-size: 15px; }
  main { padding-left: 13px; padding-right: 13px; }
  .home-heading h1 { font-size: 23px; }
  .home-heading .subtitle { font-size: 11px; }
  .metric { padding-left: 10px; padding-right: 10px; }
  .metric-label { font-size: 10px; }
  .metric-value { font-size: 25px; }
  .home-grid > .panel { padding-left: 13px; padding-right: 13px; }
  .conversation-row { gap: 8px; }
  .conversation-row .avatar { width: 31px; height: 31px; font-size: 10px; }
  .section-head h2 { font-size: 14px; }
  .mobile-nav { padding-left: 4px; padding-right: 4px; }
  .mobile-nav .nav-label, .mobile-nav.nav button .nav-label { font-size: 9px; }
  .inbox .chat-head { gap: 7px; padding-right: 8px; }
  .inbox .chat-head .avatar { display: none; }
  .inbox .composer, .keyboard-open .inbox .composer { padding-left: 10px; padding-right: 10px; }
  .inbox .composer-tools, .keyboard-open .inbox .composer-tools { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.6fr); gap: 5px; }
  .inbox .composer-tools button { font-size: 10px; padding: 7px 6px; }
  .pwa-update { flex-wrap: wrap; }
  .pwa-update-copy { flex-basis: 100%; }
  .pwa-update-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 700px) and (max-height: 600px) {
  .conversation-open .inbox .chat-head { min-height: calc(52px + env(safe-area-inset-top)); padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .conversation-open .inbox .chat-head small { display: none; }
  .inbox .status-line { display: none; }
  .inbox .composer .tabs button { min-height: 44px; }
  .inbox .composer .tabs { margin-bottom: 3px; }
  .workspace-menu .menu-grid { gap: 6px; }
  .workspace-menu .menu-grid button { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Legible conversation text at phone viewing distance. */
@media (max-width: 700px) {
  .conversation-row .grow strong, .task-row .grow strong { font-size: 14px; }
  .conversation-row .grow p, .task-row .grow p { font-size: 13px; }
  .section-description { font-size: 12px; }
}

/* Private Telegram photos keep a deterministic fallback without layout shifts. */
.telegram-avatar { position: relative; overflow: hidden; flex-shrink: 0; }
.telegram-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.telegram-avatar img.loaded { opacity: 1; }
.profile-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.profile-heading h2 { margin: 0; }
.country-badge { display: inline-block; align-items: center; width: fit-content; max-width: 100%; gap: 4px; padding: 2px 7px; margin: 3px 0 1px; border: 1px solid #d5e7e5; border-radius: 6px; background: #edf6f4; color: #315b56; font-size: 11px; font-weight: 600; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.country-empty { background: #f2f4f7; border-color: #e1e5eb; color: #697589; font-weight: 500; }
.chat-item .grow,.conversation-row .grow { min-width: 0; }
.chat-item .grow>strong,.conversation-row .grow>strong { display: block; }
.chat-head .grow { min-width: 0; }
.chat-head .grow>small { display: block; }
.chat-head button.country-badge { min-height: 24px; margin: 1px 0 3px; padding: 2px 7px; font-size: 11px; }
.chat-head button.country-badge:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
@media (max-width: 700px) {
  .chat-head button.country-badge { min-height: 26px; }
  .keyboard-open .chat-head .grow>small { display: none; }
}

/* ---- mobile overflow fix (20261115) ----
   Issue: a long "white-space: nowrap" child inside .chat-head (country badge,
   long title segment, etc.) could grow <main> beyond its parent width because
   <main> is a flex item with the default min-width: auto. Setting min-width: 0
   lets main shrink to its parent; the badge then honours its own max-width:100%
   + text-overflow:ellipsis. Safety belts: ensure the inbox layer chain also
   caps at the viewport, and that nowrap chat-head children ellipsize cleanly. */
main[data-view="chat"],
main:has(.inbox),
main:has(.inbox.has-chat),
.conversation-open main[data-view="chat"],
.conversation-open main:has(.inbox.has-chat),
.keyboard-open.conversation-open main:has(.inbox.has-chat) { min-width: 0; max-width: 100%; }
.inbox, .inbox .conversation, .inbox .chat-head, .inbox .chat-list,
.inbox .messages, .inbox .composer { min-width: 0; max-width: 100%; }
.inbox .chat-head .grow { min-width: 0; max-width: 100%; overflow: hidden; }
.inbox .chat-head .grow > * { max-width: 100%; }
.inbox .chat-head h3 { overflow-wrap: anywhere; min-width: 0; }
.inbox .chat-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: block; }
.chat-head button.country-badge { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
