:root {
  color-scheme: dark;
  color: #ebf0f2;
  background: #10151d;
  font: 14px/1.5 Inter, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  --bg: #10151d;
  --sidebar: #111820;
  --surface: #171f29;
  --raised: #1d2733;
  --input: #111923;
  --border: #2c3948;
  --text: #ebf0f2;
  --secondary: #bfccd6;
  --muted: #a1afbd;
  --mint: #70e2c0;
  --blue: #83bcff;
  --violet: #bca6ff;
  --amber: #f4c578;
  --danger: #ffa9b6;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled, select:disabled { opacity: .56; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}
a { color: var(--mint); text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.24; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.025em; }
h2 { font-size: 20px; font-weight: 620; letter-spacing: -.012em; }
h3 { font-size: 15px; font-weight: 620; }
input, select, textarea {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--input);
  line-height: 1.4;
}
input::placeholder, textarea::placeholder { color: #8fa0af; }
textarea { min-height: 104px; resize: vertical; }
select { cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--mint); flex: none; }
input[readonly] { color: var(--muted); }
[hidden] { display: none !important; }

.skip-link, .sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus { z-index: 10; top: 10px; left: 10px; width: auto; height: auto; clip-path: none; padding: 10px; background: var(--surface); }
.login-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.login-screen:not([hidden]) ~ .skip-link { display: none; }
.login-screen .login-card { width: min(100%, 420px); display: grid; gap: 14px; padding: clamp(20px, 6vw, 36px); }
.login-card .brand { padding: 0 0 8px; }
.login-card .button { justify-self: start; }
.login-form { display: grid; gap: 12px; }
.login-form input { font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
.signed-in-user { min-width: 0; max-width: min(205px, 25vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 23px 14px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 28px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.025em; white-space: nowrap; }
.brand small { font-size: 14px; font-weight: 500; color: var(--muted); }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 9px;
  background: var(--mint);
  color: #102720;
}
.brand-mark::before { content: ""; width: 16px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 6px; transform: rotate(-28deg); }
.brand-mark::after { content: ""; width: 5px; height: 5px; position: absolute; border-radius: 50%; background: currentColor; transform: translate(5px, -3px); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 10px;
  background: transparent;
  color: var(--secondary);
  text-align: left;
  white-space: nowrap;
  margin-bottom: 3px;
  font-size: 13px;
  transition: background-color 130ms, color 130ms, border-color 130ms;
}
.nav-item:hover { background: var(--raised); }
.nav-item.active { background: #1b322e; border-color: #31564b; color: #a7f0da; font-weight: 620; }
.nav-icon { width: 18px; flex: none; text-align: center; font-size: 18px; line-height: 1; color: #9cacbc; }
.nav-item.active .nav-icon { color: var(--mint); }
.nav-count { margin-left: auto; color: inherit; background: #70e2c01c; border-radius: 4px; min-width: 24px; padding: 1px 5px; text-align: center; font-size: 11px; }
.sidebar-bottom { margin-top: auto; padding-top: 16px; }
.connections { display: grid; gap: 7px; border-top: 1px solid var(--border); padding: 14px 8px 10px; }
.connection { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--secondary); }
.connection-status { margin-left: auto; color: var(--muted); font-size: 10px; }
.status-dot { width: 7px; height: 7px; flex: none; border: 1px solid #a1afbd; border-radius: 50%; }
.connection.live .status-dot { border-color: var(--mint); background: var(--mint); }
.graph-link { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 4px 8px; color: var(--secondary); font-size: 12px; }
.graph-link:hover { color: var(--mint); }

main { display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: 77px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 30px; border-bottom: 1px solid var(--border); }
.topbar-actions { display: flex; gap: 10px; align-items: center; min-width: 0; }
.profile-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; min-width: 0; }
.profile-label span { white-space: nowrap; }
.profile-label select { width: min(230px, 26vw); font-size: 12px; text-overflow: ellipsis; }
.icon-button {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
  font-size: 21px;
  line-height: 1;
}
.icon-button:hover { background: var(--raised); color: var(--text); }
.content { flex: 1; min-width: 0; padding: 24px 30px 30px; }
.footer { display: flex; justify-content: space-between; gap: 10px; padding: 11px 30px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
#mobile-connections { display: none; }

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 41px; margin-bottom: 18px; }
.section-header p { color: var(--muted); margin-top: 5px; font-size: 13px; text-wrap: pretty; }
.button {
  min-height: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid #46576a;
  border-radius: 8px;
  padding: 8px 13px;
  color: var(--text);
  background: #283747;
  font-weight: 580;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  transition: background-color 130ms, border-color 130ms, color 130ms;
}
.button:not(:disabled):hover { background: #324456; }
.button.primary { border-color: var(--mint); background: var(--mint); color: #102821; font-weight: 680; }
.button.primary:not(:disabled):hover { background: #a1f1da; border-color: #a1f1da; }
.button.ghost { border-color: var(--border); background: var(--input); color: var(--secondary); }
.button.ghost:not(:disabled):hover { border-color: #53677b; color: var(--text); }
.button.danger { background: #402732; border-color: #764251; color: var(--danger); }
.button.small { min-height: 35px; padding: 6px 10px; font-size: 12px; }
.hint, .field-help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.muted { color: var(--muted); }
.permission { color: var(--amber); font-size: 12px; }
.mono, .ticket-number { font-family: "IBM Plex Mono", Consolas, monospace; }
.no-wrap { white-space: nowrap; }
.numeric { text-align: right; }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-item {
  display: flex;
  min-width: 0;
  min-height: 90px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 5px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  text-align: left;
}
.summary-item .label { font-size: 12px; color: var(--muted); }
.summary-item .value { display: block; font-size: 25px; font-weight: 610; letter-spacing: -.045em; line-height: 1.18; overflow-wrap: anywhere; }
button.summary-item:hover, .summary-item.emphasis { border-color: #436a60; background: #1a2a2a; }
.summary-item.emphasis .value { color: var(--mint); }
.workspace {
  display: grid;
  grid-template-columns: minmax(245px, 335px) minmax(0, 1fr);
  min-height: 504px;
  height: clamp(504px, calc(100dvh - 305px), 850px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: clip;
  background: var(--surface);
}
.inbox-panel { min-width: 0; min-height: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.inbox-filters { padding: 14px; display: grid; gap: 9px; border-bottom: 1px solid var(--border); }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; font-size: 13px; }
.search-wrap::before { content: ""; position: absolute; width: 12px; height: 12px; top: 13px; left: 12px; border: 1.5px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-wrap::after { content: ""; position: absolute; width: 6px; height: 1.5px; left: 21px; top: 24px; transform: rotate(45deg); background: var(--muted); pointer-events: none; }
.filter-row { display: grid; grid-template-columns: 1fr 1.1fr; gap: 7px; }
.filter-row select { min-height: 37px; padding: 7px 8px; font-size: 12px; }
.list-caption { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px 8px; color: var(--muted); font-size: 11px; }
#list-count { display: grid; min-width: 24px; padding: 1px 5px; place-items: center; background: var(--raised); border-radius: 5px; }
.ticket-list { min-height: 0; overflow: auto; padding: 0 8px 8px; scrollbar-width: thin; }
.ticket-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  margin: 0 0 4px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-bottom-color: #2b3746;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}
.ticket-card:hover { background: var(--raised); }
.ticket-card.selected { background: #19302d; border-color: #446e62; box-shadow: inset 2px 0 var(--mint); }
.ticket-card-top, .ticket-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.ticket-number { font-size: 12px; color: #a4b6c5; }
.ticket-age { font-size: 11px; color: var(--muted); }
.ticket-subject { color: var(--text); font-size: 14px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-person { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-card-state { margin-top: 3px; }
.badge, .ticket-state {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 22px;
  width: max-content;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid #48596c;
  border-radius: 5px;
  color: var(--secondary);
  background: #213040;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}
.badge.media { color: var(--violet); background: #2c2540; border-color: #4d4066; }
.badge.client { color: var(--blue); background: #203449; border-color: #3c5269; }
.badge.payment, .badge.warn { color: var(--amber); background: #3b3021; border-color: #665233; }
.badge.other, .badge.success { color: var(--mint); background: #1b332d; border-color: #356657; }
.ticket-state { background: none; border-color: transparent; padding-left: 0; color: var(--muted); }
.ticket-state::before { content: ""; width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 50%; flex: none; }
.ticket-state.active { color: var(--mint); }
.ticket-state.active::before, .ticket-state.admin::before { background: currentColor; }
.ticket-state.admin, .ticket-state.resolution { color: var(--amber); }
.ticket-state.waiting { color: var(--blue); }
.ticket-state.closed { color: #a1afbd; }
.ticket-state.closed::before { height: 0; border-width: 1px 0 0; border-radius: 0; }

.ticket-detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #141c26; }
.ticket-detail > .empty-state, .ticket-detail > .loading-state { flex: 1; }
.detail-back { display: none; }
.ticket-head { padding: 18px 21px 14px; border-bottom: 1px solid var(--border); }
.detail-kicker { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 7px; }
.ticket-head h2 { font-size: 21px; overflow-wrap: anywhere; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 8px 0 12px; font-size: 12px; color: var(--muted); }
.detail-meta strong { color: var(--secondary); font-weight: 600; margin-left: 3px; }
.detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.detail-actions .spacer { flex: 1; }
.thread { flex: 1; min-height: 140px; overflow: auto; padding: 17px 21px 5px; scrollbar-width: thin; }
.ticket-detail > .banner { margin: 8px 20px 0; }
.message { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; margin-bottom: 17px; }
.avatar { display: grid; place-items: center; height: 32px; border: 1px solid #415368; border-radius: 8px; color: #c1d2e7; background: #253446; font-size: 11px; font-weight: 650; }
.message.auto .avatar { border-color: #456656; color: var(--mint); background: #253b34; }
.message.reply .avatar { border-color: #406153; color: #b1e6d5; background: #223731; }
.message.note .avatar { border-color: #55456f; color: var(--violet); background: #322a46; }
.message-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; margin: 0 0 4px; }
.message-title strong { overflow-wrap: anywhere; font-size: 13px; }
.message-type, .message-title time, .message-delivery { color: var(--muted); font-size: 11px; }
.message-title time { margin-left: auto; white-space: nowrap; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--secondary); font-size: 13px; line-height: 1.62; }
.message.note .message-body, .message.auto .message-body { padding: 8px 10px; border-radius: 7px; }
.message.note .message-body { background: #292337; border: 1px solid #4b3f61; }
.message.auto .message-body { background: #1b2b2b; border: 1px solid #314c44; }
.message.system { grid-template-columns: 1fr; text-align: center; }
.message.system .message-text { color: var(--muted); font-size: 12px; }
.message-delivery { margin-top: 5px; color: var(--amber); }
.feedback-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.composer { padding: 12px 21px 13px; border-top: 1px solid var(--border); background: var(--surface); }
.composer-top, .composer-footer { display: flex; align-items: center; gap: 8px; }
.composer-top { margin-bottom: 8px; }
.composer-top select { max-width: 300px; min-height: 36px; padding-block: 6px; font-size: 12px; }
.composer textarea { min-height: 68px; max-height: 25vh; font-size: 13px; }
.composer-footer { margin-top: 8px; justify-content: space-between; }
.composer .checkbox { display: flex; align-items: center; gap: 7px; min-height: 36px; color: var(--secondary); font-size: 12px; }
.composer.writing-note textarea { background: #222032; border-color: #55466e; }
.composer-info { margin-top: 5px; color: var(--muted); font-size: 11px; }
.empty-state { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 200px; padding: 22px; text-align: center; }
.empty-symbol { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--mint); background: #223132; font-size: 23px; }
.empty-state p { max-width: 340px; margin-top: 6px; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.empty-state .button { margin-top: 13px; }
.loading-state { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 11px; font-size: 13px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--mint); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

.banner { margin: 0 0 14px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.banner.info { background: #1e303e; color: #c2ddee; border-color: #3c5369; }
.banner.warning { background: #332c22; color: var(--amber); border-color: #5f4b31; }
.banner.error { background: #372631; color: var(--danger); border-color: #6e4151; }
.topbar + .banner { margin: 12px 30px 0; }
.panel { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack { display: grid; gap: 14px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 12px; }
.template-card { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; min-height: 180px; }
.card-top, .card-bottom { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.card-bottom { margin-top: auto; padding-top: 4px; width: 100%; }
.card-bottom .version { margin-left: auto; color: var(--muted); font-size: 11px; }
.template-text, .preview-text { color: var(--secondary); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.preview-text { background: var(--input); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 13px; }
.toolbar input { max-width: 370px; }
.audit-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 210px)); gap: 10px; margin-bottom: 12px; }
.activity-list { padding: 0; margin: 0; list-style: none; }
.activity-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) minmax(100px, 180px) minmax(85px, 130px);
  align-items: start;
  gap: 6px 14px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}
.activity-list .activity-row:last-child { padding-bottom: 0; }
.activity-time, .activity-description, .activity-platform { color: var(--muted); font-size: 12px; }
.activity-action .ticket-number { margin-left: 8px; }
.activity-description, .activity-platform, .activity-actor > span:first-child { display: block; }
.activity-description { margin-top: 3px; }
.activity-actor { color: var(--secondary); font-size: 13px; }
.activity-result .badge { white-space: normal; }
.activity-compact .activity-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.activity-compact .activity-action, .activity-compact .activity-time { grid-column: 1 / -1; }
.activity-compact .activity-result { justify-self: end; }
.table-wrap { overflow: auto; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; font-weight: 550; white-space: nowrap; }
td { vertical-align: middle; color: var(--secondary); overflow-wrap: anywhere; }
td .subtext { font-size: 11px; color: var(--muted); margin-top: 3px; }
tbody tr:last-child td { border-bottom: 0; }
.stats-large { font-size: 31px; font-weight: 650; margin: 6px 0; }
.stat-label, .bar-label { font-size: 12px; color: var(--secondary); }
.bar-row { margin: 13px 0; }
.bar-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.bar-track { height: 5px; border-radius: 4px; overflow: hidden; background: #314050; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--amber); }
.bar-fill.media { background: var(--violet); }
.bar-fill.client { background: var(--blue); }
.bar-fill.other { background: var(--mint); }
.role-tag { color: var(--mint); font-size: 12px; }
.settings-form, label.field { display: grid; gap: 6px; }
.settings-form { gap: 13px; max-width: 570px; }
label.field { color: var(--secondary); font-size: 13px; }
label.field > span:first-child { font-weight: 560; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1/-1; }
.checkline { display: flex; align-items: center; gap: 9px; min-height: 35px; color: var(--secondary); font-size: 13px; }
.toast { position: fixed; z-index: 5; right: 20px; bottom: 20px; max-width: min(430px, calc(100vw - 40px)); padding: 11px 14px; border-radius: 9px; border: 1px solid #547a6e; background: #234438; color: #d0f7ea; box-shadow: 0 12px 29px #0005; font-size: 13px; }
.toast.bad { background: #432a36; border-color: #744554; color: var(--danger); }
dialog { width: min(600px, calc(100% - 28px)); max-height: min(90dvh, 740px); padding: 0; border: 1px solid #485970; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 18px 66px #0008; overflow: auto; }
dialog::backdrop { background: #080d14c9; }
.dialog-header, .dialog-footer { display: flex; align-items: center; gap: 9px; padding: 12px 17px; background: var(--surface); }
.dialog-header { justify-content: space-between; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 16px 17px; display: grid; gap: 13px; }
.author-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--border); position: sticky; bottom: 0; }
#modal-error { margin: 0 17px 12px; }

@media (min-width: 1750px) {
  .content { width: 100%; max-width: 1640px; margin-inline: auto; }
}
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .topbar, .content, .footer { padding-inline: 20px; }
  .workspace { grid-template-columns: minmax(226px, 285px) minmax(0, 1fr); }
  .ticket-head, .thread, .composer { padding-inline: 15px; }
}
@media (max-width: 850px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 11px 15px 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { min-height: 42px; padding: 0 0 7px; }
  .brand-mark { width: 31px; height: 31px; }
  #navigation { display: flex; gap: 5px; overflow: auto; padding: 3px 2px; scrollbar-width: thin; }
  .nav-item { width: auto; flex: none; padding-inline: 9px; }
  .sidebar-bottom { display: none; }
  .topbar { min-height: 68px; }
  .profile-label select { width: min(200px, 35vw); }
  .workspace { height: clamp(552px, calc(100dvh - 395px), 850px); }
  #mobile-connections { display: flex; flex-wrap: wrap; gap: 8px; }
  #mobile-connections .connection { font-size: 11px; }
  #mobile-connections .connection-status { display: none; }
}
@media (max-width: 620px) {
  .topbar, .content, .footer { padding-inline: 14px; }
  .topbar { min-height: 61px; gap: 10px; }
  h1 { font-size: 21px; }
  h2 { font-size: 17px; }
  .profile-label > span { position: absolute; clip-path: inset(50%); }
  .profile-label select { width: min(165px, 40vw); }
  .topbar-actions { gap: 6px; }
  .content { padding-block: 14px 18px; }
  .topbar + .banner { margin: 9px 14px 0; }
  .section-header { gap: 8px; margin-bottom: 12px; }
  .section-header p { font-size: 12px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
  .summary-item { min-height: 70px; padding: 8px 11px; }
  .summary-item .value { font-size: 22px; }
  .workspace { display: block; height: auto; min-height: 0; }
  .app-shell:has(.workspace.show-detail) .sidebar,
  .app-shell:has(.workspace.show-detail) .topbar,
  .content:has(.workspace.show-detail) > .section-header,
  .content:has(.workspace.show-detail) > .summary-strip { display: none; }
  .inbox-panel { border: 0; }
  .ticket-list { max-height: 55vh; }
  .ticket-detail { display: none; }
  .workspace.show-detail .inbox-panel { display: none; }
  .workspace.show-detail .ticket-detail { display: flex; }
  .detail-back { display: inline-flex; align-self: start; margin: 9px 12px 0; }
  .ticket-head { padding: 11px 13px 12px; }
  .ticket-head h2 { font-size: 18px; }
  .detail-meta { gap: 4px 10px; }
  .thread { max-height: 43dvh; padding-inline: 13px; }
  .composer { padding-inline: 13px; }
  .composer textarea { max-height: 38vh; }
  .composer-footer { flex-wrap: wrap; }
  .button.small, .filter-row select { min-height: 40px; }
  .detail-actions .spacer { display: none; }
  .grid-two, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .panel { padding: 12px; }
  .audit-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .activity-action, .activity-time { grid-column: 1 / -1; }
  .activity-result { justify-self: end; }
  table { font-size: 12px; }
  .message-title time { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
