:root {
  color-scheme: light;
  --ink: #132733;
  --muted: #667985;
  --paper: #ffffff;
  --canvas: #edf2f3;
  --navy: #152d3d;
  --navy-soft: #23475b;
  --teal: #178b85;
  --teal-dark: #0d6966;
  --line: #d8e1e4;
  --danger: #a62f3c;
  --danger-bg: #fff0f1;
  --success: #166b4e;
  --success-bg: #eaf7f1;
  --surface-soft: #f7faf9;
  --surface-muted: #f0f5f5;
  --surface-hover: #f5f8f8;
  --surface-selected: #e8f4f2;
  --thread-canvas: #e9f0f1;
  --bubble-in: #ffffff;
  --bubble-out: #dff2ed;
  --overlay: rgba(5, 20, 28, .45);
  --shadow: 0 24px 70px rgba(14, 39, 52, 0.13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
svg { display: block; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(23, 139, 133, .17), transparent 28rem),
    linear-gradient(145deg, #f6f8f7, #e5edef);
}
.auth-card {
  width: min(100%, 31rem);
  padding: clamp(1.5rem, 5vw, 2.75rem);
  border: 1px solid rgba(21, 45, 61, .09);
  border-radius: 1.4rem;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
}
.brand-mark {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border-radius: 1rem;
  color: white;
  background: linear-gradient(145deg, var(--navy), var(--teal));
  font-weight: 800;
  letter-spacing: -.08em;
}
.brand-mark-small { width: 2.2rem; height: 2.2rem; border-radius: .65rem; font-size: .8rem; }
.eyebrow { margin: 1.4rem 0 .35rem; color: var(--teal-dark); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.75rem, 4vw, 2.35rem); letter-spacing: -.04em; }
h2 { letter-spacing: -.025em; }
.muted { color: var(--muted); line-height: 1.55; }
form { display: grid; gap: 1rem; margin-top: 1.5rem; }
label { display: grid; gap: .45rem; font-size: .86rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .83rem .95rem;
  color: var(--ink);
  background: var(--paper);
  outline: none;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23, 139, 133, .14); }
.button { display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; border: 0; border-radius: .75rem; padding: .72rem 1rem; cursor: pointer; font-weight: 800; }
.button:disabled { cursor: wait; opacity: .6; }
.button-primary { color: white; background: var(--navy); }
.button-primary:hover { background: var(--navy-soft); }
.button-quiet { color: #dbe9ed; background: rgba(255, 255, 255, .08); }
.alert { margin-top: 1.2rem; border: 1px solid; border-radius: .8rem; padding: .9rem 1rem; font-size: .9rem; line-height: 1.45; }
.alert ul { margin-bottom: 0; padding-left: 1.25rem; }
.alert-error { color: var(--danger); border-color: #f0c6cb; background: var(--danger-bg); }
.alert-success { color: var(--success); border-color: #bde4d2; background: var(--success-bg); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 16rem minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 1.25rem; color: white; background: var(--navy); }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; color: white; text-decoration: none; font-weight: 800; }
.sidebar nav { display: grid; gap: .35rem; margin-top: 2.5rem; }
.nav-link { display: flex; min-width: 0; align-items: center; gap: .75rem; border-radius: .7rem; padding: .75rem .9rem; color: #c9d9df; text-decoration: none; font-weight: 700; }
.nav-link svg { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-link > span:not(.nav-count) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link:hover, .nav-link.is-active { color: white; background: rgba(255, 255, 255, .1); }
.nav-count { display: inline-grid; min-width: 1.15rem; height: 1.15rem; margin-left: auto; place-items: center; border-radius: 999px; padding: 0 .28rem; color: var(--navy); background: #8ee0d1; font-size: .6rem; }
.sidebar-user { display: grid; gap: .35rem; margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; }
.sidebar-user-heading { display: flex; min-width: 0; align-items: center; gap: .7rem; }
.sidebar-user-heading > span:last-child { display: grid; min-width: 0; gap: .1rem; }
.sidebar-user-heading strong, .sidebar-user-heading small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-heading small { color: #a9c0ca; font-size: .72rem; }
.user-avatar { display: inline-grid; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: linear-gradient(145deg, var(--teal-dark), var(--teal)); font-size: .78rem; font-weight: 900; }
.sidebar-user .button { margin-top: .65rem; }
.theme-toggle { border: 0; cursor: pointer; font: inherit; }
.theme-toggle-sidebar { display: flex; align-items: center; gap: .65rem; margin-top: .65rem; border-radius: .65rem; padding: .6rem .7rem; color: #dbe9ed; background: rgba(255,255,255,.07); font-size: .76rem; font-weight: 800; text-align: left; }
.theme-toggle-sidebar:hover { background: rgba(255,255,255,.12); }
.theme-toggle-icon { display: inline-grid; width: 1.45rem; height: 1.45rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: rgba(255,255,255,.1); font-size: .9rem; }
.profile-settings { margin-top: .55rem; color: #dbe9ed; font-size: .74rem; }
.profile-settings summary { cursor: pointer; font-weight: 800; }
.profile-settings form { gap: .45rem; margin: .65rem 0 0; }
.profile-settings label { color: #b9cdd5; font-size: .68rem; }
.profile-settings input { padding: .55rem .6rem; }
.profile-settings [data-signature-result] { min-height: .8rem; color: #8ee0d1; font-size: .62rem; }
.mobile-nav, .mobile-drawer, .mobile-drawer-backdrop { display: none; }
.workspace { min-width: 0; padding: clamp(1.25rem, 4vw, 3rem); }
.workspace-header { display: flex; align-items: center; justify-content: space-between; }
.workspace-header .eyebrow { margin-top: 0; }
.status-pill { border: 1px solid #b7ded6; border-radius: 999px; padding: .45rem .7rem; color: var(--success); background: var(--success-bg); font-size: .75rem; font-weight: 800; }
.empty-state { margin-top: 2.5rem; border: 1px solid var(--line); border-radius: 1rem; padding: 2.5rem; background: var(--paper); }
.empty-state p { max-width: 42rem; color: var(--muted); line-height: 1.6; }

.chat-workspace { min-width: 0; height: 100vh; display: grid; grid-template-columns: minmax(19rem, 26rem) minmax(0, 1fr); overflow: hidden; }
.inbox-panel { display: flex; min-width: 0; min-height: 0; flex-direction: column; border-right: 1px solid var(--line); background: var(--paper); }
.inbox-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.4rem 1.3rem .8rem; }
.inbox-header .eyebrow { margin-top: 0; }
.inbox-header h1 { font-size: 2rem; }
.inbox-header-actions { display: flex; align-items: center; gap: .5rem; }
.new-chat-button { display: inline-flex; min-height: 2.75rem; align-items: center; gap: .35rem; border: 0; border-radius: 999px; padding: .55rem .8rem; color: white; background: var(--teal-dark); cursor: pointer; font-size: .74rem; font-weight: 900; }
.new-chat-button > span:first-child { font-size: 1.15rem; line-height: 1; }
.sync-status { margin-top: .25rem; border-radius: 999px; padding: .35rem .55rem; color: var(--success); background: var(--success-bg); font-size: .68rem; font-weight: 800; }
.sync-status.is-error { color: var(--danger); background: var(--danger-bg); }
.search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; margin: 0; padding: .5rem 1rem; }
.search-form.has-clear { grid-template-columns: minmax(0, 1fr) auto auto; }
.search-form input { min-width: 0; padding: .66rem .75rem; font-size: .82rem; }
.button-search { width: 2.75rem; padding: .65rem; color: white; background: var(--teal-dark); }
.button-search svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search-clear { display: inline-flex; align-items: center; color: var(--ink); border: 1px solid var(--line); background: var(--paper); padding: .65rem .75rem; text-decoration: none; }
.filter-strip { display: flex; gap: .4rem; overflow-x: auto; padding: .55rem 1rem .75rem; scrollbar-width: none; }
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip { display: inline-flex; min-height: 2.25rem; flex: 0 0 auto; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: .38rem .7rem; color: var(--muted); background: var(--surface-soft); text-decoration: none; font-size: .74rem; font-weight: 800; }
.filter-chip:hover, .filter-chip.is-active { color: white; border-color: var(--navy); background: var(--navy); }
.filter-more { position: relative; flex: 0 0 auto; }
.filter-more > summary { cursor: pointer; list-style: none; }
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-menu { position: absolute; z-index: 25; top: calc(100% + .35rem); right: 0; display: grid; min-width: 12rem; overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; padding: .35rem; background: var(--paper); box-shadow: 0 12px 35px rgba(14,39,52,.16); }
.filter-menu a { border-radius: .55rem; padding: .65rem .7rem; color: var(--ink); text-decoration: none; font-size: .78rem; font-weight: 750; }
.filter-menu a:hover, .filter-menu a.is-active { color: var(--teal-dark); background: var(--surface-selected); }
.conversation-list { min-height: 0; flex: 1; overflow-y: auto; border-top: 1px solid var(--line); }
.conversation-row { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid #e8edef; color: inherit; text-decoration: none; }
.conversation-row:hover { background: var(--surface-hover); }
.conversation-row.is-selected { background: var(--surface-selected); box-shadow: inset 3px 0 var(--teal); }
.avatar { position: relative; display: grid; width: 2.65rem; height: 2.65rem; place-items: center; overflow: hidden; border-radius: 50%; color: var(--teal-dark); background: #dcefed; font-weight: 900; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .15s ease; }
.avatar img.is-loaded { opacity: 1; }
.conversation-summary, .conversation-heading, .conversation-meta { display: flex; min-width: 0; }
.conversation-summary { flex-direction: column; gap: .18rem; }
.conversation-heading { align-items: baseline; justify-content: space-between; gap: .6rem; }
.conversation-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.conversation-heading time { flex: 0 0 auto; color: var(--muted); font-size: .64rem; }
.conversation-identifier, .conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .76rem; }
.conversation-preview { color: #40545f; }
.conversation-meta { align-items: center; gap: .4rem; margin-top: .18rem; }
.state-tag { display: inline-flex; border-radius: 999px; padding: .25rem .48rem; color: #49606c; background: #e7edef; font-size: .68rem; font-weight: 800; text-transform: capitalize; }
.state-in_progress { color: #135f78; background: #e3f3f8; }
.state-waiting_customer { color: #795819; background: #fff4d9; }
.state-resolved { color: var(--success); background: var(--success-bg); }
.unread-badge { display: inline-grid; min-width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 999px; padding: 0 .35rem; color: white; background: var(--teal-dark); font-size: .62rem; font-weight: 900; }
.external-hint { color: #7a667f; font-size: .61rem; }
.pagination { display: flex; align-items: center; justify-content: space-between; min-height: 2.8rem; padding: .65rem 1rem; border-top: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: .72rem; }
.pagination a { color: var(--teal-dark); font-weight: 800; }
.compact-empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.compact-empty p { margin: 0 0 .6rem; }
.compact-empty span { display: block; margin-top: .65rem; font-size: .72rem; line-height: 1.4; }
.compact-empty a { color: var(--teal-dark); font-weight: 800; }

.thread-panel { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; background-color: var(--thread-canvas); background-image: radial-gradient(rgba(21, 45, 61, .045) 1px, transparent 1px); background-size: 18px 18px; }
.thread-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 5.2rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 94%, transparent); }
.thread-identity { min-width: 0; margin-right: auto; }
.thread-identity h2, .thread-identity p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-avatar { flex: 0 0 auto; }
.mobile-thread-back { display: none; color: var(--navy); text-decoration: none; font-size: 1.45rem; font-weight: 900; }
.thread-header h2 { margin: 0; font-size: 1.15rem; }
.thread-header p { margin: .25rem 0 0; color: var(--muted); font-size: .76rem; }
.thread-header-meta { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .7rem; }
.message-timeline { display: flex; min-height: 0; flex: 1; flex-direction: column; gap: .65rem; overflow-y: auto; padding: 1.2rem clamp(.8rem, 3vw, 2rem); scroll-behavior: smooth; }
.message-bubble { width: fit-content; max-width: min(78%, 44rem); border: 1px solid rgba(21,45,61,.08); border-radius: .95rem; padding: .68rem .78rem .48rem; box-shadow: 0 4px 14px rgba(14,39,52,.05); }
.message-bubble.is-inbound { align-self: flex-start; border-bottom-left-radius: .25rem; background: var(--bubble-in); }
.message-bubble.is-outbound { align-self: flex-end; border-bottom-right-radius: .25rem; background: var(--bubble-out); }
.message-body p { margin: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; font-size: .9rem; }
.message-bubble footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin-top: .4rem; color: #687a83; font-size: .6rem; }
.outside-badge { color: #714b7d; font-weight: 800; }
.message-type-label { color: var(--muted); font-style: italic; }
.message-image { display: block; width: min(100%, 24rem); max-height: 25rem; border-radius: .65rem; object-fit: contain; background: #d7e0e2; }
.message-image-placeholder { display: grid; min-width: 10rem; min-height: 4.5rem; place-items: center; border-radius: .65rem; padding: .7rem; color: var(--muted); background: #d7e0e2; font-size: .74rem; }
.message-bubble audio { width: min(20rem, 68vw); }
.file-card { display: block; border: 1px solid #c9d8dc; border-radius: .65rem; padding: .8rem; color: var(--navy); background: rgba(255,255,255,.65); font-weight: 800; text-decoration: none; }
.media-unavailable { display: inline-block; color: var(--muted); font-size: .74rem; }
.load-older { align-self: center; border-radius: 999px; padding: .45rem .8rem; color: var(--teal-dark); background: var(--paper); box-shadow: 0 2px 8px rgba(14,39,52,.08); font-size: .72rem; font-weight: 800; text-decoration: none; }
.composer-disabled { display: flex; min-height: 3.3rem; align-items: center; justify-content: center; gap: .7rem; padding: .65rem 1rem; border-top: 1px solid var(--line); color: var(--muted); background: var(--paper); font-size: .76rem; text-align: center; }
.composer-claim { flex: 0 0 auto; color: white; background: var(--teal-dark); }
.message-composer { position: relative; border-top: 1px solid var(--line); padding: .65rem 1rem .7rem; background: color-mix(in srgb, var(--paper) 98%, transparent); }
.message-composer form { position: relative; gap: .45rem; margin: 0; }
.safe-mode-note { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; border-radius: .65rem; padding: .45rem .7rem; color: #6d571c; background: #fff5d8; font-size: .68rem; }
.safe-mode-note span { color: #806d3d; }
.composer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: end; }
.composer-row textarea { min-height: 2.9rem; max-height: 9rem; border-radius: 1.3rem; padding: .78rem 1rem; }
.composer-send { min-width: 5.4rem; height: 2.9rem; border-radius: 1.45rem; color: white; background: var(--teal-dark); }
.composer-options { display: flex; min-width: 0; align-items: center; gap: .8rem; color: var(--muted); font-size: .66rem; }
.composer-options > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-options > [data-message-preview] { flex: 1; }
.composer-result { color: var(--teal-dark); font-weight: 800; }
.quick-reply-menu { position: absolute; z-index: 5; bottom: calc(100% + .4rem); left: 0; width: min(30rem, 100%); max-height: 17rem; overflow-y: auto; border: 1px solid var(--line); border-radius: .85rem; padding: .35rem; background: var(--paper); box-shadow: 0 12px 35px rgba(14,39,52,.16); }
.quick-reply-menu button { display: grid; width: 100%; gap: .15rem; border: 0; border-radius: .6rem; padding: .65rem .75rem; color: var(--ink); background: transparent; text-align: left; cursor: pointer; }
.quick-reply-menu button:hover { background: #edf7f5; }
.quick-reply-menu span { color: var(--muted); font-size: .65rem; }
.thread-empty { margin: auto; padding: 2rem; color: var(--muted); text-align: center; }
.thread-empty h2 { color: var(--ink); }
.inline-action { display: inline-block; margin-top: .75rem; color: white; text-decoration: none; }
.workspace-alert { margin: .75rem 1rem 0; }
.new-activity { padding: .55rem 1rem; color: #6d571c; background: #fff1c5; font-size: .76rem; text-align: center; }
.new-activity a { font-weight: 800; }
.workflow-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 96%, transparent); }
.workflow-owner { max-width: 10rem; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; font-weight: 800; }
.workflow-more { position: relative; margin-left: auto; }
.workflow-more > summary { display: grid; width: 2.75rem; height: 2.75rem; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--paper); cursor: pointer; font-weight: 900; letter-spacing: .08em; list-style: none; }
.workflow-more > summary::-webkit-details-marker { display: none; }
.workflow-menu { position: absolute; z-index: 35; top: calc(100% + .4rem); right: 0; display: grid; width: min(18rem, calc(100vw - 1.3rem)); gap: .55rem; border: 1px solid var(--line); border-radius: .85rem; padding: .7rem; background: var(--paper); box-shadow: 0 16px 42px rgba(14,39,52,.2); }
.workflow-menu label { gap: .3rem; color: var(--muted); font-size: .72rem; }
.workflow-menu select { width: 100%; }
.workflow-bar select { width: auto; min-width: 9rem; padding: .45rem .55rem; font-size: .7rem; }
.action-button { padding: .48rem .65rem; color: white; background: var(--navy); font-size: .68rem; }
.action-button:hover { background: var(--navy-soft); }
.action-button-muted { color: var(--ink); border: 1px solid var(--line); background: var(--paper); }
.workflow-message { color: var(--muted); font-size: .7rem; }
.conversation-contact-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-soft); font-size: .72rem; }
.conversation-contact-bar form { display: flex; align-items: end; gap: .5rem; margin: 0; }
.conversation-contact-bar label { display: flex; align-items: center; gap: .5rem; }
.conversation-contact-bar select, .conversation-contact-bar input { width: auto; min-width: 14rem; padding: .45rem .55rem; font-size: .72rem; }
.conversation-contact-bar a { color: var(--teal-dark); font-weight: 800; }
.conversation-contact-bar.is-unknown { display: block; padding: .7rem 1rem; }
.unknown-contact-panel { width: 100%; }
.unknown-contact-panel > summary { display: flex; min-height: 2rem; align-items: center; justify-content: space-between; gap: .75rem; color: var(--teal-dark); cursor: pointer; font-weight: 900; list-style: none; }
.unknown-contact-panel > summary::-webkit-details-marker { display: none; }
.unknown-contact-panel > summary::after { content: '+'; display: inline-grid; width: 1.65rem; height: 1.65rem; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--navy); background: #e5efee; font-size: 1rem; }
.unknown-contact-panel[open] > summary::after { content: '−'; }
.unknown-contact-panel > summary span { margin-left: auto; color: var(--muted); font-size: .68rem; font-weight: 700; }
.unknown-contact-panel > .unknown-contact-flow { margin-top: .6rem; }
.unknown-contact-flow { display: grid; width: 100%; gap: .6rem; }
.unknown-contact-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.unknown-contact-heading strong { color: var(--ink); font-size: .78rem; }
.unknown-contact-heading span { color: var(--muted); }
.contact-create-flow, .contact-recovery-flow { border: 1px solid var(--line); border-radius: .7rem; padding: .6rem .75rem; background: var(--paper); }
.contact-create-flow summary, .contact-recovery-flow summary { cursor: pointer; color: var(--teal-dark); font-size: .74rem; font-weight: 900; }
.unknown-contact-flow form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: .55rem .75rem; margin-top: .7rem; }
.unknown-contact-flow form > input[type="hidden"] { display: none; }
.unknown-contact-flow label { display: grid; align-items: initial; gap: .3rem; min-width: 0; color: var(--muted); font-weight: 800; }
.unknown-contact-flow select, .unknown-contact-flow input { width: 100%; min-width: 0; }
.unknown-contact-flow fieldset { display: flex; grid-column: 1 / -1; flex-wrap: wrap; gap: .45rem .9rem; border: 1px solid var(--line); border-radius: .6rem; padding: .55rem .7rem; }
.unknown-contact-flow fieldset legend { color: var(--muted); font-weight: 800; }
.unknown-contact-flow .checkbox-field { display: flex; align-items: center; gap: .4rem; }
.unknown-contact-flow .checkbox-field input { width: auto; min-width: 0; }
.unknown-contact-flow button { justify-self: start; }

.directory-workspace { min-width: 0; max-height: 100vh; overflow-y: auto; padding: clamp(1.1rem, 3vw, 2.3rem); }
.directory-header { gap: 1rem; }
.directory-summary { display: flex; gap: .65rem; }
.directory-summary span { border: 1px solid var(--line); border-radius: .8rem; padding: .55rem .75rem; color: var(--muted); background: var(--paper); font-size: .72rem; }
.directory-summary strong { color: var(--ink); font-size: .95rem; }
.role-tabs { display: flex; gap: .4rem; overflow-x: auto; margin: 1.25rem 0 .9rem; padding-bottom: .15rem; }
.directory-layout { display: grid; grid-template-columns: minmax(17rem, 22rem) minmax(22rem, 1fr) minmax(17rem, 21rem); gap: 1rem; align-items: start; }
.directory-list-card, .directory-detail-card, .directory-create-card { border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); box-shadow: 0 8px 24px rgba(14,39,52,.04); }
.directory-list-card { position: sticky; top: 1rem; overflow: hidden; }
.directory-switch { display: grid; grid-template-columns: 1fr 1fr; padding: .45rem; background: var(--surface-muted); }
.directory-switch a { border-radius: .65rem; padding: .65rem; color: var(--muted); text-align: center; text-decoration: none; font-size: .78rem; font-weight: 800; }
.directory-switch a.is-active { color: white; background: var(--navy); }
.directory-records { max-height: calc(100vh - 18rem); overflow-y: auto; border-top: 1px solid var(--line); }
.directory-record { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); gap: .7rem; align-items: center; padding: .8rem .9rem; border-bottom: 1px solid #e8edef; text-decoration: none; }
.directory-record .record-channel { color: var(--teal-dark); }
.directory-record:hover, .directory-record.is-selected { background: var(--surface-selected); }
.directory-record.is-selected { box-shadow: inset 3px 0 var(--teal); }
.directory-record > span:last-child { display: grid; min-width: 0; gap: .15rem; }
.directory-record strong, .directory-record small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.directory-record strong { font-size: .82rem; }
.directory-record small { color: var(--muted); font-size: .68rem; }
.avatar-company { color: #6d4f78; background: #eee4f0; }
.directory-detail-card { min-height: 28rem; padding: 1.25rem; }
.mobile-directory-back { display: none; margin-bottom: 1rem; color: var(--teal-dark); text-decoration: none; font-size: .78rem; font-weight: 900; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.detail-heading .eyebrow { margin-top: 0; }
.detail-heading h2 { margin: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 1.2rem 0; }
.detail-grid > div { border: 1px solid var(--line); border-radius: .75rem; padding: .7rem; background: var(--surface-soft); }
.detail-grid .detail-span { grid-column: 1 / -1; }
.detail-grid dt { color: var(--muted); font-size: .65rem; font-weight: 800; text-transform: uppercase; }
.detail-grid dd { margin: .25rem 0 0; overflow-wrap: anywhere; font-size: .8rem; }
.role-badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.2rem; }
.role-badges span { border-radius: 999px; padding: .3rem .55rem; color: var(--teal-dark); background: #e4f3f0; font-size: .66rem; font-weight: 800; }
.directory-detail-card h3 { margin: 1.25rem 0 .65rem; font-size: .88rem; }
.channel-list, .related-list { display: grid; gap: .45rem; }
.channel-item, .related-list a { display: flex; align-items: center; justify-content: space-between; gap: .75rem; border: 1px solid var(--line); border-radius: .7rem; padding: .65rem .75rem; text-decoration: none; }
.channel-item > span:first-child { display: grid; gap: .12rem; }
.channel-item small, .related-list small { color: var(--muted); font-size: .68rem; }
.related-list a:hover { border-color: var(--teal); background: #f2faf8; }
.inline-editor { margin-top: .8rem; border: 1px dashed #b9c9ce; border-radius: .75rem; padding: .7rem; }
.inline-editor summary, .directory-create-card summary { cursor: pointer; color: var(--teal-dark); font-size: .78rem; font-weight: 900; }
.inline-editor form { margin-top: .8rem; }
.directory-empty { display: grid; min-height: 24rem; place-content: center; color: var(--muted); text-align: center; }
.directory-empty h2 { margin-bottom: .2rem; color: var(--ink); }
.directory-create-card { padding: .8rem; }
.directory-create-card > details { border-bottom: 1px solid var(--line); padding: .6rem .35rem .9rem; }
.directory-create-card > details:last-child { border-bottom: 0; }
.directory-create-card form { margin-top: 1rem; }
.directory-create-card fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; border: 1px solid var(--line); border-radius: .75rem; padding: .7rem; }
.directory-create-card legend { color: var(--muted); font-size: .7rem; font-weight: 800; }
.checkbox-field { display: flex; align-items: center; gap: .45rem; font-size: .72rem; }
.checkbox-field input { width: auto; }

.admin-workspace { min-width: 0; height: 100vh; padding: clamp(1.25rem, 4vw, 3rem); overflow-y: auto; }
.admin-header { max-width: 70rem; }
.admin-intro { margin: .45rem 0 0; color: var(--muted); font-size: .86rem; }
.admin-section-nav { display: flex; max-width: 70rem; gap: .6rem; overflow-x: auto; margin-top: 1.5rem; padding-bottom: .2rem; scrollbar-width: none; }
.admin-section-nav::-webkit-scrollbar { display: none; }
.admin-section-nav a { display: flex; min-width: 10rem; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: .85rem; padding: .72rem .85rem; color: var(--ink); background: var(--paper); text-decoration: none; font-size: .78rem; font-weight: 800; }
.admin-section-nav a:hover { border-color: var(--teal); background: var(--surface-selected); }
.admin-section-nav svg, .admin-card-icon svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.admin-section-nav b { display: inline-grid; min-width: 1.4rem; height: 1.4rem; margin-left: auto; place-items: center; border-radius: 999px; color: var(--teal-dark); background: var(--surface-selected); font-size: .66rem; }
.admin-sections { display: grid; max-width: 70rem; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; margin-top: 1rem; align-items: start; }
.admin-card { min-width: 0; scroll-margin-top: 1rem; border: 1px solid var(--line); border-radius: 1rem; padding: 1.15rem; background: var(--paper); box-shadow: 0 8px 28px rgba(14,39,52,.04); }
.admin-card-header { display: flex; align-items: center; gap: .8rem; padding-bottom: 1rem; }
.admin-card-header > span:nth-child(2) { min-width: 0; }
.admin-card-header h2 { margin: 0; font-size: 1.05rem; }
.admin-card-header p { margin: .18rem 0 0; color: var(--muted); font-size: .7rem; }
.admin-card-icon { display: inline-grid; width: 2.35rem; height: 2.35rem; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--teal-dark); background: var(--surface-selected); }
.admin-card form { margin-top: 1rem; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.admin-create-panel { margin-top: .9rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.admin-create-panel > summary { display: flex; align-items: center; gap: .7rem; border-radius: .75rem; padding: .65rem; color: var(--ink); background: var(--surface-soft); cursor: pointer; list-style: none; }
.admin-create-panel > summary::-webkit-details-marker { display: none; }
.admin-create-panel > summary > span:last-child { display: grid; min-width: 0; gap: .12rem; }
.admin-create-panel > summary small { color: var(--muted); font-size: .67rem; font-weight: 500; }
.admin-add-icon { display: inline-grid; width: 2rem; height: 2rem; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--teal-dark); font-size: 1.25rem; font-weight: 400; }
.admin-panel-body { padding: .2rem .2rem 0; }
.admin-panel-body .muted { margin-bottom: 0; font-size: .75rem; }
.admin-panel-body .button-primary { justify-self: start; }
.form-actions-row { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.form-actions-row label { max-width: 7rem; }
.quick-reply-admin-list { display: grid; gap: .6rem; margin-top: .9rem; }
.quick-reply-admin { border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; background: var(--surface-soft); }
.quick-reply-admin.is-inactive { opacity: .62; }
.quick-reply-admin summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.quick-reply-admin summary > span:first-child { display: grid; gap: .15rem; }
.quick-reply-admin summary small { color: var(--muted); }
.quick-reply-admin summary > span:last-child { color: var(--teal-dark); font-size: .68rem; font-weight: 800; }
.compact-danger-form { margin-top: .5rem !important; }
.compact-danger-form .button { color: var(--danger); background: var(--danger-bg); }
.user-table { display: grid; border-top: 1px solid var(--line); }
.user-row { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) auto auto; gap: .7rem; align-items: center; padding: .75rem 0; border-bottom: 1px solid var(--line); font-size: .78rem; }
.user-row-identity { display: grid; min-width: 0; gap: .12rem; }
.user-row-identity strong, .user-row-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row small { color: var(--muted); }
.user-role { color: var(--muted); font-size: .7rem; }
.user-row .status-pill { padding: .3rem .5rem; font-size: .65rem; }
.admin-empty { display: grid; justify-items: center; gap: .25rem; border: 1px dashed var(--line); border-radius: .8rem; padding: 1.2rem; color: var(--muted); text-align: center; }
.admin-empty > span { display: inline-grid; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; color: var(--teal-dark); background: var(--surface-selected); font-size: 1.2rem; font-weight: 900; }
.admin-empty strong { color: var(--ink); font-size: .8rem; }
.admin-empty small { max-width: 20rem; font-size: .7rem; line-height: 1.45; }
.notification-list { display: grid; gap: .75rem; margin-top: 2rem; }
.notification-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border: 1px solid var(--line); border-radius: 1rem; padding: 1rem 1.2rem; background: var(--paper); }
.notification-card.is-unseen { border-left: 4px solid var(--teal); }
.notification-card h2 { margin: .25rem 0; font-size: 1rem; }
.notification-card p { margin: .2rem 0; color: var(--muted); font-size: .8rem; }
.notification-card time { color: var(--muted); font-size: .66rem; }
.notification-state { color: var(--teal-dark); font-size: .64rem; font-weight: 900; text-transform: uppercase; }
.notification-card .handled-note { color: #704e7a; font-weight: 800; }
.notification-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.notification-actions a { text-decoration: none; }
.new-chat-dialog { width: min(92vw, 32rem); border: 1px solid var(--line); border-radius: 1.15rem; padding: 0; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
.new-chat-dialog::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
.new-chat-form { gap: .9rem; margin: 0; padding: 1.1rem; }
.new-chat-form header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .85rem; }
.new-chat-form header .eyebrow { margin: 0 0 .2rem; }
.new-chat-form header h2 { margin: 0; }
.new-chat-form header button { display: grid; width: 2.75rem; height: 2.75rem; place-items: center; border: 0; border-radius: 50%; color: var(--ink); background: var(--surface-muted); cursor: pointer; font-size: 1.4rem; }
.new-chat-form > .muted { margin: 0; font-size: .8rem; }
.new-chat-form footer { display: flex; justify-content: flex-end; gap: .6rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.new-chat-result { min-height: 1.2rem; color: var(--danger); font-size: .78rem; font-weight: 750; }
.form-divider { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .72rem; }
.form-divider::before, .form-divider::after { height: 1px; flex: 1; background: var(--line); content: ''; }
.detail-heading-actions { display: flex; align-items: center; gap: .55rem; }
.detail-heading-actions a { color: white; text-decoration: none; }
.message-bubble.is-pending { opacity: .72; }

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e9edef;
  --muted: #8696a0;
  --paper: #111b21;
  --canvas: #0b141a;
  --navy: #202c33;
  --navy-soft: #2a3942;
  --teal: #00a884;
  --teal-dark: #00a884;
  --line: #2a3942;
  --danger: #ff7180;
  --danger-bg: #3a2026;
  --success: #53d6a6;
  --success-bg: #15372d;
  --surface-soft: #182229;
  --surface-muted: #202c33;
  --surface-hover: #18272f;
  --surface-selected: #0b3b34;
  --thread-canvas: #0b141a;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --overlay: rgba(0, 0, 0, .62);
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}
html[data-theme="dark"] .auth-shell { background: radial-gradient(circle at 20% 20%, rgba(0,168,132,.15), transparent 28rem), linear-gradient(145deg, #111b21, #0b141a); }
html[data-theme="dark"] .auth-card { border-color: var(--line); background: rgba(17,27,33,.97); }
html[data-theme="dark"] .sidebar { border-right: 1px solid var(--line); background: #111b21; }
html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.is-active { background: #202c33; }
html[data-theme="dark"] .button-primary,
html[data-theme="dark"] .action-button,
html[data-theme="dark"] .composer-claim,
html[data-theme="dark"] .composer-send { color: #f1fffb; background: #008069; }
html[data-theme="dark"] .button-primary:hover,
html[data-theme="dark"] .action-button:hover { background: #00a884; }
html[data-theme="dark"] .alert-error { border-color: #66313a; }
html[data-theme="dark"] .alert-success { border-color: #245944; }
html[data-theme="dark"] .sync-status { color: var(--success); background: var(--success-bg); }
html[data-theme="dark"] .avatar { color: #74d7c3; background: #23373c; }
html[data-theme="dark"] .conversation-row { border-bottom-color: var(--line); }
html[data-theme="dark"] .conversation-preview { color: #aebac1; }
html[data-theme="dark"] .state-tag { color: #aebac1; background: #26353d; }
html[data-theme="dark"] .state-in_progress { color: #53bdeb; background: #123746; }
html[data-theme="dark"] .state-waiting_customer { color: #f5c96b; background: #453818; }
html[data-theme="dark"] .state-resolved { color: var(--success); background: var(--success-bg); }
html[data-theme="dark"] .external-hint { color: #c79bd4; }
html[data-theme="dark"] .thread-panel { background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); }
html[data-theme="dark"] .message-bubble { border-color: rgba(255,255,255,.035); box-shadow: 0 4px 14px rgba(0,0,0,.16); }
html[data-theme="dark"] .message-bubble footer { color: #9cabb3; }
html[data-theme="dark"] .outside-badge { color: #d5a6e1; }
html[data-theme="dark"] .message-image { background: #1b262d; }
html[data-theme="dark"] .file-card { color: var(--ink); border-color: var(--line); background: rgba(255,255,255,.04); }
html[data-theme="dark"] .safe-mode-note { color: #f1cf72; background: #3f3519; }
html[data-theme="dark"] .safe-mode-note span { color: #d8bd78; }
html[data-theme="dark"] .quick-reply-menu button:hover { background: var(--surface-hover); }
html[data-theme="dark"] .new-activity { color: #f1cf72; background: #3f3519; }
html[data-theme="dark"] .unknown-contact-panel > summary::after { color: var(--ink); background: var(--surface-muted); }
html[data-theme="dark"] .avatar-company { color: #d4a8df; background: #3b2e3f; }
html[data-theme="dark"] .role-badges span { color: #74d7c3; background: #163a34; }
html[data-theme="dark"] .related-list a:hover { background: var(--surface-hover); }
html[data-theme="dark"] .notification-card .handled-note { color: #d5a6e1; }
html[data-theme="dark"] .mobile-thread-back { color: var(--ink); }
html[data-theme="dark"] .directory-switch a.is-active,
html[data-theme="dark"] .filter-chip:hover,
html[data-theme="dark"] .filter-chip.is-active { color: white; border-color: #008069; background: #008069; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
  body.drawer-open { overflow: hidden; }
  .app-shell { min-height: calc(100dvh - 4rem); grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; height: calc(4rem + env(safe-area-inset-bottom)); grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); padding: .22rem .25rem env(safe-area-inset-bottom); background: color-mix(in srgb, var(--paper) 97%, transparent); box-shadow: 0 -8px 24px rgba(14,39,52,.09); backdrop-filter: blur(14px); }
  .mobile-nav a, .mobile-nav button { position: relative; display: flex; min-width: 0; align-items: center; justify-content: center; flex-direction: column; gap: .1rem; border: 0; border-radius: .65rem; color: var(--muted); background: transparent; text-decoration: none; font-size: .68rem; font-weight: 800; }
  .mobile-nav .mobile-nav-icon { position: relative; display: grid; width: 1.9rem; height: 1.75rem; place-items: center; border-radius: 999px; }
  .mobile-nav svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-nav .is-active { color: var(--teal-dark); }
  .mobile-nav .is-active .mobile-nav-icon { background: var(--surface-selected); }
  .mobile-nav-icon b { position: absolute; top: -.25rem; left: 1.15rem; min-width: 1rem; border-radius: 999px; padding: .11rem .28rem; color: white; background: var(--danger); font-size: .5rem; }
  .mobile-drawer-backdrop { position: fixed; z-index: 48; inset: 0; display: block; background: var(--overlay); backdrop-filter: blur(2px); }
  .mobile-drawer-backdrop[hidden] { display: none; }
  .mobile-drawer { position: fixed; z-index: 49; right: 0; bottom: 0; left: 0; display: block; max-height: min(86dvh, 42rem); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-bottom: 0; border-radius: 1.2rem 1.2rem 0 0; padding: .85rem 1rem calc(.9rem + env(safe-area-inset-bottom)); background: var(--paper); box-shadow: 0 -18px 60px rgba(5,20,28,.25); transform: translateY(105%); transition: transform .2s ease; }
  .mobile-drawer.is-open { transform: translateY(0); }
  .mobile-drawer header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding: 0 0 .75rem; }
  .drawer-identity { display: flex; min-width: 0; align-items: center; gap: .7rem; }
  .drawer-identity > span:last-child { display: grid; min-width: 0; gap: .1rem; }
  .drawer-identity strong, .drawer-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .drawer-identity small { color: var(--muted); font-size: .68rem; }
  .mobile-drawer header button { border: 0; border-radius: 50%; width: 2.3rem; height: 2.3rem; color: var(--ink); background: var(--surface-muted); font-size: 1.35rem; }
  .drawer-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-top: .75rem; }
  .drawer-action { display: flex; min-width: 0; min-height: 3.6rem; align-items: center; gap: .65rem; border: 1px solid var(--line); border-radius: .8rem; padding: .7rem; color: var(--ink); background: var(--surface-soft); text-align: left; text-decoration: none; font-size: .72rem; font-weight: 800; }
  .drawer-action.is-active { color: var(--teal-dark); border-color: var(--teal); background: var(--surface-selected); }
  .drawer-action svg { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .drawer-action .theme-toggle-icon { color: var(--teal-dark); background: var(--surface-selected); }
  .drawer-push-status { display: block; margin-top: .4rem; color: var(--muted); font-size: .68rem; line-height: 1.4; }
  .drawer-preferences { margin-top: .65rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface-soft); }
  .drawer-preferences > summary { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .75rem; cursor: pointer; list-style: none; font-size: .74rem; font-weight: 800; }
  .drawer-preferences > summary::-webkit-details-marker { display: none; }
  .drawer-preferences > summary small { max-width: 45%; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: .66rem; font-weight: 500; }
  .drawer-signature { gap: .55rem; margin: 0; border-top: 1px solid var(--line); padding: .7rem; }
  .drawer-signature [data-signature-result] { min-height: 1rem; color: var(--teal-dark); font-size: .7rem; }
  .drawer-logout { width: 100%; margin-top: .65rem; padding: .65rem; color: var(--danger); background: var(--danger-bg); }
  .workspace-header { align-items: flex-start; gap: 1rem; }
  .inbox-header { align-items: center; padding: .95rem .85rem .5rem; }
  .inbox-header .eyebrow { display: none; }
  .inbox-header h1 { font-size: 1.55rem; }
  .inbox-header-actions { flex-direction: row-reverse; }
  .new-chat-button { width: 2.75rem; padding: 0; justify-content: center; }
  .new-chat-button > span:last-child { display: none; }
  .sync-status { margin: 0; padding: .3rem .48rem; }
  .search-form { padding: .45rem .75rem; }
  .search-form input { min-height: 2.75rem; border-radius: 1.4rem; padding-left: 1rem; font-size: 16px; }
  .filter-strip { padding: .45rem .75rem .65rem; }
  .conversation-row { grid-template-columns: 3rem minmax(0, 1fr); gap: .7rem; padding: .78rem .8rem; }
  .conversation-row .avatar { width: 3rem; height: 3rem; }
  .conversation-identifier { display: none; }
  .conversation-meta .state-tag { display: none; }
  .conversation-preview { font-size: .8rem; }
  .chat-workspace { height: calc(100dvh - 4rem - env(safe-area-inset-bottom)); min-height: 0; grid-template-columns: 1fr; overflow: hidden; }
  .inbox-panel { min-height: 0; max-height: none; border: 0; }
  .thread-panel { min-height: 0; }
  .app-shell:not(.has-conversation) .thread-panel { display: none; }
  .app-shell.has-conversation .inbox-panel { display: none; }
  .mobile-thread-back { display: inline-flex; flex: 0 0 auto; }
  .thread-header { min-height: 4.2rem; gap: .6rem; padding: .6rem .7rem; }
  .thread-header-meta { display: none; }
  .thread-avatar { width: 2.4rem; height: 2.4rem; }
  .thread-identity h2 { font-size: 1rem; }
  .workflow-bar { flex-wrap: nowrap; min-height: 3.55rem; overflow: visible; padding: .4rem .65rem; }
  .workflow-bar .action-button { min-height: 2.55rem; flex: 0 0 auto; padding: .55rem .65rem; }
  .workflow-owner { flex: 1; }
  .workflow-message { position: absolute; top: 100%; left: .65rem; }
  .conversation-contact-bar { max-height: none; overflow: visible; }
  .conversation-contact-bar.is-unknown { display: block; border-bottom: 1px solid var(--line); padding: .35rem .65rem; background: var(--surface-soft); }
  .unknown-contact-panel { position: static; width: 100%; }
  .unknown-contact-panel > summary { width: 100%; min-height: 2.75rem; justify-content: flex-start; border: 0; border-radius: .65rem; padding: 0 .25rem; background: transparent; box-shadow: none; }
  .unknown-contact-panel > summary strong, .unknown-contact-panel > summary span { display: inline; }
  .unknown-contact-panel > summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .unknown-contact-panel > summary::after { width: 2rem; height: 2rem; margin-left: auto; }
  .unknown-contact-panel > .unknown-contact-flow { position: fixed; z-index: 60; right: .55rem; bottom: calc(4rem + env(safe-area-inset-bottom) + .55rem); left: .55rem; width: auto; max-height: min(68dvh, 34rem); margin: 0; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 1rem; padding: .75rem; background: var(--paper); box-shadow: 0 18px 58px rgba(5,20,28,.35); }
  .message-timeline { min-height: 0; padding: .8rem .65rem; }
  .message-bubble { max-width: 90%; }
  .message-composer { padding: .5rem .65rem calc(.55rem + env(safe-area-inset-bottom)); }
  .safe-mode-note { align-items: flex-start; flex-direction: column; gap: .1rem; }
  .composer-row textarea { font-size: 16px; }
  .composer-send { width: 3rem; min-width: 3rem; overflow: hidden; padding: 0; font-size: 0; }
  .composer-send::before { content: '➤'; font-size: 1.05rem; }
  .composer-options { flex-wrap: wrap; gap: .35rem .7rem; }
  .composer-options [data-message-preview] { flex-basis: 100%; }
  .composer-disabled { align-items: stretch; flex-direction: column; gap: .35rem; padding: .5rem .65rem calc(.55rem + env(safe-area-inset-bottom)); }
  .composer-claim { width: 100%; min-height: 2.8rem; }
  .admin-workspace { height: auto; min-height: calc(100dvh - 4rem); padding: .85rem .75rem 1.5rem; overflow: visible; }
  .admin-header { padding: .1rem .15rem; }
  .admin-header h1 { font-size: 1.7rem; }
  .admin-header .eyebrow { margin-bottom: .2rem; }
  .admin-intro { max-width: 21rem; margin-top: .3rem; font-size: .76rem; line-height: 1.4; }
  .admin-section-nav { position: sticky; z-index: 5; top: 0; gap: .45rem; margin: .75rem -.75rem 0; padding: .55rem .75rem; background: color-mix(in srgb, var(--canvas) 94%, transparent); backdrop-filter: blur(12px); }
  .admin-section-nav a { min-width: auto; flex: 1 0 auto; border-radius: 999px; padding: .55rem .7rem; }
  .admin-section-nav a svg { width: 1rem; height: 1rem; }
  .admin-sections { grid-template-columns: 1fr; gap: .75rem; margin-top: .35rem; }
  .admin-card { border-radius: .9rem; padding: .9rem; box-shadow: none; }
  .admin-card-header { padding-bottom: .75rem; }
  .admin-card-icon { width: 2.15rem; height: 2.15rem; }
  .admin-card-header h2 { font-size: 1rem; }
  .admin-create-panel { margin-top: .65rem; padding-top: .65rem; }
  .admin-create-panel > summary { padding: .55rem; }
  .admin-add-icon { width: 1.8rem; height: 1.8rem; }
  .admin-panel-body form { gap: .75rem; }
  .admin-panel-body .button-primary { width: 100%; }
  .user-row { grid-template-columns: 2.15rem minmax(0, 1fr) auto; gap: .6rem; padding: .65rem 0; }
  .user-row .user-avatar { width: 2.15rem; height: 2.15rem; }
  .user-row .status-pill { display: none; }
  .user-role { border-radius: 999px; padding: .25rem .42rem; background: var(--surface-muted); font-size: .62rem; }
  .form-pair { grid-template-columns: 1fr; gap: .75rem; }
  .form-actions-row { align-items: stretch; flex-direction: column; }
  .form-actions-row label { max-width: none; }
  .admin-card input, .admin-card select, .admin-card textarea { padding: .72rem .8rem; }
  .notification-card { align-items: flex-start; flex-direction: column; }
  .notification-actions { justify-content: flex-start; }
  .conversation-contact-bar form { width: 100%; align-items: stretch; flex-direction: column; }
  .conversation-contact-bar label { align-items: stretch; flex-direction: column; }
  .conversation-contact-bar select { width: 100%; min-width: 0; }
  .conversation-contact-bar input { width: 100%; min-width: 0; }
  .unknown-contact-heading { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .unknown-contact-flow form { display: grid; grid-template-columns: 1fr; }
  .unknown-contact-flow fieldset { grid-column: 1; }
  .search-form.has-clear { grid-template-columns: minmax(0, 1fr) auto; }
  .search-form.has-clear .search-clear { grid-column: 1 / -1; justify-content: center; }
  .directory-workspace { max-height: none; overflow: visible; }
  .directory-header { align-items: flex-start; flex-direction: column; }
  .directory-layout { grid-template-columns: 1fr; }
  .directory-list-card { position: static; }
  .directory-records { max-height: 30rem; }
  .app-shell:not(.has-directory-selection) .directory-detail-card { display: none; }
  .app-shell.has-directory-selection .directory-list-card, .app-shell.has-directory-selection .directory-create-card, .app-shell.has-directory-selection .role-tabs, .app-shell.has-directory-selection .directory-header { display: none; }
  .app-shell.has-directory-selection .directory-workspace { padding: .75rem; }
  .app-shell.has-directory-selection .directory-layout { margin-top: 0; }
  .mobile-directory-back { display: inline-flex; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-heading { align-items: flex-start; }
  .detail-heading-actions { align-items: flex-end; flex-direction: column-reverse; }
  .new-chat-dialog { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .new-chat-form { padding: .9rem; }
  .new-chat-form footer .button { flex: 1; }
}

@media (min-width: 761px) and (max-width: 1250px) {
  .directory-layout { grid-template-columns: minmax(17rem, 21rem) minmax(22rem, 1fr); }
  .directory-create-card { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}
