/* Presentation refinements. Existing markup, controls and data contracts stay in place. */
:root {
  --canvas: #101010;
  --canvas-deep: #0c0c0c;
  --surface: #191919;
  --surface-raised: #222;
  --surface-soft: #252525;
  --control: #151515;
  --sidebar: #141414;
  --ink: #f5f5f5;
  --ink-secondary: #d6d6d6;
  --muted: #aaa;
  --quiet: #999;
  --line: #303030;
  --line-strong: #484848;
  --accent: #ededed;
  --accent-hover: #fff;
  --accent-soft: #272727;
  --on-accent: #171717;
  --brand-wordmark: #8d8d8d;
  --focus-ring: #dedede;
  --radius-control: 9px;
  --radius-surface: 14px;
  --space-panel: 24px;
  --ease-ui: cubic-bezier(.22, 1, .36, 1);
  --motion-fast: 140ms;
  --motion-normal: 200ms;
  --motion-panel: 260ms;
  --z-dropdown: 40;
  --z-sidebar: 60;
  --z-modal: 120;
  --z-toast: 150;
  --shadow-raised: 0 16px 48px #0005, 0 2px 8px #0003;
}

html[data-theme='light'], #app[data-theme='light'] {
  --canvas: #f6f6f6;
  --canvas-deep: #eee;
  --surface: #fff;
  --surface-raised: #fff;
  --surface-soft: #f0f0f0;
  --control: #fafafa;
  --sidebar: #fafafa;
  --ink: #202020;
  --ink-secondary: #414141;
  --muted: #626262;
  --quiet: #6d6d6d;
  --line: #e1e1e1;
  --line-strong: #b7b7b7;
  --accent: #242424;
  --accent-hover: #080808;
  --accent-soft: #ebebeb;
  --on-accent: #fff;
  --brand-wordmark: #737373;
  --focus-ring: #343434;
  --green: #247347;
  --amber: #8a571a;
  --shadow-raised: 0 16px 48px #00000012, 0 2px 8px #00000008;
}

html { scrollbar-gutter: stable; text-size-adjust: 100%; }
body { line-height: 1.65; }
button, input, textarea, select { letter-spacing: inherit; }
button, a { touch-action: manipulation; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
button:focus-visible, a:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}
input:not([type='checkbox']):focus-visible, textarea:focus-visible, select:focus-visible {
  outline-offset: 2px;
}
input:not([type='checkbox']):not([type='hidden']):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
:where(input, select, textarea) { scroll-margin-block: 100px 32px; }
:where(input, textarea, select):disabled { cursor: not-allowed; opacity: .6; }
pre, code { tab-size: 2; }
input[type='search']::-webkit-search-cancel-button { cursor: pointer; }

/* Shell and typography */
.sidebar { z-index: var(--z-sidebar); }
.sidebar-brand { height: 88px; }
.brand-symbol { color: var(--ink); width: 30px; height: 30px; }
.brand-copy strong { font-size: 15px; letter-spacing: -.25px; }
.sidebar-nav { gap: 4px; padding-inline: 14px; }
.nav-label { font-size: 11px; margin-top: 26px; }
.nav-item { min-height: 43px; font-size: 13px; padding: 10px 12px; border-radius: 9px; }
.nav-item.is-active { color: var(--ink); border-color: var(--line); }
.nav-item b { font-size: 11px; border-radius: 5px; }
.nav-item.is-active b { color: var(--ink); background: var(--surface-soft); }
.operator-card strong { font-size: 12px; }
.operator-card small { font-size: 11px; }
.operator-profile { min-height: 44px; }
.operator-card .icon-button { width: 36px; height: 36px; }
.topbar { position: relative; min-height: 76px; overflow: clip; }
.breadcrumb strong { font-size: 13px; }
.topbar-connection strong { font-size: 12px; }
.topbar-left, .topbar-actions { min-width: 0; }
.breadcrumb { min-width: 0; }
.breadcrumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-content { padding-top: 34px; padding-bottom: 56px; min-width: 0; }
.page-heading { margin-bottom: 30px; align-items: flex-start; }
.page-heading h1 { font-size: 30px; line-height: 1.25; letter-spacing: -.9px; font-weight: 700; }
.page-heading p:last-child { font-size: 14px; line-height: 1.65; max-width: 64ch; }
.page-actions, .overview-actions { padding-top: 2px; }
.surface-card { border-radius: var(--radius-surface); }
.surface-head { margin-bottom: 22px; }
.surface-head > div { min-width: 0; }
.surface-head h2 { font-size: 17px; letter-spacing: -.35px; }
.surface-note { font-size: 13px; line-height: 1.65; max-width: 72ch; }
.surface-head .text-button, .surface-foot .text-button { font-size: 13px; }
.surface-foot { padding-top: 16px; margin-top: 18px; }
.surface-foot > span { font-size: 12px; }
.metric-grid { padding-block: 24px; border-radius: var(--radius-surface); }
.metric-card p { font-size: 13px; margin-bottom: 10px; }
.metric-card strong { font-size: 34px; letter-spacing: -1px; }
.metric-card.is-coral strong { color: var(--ink); }
.metric-card > span { font-size: 12px; }
.history-count { font-size: 14px; }
.live-label, .secure-label { font-size: 12px; }
.status-badge { font-size: 12px; line-height: 1.5; padding: 4px 8px; border-radius: 6px; }

/* A single control vocabulary across all screens */
.primary-button, .outline-button, .credential-action {
  min-height: 42px;
  padding: 10px 15px;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 650;
  justify-content: center;
}
.primary-button { box-shadow: 0 1px 2px #00000012; }
.icon-button { border-radius: var(--radius-control); }
.stack-form > .primary-button, .auth-submit { justify-content: center; }
.text-button, .row-action, .field-action { font-size: 12px; }
.row-action { min-height: 36px; }
.row-action + .row-action { margin-inline-start: 12px; }
.danger-button:hover:not(:disabled) { color: var(--danger); }
.primary-button:focus-visible { outline-color: var(--focus-ring); }
input:not([type='checkbox']):not([type='radio']):not([type='hidden']), select, textarea {
  border-radius: var(--radius-control);
  font-size: 14px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background-color var(--motion-fast);
}
.stack-form > label, .config-label, .user-field-label label, .notification-field,
.auth-form label { font-size: 13px; line-height: 1.55; }
.field-help { font-size: 12px; line-height: 1.65; margin-top: 6px; }
.form-message { font-size: 13px; line-height: 1.65; }
.secret-field { min-width: 0; }
.secret-field .secret-toggle { top: 50%; transform: translateY(-50%); }
.notification-field .secret-field { display: block; }
.notification-field .secret-toggle { width: 36px; height: 36px; min-height: 36px; right: 6px; }
input[type='file'] { white-space: normal; overflow: hidden; }
input[type='file']::file-selector-button {
  margin: -4px 12px -4px -4px;
  padding: 7px 12px;
  color: var(--ink-secondary);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}

/* Dense data remains readable, including long names and IDs */
table { font-size: 13px; }
th { font-size: 12px; font-weight: 550; padding-bottom: 14px; }
td { padding-block: 17px; }
.table-primary strong { font-size: 13px; }
.table-primary small, .table-sub { font-size: 12px; }
.table-primary { min-width: 0; }
.table-primary > span:last-child { min-width: 0; }
.table-primary strong { overflow: hidden; text-overflow: ellipsis; }
.dashboard-grid table { table-layout: fixed; }
.dashboard-grid th:first-child { width: 40%; }
.dashboard-grid th:last-child { width: 22%; }
.dashboard-grid .table-primary strong { max-width: 100%; }
.dashboard-grid .table-primary > span:last-child { overflow: hidden; }
.table-scroll { overscroll-behavior-inline: contain; }
.activity-row { padding-block: 16px; gap: 0 12px; }
.activity-row strong { font-size: 13px; }
.activity-row p, .activity-row time { font-size: 12px; }
.activity-icon { width: 32px; height: 32px; }
.empty-state { min-height: 250px; padding: 40px 20px; }
.empty-state h3 { font-size: 15px; }
.empty-state p { font-size: 13px; max-width: 38ch; margin-bottom: 20px; }
.empty-state p:last-child { margin-bottom: 0; }
.session-summary p { font-size: 13px; margin-bottom: 0; }
.session-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.session-summary-metrics { gap: 28px; flex-shrink: 0; }
.session-summary-metrics small { font-size: 12px; }
.session-summary h2 { margin-top: 0; }
.client-session-row { grid-template-columns: minmax(170px, 1.15fr) 112px minmax(155px, 1fr) auto; }
.client-session-row > div:nth-child(2) { min-width: 0; }
.session-health strong { font-size: 13px; }
.session-identity small, .session-health small { font-size: 12px; }
.session-health small { white-space: normal; overflow-wrap: anywhere; }
.session-actions { min-width: 0; gap: 6px; }
.session-actions .icon-button { width: 36px; height: 36px; min-height: 36px; }
.session-actions .danger-icon { color: var(--danger); }
.session-empty, .bots-empty { font-size: 13px; }
.activity-log-copy strong { font-size: 13px; white-space: normal; overflow-wrap: anywhere; }
.activity-log-copy small { font-size: 12px; }
.activity-log-row > time, .activity-log-category, .activity-log-footer { font-size: 12px; }
.activity-log-row { padding-block: 17px; }
.activity-log-tab { min-height: 38px; font-size: 13px; border-radius: 8px; }
.activity-log-search input { font-size: 13px; }
.activity-log-tabs { padding: 2px; }
.activity-log-empty { padding: 28px; text-align: center; font-size: 13px; }
.activity-log-empty span { max-width: 50ch; }

/* Forms, settings, messages */
.settings-tabs { gap: 26px; }
.settings-tab { padding: 15px 2px 16px; }
.settings-tab[aria-selected='true']::after { bottom: 0; border-radius: 2px; }
.settings-section { padding-block: 30px; }
.settings-section-heading h2 { font-size: 14px; }
.settings-option-copy strong, .settings-select-row strong { font-size: 14px; }
.settings-option-copy small, .settings-select-row small, .settings-hint { font-size: 12px; }
.settings-option { min-height: 72px; }
.settings-count { font-size: 11px; }
.settings-search input { font-size: 13px; }
.setting-switch { border: 1px solid transparent; }
.setting-switch i { top: 2px; left: 2px; }
.settings-option input:disabled + .setting-switch,
.notification-master input:disabled + .setting-switch,
.notification-event input:disabled + .setting-switch { opacity: .45; }
.notification-card-head h2 { font-size: 17px; }
.notification-card-head p, .notification-master, .notification-event { font-size: 13px; }
.notification-event { min-height: 56px; }
.notification-field { margin-top: 20px; }
.notification-field .field-optional { font-size: 12px; }
.notification-field textarea { min-height: 136px; font-size: 13px; line-height: 1.75; }
.template-variables { margin-top: 10px; gap: 7px; }
.template-variable { min-height: 32px; font-size: 12px; padding-inline: 11px; border-radius: 7px; }
.notification-actions { flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.notification-save-mobile { justify-self: end; }
.command-description { border: 1px solid var(--line); padding: 16px; }
.command-description strong { font-size: 14px; }
.command-description p { font-size: 13px; }
.action-row { grid-template-columns: minmax(0, 1fr); padding: 14px 12px; }
.action-row strong { font-size: 13px; }
.action-row > .action-number, .action-row > span:last-child:not(:nth-child(2)) { display: none; }
.ops-select-trigger { border-radius: var(--radius-control); }
.ops-select-current strong, .ops-select-option-copy strong { font-size: 13px; }
.ops-select-current small, .ops-select-option-copy small { font-size: 12px; }
.ops-select-option { min-height: 48px; }
.ops-select-option:has(.ops-select-option-mark:not(.is-online)) { grid-template-columns: minmax(0, 1fr) 18px; }
.ops-select-option-mark:not(.is-online) { display: none; }
.ops-select.is-open { z-index: var(--z-dropdown); }
.ops-select-menu { z-index: var(--z-dropdown); padding: 6px; border-radius: 11px; }
.ops-select-menu[data-ui-floating] { position: fixed; right: auto; margin: 0; }
.ops-select-menu.is-leaving { transition: opacity 110ms ease-out, transform 110ms ease-out; transform: translateY(-3px); }
.ops-select-chevron { transition: transform var(--motion-normal) var(--ease-ui); }
.ticket-client-search { font-size: 13px; }
.ticket-client-row strong { font-size: 13px; overflow-wrap: anywhere; }
.ticket-client-row small { font-size: 12px; }
.ticket-client-row em { font-size: 11px; }
.ticket-client-filters button, .ticket-preset strong { font-size: 12px; }
.ticket-preset small, .ticket-format-help { font-size: 12px; }
.ticket-thread-identity h2 { overflow-wrap: anywhere; }
.ticket-thread-actions .outline-button { font-size: 12px; min-height: 38px; }
.ticket-thread-head span { font-size: 12px; }
.ticket-message p, .ticket-message-body { font-size: 14px; line-height: 1.75; }
.ticket-message strong, .ticket-message time { font-size: 12px; }
.ticket-message > div { flex-wrap: wrap; }
.ticket-no-selection p { font-size: 13px; }
.ticket-no-selection { min-height: 330px; }
.compact-tool { min-height: 34px; font-size: 12px; padding-inline: 10px; }
.ticket-presets-card .icon-button { flex-shrink: 0; }
.bot-filters { min-width: 0; }
.bot-entry-name strong, .bot-entry summary strong { overflow-wrap: anywhere; }
.bot-import-modal-card { border-radius: 16px; max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain; }
.bot-import-tabs button { border-radius: var(--radius-control); }
.bot-import-modal-card [data-bot-import-single] > label,
.bot-import-modal-card [data-bot-import-zip] > label { display: block; margin-block: 12px 7px; }
.bot-import-modal-card [data-bot-import-single] > label:first-child,
.bot-import-modal-card [data-bot-import-zip] > label:first-child { margin-top: 0; }
.permission-group { border-radius: 10px; }
.permission-group legend, .permission-option { font-size: 13px; }
.disclosure-item summary strong { font-size: 13px; }
.disclosure-item summary small, .disclosure-content { font-size: 12px; }
.disclosure-chevron { transition: transform var(--motion-normal) var(--ease-ui); }

/* Remove ornamental arrows from controls with a visible text label. */
:is(button, a):not(.icon-button):not(.nav-item) > svg:has(use:is([href$='#arrow-right'], [href$='#arrow-up-right'], [href$='#arrow-narrow-right'])) { display: none; }
[data-ui-decoration] { display: none !important; }

/* Loading, feedback and bounded motion */
:where(.surface-card, .metric-grid, .sidebar, .topbar, .settings-options, .auth-view) {
  transition: background-color var(--motion-normal), border-color var(--motion-normal), color var(--motion-fast);
}
:where(button, a, summary) {
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast), opacity var(--motion-fast);
}
:is(.primary-button, .outline-button, .icon-button, .credential-action):active:not(:disabled) { transform: translateY(1px); }
.setting-switch { transition: background-color var(--motion-normal), border-color var(--motion-normal); }
.setting-switch i, .switch-track i { transition: transform var(--motion-normal) var(--ease-ui), background-color var(--motion-normal); }
.page-content.is-entering { animation: ui-view-in 170ms var(--ease-ui); }
.loading-state { gap: 16px; max-width: none; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-surface); background: var(--surface); }
.loading-line { position: relative; overflow: hidden; height: 18px; background: var(--surface-soft); border-radius: 5px; animation: none; }
.loading-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent);
  transform: translateX(-100%);
  animation: ui-skeleton 1.6s ease-in-out infinite;
}
.activity-log-loading { padding: 40px 24px; gap: 16px; }
.ui-skeleton-stack { width: min(100%, 640px); display: grid; gap: 16px; }
.ui-skeleton-stack .loading-line { width: 100%; height: 18px; }
.ui-skeleton-stack .loading-line:last-child { width: 62%; }
.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 30%;
  opacity: 0;
  background: var(--ink-secondary);
  transform: scaleX(0);
  transform-origin: left;
  pointer-events: none;
}
.topbar:has(.refresh-button.is-refreshing)::after { opacity: .65; animation: ui-progress 1.3s var(--ease-ui) infinite; }
.auth-submit:disabled::before, button[data-ui-busy]::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: refresh-spin .7s linear infinite;
}
.toast-region { z-index: var(--z-toast); pointer-events: none; }
.toast { min-height: 54px; padding: 15px 18px; font-size: 13px; border-radius: 12px; }
.toast > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.bot-import-modal, .cookie-viewer-backdrop, .browser-session-backdrop { z-index: var(--z-modal); overscroll-behavior: contain; }
.bot-import-modal:not([hidden]), .cookie-viewer-backdrop, .browser-session-backdrop { animation: ui-overlay-in var(--motion-normal) ease-out; }
.bot-import-modal:not([hidden]) > section, .cookie-viewer-backdrop > section, .browser-session-dialog { animation: ui-dialog-in var(--motion-panel) var(--ease-ui); }
.cookie-viewer { min-height: 0; }
.auth-grid { gap: 64px; }
.auth-sheet { max-width: 390px; }
.auth-copy h1 { margin-bottom: 28px; letter-spacing: -.8px; font-weight: 700; }
.auth-form { gap: 10px; }
.auth-submit { min-height: 48px; margin-top: 20px; }
.auth-wordmark { letter-spacing: -.045em; }
.auth-wordmark-client { letter-spacing: .35em; margin-left: 5px; }
.auth-topbar { padding-block: 26px; }

@keyframes ui-view-in { from { opacity: .35; } to { opacity: 1; } }
@keyframes ui-skeleton { to { transform: translateX(100%); } }
@keyframes ui-progress { from { transform: translateX(-110%) scaleX(.5); } to { transform: translateX(440%) scaleX(1); } }
@keyframes ui-overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui-dialog-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

@media (hover: hover) {
  .primary-button:hover:not(:disabled) { box-shadow: 0 3px 12px #0002; }
  .session-row:hover, .activity-log-row:hover { background: color-mix(in srgb, var(--surface-soft) 45%, transparent); }
  .settings-option:hover { background: color-mix(in srgb, var(--surface-soft) 25%, transparent); }
  .nav-item:hover { border-color: var(--line); }
}

@media (max-width: 1280px) and (min-width: 768px) {
  .client-session-row { grid-template-columns: minmax(180px, 1fr) 120px minmax(155px, 1fr); gap: 12px; }
  .client-session-row .session-actions { grid-column: 1 / -1; justify-content: flex-start; padding-left: 44px; }
  .client-session-row .session-actions:empty { display: none; }
  .metric-card { padding-inline: 18px; }
  .metric-card p, .metric-card > span { font-size: 12px; }
  .page-heading h1 { font-size: 28px; }
}

@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
  .metric-card { padding: 22px; border-bottom: 1px solid var(--line); }
  .metric-card:nth-child(2) { border-right: 0; }
  .metric-card:nth-child(n+3) { border-bottom: 0; }
  .activity-list { grid-template-columns: 1fr; }
  .activity-row:nth-child(2) { border-top: 1px solid var(--line); padding-top: 16px; }
  .notification-channels { grid-template-columns: minmax(0, 1fr); }
  .activity-log-toolbar { grid-template-columns: minmax(0, 1fr); }
  .session-summary { flex-wrap: wrap; }
  .settings-section { grid-template-columns: 135px minmax(0, 1fr); gap: 24px; }
}

@media (max-width: 767px) {
  :root { --space-panel: 18px; }
  html { scrollbar-gutter: auto; }
  .sidebar { width: min(286px, calc(100vw - 48px)); transition: transform var(--motion-panel) var(--ease-ui); }
  .sidebar-open .sidebar { box-shadow: none; }
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-sidebar) - 1);
    background: #0009;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--motion-normal), visibility var(--motion-panel);
  }
  body.sidebar-open::before { opacity: 1; visibility: visible; }
  .sidebar-brand { height: 78px; }
  .sidebar-nav { gap: 5px; }
  .nav-item { min-height: 46px; font-size: 14px; }
  .sidebar-bottom { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .operator-card strong { font-size: 13px; }
  .operator-card small { font-size: 12px; }
  .operator-card .icon-button { width: 44px; height: 44px; }
  .topbar { min-height: 72px; padding: 12px 16px; gap: 10px; }
  .topbar-left { gap: 10px; flex: 1; }
  .topbar-left > div { min-width: 0; }
  .topbar .icon-button, .topbar .refresh-button { width: 44px; height: 44px; min-height: 44px; }
  .topbar-actions { gap: 6px; }
  .topbar-connection { padding: 4px; }
  .breadcrumb strong { font-size: 13px; }
  .page-content { padding: 26px 16px 40px; }
  .page-heading { gap: 18px; margin-bottom: 24px; }
  .page-heading h1 { font-size: 27px; letter-spacing: -.65px; }
  .page-heading p:last-child { font-size: 14px; }
  .page-actions, .overview-actions { max-width: 100%; padding: 0; gap: 8px; }
  .page-actions .outline-button { font-size: 13px; }
  .surface-card { padding: 20px 18px; }
  .surface-head { gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
  .surface-head h2 { font-size: 17px; }
  .surface-note { font-size: 13px; }
  .metric-card { padding: 20px 18px; }
  .metric-card strong { font-size: 30px; }
  .metric-card p { font-size: 13px; line-height: 1.5; }
  .metric-card > span { font-size: 12px; }
  .primary-button, .outline-button, .credential-action { min-height: 44px; font-size: 14px; }
  .icon-button { width: 44px; height: 44px; min-height: 44px; }
  .text-button, .row-action, .field-action { min-height: 40px; }
  .page-content input:not([type='checkbox']):not([type='hidden']),
  .page-content select, .page-content textarea, .auth-form input { font-size: 16px !important; }
  .page-content input:not([type='checkbox']):not([type='hidden']), .page-content select { min-height: 46px; }
  table { min-width: 560px; }
  .dashboard-grid table { min-width: 0; table-layout: auto; }
  .dashboard-grid thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dashboard-grid tbody { display: grid; }
  .dashboard-grid tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 18px 0; border-top: 1px solid var(--line); }
  .dashboard-grid td { padding: 0; border: 0; min-width: 0; white-space: normal; }
  .dashboard-grid td:first-child { grid-column: 1 / -1; }
  .dashboard-grid td:nth-child(3) { text-align: right; font-size: 12px; }
  .dashboard-grid td:last-child { display: flex; align-items: center; gap: 20px; grid-column: 1 / -1; }
  .dashboard-grid .table-primary strong { white-space: normal; overflow-wrap: anywhere; }
  .dashboard-grid .row-action + .row-action { margin-inline-start: 0; }
  .dashboard-grid .table-scroll { overflow: visible; }
  .session-summary { display: grid; gap: 22px; padding: 20px 18px; }
  .session-summary-metrics { justify-content: flex-start; gap: 36px; width: 100%; padding-top: 18px; border-top: 1px solid var(--line); }
  .session-summary-metrics strong { font-size: 24px; }
  .session-list-card, .activity-logs-card, .bot-registry-card { padding: 0; }
  .session-list-head { padding: 20px 18px; }
  .client-session-row { grid-template-columns: minmax(0, 1fr) auto; padding: 18px; gap: 14px 10px; }
  .client-session-row > div:nth-child(2) { display: block; }
  .client-session-row .session-identity { grid-column: 1; }
  .client-session-row .session-identity strong { font-size: 14px; }
  .client-session-row .session-identity small { font-size: 11px; }
  .client-session-row .session-health { display: grid; grid-column: 1 / -1; padding-left: 44px; }
  .client-session-row .session-actions { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
  .client-session-row .session-actions:empty { display: none; }
  .session-actions .icon-button { width: 44px; height: 44px; min-height: 44px; }
  .client-session-row .status-badge { font-size: 11px; padding: 4px 6px; }
  .activity-log-tabs { gap: 4px; }
  .activity-log-tab { min-height: 44px; font-size: 13px; }
  .activity-log-row { grid-template-columns: 7px minmax(0, 1fr); padding: 18px; gap: 6px 10px; }
  .activity-log-row > time { grid-column: 2; grid-row: 1; }
  .activity-log-marker { grid-column: 1; grid-row: 2; align-self: start; margin-top: 7px; }
  .activity-log-copy { grid-column: 2; grid-row: 2; }
  .activity-log-copy strong { font-size: 14px; line-height: 1.6; }
  .activity-log-copy small { white-space: normal; overflow-wrap: anywhere; }
  .activity-log-category { display: none; }
  .activity-log-footer { flex-wrap: wrap; padding: 16px 18px; gap: 10px; }
  .activity-log-toolbar { padding: 16px 18px; }
  .settings-section { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-block: 26px; }
  .settings-options { padding-inline: 16px; }
  .settings-option { gap: 16px; }
  .settings-options .settings-select-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-section-heading { padding-top: 0; }
  .settings-tab { min-height: 48px; font-size: 14px; }
  .settings-tabs { gap: 23px; }
  .settings-domain-add { flex-wrap: wrap; }
  .settings-list-tools { padding: 16px; }
  .settings-list-tools .outline-button { flex-shrink: 0; }
  .list-remove { width: 44px; height: 44px; min-height: 44px; flex-shrink: 0; }
  .notification-card { padding: 20px 18px; }
  .notification-card-head { flex-wrap: wrap; gap: 14px; }
  .notification-master { min-height: 36px; }
  .notification-event-grid { grid-template-columns: minmax(0, 1fr); }
  .notification-event { font-size: 14px; min-height: 58px; }
  .notification-field .field-optional { display: inline-block; margin-left: 4px; }
  .template-variable { min-height: 38px; font-size: 12px; }
  .notification-layout .notification-save-mobile { display: inline-flex; width: 100%; }
  .page-content:has(.notification-layout) > .page-heading #notifications-save { display: none; }
  .ticket-workspace { grid-template-columns: minmax(0, 1fr); }
  .ticket-client-list { max-height: 270px; overflow-y: auto; }
  .ticket-client-filters button { min-height: 40px; font-size: 13px; }
  .ticket-presets-list { grid-template-columns: minmax(0, 1fr); }
  .ticket-client-tools { gap: 4px; }
  .compact-tool { min-height: 40px; font-size: 12px; }
  .ticket-thread-card > .ticket-client-tools .compact-tool { min-height: 30px; height: 30px; font-size: 11px; padding: 0 7px; }
  .ticket-preset { padding: 14px; }
  .ticket-preset strong { font-size: 13px; }
  .ticket-no-selection { min-height: 250px; padding: 24px 8px; }
  .ticket-thread-actions .outline-button { min-height: 42px; font-size: 13px; }
  .bot-filters { grid-template-columns: minmax(0, 1fr); padding: 0 18px 18px; }
  .bot-registry-card > .surface-head { padding: 20px 18px; flex-wrap: wrap; }
  .bot-import-modal, .cookie-viewer-backdrop { padding: 12px; }
  .bot-import-modal-card { padding: 20px; max-height: calc(100dvh - 24px); }
  .bot-import-modal-card h2 { font-size: 20px; }
  .cookie-viewer { max-height: calc(100dvh - 24px); }
  .cookie-viewer-actions { flex-wrap: wrap; }
  .toast-region { right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); }
  .toast { padding: 14px 16px; }
  .auth-topbar { padding: 20px; }
  .auth-grid { width: calc(100% - 40px); padding-top: 32px; }
  .auth-copy h1 { font-size: 28px; }
  .auth-form label { font-size: 14px; }
  .auth-topbar .icon-button { width: 44px; height: 44px; }
  .ops-select-trigger { min-height: 48px; }
  .ops-select-option { min-height: 48px; }
  .ops-select-current strong, .ops-select-option-copy strong { font-size: 14px; }
}

@media (max-width: 359px) {
  .page-content { padding-inline: 12px; }
  .topbar { padding-inline: 12px; }
  .topbar-actions { gap: 4px; }
  .topbar-connection { display: none; }
  .page-actions > button { white-space: normal; text-align: center; }
  .metric-card { padding-inline: 14px; }
  .client-session-row { padding-inline: 14px; }
  .session-summary-metrics { gap: 28px; }
}

/* Account cards have their own header, editable controls and status grid. */
.bot-registry-card { padding: 0; background: transparent; border: 0; }
.bot-registry-card > .surface-head { padding: 0 0 20px; }
.bot-registry-card > .surface-head h2 { font-size: 17px; }
.bot-filters { padding: 18px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(170px, .55fr)); }
.bot-filters input, .bot-filters .ops-select-trigger { min-height: 44px !important; }
.bot-filters .ops-select-current strong { font-size: 13px; }
.bot-list { border: 0; gap: 18px; border-radius: 0; }
.bot-entry, .bot-entry:last-child { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.bot-entry-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto auto; gap: 16px; align-items: center; min-height: 88px; padding: 20px 24px; }
.bot-entry-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bot-account-avatar { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; color: var(--ink-secondary); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 11px; font-size: 13px; font-weight: 700; }
.bot-entry-account { min-width: 0; }
.bot-entry-account strong { font-size: 15px; font-weight: 700; white-space: normal; overflow-wrap: anywhere; }
.bot-entry-account small { font-size: 12px; }
.bot-entry-session { display: block; color: var(--muted); font-size: 12px; }
.bot-entry-game { display: inline-flex; align-items: center; padding: 4px 8px; color: var(--ink-secondary); background: var(--surface-soft); border-radius: 6px; font-size: 12px; }
.bot-entry-body, .bot-entry:last-child .bot-entry-body { display: grid; grid-template-columns: minmax(260px, .85fr) minmax(0, 1.6fr); gap: 26px; padding: 22px 24px; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.bot-entry-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-content: start; min-width: 0; }
.bot-entry-login-control { grid-column: 1 / -1; }
.bot-entry-login-control strong { font-size: 13px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.bot-entry-statuses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; min-width: 0; }
.bot-entry-quick-control > span, .bot-entry-health > span { font-size: 12px; font-weight: 550; color: var(--muted); }
.bot-entry-quick-control .ops-select-trigger { min-height: 44px; padding: 9px 12px; }
.bot-entry-quick-control .ops-select-current strong { font-size: 13px; }
.bot-entry-quick-control .ops-select-current small { display: none; }
.bot-entry-health { min-width: 0; gap: 7px; }
.bot-entry-health strong { font-size: 13px; line-height: 1.6; font-weight: 650; }
.bot-entry-health small { font-size: 12px; line-height: 1.6; }
.trade-status-online { color: var(--green) !important; }
.trade-status-idle { color: var(--amber) !important; }
.bot-entry-footer.bot-row-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px 20px; padding: 16px 24px; border-top: 1px solid var(--line); border-radius: 0 0 14px 14px; background: var(--control); }
.bot-actions-main, .bot-actions-secondary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.bot-entry-footer .outline-button, .bot-entry-footer .icon-button { min-height: 38px; font-size: 12px; }
.bot-entry-footer .icon-button { width: 38px; height: 38px; background: transparent; }
.bot-entry-footer .ui-icon { width: 17px; height: 17px; }
.bot-entry-footer [data-bot-delete] { margin-left: 4px; }
.bots-empty { min-height: 240px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface); }

/* Permissions stay in the form when collapsed, preserving checkbox values. */
.ui-sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.permissions-disclosure { margin-top: 12px; border: 1px solid var(--line-strong); border-radius: 10px; }
.permissions-disclosure > summary, .permission-group > summary { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 14px 16px; list-style: none; cursor: pointer; border-radius: 10px; }
.permissions-disclosure > summary::-webkit-details-marker, .permission-group > summary::-webkit-details-marker { display: none; }
.permissions-disclosure > summary:hover, .permission-group > summary:hover { background: var(--surface-soft); }
.permissions-disclosure > summary:focus-visible, .permission-group > summary:focus-visible { outline-offset: -3px; }
.permissions-disclosure-copy { display: grid; gap: 3px; margin-right: auto; min-width: 0; }
.permissions-disclosure-copy strong { font-size: 14px; font-weight: 650; }
.permissions-disclosure-copy small { font-size: 12px; color: var(--muted); }
.permissions-disclosure-action { font-size: 12px; color: var(--ink-secondary); }
.permissions-when-open { display: none; }
.permissions-disclosure[open] > summary .permissions-when-open { display: inline; }
.permissions-disclosure[open] > summary .permissions-when-closed { display: none; }
.permission-chevron { display: grid; place-items: center; flex: 0 0 18px; color: var(--muted); transition: transform var(--motion-normal) var(--ease-ui); }
.permission-chevron .ui-icon { width: 18px; height: 18px; }
.permissions-disclosure[open] > summary > .permission-chevron, .permission-group[open] > summary > .permission-chevron { transform: rotate(180deg); }
.permissions-disclosure-content { padding: 0 12px 12px; }
.permission-groups { display: grid; gap: 10px; }
.permission-group { padding: 0; border: 1px solid var(--line); border-radius: 9px; min-width: 0; margin: 0; }
.permission-group > summary { min-height: 54px; padding: 13px 16px; border-radius: 9px; }
.permission-group-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.permission-group-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.permission-fields { min-width: 0; margin: 0; padding: 0 16px 12px; border: 0; }
.permission-fields .settings-options { background: transparent; border: 0; border-radius: 0; padding: 0; gap: 0 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.permission-option { min-height: 58px; padding-block: 14px; }
.permission-option .settings-option-copy strong { font-size: 13px; font-weight: 500; }
#user-permissions-form { padding: 0; }
.user-create-card + .user-create-card { margin-top: 24px; }
.user-create-mark { display: none; }
.role-badge { font-size: 11px; }

/* Preset text is a real button, styled explicitly instead of native button chrome. */
.ticket-workspace { grid-template-columns: minmax(210px, .52fr) minmax(220px, .58fr) minmax(0, 1.55fr) minmax(200px, .5fr); }
.ticket-presets-list { display: grid; gap: 12px; align-content: start; }
.ticket-preset { display: grid; gap: 0; padding: 0; overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--control); }
.ticket-preset:hover { background: var(--control); }
.ticket-preset-select { appearance: none; display: grid; align-content: start; gap: 8px; width: 100%; min-width: 0; padding: 15px 14px; border: 0; border-radius: 9px 9px 0 0; color: var(--ink); background: transparent; font: inherit; text-align: left; cursor: pointer; }
.ticket-preset-select:hover { background: var(--surface-soft); }
.ticket-preset-select:focus-visible { outline-offset: -3px; }
.ticket-preset.is-editing { border-color: var(--ink-secondary); }
.ticket-preset.is-editing .ticket-preset-select { background: var(--surface-soft); }
.ticket-preset-editor-title { margin: 0 0 6px; color: var(--ink); font-size: 14px; font-weight: 650; line-height: 1.5; }
.ticket-preset-select strong { display: block; font-size: 14px; font-weight: 650; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.ticket-preset-select small { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.ticket-preset-select small:empty { display: none; }
.ticket-preset-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.ticket-preset-actions .compact-tool { min-height: 36px; padding: 7px 10px; font-size: 12px; color: var(--ink-secondary); background: transparent; border-color: var(--line-strong); border-radius: 7px; }
.ticket-preset-actions .compact-tool .ui-icon { width: 15px; height: 15px; }
.ticket-preset-actions .preset-insert { margin-left: auto; color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.ticket-preset-actions .preset-insert:hover { background: var(--accent-hover); }
.ticket-presets-card > .surface-head { align-items: flex-start; gap: 12px; }
.ticket-presets-card > .surface-head .surface-note { font-size: 13px; line-height: 1.6; }
.ticket-presets-card .surface-head .icon-button { width: 40px; height: 40px; min-height: 40px; font-size: 20px; }
.ticket-preset-editor { display: grid; gap: 8px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.ticket-preset-editor > label { color: var(--ink-secondary); font-size: 13px; }
.ticket-preset-editor > label:not(:first-child) { margin-top: 6px; }
.ticket-preset-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ticket-preset-editor-actions > button { flex: 1; min-width: 90px; }
.ticket-preset-editor-actions > .primary-button { flex-basis: 100%; }

@media (max-width: 1200px) {
  .bot-entry-row { grid-template-columns: minmax(180px, 1fr) auto auto; }
  .bot-entry-row .bot-entry-session { display: none; }
  .bot-entry-body, .bot-entry:last-child .bot-entry-body { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .bot-entry-statuses { border-top: 1px solid var(--line); padding-top: 20px; }
  .bot-filters { grid-template-columns: minmax(0, 1fr) repeat(2, minmax(145px, .7fr)); }
}
@media (max-width: 1100px) {
  .ticket-workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .ticket-presets-card { grid-column: 1 / -1; }
  .ticket-presets-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
}
@media (min-width: 768px) and (max-width: 900px) {
  .bot-entry-row { grid-template-columns: minmax(0, 1fr) auto; }
  .bot-entry-identity { grid-column: 1 / -1; }
  .bot-entry-game { justify-self: start; }
  .bot-entry-status { justify-self: end; }
}
@media (max-width: 767px) {
  .bot-registry-card > .surface-head { padding: 0 0 16px; }
  .bot-filters { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 12px; }
  .bot-entry-row { grid-template-columns: minmax(0, 1fr) auto; gap: 14px 12px; padding: 18px; }
  .bot-entry-identity { grid-column: 1 / -1; }
  .bot-entry-game { display: inline-flex; justify-self: start; font-size: 12px; }
  .bot-entry-status { justify-self: end; }
  .bot-entry-account strong { font-size: 15px; }
  .bot-entry-body, .bot-entry:last-child .bot-entry-body { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 20px; }
  .bot-entry-controls { gap: 12px; }
  .bot-entry-statuses { grid-template-columns: minmax(0, 1fr); gap: 18px; padding-top: 18px; }
  .bot-entry-health { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 3px 12px; }
  .bot-entry-health > span { grid-row: 1 / span 2; }
  .bot-entry-health > small { grid-column: 2; }
  .bot-entry-health strong { font-size: 13px; }
  .bot-entry-footer.bot-row-actions { padding: 16px 18px; gap: 12px; }
  .bot-actions-main, .bot-actions-secondary { width: 100%; gap: 8px; }
  .bot-actions-secondary { border-top: 1px solid var(--line); padding-top: 12px; }
  .bot-entry-footer .outline-button, .bot-entry-footer .icon-button { min-height: 42px; }
  .bot-entry-footer .icon-button { width: 42px; height: 42px; }
  .bot-actions-main .outline-button { flex: 1; padding-inline: 8px; }
  .bot-entry-footer [data-bot-delete] { margin-left: auto; }
  .permissions-disclosure > summary { padding: 14px; gap: 8px; }
  .permissions-disclosure-action { font-size: 12px; }
  .permission-group > summary { min-height: 58px; padding: 14px; }
  .permission-fields { padding-inline: 14px; }
  .permission-option { min-height: 62px; }
  .user-list-card table { min-width: 0; table-layout: auto; }
  .user-list-card thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .user-list-card tbody { display: grid; }
  .user-list-card tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 18px 0; border-top: 1px solid var(--line); }
  .user-list-card td { min-width: 0; padding: 0; border: 0; white-space: normal; }
  .user-list-card td:first-child { grid-column: 1 / -1; }
  .user-list-card td:nth-child(3), .user-list-card td:last-child { justify-self: end; }
  .user-list-card td:nth-child(4) { align-self: center; font-size: 12px; }
  .user-list-card td:last-child:not(:has(button)) { display: none; }
  .user-list-card .table-primary strong { overflow-wrap: anywhere; }
  .user-list-card .table-primary small { overflow-wrap: anywhere; }
  .user-list-card .table-scroll { overflow: visible; }
  .dashboard-grid td:last-child:nth-child(3) { display: block; grid-column: 2; grid-row: 2; text-align: right; }
  .ticket-workspace { grid-template-columns: minmax(0, 1fr); }
  .ticket-presets-card { grid-column: auto; }
  .ticket-presets-list { grid-template-columns: minmax(0, 1fr); }
  .ticket-preset { padding: 0; }
  .ticket-preset-actions .compact-tool { min-height: 42px; font-size: 13px; }
  .ticket-presets-card .surface-head .icon-button { width: 44px; height: 44px; min-height: 44px; }
}
@media (max-width: 359px) {
  .bot-entry-controls { grid-template-columns: minmax(0, 1fr); }
  .bot-entry-health { grid-template-columns: 90px minmax(0, 1fr); gap: 4px 10px; }
  .permissions-disclosure-action { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .topbar:has(.refresh-button.is-refreshing)::after { width: 100%; transform: none; opacity: .5; }
  .loading-line::after { transform: none; background: none; }
  :is(.primary-button, .outline-button, .icon-button, .credential-action):active:not(:disabled) { transform: none; }
}

.page-content .ticket-workspace {
  display: grid;
  grid-template-columns: minmax(150px, var(--ticket-clients, 220px)) 12px minmax(72px, var(--ticket-inbox, 200px)) 12px minmax(0, 1fr) 12px minmax(170px, var(--ticket-presets, 280px));
  gap: 0;
  align-items: stretch;
  min-width: 0;
}
.page-content .ticket-workspace > .surface-card { min-width: 0; grid-column: auto; }
.page-content .ticket-presets-list { grid-template-columns: minmax(0, 1fr); }
.ticket-workspace.is-resizing, .ticket-workspace.is-resizing * { cursor: col-resize; user-select: none; }
.ticket-pane-resize { position: relative; cursor: col-resize; touch-action: none; }
.ticket-pane-resize::before { content: ''; position: absolute; top: 0; bottom: 0; left: -6px; right: -6px; }
.ticket-pane-resize::after { content: ''; position: absolute; top: 18px; bottom: 18px; left: 5px; width: 2px; border-radius: 2px; background: var(--line); }
.ticket-pane-resize:hover::after, .ticket-pane-resize.is-active::after { background: var(--ink-secondary); }
.ticket-workspace.is-avatar-rail .ticket-inbox-card { padding: 10px 6px; }
.ticket-workspace.is-avatar-rail .ticket-inbox-card .surface-head,
.ticket-workspace.is-avatar-rail .ticket-inbox-card .ticket-client-row > span:nth-child(2),
.ticket-workspace.is-avatar-rail .ticket-inbox-card .ticket-client-row em { display: none; }
.ticket-workspace.is-avatar-rail .ticket-inbox-card .ticket-client-row { grid-template-columns: 1fr; justify-items: center; gap: 0; padding: 4px 0; }
.ticket-preset { grid-template-columns: minmax(0, 1fr); padding: 0; overflow: hidden; }
.ticket-preset-select, .ticket-preset-select strong, .ticket-preset-select small { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.ticket-preset-actions { justify-content: center; gap: 10px; }
.ticket-preset-actions .compact-tool {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  justify-content: center;
}
.ticket-preset-actions .compact-tool > .ui-icon { display: block !important; width: 16px; height: 16px; flex: 0 0 16px; }
.ticket-inbox-card .surface-head { align-items: center; margin-bottom: 12px; }
@media (max-width: 980px) {
  .page-content .ticket-workspace { grid-template-columns: minmax(0, 1fr); }
  .ticket-pane-resize { display: none; }
}
.ticket-reply-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ticket-composer { position: relative; display: grid; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--surface) 88%, #000); overflow: hidden; }
.ticket-composer .ticket-format-toolbar { display: flex; align-items: center; gap: 1px; margin: 0; padding: 3px 6px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, #000); }
.ticket-composer .ticket-format-toolbar .compact-tool { width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; line-height: 1; }
.ticket-composer .ticket-format-toolbar .compact-tool i { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 650; }
.ticket-composer .ticket-format-toolbar .compact-tool u, .ticket-composer .ticket-format-toolbar .compact-tool s { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.ticket-composer .ticket-format-toolbar .compact-tool:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.ticket-composer .ticket-format-toolbar .compact-tool:disabled { opacity: 0.4; }
.ticket-composer .ticket-format-toolbar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ticket-composer .ticket-format-toolbar .compact-tool:has(.editor-gif) { width: auto; min-width: 34px; padding: 0 6px; }
.ticket-composer .editor-gif { font-size: 10px; font-weight: 750; letter-spacing: 0.04em; }
.ticket-composer textarea { min-height: 84px; border: 0; border-radius: 0; background: transparent; resize: vertical; }
.ticket-composer .ticket-reply-files { display: grid; gap: 8px; padding: 0 10px 10px; }
.ticket-composer .ticket-reply-files:empty { display: none; }
.ticket-composer .ticket-reply-file.is-image, .ticket-composer .ticket-reply-file.is-gif, .ticket-composer .ticket-reply-file.is-video { width: auto; }
.ticket-composer .ticket-reply-file.is-image img, .ticket-composer .ticket-reply-file.is-gif img, .ticket-composer .ticket-reply-file.is-video video { width: 100%; max-height: 320px; height: auto; object-fit: contain; border-radius: 8px; background: #0b0b0b; }
.ticket-composer .ticket-reply-file.is-file { display: flex; align-items: center; gap: 8px; width: auto; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.ticket-composer .ticket-reply-file.is-file .ticket-reply-file-icon { width: auto; height: auto; padding: 0; background: transparent; font-size: 10px; font-weight: 700; }
.ticket-composer .ticket-reply-file.is-file small { margin: 0; }
.ticket-composer .ticket-reply-file button { top: 8px; right: 8px; width: 22px; height: 22px; }
.ticket-composer .ticket-drop-overlay { top: 35px; right: 0; bottom: 0; left: 0; height: auto; border: 0; border-radius: 0; }
.ticket-upload-icon { display: grid; place-items: center; color: var(--muted); }
.ticket-link-dialog { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 64px; display: grid; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); }
.ticket-link-dialog p { margin: 0; font-size: 13px; font-weight: 650; }
.ticket-link-dialog label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.ticket-link-dialog input { width: 100%; }
.ticket-link-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ticket-link-dialog-actions button { min-height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); }
.ticket-link-dialog-actions button[type="submit"] { background: var(--accent); color: var(--accent-ink, #111); border-color: transparent; }

/* The ticket desk stays inside the window. Messages scroll; the reply field stays on screen. */
.page-content:has(.ticket-workspace) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.page-content:has(.ticket-workspace) > .page-heading {
  flex-shrink: 0;
  margin-bottom: 14px;
}
.page-content:has(.ticket-workspace) > .ticket-workspace {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}
.page-content .ticket-clients-card,
.page-content .ticket-presets-card,
.page-content .ticket-thread-card {
  min-height: 0;
  max-height: none;
  height: auto;
  align-self: stretch;
}
.ticket-thread-card > .ticket-client-tools,
.ticket-thread-card > .ticket-wallet-form,
.ticket-thread-card > .ticket-trade-form {
  flex-shrink: 0;
}
.ticket-client-tools .compact-tool.is-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line-strong);
}
.ticket-trade-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  max-height: 48vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}
.ticket-trade-form > label,
.ticket-trade-form .field-help {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.ticket-trade-form .field-help {
  margin: 0;
  font-weight: 500;
}
.ticket-trade-form input[type='url'],
.ticket-trade-form textarea {
  width: 100%;
  min-width: 0;
}
.ticket-trade-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ticket-trade-meta label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.ticket-trade-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ticket-trade-form .manual-trade-items {
  max-height: 260px;
}
.ticket-trade-form .manual-trade-toolbar {
  margin-top: 0;
}
.ticket-trade-form::-webkit-scrollbar,
.ticket-thread-card > .ticket-trade-form .manual-trade-items::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.ticket-thread-card > .ticket-client-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.ticket-thread-card > .ticket-client-tools::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
.ticket-thread-card > .ticket-client-tools .compact-tool {
  flex: 0 0 auto;
  min-height: 28px;
  height: 28px;
  padding: 0 6px;
  gap: 4px;
  font-size: 10px;
}
.ticket-thread-card > .ticket-client-tools .compact-tool .ui-icon {
  width: 12px;
  height: 12px;
}
.ticket-thread {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}
.ticket-thread-head { flex-shrink: 0; padding-bottom: 12px; }
.ticket-thread .ticket-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  align-content: start;
  grid-auto-rows: max-content;
}
.ticket-thread .ticket-message {
  height: auto;
  min-height: 0;
}
.ticket-thread .ticket-reply-form {
  flex-shrink: 0;
  gap: 8px;
  padding-top: 12px;
}
.ticket-reply-form textarea,
.ticket-composer textarea {
  height: 72px;
  min-height: 56px;
  max-height: 120px;
}
.ticket-thread .ticket-reply-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
}
.ticket-thread .ticket-reply-actions .ticket-target { grid-column: 1 / -1; padding: 2px 0; }
.ticket-thread .ticket-reply-actions .ticket-preview-open,
.ticket-thread .ticket-reply-actions .primary-button {
  min-width: 0;
  min-height: 34px;
  max-width: 100%;
  padding: 6px 10px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 1280px) and (min-width: 981px) {
  .page-content .ticket-workspace {
    grid-template-columns: minmax(120px, 170px) 12px minmax(64px, 150px) 12px minmax(240px, 1fr) 12px minmax(140px, 190px);
  }
}
@media (min-width: 981px) {
  .page-content:has(.ticket-workspace) {
    overflow: hidden;
    padding-bottom: 14px;
  }
  .page-content .ticket-clients-card,
  .page-content .ticket-inbox-card,
  .page-content .ticket-presets-card,
  .page-content .ticket-thread-card { grid-column: auto; }
}
@media (max-width: 980px) {
  .page-content:has(.ticket-workspace) { overflow: auto; }
  .page-content:has(.ticket-workspace) > .ticket-workspace { flex: none; }
  .page-content .ticket-clients-card,
  .page-content .ticket-presets-card {
    height: auto;
    max-height: 280px;
  }
  .page-content .ticket-thread-card {
    height: min(760px, calc(100dvh - 132px));
    max-height: none;
  }
}
@media (max-height: 760px) {
  .page-content:has(.ticket-workspace) { padding-top: 12px; padding-bottom: 10px; }
  .page-content:has(.ticket-workspace) > .page-heading { margin-bottom: 8px; }
  .page-content:has(.ticket-workspace) > .page-heading h1 { font-size: 22px; margin-bottom: 0; }
  .ticket-reply-form textarea,
  .ticket-composer textarea { height: 56px; min-height: 48px; }
  .ticket-thread { gap: 8px; }
  .ticket-thread-head { padding-bottom: 8px; }
  .ticket-thread .ticket-reply-form { padding-top: 8px; }
}
