:root {
  color-scheme: light;
  --bg: #f2f2f0;
  --surface: #fff;
  --surface-2: #f8f8f6;
  --surface-3: #ececea;
  --text: #202223;
  --muted: #6d7175;
  --faint: #8c9196;
  --border: #dededb;
  --border-strong: #c5c7c3;
  --nav: #202322;
  --nav-text: #d9ddda;
  --nav-hover: #303432;
  --accent: #008060;
  --accent-dark: #006e52;
  --accent-soft: #e6f3ef;
  --blue: #235ee7;
  --blue-soft: #edf3ff;
  --red: #b42318;
  --red-soft: #ffebe9;
  --amber: #9c5a00;
  --amber-soft: #fff2dd;
  --purple: #6549c7;
  --purple-soft: #f1edff;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 12px 32px rgb(0 0 0 / .07);
  --radius: 12px;
  --sidebar-width: 220px;
  --queue-width: 185px;
  --list-width: 340px;
  --density: 1;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-design='edesk'] {
  --bg: #eef2f7;
  --surface-2: #f4f7fb;
  --nav: #15233e;
  --nav-hover: #213454;
  --accent: #1268d6;
  --accent-dark: #0b57b5;
  --accent-soft: #e8f2ff;
  --radius: 7px;
  --shadow: 0 1px 2px rgb(14 30 58 / .08);
  --sidebar-width: 200px;
  --queue-width: 170px;
  --list-width: 318px;
  --density: .88;
}

body[data-design='gorgias'] {
  --bg: #f5f3f8;
  --surface-2: #faf8fc;
  --nav: #241d32;
  --nav-hover: #392e4c;
  --accent: #6f4cca;
  --accent-dark: #5a3cad;
  --accent-soft: #f0ebfa;
  --radius: 15px;
  --sidebar-width: 212px;
  --queue-width: 172px;
  --list-width: 320px;
}

* { box-sizing: border-box; }
html, body, #root { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; color: var(--text); background: var(--bg); font-size: 14px; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
.muted { color: var(--muted); }

.boot-state, .fatal-state { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; }
.fatal-state h1 { margin: 0; color: var(--text); font-size: 22px; }
.fatal-state p { max-width: 500px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { height: 100%; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { z-index: 20; min-height: 0; display: flex; flex-direction: column; padding: 13px 10px; color: var(--nav-text); background: var(--nav); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 7px 18px; }
.brand__mark { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(145deg, #fbf3d8, #d6b454); color: #342f1b; font-size: 11px; font-weight: 850; box-shadow: inset 0 0 0 1px #fff8; }
.brand strong, .brand small { display: block; }
.brand strong { color: white; font-size: 14px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: #939a96; font-size: 9px; }
.main-nav { flex: 1; min-height: 0; }
.nav-label { margin: 17px 10px 7px; color: #828985; font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.nav-item { width: 100%; min-height: 38px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; margin: 2px 0; padding: 8px 10px; border: 0; border-radius: 8px; color: #cbd0cd; background: transparent; text-align: left; font-size: 12px; }
.nav-item:hover { background: var(--nav-hover); color: white; }
.nav-item.is-active { color: white; background: var(--nav-hover); box-shadow: inset 2px 0 #dfc15e; }
.nav-icon { color: #aab0ac; font-size: 15px; text-align: center; }
.nav-count { min-width: 22px; padding: 2px 6px; border-radius: 12px; color: #dce0dd; background: #ffffff14; text-align: center; font-size: 9px; }
.sidebar__bottom { border-top: 1px solid #ffffff16; padding-top: 8px; }
.safe-mode, .user-card { width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 6px; }
.safe-mode > span { width: 8px; height: 8px; border-radius: 50%; background: #59d2a6; box-shadow: 0 0 0 4px #59d2a61c; }
.safe-mode strong, .safe-mode small, .user-card strong, .user-card small { display: block; }
.safe-mode strong, .user-card strong { color: #e9ebe9; font-size: 10px; }
.safe-mode small, .user-card small { margin-top: 2px; color: #888f8a; font-size: 8px; }
.user-card { border: 0; border-radius: 8px; background: transparent; text-align: left; }
.user-card:hover { background: #ffffff0c; }
.user-card > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #ffffff15; color: white; font-size: 9px; font-weight: 800; }

.app-content { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 16px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / .96); }
.global-search { position: relative; width: min(540px, 48vw); }
.global-search > span { position: absolute; left: 11px; top: 7px; color: var(--muted); font-size: 17px; }
.global-search input { width: 100%; height: 38px; padding: 0 38px 0 35px; border: 1px solid var(--border); border-radius: 9px; outline: 0; background: var(--surface-2); }
.global-search input:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.global-search kbd { position: absolute; top: 9px; right: 10px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--faint); background: white; font-size: 9px; }
.topbar__actions, .design-picker { display: flex; align-items: center; gap: 7px; }
.design-picker { padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.design-option { padding: 6px 8px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 9px; }
.design-option.is-active { color: var(--text); background: white; box-shadow: 0 1px 3px #00000012; font-weight: 700; }
.icon-button { position: relative; min-width: 31px; height: 31px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: white; }
.notification-dot { position: absolute; right: 5px; top: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--red); }
.mobile-menu { display: none; }
.app-view { flex: 1; min-width: 0; min-height: 0; }
.mobile-nav { display: none; }

.button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: white; font-size: 11px; font-weight: 680; box-shadow: 0 1px 1px #00000008; }
.button:hover { background: var(--surface-2); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button--primary { color: white; border-color: var(--accent-dark); background: var(--accent); }
.button--primary:hover { background: var(--accent-dark); }
.button--danger { color: var(--red); }
.button--block { width: 100%; margin-top: 10px; }
.button--large { min-height: 43px; }
.text-button { padding: 2px 3px; border: 0; color: var(--accent); background: transparent; font-size: 10px; font-weight: 700; }

.inbox-screen { height: 100%; display: grid; grid-template-columns: var(--queue-width) var(--list-width) minmax(0, 1fr); background: var(--surface); }
.queues-panel { min-width: 0; overflow: auto; border-right: 1px solid var(--border); background: var(--surface-2); padding: calc(12px * var(--density)) 9px; }
.queues-title { display: flex; align-items: center; justify-content: space-between; padding: 2px 7px 10px; }
.queues-title strong { font-size: 12px; }
.queues-title .icon-button { min-width: 25px; height: 25px; }
.queue-link { width: 100%; display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 7px; padding: calc(8px * var(--density)) 8px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; text-align: left; }
.queue-link:hover { background: var(--surface-3); }
.queue-link.is-active { color: var(--text); background: white; box-shadow: 0 1px 2px #0000000d; }
.queue-link strong { font-size: 10px; font-weight: 620; }
.queue-link > span { text-align: center; font-size: 10px; }
.queue-link em { min-width: 18px; color: var(--faint); font-style: normal; font-size: 9px; text-align: right; }
.queue-group { margin: 17px 8px 6px; color: var(--faint); font-size: 8px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.saved-view { margin-top: 18px; padding: 10px 7px; border-top: 1px solid var(--border); }
.saved-view small { color: var(--faint); font-size: 8px; text-transform: uppercase; }
.saved-view button { width: 100%; display: flex; justify-content: space-between; margin-top: 6px; padding: 6px 0; border: 0; background: transparent; font-size: 10px; text-align: left; }

.ticket-list { min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); }
.list-head { min-height: calc(70px * var(--density)); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(12px * var(--density)) 13px; border-bottom: 1px solid var(--border); }
.list-head h1 { margin: 0; font-size: 16px; letter-spacing: -.025em; }
.list-head p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.tickets { flex: 1; overflow: auto; background: #fafaf9; }
.ticket { width: 100%; display: block; padding: calc(12px * var(--density)) 12px; border: 0; border-bottom: 1px solid #e9e9e6; background: transparent; text-align: left; }
.ticket:hover { background: var(--surface-2); }
.ticket.is-selected { background: white; box-shadow: inset 3px 0 var(--accent); }
.ticket__head { display: flex; align-items: center; gap: 7px; }
.ticket__head strong { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; }
.ticket__head time { color: var(--faint); font-size: 8px; }
.ticket__subject, .ticket__preview { display: block; overflow: hidden; text-overflow: ellipsis; }
.ticket__subject { margin: 6px 0 3px; white-space: nowrap; font-size: 11px; font-weight: 700; }
.ticket__preview { height: 30px; color: var(--muted); font-size: 9px; line-height: 15px; }
.ticket__meta { display: flex; align-items: center; gap: 5px; margin-top: 7px; overflow: hidden; }
.avatar { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 7px; color: #4e5651; background: #e6e9e7; font-size: 8px; font-weight: 800; }
.avatar--large { width: 37px; height: 37px; border-radius: 11px; font-size: 10px; }
.channel-badge, .tag, .capability { display: inline-flex; align-items: center; width: fit-content; border-radius: 99px; padding: 3px 7px; white-space: nowrap; font-size: 8px; font-weight: 750; }
.channel-badge { color: #2c5fac; background: var(--blue-soft); text-transform: capitalize; }
.channel-badge--allegro { color: #ad3d00; background: #fff0e7; }
.tag { color: #555b58; background: #efefed; }
.tag--danger { color: var(--red); background: var(--red-soft); }
.tag--warning { color: var(--amber); background: var(--amber-soft); }
.tag--safe { color: #00694e; background: #e4f3ed; }
.tag--draft { margin-bottom: 8px; color: var(--purple); background: var(--purple-soft); }

.workspace { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(390px, 1fr) 292px; }
.conversation-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: white; }
.conversation-head { min-height: calc(70px * var(--density)); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(11px * var(--density)) 14px; border-bottom: 1px solid var(--border); }
.conversation-head > div:first-of-type { min-width: 0; }
.conversation-head h2 { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; letter-spacing: -.02em; }
.conversation-head p { display: flex; align-items: center; gap: 5px; margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.conversation-head__actions { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; }
.conversation-head select, .composer select { min-height: 32px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 7px; background: white; font-size: 9px; }
.mobile-back { display: none; }
.thread { flex: 1; min-height: 0; overflow: auto; padding: calc(19px * var(--density)) clamp(16px, 3vw, 48px); background: var(--surface-2); }
.message { max-width: 700px; margin-bottom: calc(18px * var(--density)); }
.message--outbound { margin-left: auto; }
.message__meta { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; color: var(--muted); font-size: 8px; }
.message__meta time { margin-left: auto; }
.message__bubble { padding: calc(12px * var(--density)) 14px; border: 1px solid var(--border); border-radius: 5px 13px 13px; background: white; box-shadow: 0 1px 2px #00000008; }
.message--outbound .message__bubble { border-color: color-mix(in srgb, var(--accent) 20%, var(--border)); border-radius: 13px 5px 13px 13px; background: color-mix(in srgb, var(--accent) 5%, white); }
.message__bubble p { margin: 0; white-space: pre-wrap; line-height: 1.55; font-size: 11px; }
.attachment { display: flex; align-items: center; gap: 6px; margin-top: 9px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; color: var(--accent); background: var(--surface-2); font-size: 9px; }
.attachment small { margin-left: auto; color: var(--muted); }
.internal-note { max-width: 620px; margin: 15px auto; padding: 10px 12px; border: 1px dashed #ddad5c; border-radius: 9px; background: #fff9eb; }
.internal-note strong, .internal-note time { color: #815000; font-size: 8px; }
.internal-note p { margin: 4px 0; font-size: 10px; }
.composer { padding: 9px 12px 11px; border-top: 1px solid var(--border); background: white; }
.composer__tabs { display: flex; gap: 5px; margin-bottom: 6px; }
.composer__tabs button { padding: 4px 8px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 9px; }
.composer__tabs button.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.composer__tools { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.composer__channel { margin-left: auto; color: var(--muted); font-size: 8px; }
.composer textarea { width: 100%; min-height: 76px; max-height: 170px; resize: vertical; padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: 8px; outline: 0; line-height: 1.45; font-size: 11px; }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.composer footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; }
.composer footer span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; }
.composer footer i { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }

.context-panel { min-width: 0; overflow: auto; padding: 10px; border-left: 1px solid var(--border); background: #fafaf9; }
.context-mobile-head { display: none; }
.context-card { margin-bottom: 9px; overflow: hidden; border: 1px solid var(--border); border-radius: 9px; background: white; }
.context-card > header { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 9px 10px; border-bottom: 1px solid #ecece9; }
.context-card > header strong { font-size: 10px; }
.customer-card { display: flex; align-items: center; gap: 9px; padding: 10px; }
.customer-card strong, .customer-card small { display: block; }
.customer-card strong { font-size: 10px; }
.customer-card small { margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; font-size: 8px; }
.facts { display: grid; gap: 7px; margin: 0; padding: 10px; }
.facts > div { display: grid; grid-template-columns: 82px 1fr; gap: 7px; font-size: 9px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.cache-status { display: block; margin: 0 10px 10px; padding: 5px 7px; border-radius: 6px; color: #27654f; background: #ecf7f3; font-size: 8px; }
.cache-status--stale { color: var(--amber); background: var(--amber-soft); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 9px; }
.action-tile { min-height: 52px; display: grid; place-items: center; gap: 3px; padding: 7px; border: 1px solid var(--border); border-radius: 8px; background: white; font-size: 8px; font-weight: 700; }
.action-tile:hover { border-color: var(--accent); background: var(--accent-soft); }
.action-tile span { color: var(--accent); font-size: 15px; }
.context-card > .button--block { width: calc(100% - 18px); margin: 0 9px 9px; }
.timeline { display: grid; gap: 8px; padding: 9px; }
.timeline > div { display: flex; gap: 7px; }
.timeline p, .timeline small { margin: 0; }
.timeline strong, .timeline small { display: block; font-size: 8px; }
.timeline small { margin-top: 2px; color: var(--muted); }
.state-dot { width: 7px; height: 7px; margin-top: 3px; border-radius: 50%; background: var(--amber); }
.state-dot--confirmed { background: var(--accent); }
.state-dot--failed, .state-dot--uncertain { background: var(--red); }
.collision-alert { margin-bottom: 9px; padding: 8px 9px; border-radius: 8px; color: #724800; background: var(--amber-soft); font-size: 8px; line-height: 1.4; }
.empty-compact { padding: 12px; color: var(--muted); font-size: 9px; line-height: 1.45; }

.empty-state { height: 100%; display: grid; place-content: center; justify-items: center; padding: 25px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 10px 0 4px; color: var(--text); font-size: 14px; }
.empty-state p { max-width: 280px; margin: 0; line-height: 1.45; font-size: 10px; }
.empty-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--faint); background: var(--surface-3); font-size: 20px; }

.page-scroll { height: 100%; overflow: auto; padding: 19px; }
.page-heading { max-width: 1220px; display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 0 auto 16px; }
.page-heading h1 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.page-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.heading-actions { display: flex; gap: 8px; }
.metric-grid, .dashboard-grid, .channel-grid, .settings-grid { max-width: 1220px; margin: 0 auto; }
.metric-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.metric-card, .panel { border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.metric-card { padding: 14px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 8px; }
.metric-card strong { display: block; margin: 8px 0 5px; font-size: 24px; letter-spacing: -.04em; }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 12px; }
.panel { overflow: hidden; }
.panel--wide { grid-column: 1 / -1; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 15px; border-bottom: 1px solid var(--border); }
.panel > header h2 { margin: 0; font-size: 13px; }
.panel > header p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.bar-list { display: grid; gap: 11px; padding: 15px; }
.bar-list > div { display: grid; grid-template-columns: 100px 1fr 25px; align-items: center; gap: 9px; font-size: 9px; }
.bar-list progress { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 10px; background: var(--surface-3); appearance: none; }
.bar-list progress::-webkit-progress-bar { border-radius: 10px; background: var(--surface-3); }
.bar-list progress::-webkit-progress-value { border-radius: 10px; background: var(--accent); }
.bar-list progress::-moz-progress-bar { border-radius: 10px; background: var(--accent); }
.reason-list { padding: 8px 15px; }
.reason-list > div, .gate-list > div, .policy-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #ececea; font-size: 10px; }
.reason-list > div:last-child, .gate-list > div:last-child, .policy-list > div:last-child { border-bottom: 0; }
.health-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.health-grid > div { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; padding: 15px; border-right: 1px solid var(--border); }
.health-grid > div:last-child { border: 0; }
.health-grid strong, .health-grid small { display: block; }
.health-grid strong { font-size: 10px; }
.health-grid small { grid-column: 2; margin-top: 3px; color: var(--muted); font-size: 8px; }
.health-dot { width: 8px; height: 8px; margin-top: 2px; border-radius: 50%; }
.health-dot--ok { background: #25a575; }
.health-dot--paused { background: #d2983e; }

.accounts-panel { max-width: 1220px; margin: 0 auto 13px; }
.account-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto auto; align-items: center; gap: 11px; padding: 12px 15px; border-top: 1px solid #ececea; }
.account-row:first-child { border-top: 0; }
.account-row strong, .account-row small { display: block; }
.account-row strong { font-size: 11px; }
.account-row small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.channel-logo { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 9px; font-weight: 850; }
.switch { width: 37px; height: 21px; position: relative; border: 0; border-radius: 20px; background: #bbbeba; }
.switch::after { content: ''; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0003; transition: transform .15s; }
.switch.is-on { background: var(--accent); }
.switch.is-on::after { transform: translateX(16px); }
.channel-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.channel-card { padding: 13px; border: 1px solid var(--border); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.channel-card > header { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; }
.channel-card h2 { margin: 0; font-size: 12px; }
.channel-card header p { margin: 3px 0 0; color: var(--muted); font-size: 8px; text-transform: capitalize; }
.channel-card dl { display: grid; gap: 7px; margin: 14px 0 10px; }
.channel-card dl > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.channel-card dt { color: var(--muted); font-size: 9px; }
.channel-card dd { margin: 0; }
.channel-card__note { min-height: 34px; margin: 0; color: var(--muted); font-size: 8px; line-height: 1.45; }
.capability--active { color: #00694e; background: #e4f3ed; }
.capability--read_only { color: #175eab; background: #e8f2ff; }
.capability--dark { color: #6e4c9e; background: #f0eafb; }
.capability--manual { color: #8a5500; background: #fff1d8; }
.capability--blocked, .capability--unsupported { color: #777; background: #ececea; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.person-row { display: grid; grid-template-columns: 42px 1fr auto auto; align-items: center; gap: 10px; padding: 12px 15px; border-top: 1px solid #ececea; }
.person-row:first-of-type { border-top: 0; }
.person-row strong, .person-row small { display: block; }
.person-row strong { font-size: 10px; }
.person-row small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.gate-list, .policy-list { padding: 6px 15px; }
.prototype-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; padding: 15px; }
.prototype-card { position: relative; display: grid; gap: 5px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: white; text-align: left; }
.prototype-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent); }
.prototype-card strong { font-size: 10px; }
.prototype-card small { color: var(--muted); font-size: 8px; }
.prototype-preview { height: 80px; display: grid; grid-template-columns: 20% 31% 1fr; gap: 3px; padding: 5px; border-radius: 7px; background: #eef0ed; }
.prototype-preview i, .prototype-preview b, .prototype-preview em { border-radius: 3px; background: white; }
.prototype-preview i { background: #262a28; }
.prototype-preview--edesk { grid-template-columns: 18% 35% 1fr; background: #e9f0f8; }
.prototype-preview--edesk i { background: #182945; }
.prototype-preview--gorgias { grid-template-columns: 16% 25% 1fr; background: #f1edf5; }
.prototype-preview--gorgias i { background: #2b213a; }
.selected-label { position: absolute; top: 14px; right: 14px; padding: 3px 6px; border-radius: 10px; color: white; background: var(--accent); font-size: 7px; }

.audit-panel { max-width: 1220px; margin: 0 auto; overflow: auto; }
.audit-panel table { width: 100%; border-collapse: collapse; font-size: 9px; }
.audit-panel th { padding: 9px 11px; color: var(--muted); background: var(--surface-2); text-align: left; font-size: 8px; text-transform: uppercase; }
.audit-panel td { max-width: 480px; padding: 10px 11px; border-top: 1px solid var(--border); overflow-wrap: anywhere; vertical-align: top; }
.audit-panel code { color: var(--accent); font-size: 8px; }

.auth-page { min-height: 100%; display: grid; place-items: center; overflow: auto; padding: 25px; background: radial-gradient(circle at 50% 10%, #fff 0, #f0f1ee 55%, #e7e9e6 100%); }
.auth-card { width: min(430px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 17px; background: white; box-shadow: 0 20px 50px #00000012; }
.brand--auth { padding: 0 0 22px; }
.brand--auth strong { color: var(--text); }
.auth-card h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.03em; }
.auth-card .muted { line-height: 1.5; font-size: 10px; }
.form-stack { display: grid; gap: 12px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field { display: grid; gap: 5px; }
.field > span { color: var(--muted); font-size: 9px; font-weight: 650; }
.field input, .field textarea, .field select { width: 100%; min-height: 36px; padding: 9px 10px; border: 1px solid var(--border-strong); border-radius: 8px; outline: 0; background: white; font-size: 11px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.check-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.auth-foot { margin: 17px 0 0; color: var(--faint); font-size: 8px; text-align: center; }
.setup-callout { padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.setup-callout p { margin: 4px 0 9px; color: var(--muted); font-size: 9px; }
.setup-callout code { display: block; padding: 7px; border-radius: 6px; background: white; overflow-wrap: anywhere; font-size: 10px; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: #1118158f; backdrop-filter: blur(2px); }
.modal { width: min(590px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--border); border-radius: 15px; background: white; box-shadow: 0 25px 70px #0005; }
.modal__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--border); }
.modal__header h2 { margin: 3px 0 0; font-size: 17px; }
.modal__header p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.modal__body { display: grid; gap: 13px; padding: 17px 18px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.eyebrow { color: var(--accent); font-size: 8px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.recap { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.recap > div { padding: 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.recap span, .recap strong { display: block; }
.recap span { color: var(--muted); font-size: 8px; }
.recap strong { margin-top: 4px; font-size: 10px; overflow-wrap: anywhere; }
.recap--large > div:nth-child(5) { grid-column: 1 / -1; }
.warning-callout, .info-callout { padding: 10px 11px; border-radius: 8px; font-size: 9px; line-height: 1.5; }
.warning-callout { color: #704700; background: var(--amber-soft); }
.info-callout { color: #2b5585; background: var(--blue-soft); }
.modal blockquote { margin: 0; padding: 12px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--surface-2); white-space: pre-wrap; font-size: 10px; line-height: 1.5; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 16px 18px; }
.recovery-grid code { padding: 8px; border-radius: 6px; background: var(--surface-2); text-align: center; font-size: 9px; }

.toast-region { position: fixed; z-index: 200; right: 17px; bottom: 17px; display: grid; gap: 7px; }
.toast { min-width: 280px; max-width: 390px; padding: 10px 12px; border: 1px solid #2e4940; border-radius: 9px; color: white; background: #17251f; box-shadow: 0 14px 35px #0004; font-size: 10px; animation: toast-in .18s ease-out; }
.toast--error { border-color: #85423a; background: #461f1a; }
.toast--info { border-color: #405d83; background: #1c304a; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

body[data-design='edesk'] .ticket__preview { height: 15px; white-space: nowrap; }
body[data-design='edesk'] .message__bubble { border-radius: 5px; }
body[data-design='edesk'] .channel-card, body[data-design='edesk'] .metric-card { box-shadow: none; }
body[data-design='gorgias'] .thread { background: linear-gradient(180deg, #faf9fc, #f6f3f9); }
body[data-design='gorgias'] .message__bubble { border-radius: 15px; }
body[data-design='gorgias'] .composer { margin: 0 10px 10px; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 25px #0000000c; }

@media (max-width: 1280px) {
  .design-option { max-width: 92px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .workspace { grid-template-columns: minmax(390px, 1fr); }
  .context-panel { position: fixed; z-index: 40; top: 58px; right: 0; bottom: 0; width: 310px; transform: translateX(102%); transition: transform .18s ease; box-shadow: -16px 0 35px #0002; }
  .context-panel.is-open { transform: translateX(0); }
  .context-mobile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  :root { --sidebar-width: 184px; --queue-width: 155px; --list-width: 300px; }
  .design-picker { display: none; }
  .channel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-grid { grid-template-columns: 1fr 1fr; }
  .health-grid > div:nth-child(2) { border-right: 0; }
  .health-grid > div { border-bottom: 1px solid var(--border); }
  .settings-grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: auto; }
}

@media (max-width: 760px) {
  body { overflow: hidden; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 245px; transform: translateX(-101%); transition: transform .18s ease; box-shadow: 14px 0 35px #0004; }
  .sidebar.is-open { transform: translateX(0); }
  .topbar { height: 52px; padding: 7px 10px; }
  .mobile-menu { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: white; }
  .global-search { width: 100%; }
  .global-search input { height: 35px; }
  .topbar__actions { display: none; }
  .app-view { padding-bottom: 57px; }
  .mobile-nav { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; height: 58px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); background: white; padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav .nav-item { min-height: 55px; display: flex; flex-direction: column; justify-content: center; gap: 2px; margin: 0; padding: 4px; border-radius: 0; color: var(--muted); text-align: center; font-size: 8px; }
  .mobile-nav .nav-item.is-active { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
  .mobile-nav .nav-icon { color: inherit; font-size: 15px; }
  .mobile-nav .nav-count { display: none; }
  .inbox-screen { grid-template-columns: 1fr; }
  .queues-panel { display: none; }
  .ticket-list { border: 0; }
  .workspace { grid-column: 1; min-height: 0; }
  .mobile-hidden { display: none; }
  .conversation-head { min-height: 62px; padding: 8px; }
  .conversation-head h2 { max-width: 58vw; font-size: 12px; }
  .conversation-head p { max-width: 58vw; overflow: hidden; white-space: nowrap; }
  .conversation-head__actions select { display: none; }
  .conversation-head__actions .button { min-height: 30px; padding: 5px 7px; font-size: 8px; }
  .mobile-back { display: grid; }
  .thread { padding: 13px 10px; }
  .composer { padding: 8px; }
  .composer__tools { overflow-x: auto; }
  .composer__channel { display: none; }
  .composer footer span { max-width: 145px; }
  .context-panel { top: 52px; bottom: 58px; width: min(330px, 92vw); }
  .page-scroll { padding: 12px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 18px; }
  .heading-actions .button { font-size: 9px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: auto; }
  .channel-grid { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 36px 1fr auto; }
  .account-row .capability, .account-row .button { display: none; }
  .prototype-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 90vh; border-radius: 17px 17px 0 0; }
  .recap { grid-template-columns: 1fr; }
  .recap--large > div:nth-child(5) { grid-column: auto; }
  .toast-region { left: 10px; right: 10px; bottom: 68px; }
  .toast { min-width: 0; max-width: none; }
  .health-grid { grid-template-columns: 1fr; }
  .health-grid > div { border-right: 0; }
}
