:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --panel-alt: #f7f9fc;
  --panel-alt-hover: #eef4fb;
  --line: #d8e1ed;
  --line-strong: #b9c7d8;
  --text: #172033;
  --muted: #64748b;
  --accent: #1f6feb;
  --accent-strong: #1557c0;
  --accent-soft: rgba(31, 111, 235, 0.1);
  --brand: #d52b1e;
  --brand-strong: #b91f16;
  --brand-soft: rgba(213, 43, 30, 0.1);
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.1);
  --badge: #b7791f;
  --badge-soft: rgba(183, 121, 31, 0.12);
  --success: #16834a;
  --success-soft: rgba(22, 131, 74, 0.11);
  --surface-soft: #f8fafc;
  --shadow: 0 18px 42px rgba(30, 41, 59, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
}

body {
  font-family: Arial, sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  color: var(--text);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.login-logo {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.login-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
}

.login-subtitle {
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  text-align: center;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.turnstile-container {
  width: 100%;
  min-height: 65px;
}

.account-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 10px;
}

.account-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.account-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.app-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(213, 43, 30, 0.18);
}

.app-topbar .session-status {
  flex: 1 1 auto;
  min-width: 160px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.app-body {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  min-height: 0;
}

.sidebar,
.detail-pane {
  min-width: 0;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  padding: 22px 18px;
  box-shadow: 12px 0 32px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-pane {
  padding: 26px;
  background: var(--bg);
  overflow: hidden;
}

.sidebar-header,
.workspace-header,
.reply-actions,
.ticket-row-top,
.reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.sidebar-summary {
  margin: 18px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.search-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 11px 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-input:focus {
  outline: none;
  border-color: rgba(31, 111, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

select.search-input {
  color-scheme: light;
}

select.search-input option {
  color: #101319;
  background: #f5f7fb;
}

select.native-multi-filter {
  display: none !important;
}

.multi-filter-control {
  position: relative;
  flex: 0 1 190px;
  min-width: 170px;
}

.multi-filter-button {
  width: 100%;
  min-height: 42px;
  text-align: left;
  cursor: pointer;
}

.multi-filter-button::after {
  content: "v";
  float: right;
  color: var(--muted);
}

.multi-filter-button.has-selection {
  border-color: rgba(31, 111, 235, 0.42);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.multi-filter-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(31, 111, 235, 0.24);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.multi-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.multi-filter-option:hover {
  background: var(--accent-soft);
}

.multi-filter-option input {
  margin: 0;
  accent-color: var(--accent);
}

.inbox-filter.active {
  border-color: rgba(31, 111, 235, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #efb443;
  color: #10131a;
  font-size: 11px;
  font-weight: 700;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  margin-top: 4px;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

.session-status,
.reply-status,
.ticket-preview,
.ticket-secondary,
.message-meta,
.message-empty,
.reply-hint {
  color: var(--muted);
}

.session-status {
  font-size: 15px;
  line-height: 1.4;
}

.inbox-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #ffffff;
}

.stat-pill.highlight,
.chip.highlight {
  color: var(--badge);
  border-color: rgba(240, 180, 41, 0.28);
  background: var(--badge-soft);
}

.chip.executive {
  color: #ff9f43;
  border-color: rgba(255, 159, 67, 0.28);
  background: rgba(255, 159, 67, 0.14);
}

.chip.company-claro {
  color: #0057b8;
  border-color: rgba(0, 87, 184, 0.28);
  background: rgba(0, 87, 184, 0.1);
}

.chip.company-ibr {
  color: #6f42c1;
  border-color: rgba(111, 66, 193, 0.28);
  background: rgba(111, 66, 193, 0.12);
}

.chip.company-atento {
  color: #00796b;
  border-color: rgba(0, 121, 107, 0.28);
  background: rgba(0, 121, 107, 0.1);
}

.chip.company-default {
  color: #4b5f7a;
  border-color: rgba(75, 95, 122, 0.24);
  background: rgba(75, 95, 122, 0.08);
}

.stat-pill.active,
.chip.active {
  color: var(--accent-strong);
  border-color: rgba(31, 111, 235, 0.3);
  background: var(--accent-soft);
}

.stat-pill.success,
.chip.success {
  color: var(--success);
  border-color: rgba(39, 174, 96, 0.3);
  background: var(--success-soft);
}

.chip.danger {
  color: var(--danger);
  border-color: rgba(198, 40, 40, 0.3);
  background: var(--danger-soft);
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.ticket-card {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
  text-align: left;
}

.ticket-card:hover {
  border-color: var(--accent-strong);
  background: #f9fbfe;
  transform: translateY(-1px);
}

.ticket-card.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent), var(--shadow);
  background: #f5f9ff;
}

.ticket-card.has-unread {
  border-color: rgba(240, 180, 41, 0.24);
}

.ticket-row-top {
  align-items: flex-start;
}

.ticket-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.ticket-title {
  font-size: 18px;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ticket-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--badge-soft);
  color: var(--badge);
  font-size: 12px;
  font-weight: 700;
}

.ticket-secondary {
  font-size: 13px;
  line-height: 1.35;
}

.ticket-secondary.strong {
  color: var(--text);
}

.ticket-secondary.meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-separator {
  color: #607089;
}

.ticket-preview {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.ticket-card-action {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.ticket-card-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-card-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.take-ticket-button {
  padding: 8px 12px;
}

.empty-state,
.workspace {
  max-width: 1280px;
  margin: 0 auto;
}

.empty-state {
  padding-top: 78px;
}

.hidden {
  display: none !important;
}

.workspace {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-header {
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.tag-picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.tag-picker-chip:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.ticket-workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  min-height: 0;
  flex: 1 1 auto;
}

.conversation-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ticket-side-panel {
  align-self: stretch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 16px;
  overflow: auto;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.05);
}

.ticket-side-panel-header {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.ticket-side-panel-header h3 {
  margin: 0;
  font-size: 18px;
}

.ticket-meta-stack {
  grid-template-columns: 1fr;
}

.ticket-meta-stack .meta-card,
.ticket-meta-stack .meta-card.span-3,
.ticket-meta-stack .meta-card.span-4,
.ticket-meta-stack .meta-card.span-5,
.ticket-meta-stack .meta-card.span-6,
.ticket-meta-stack .meta-card.span-8,
.ticket-meta-stack .meta-card.span-12 {
  grid-column: 1 / -1;
}

.workspace-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.workspace-banner.info {
  border-color: rgba(31, 111, 235, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.workspace-banner.success {
  border-color: rgba(39, 174, 96, 0.3);
  background: var(--success-soft);
  color: var(--success);
}

.workspace-banner.error {
  border-color: rgba(214, 72, 95, 0.3);
  background: var(--danger-soft);
  color: #ffb2bf;
}

.workspace-banner.warning {
  border-color: rgba(217, 143, 7, 0.32);
  background: #fff7e6;
  color: #875600;
}

.compact-result-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.compact-error-title {
  margin-top: 10px;
  font-weight: 700;
}

.compact-success-note {
  margin-top: 8px;
}

.meta-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 58px;
  padding: 8px 14px;
  background: #ffffff;
}

.meta-card.span-4 {
  grid-column: span 4;
}

.meta-card.span-3 {
  grid-column: span 3;
}

.meta-card.span-5 {
  grid-column: span 5;
}

.meta-card.span-6 {
  grid-column: span 6;
}

.meta-card.span-8 {
  grid-column: span 8;
}

.meta-card.span-12 {
  grid-column: 1 / -1;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.meta-value {
  font-size: 15px;
  line-height: 1.2;
}

.workspace-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.context-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 2px 0 14px;
}

.context-panel {
  margin: 0 0 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  scroll-margin-top: 18px;
}

.context-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.transfer-panel-actions {
  display: flex;
  gap: 10px;
}

.context-panel-title {
  font-size: 18px;
  margin-top: 4px;
}

.context-panel-copy {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin-top: 6px;
}

.context-panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: #ffffff;
}

.history-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-card-title {
  font-size: 16px;
  font-weight: 700;
}

.history-card-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.history-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.history-empty-copy {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-preview-line {
  border-left: 2px solid var(--line-strong);
  padding-left: 10px;
  color: #d6deea;
  font-size: 14px;
  line-height: 1.45;
}

.history-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.history-detail-window {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 10px;
}

.context-panel-nav {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  flex: 1 1 auto;
  min-height: min(240px, 30vh);
  max-height: none;
  overflow: auto;
  scroll-behavior: smooth;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.58)),
    var(--surface-soft);
}

body[data-app-mode="executive"] .detail-pane {
  padding-top: 22px;
  padding-bottom: 44px;
  overflow: visible;
}

body[data-app-mode="executive"] .app-shell {
  height: auto;
  min-height: 100vh;
  grid-template-rows: auto auto;
}

body[data-app-mode="executive"] .app-body {
  min-height: calc(100vh - 66px);
}

body[data-app-mode="executive"] .sidebar {
  overflow: visible;
}

body[data-app-mode="executive"] .workspace {
  height: auto;
  min-height: calc(100vh - 132px);
  overflow: visible;
}

body[data-app-mode="executive"] .ticket-workspace-layout {
  min-height: calc(100vh - 232px);
}

body[data-app-mode="executive"] .messages {
  flex: 0 0 auto;
  height: clamp(476px, 64vh, 784px);
  min-height: 476px;
  max-height: 784px;
}

.message-card {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 18px;
  padding: 12px 14px;
  width: fit-content;
  max-width: min(78%, 680px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.message-card.actor-ejecutivo,
.message-card.actor-admin {
  align-self: flex-end;
  border-color: rgba(31, 111, 235, 0.26);
  border-bottom-right-radius: 6px;
  background: #eaf3ff;
}

.message-card.actor-tecnico {
  align-self: flex-start;
  border-color: rgba(39, 174, 96, 0.34);
  border-bottom-left-radius: 6px;
  background: #f4fbf7;
}

.message-card:not(.actor-ejecutivo):not(.actor-admin):not(.actor-tecnico) {
  align-self: center;
  max-width: min(90%, 720px);
  border-style: dashed;
  background: #ffffff;
}

.message-meta {
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.message-card.actor-ejecutivo .message-meta,
.message-card.actor-admin .message-meta {
  color: var(--accent-strong);
  text-align: right;
}

.message-card.actor-tecnico .message-meta {
  color: var(--success);
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.message-body.muted {
  color: var(--muted);
}

.message-media {
  margin-top: 12px;
}

.message-image {
  display: block;
  width: 100%;
  max-width: 420px;
  max-height: 420px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.message-video {
  display: block;
  width: 100%;
  max-width: 520px;
  max-height: 420px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #000;
}

.message-media-link {
  display: inline-block;
}

.message-media-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.message-media-status.error {
  color: var(--danger);
}

.media-retry-button {
  border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 5px 10px;
}

.media-retry-button:hover:not(:disabled) {
  background: #fff5f5;
}

.media-retry-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.reply-form {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  flex: 0 0 auto;
}

.reply-header {
  margin-bottom: 10px;
}

.reply-label {
  font-size: 14px;
}

.reply-hint {
  font-size: 12px;
}

.reply-hint:empty {
  display: none;
}

.reply-actions {
  margin-top: 12px;
}

.reply-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: clamp(90px, 14vh, 120px);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

textarea:focus {
  outline: none;
  border-color: rgba(31, 111, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

button {
  border: 0;
  border-radius: 10px;
  font: inherit;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease, border-color 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.primary-button {
  background: linear-gradient(180deg, #e33b2f, var(--brand));
  color: #fff;
  min-width: 150px;
}

.ghost-button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.danger-button {
  background: linear-gradient(180deg, #ea6477, var(--danger));
  color: #fff;
}

.reply-status {
  min-height: 20px;
  font-size: 14px;
}

.reply-status.success {
  color: var(--success);
}

.reply-status.error {
  color: var(--danger);
}

.reply-status.pending {
  color: var(--accent-strong);
}

.image-attachment-bar {
  margin-top: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.transfer-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.transfer-option-button {
  min-width: 220px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.transfer-option-hint {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.close-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.close-option-button {
  min-height: 88px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  padding: 14px;
  text-align: left;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.close-option-button:hover {
  border-color: rgba(31, 111, 235, 0.45);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.close-option-button.danger {
  border-color: rgba(218, 45, 35, 0.32);
  color: var(--danger);
}

.monitor-shell {
  min-height: 100vh;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.monitor-header {
  position: sticky;
  top: 0;
  z-index: 35;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 -24px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.monitor-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.monitor-brand h1 {
  margin: 0;
  font-size: 22px;
}

.monitor-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.monitor-header-actions,
.monitor-tabs,
.monitor-filter-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.monitor-header-actions {
  justify-content: flex-end;
}

.monitor-tabs {
  align-content: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

#teamTab {
  order: 10;
}

#usersTab {
  order: 20;
}

#registrationTab {
  order: 30;
}

#historyTab {
  order: 40;
}

#bulkActionsTab {
  order: 50;
}

#treeTab {
  order: 60;
}

#settingsTab {
  order: 70;
}

#auditTab {
  order: 90;
}

.compact-monitor-tab {
  display: none;
}

.monitor-link-button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border-color: rgba(31, 111, 235, 0.28);
  background: #f5f9ff;
  box-shadow: 0 10px 24px rgba(31, 111, 235, 0.08);
  color: var(--accent-strong);
}

.monitor-link-button:hover {
  border-color: rgba(31, 111, 235, 0.44);
  background: #eaf3ff;
}

.monitor-summary-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 82px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.monitor-summary-card:hover {
  border-color: rgba(31, 111, 235, 0.36);
  box-shadow: 0 14px 28px rgba(31, 111, 235, 0.09);
  transform: translateY(-1px);
}

.monitor-summary-card.active {
  border-color: rgba(31, 111, 235, 0.5);
  box-shadow: inset 4px 0 0 var(--accent), 0 14px 28px rgba(31, 111, 235, 0.1);
  background: #f5f9ff;
}

.monitor-summary-value-row {
  margin-top: 6px;
  min-height: 30px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.monitor-summary-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  flex: 0 0 auto;
}

.monitor-summary-value.active {
  color: var(--accent-strong);
}

.monitor-summary-value.highlight {
  color: var(--badge);
}

.monitor-summary-value.success {
  color: var(--success);
}

.monitor-summary-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monitor-summary {
  margin-top: 18px;
}

.monitor-summary-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
}

.monitor-filter-card {
  justify-content: flex-end;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.05);
}

.monitor-filter-card .search-input {
  flex: 1 1 190px;
}

.monitor-filter-card .primary-button {
  min-width: 120px;
}

.monitor-layout {
  display: grid;
  grid-template-columns: minmax(500px, 620px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  flex: 1 1 auto;
}

.monitor-list-panel,
.monitor-detail-panel {
  min-width: 0;
}

.monitor-detail-panel {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.monitor-list-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.monitor-panel-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.admin-ticket-list {
  max-height: calc(100vh - 290px);
  margin-top: 16px;
}

.admin-user-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.queue-assign-form {
  align-items: end;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-field-full {
  grid-column: 1 / -1;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.check-chip input {
  margin: 0;
}

.check-chip.compact-check {
  min-height: 38px;
  white-space: nowrap;
}

.multi-filter {
  min-height: 76px;
}

.muted-section {
  opacity: 0.68;
}

.context-panel-copy.compact {
  margin-top: 8px;
}

.support-profile-legend {
  display: block;
  margin-top: 14px;
}

.stacked-panel-list {
  display: grid;
  gap: 12px;
}

.audit-details {
  margin: 8px 0 0;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font: 12px/1.5 Consolas, "Courier New", monospace;
}

.context-panel.compact {
  padding: 14px;
}

.history-workspace-layout {
  margin-top: 12px;
}

body[data-app-mode="admin"] #adminMessagesContainer,
body[data-app-mode="admin"] .history-messages {
  flex: 0 0 auto;
  height: clamp(572px, 77vh, 940px);
  min-height: 572px;
  max-height: 940px;
}

.admin-user-form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

.admin-user-form-actions-spacer {
  flex: 1 1 auto;
}

.self-status-panel {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.app-topbar .self-status-panel {
  margin-top: 0;
  flex-direction: row;
  align-items: center;
}

.self-status-current,
.self-status-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.self-status-current {
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
}

.app-topbar .self-status-current {
  min-height: 42px;
  padding: 8px 10px;
}

.self-status-panel .search-input {
  max-width: 220px;
}

.app-topbar .self-status-panel .search-input {
  width: 150px;
  max-width: 150px;
}

.app-topbar .account-panel {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
}

.app-topbar .account-panel summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 10px 13px;
}

.app-topbar .account-panel summary::-webkit-details-marker {
  display: none;
}

.app-topbar .account-panel[open] .account-form {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: min(310px, 90vw);
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.monitor-detail-panel .empty-state,
.monitor-detail-panel .workspace {
  max-width: none;
}

.monitor-detail-panel .workspace {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.confirmation-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(2px);
}

.confirmation-modal {
  width: min(440px, 100%);
  border: 1px solid #cbd7ea;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.24);
  padding: 22px;
}

.confirmation-modal h3 {
  margin: 0 0 8px;
  color: #172033;
  font-size: 1.05rem;
}

.confirmation-modal p {
  margin: 0 0 16px;
  color: #52627a;
}

.confirmation-modal-input {
  width: 100%;
}

.confirmation-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .app-topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .app-topbar .session-status {
    text-align: left;
  }

  .app-topbar-actions,
  .app-topbar .self-status-panel,
  .app-topbar .self-status-controls {
    width: 100%;
  }

  .app-topbar .self-status-panel {
    flex-wrap: wrap;
  }

  .app-topbar .self-status-panel .search-input {
    flex: 1 1 180px;
    width: auto;
    max-width: none;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 42vh;
  }

  .detail-pane {
    padding: 18px;
    overflow: visible;
  }

  .workspace {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .workspace-header {
    flex-direction: column;
  }

  .ticket-workspace-layout {
    grid-template-columns: 1fr;
  }

  .ticket-side-panel {
    order: -1;
  }

  .workspace-actions,
  .workspace-actions button,
  .context-panel-nav,
  .context-panel-nav button,
  .transfer-panel-actions,
  .transfer-panel-actions button,
  .search-panel,
  .search-panel button,
  .reply-action-buttons,
  .reply-action-buttons button {
    width: 100%;
  }

  .search-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .ticket-meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-card.span-4,
  .meta-card.span-3,
  .meta-card.span-5,
  .meta-card.span-6,
  .meta-card.span-8,
  .meta-card.span-12 {
    grid-column: 1 / -1;
  }

  .messages,
  .ticket-list {
    max-height: none;
  }

  .monitor-shell {
    padding: 0 18px 18px;
  }

  .monitor-header {
    position: static;
    margin: 0 -18px;
    padding: 12px 18px;
    flex-direction: column;
    align-items: stretch;
  }

  .monitor-brand,
  .monitor-header-actions {
    flex-wrap: wrap;
  }

  .monitor-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .monitor-toolbar {
    grid-template-columns: 1fr;
  }

  .monitor-filter-card {
    justify-content: stretch;
  }

  .monitor-filter-card .search-input,
  .monitor-filter-card .primary-button,
  .monitor-filter-card .ghost-button {
    width: 100%;
  }

  .monitor-layout {
    grid-template-columns: 1fr;
  }

  .admin-ticket-list {
    max-height: none;
  }

  .admin-user-form {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 820px) and (min-width: 981px) {
  .detail-pane {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .workspace-header {
    padding-bottom: 10px;
    margin-bottom: 8px;
  }

  .workspace-main {
    gap: 7px;
  }

  .context-tools {
    margin-bottom: 10px;
  }

  .messages {
    min-height: 140px;
    padding: 14px;
  }

  body[data-app-mode="executive"] .ticket-workspace-layout {
    min-height: calc(100vh - 190px);
  }

  body[data-app-mode="executive"] .messages {
    height: clamp(420px, 56vh, 644px);
    min-height: 420px;
    max-height: 644px;
  }

  .reply-form {
    padding-top: 12px;
  }

  .reply-actions {
    margin-top: 10px;
  }

  textarea {
    min-height: 88px;
  }

  .ticket-side-panel {
    padding: 14px;
  }
}
