@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #f4f8fb;
  --bg-2: #ebf2f7;
  --card: #ffffff;
  --card-soft: #f8fbff;
  --ink: #102133;
  --muted: #607485;
  --line: #d4e1ec;
  --accent: #0f766e;
  --accent-2: #0ea5e9;
  --warn: #f59e0b;
  --danger: #e11d48;
  --ok: #16a34a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-lg: 0 22px 52px rgba(14, 33, 54, 0.12);
  --shadow-sm: 0 8px 20px rgba(17, 39, 63, 0.08);
}

html[data-theme="dark"] {
  --bg: #0b1117;
  --bg-2: #111a22;
  --card: #121b24;
  --card-soft: #152231;
  --ink: #e5edf6;
  --muted: #9cb0c2;
  --line: #28394a;
  --accent: #0f766e;
  --accent-2: #0ea5e9;
  --warn: #f59e0b;
  --danger: #fb7185;
  --ok: #22c55e;
  --shadow-lg: 0 22px 52px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  line-height: 1.5;
}

.app-body {
  min-height: 100vh;
  background:
    radial-gradient(860px 380px at 0% -12%, rgba(14, 165, 233, 0.18), rgba(255, 255, 255, 0)),
    radial-gradient(900px 420px at 100% 118%, rgba(15, 118, 110, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 14% 6%, rgba(14, 165, 233, 0.33), rgba(0, 0, 0, 0) 34%),
    radial-gradient(circle at 90% 86%, rgba(15, 118, 110, 0.35), rgba(0, 0, 0, 0) 32%),
    linear-gradient(150deg, #0b1422, #10243c 48%, #183753);
}

.login-card {
  width: min(460px, 94vw);
  padding: 34px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 17, 30, 0.9);
  box-shadow: 0 30px 66px rgba(1, 10, 20, 0.55);
  color: #ecf5ff;
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: 34px;
  letter-spacing: -0.02em;
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
}

.login-card p {
  margin: 0 0 16px;
  color: #a8bdd4;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.65);
  background: rgba(245, 251, 255, 0.86);
  backdrop-filter: blur(14px);
}

.me {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: #deedf8;
  object-fit: cover;
  box-shadow: var(--shadow-sm);
}

nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 9px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: #244057;
}

a {
  color: #0c5ba8;
}

nav a,
button,
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

button:hover,
nav a:hover,
.btn:hover {
  transform: translateY(-1px);
  border-color: #9ab5cc;
  box-shadow: 0 10px 20px rgba(17, 40, 66, 0.12);
}

.primary {
  color: #fff;
  border-color: var(--accent-2);
  background: linear-gradient(180deg, #36b7ef, #0ea5e9);
}

.success {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(180deg, #159b8f, #0f766e);
}

.danger {
  color: #fff;
  border-color: var(--danger);
  background: linear-gradient(180deg, #f43f5e, #e11d48);
}

.shell {
  display: grid;
  grid-template-columns: 340px 1fr 390px;
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 80px);
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 24px;
  padding: 14px;
  overflow: auto;
  background:
    linear-gradient(180deg, var(--card), var(--card-soft)),
    radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.08), rgba(255, 255, 255, 0) 52%);
  box-shadow: var(--shadow-lg);
}

#center-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#main-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.title {
  margin: 0 0 10px;
  font-size: 21px;
  letter-spacing: -0.01em;
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
}

.sub {
  margin: 14px 0 8px;
  font-size: 16px;
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
}

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

.small {
  font-size: 12px;
}

.tabs,
.actions,
.grid2,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.grid2 > * {
  flex: 1 1 160px;
}

.card,
.ticket,
.message,
.staff-card {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.card strong,
.staff-card strong {
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
}

.queue-filters-card {
  max-width: 460px;
  margin-top: 12px;
}

.queue-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.filters-body {
  display: grid;
  gap: 4px;
}

.ticket {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ticket:hover {
  transform: translateY(-2px);
  border-color: #9db8cf;
}

.ticket.active {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.status-chip,
.channel-chip,
.priority-chip,
.sla-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 6px;
  margin-bottom: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}

.channel-chip {
  border-color: #a9d6f3;
  background: #ebf8ff;
}

.priority-chip.normal {
  border-color: #b8e4c8;
  background: #f0fff5;
}

.priority-chip.urgent {
  border-color: #fdd9a4;
  background: #fff8ea;
}

.priority-chip.critical {
  border-color: #ffc0ce;
  background: #fff1f5;
}

.status-chip.open {
  border-color: #bfdfff;
  background: #eff8ff;
}

.status-chip.active {
  border-color: #fbd89e;
  background: #fff8df;
}

.status-chip.waiting_user {
  border-color: #d7e0e9;
  background: #f6f9fc;
}

.status-chip.closed {
  border-color: #bdecc7;
  background: #effdf3;
}

.sla-chip.ok {
  border-color: #bbe9cb;
  background: #effdf4;
}

.sla-chip.warn {
  border-color: #f9d6a1;
  background: #fff8eb;
}

.sla-chip.bad {
  border-color: #ffc6d4;
  background: #fff1f5;
}

input,
select,
textarea {
  width: 100%;
  margin: 6px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(14, 165, 233, 0.2);
  border-color: var(--accent-2);
}

.hidden {
  display: none !important;
}

.dropzone {
  border: 2px dashed #b5cde1;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  background: var(--card-soft);
  transition: 0.16s ease;
}

.dropzone.drag {
  border-color: var(--accent-2);
  background: #eaf7ff;
}

img.chart {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.analytics-metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--card);
}

.error {
  margin-top: 12px;
  color: #fecaca;
}

.chat-wrap {
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  height: calc(100vh - 72px);
  max-height: calc(100vh - 72px);
  min-height: 760px;
}

.ticket-closed-banner {
  border: 1px solid #bdecc7;
  border-radius: 12px;
  padding: 10px 12px;
  background: #effdf3;
  color: #146c43;
  font-weight: 600;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(180deg, var(--card-soft), var(--card)),
    radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.14), rgba(255, 255, 255, 0) 58%);
}

.chat-response-timer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.chat-response-timer.ok {
  background: #effdf4;
  border-color: #bbe9cb;
  color: #13663d;
}

.chat-response-timer.warn {
  background: #fff8eb;
  border-color: #f9d6a1;
  color: #8d5f0b;
}

.chat-response-timer.bad {
  background: #fff1f5;
  border-color: #ffc6d4;
  color: #9f1239;
}

.sparkline {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
}

.spark-bar {
  width: 3px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.75;
}

.chat-customer-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-customer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #c7deee;
  object-fit: cover;
  background: #e9f2fb;
}

.avatar-button {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.customer-mini {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 8px 10px;
  width: fit-content;
  min-width: 220px;
  box-shadow: var(--shadow-sm);
}

.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.presence-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.presence-chip.dot-online {
  border-color: #bdecc7;
  background: #effdf3;
  color: #13663d;
}

.presence-chip.dot-online::before {
  background: #16a34a;
}

.presence-chip.dot-recent {
  border-color: #f9d6a1;
  background: #fff8eb;
  color: #8d5f0b;
}

.presence-chip.dot-recent::before {
  background: #f59e0b;
}

.presence-chip.dot-offline {
  border-color: #d5dee8;
  background: #f4f7fb;
  color: #607485;
}

.presence-chip.dot-offline::before {
  background: #94a3b8;
}

.chat-summary {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 10px;
  background: var(--card);
}

.chat-summary summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.chat-summary-body {
  margin-top: 8px;
}

.chat-search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-search input {
  margin: 0;
}

.chat-search button {
  white-space: nowrap;
}

.chat-stream {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
  background:
    linear-gradient(180deg, var(--card), var(--card-soft)),
    radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.09), rgba(255, 255, 255, 0) 48%);
}

.chat-virtual-viewport {
  display: block;
}

.chat-row {
  display: flex;
}

.chat-row.mine {
  justify-content: flex-end;
}

.chat-row.theirs {
  justify-content: flex-start;
}

.chat-message {
  max-width: min(82%, 720px);
  border: 1px solid #cce2f2;
  border-radius: 18px 18px 18px 8px;
  padding: 8px 11px;
  background: linear-gradient(180deg, #eff8ff, #e9f5ff);
  box-shadow: 0 3px 12px rgba(23, 72, 114, 0.08);
}

.chat-message.mine {
  border-color: #bfe7d8;
  border-radius: 18px 18px 8px 18px;
  background: linear-gradient(180deg, #effff8, #e8fff4);
  box-shadow: 0 3px 12px rgba(17, 84, 61, 0.09);
}

.chat-message.internal-comment {
  border-style: dashed;
  background: linear-gradient(180deg, #fff8e8, #fff4da);
  border-color: #f5cf88;
}

.internal-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 7px;
  border: 1px solid #f2cb82;
  background: #fff3d7;
  color: #875600;
  font-size: 10px;
  font-weight: 700;
}

.chat-meta-top {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 5px;
  font-size: 11px;
  color: #4f6578;
}

.chat-meta-bottom {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  font-size: 11px;
  color: #648095;
}

.sender-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #b7deef;
  background: #eaf8ff;
  color: #20507c;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-media {
  display: block;
  margin-top: 6px;
  max-width: 100%;
  max-height: 340px;
  border-radius: 12px;
  border: 1px solid #c9deee;
  background: #eef6ff;
}

.chat-audio {
  display: block;
  margin-top: 6px;
  width: min(320px, 100%);
}

.chat-file {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #b8d7ec;
  background: #eaf6ff;
  text-decoration: none;
  color: #0b5c99;
}

.chat-media-toolbar {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-media-toolbar .btn-link,
.chat-media-toolbar button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  color: var(--ink);
  text-decoration: none;
}

.chat-media-missing {
  margin-top: 6px;
  font-size: 12px;
  color: #6a8193;
}

.chat-compose {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--card);
  box-shadow: 0 -8px 20px rgba(20, 50, 78, 0.06);
}

#reply-text {
  min-height: 52px;
  height: 52px;
  max-height: 220px;
  resize: none;
  line-height: 1.35;
}

.event-item {
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  margin-top: 6px;
  font-size: 12px;
}

.event-item.incoming { border-color: #8bc5f0; }
.event-item.queue { border-color: #f2c97f; }
.event-item.sla { border-color: #f3a0b3; }
.event-item.delivery-ok { border-color: #7ed3a3; }
.event-item.delivery-error { border-color: #f0a2a2; }

.events-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.events-clear-btn {
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.skeleton {
  border-radius: 12px;
  height: 64px;
  background: linear-gradient(90deg, rgba(180, 199, 214, 0.2), rgba(220, 233, 244, 0.55), rgba(180, 199, 214, 0.2));
  background-size: 200% 100%;
  animation: skeleton 1.2s linear infinite;
}
.skeleton.s1 { height: 92px; }
.skeleton.s2 { height: 56px; }
.skeleton.s3 { height: 280px; }
.skeleton.s4 { height: 120px; }

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background: rgba(6, 14, 22, 0.78);
}

.media-lightbox-inner {
  position: relative;
  width: min(94vw, 1100px);
  max-height: 92vh;
}

.media-lightbox-close {
  position: absolute;
  top: -12px;
  right: -8px;
  z-index: 2;
  border-radius: 999px;
  width: 34px;
  height: 34px;
}

.lightbox-media {
  width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
}

.composer-tools {
  margin-bottom: 10px;
  border: 1px dashed #b9d2e6;
  border-radius: 12px;
  padding: 8px 10px;
  background: #fafdff;
}

.composer-tools summary {
  cursor: pointer;
  font-weight: 600;
  color: #35556f;
  list-style: none;
}

.composer-tools summary::-webkit-details-marker {
  display: none;
}

.templates-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 8px;
  background: var(--card-soft);
}

.templates-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.templates-row select {
  margin: 0;
  flex: 1;
}

.chat-compose-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.chat-compose-row {
  display: flex;
  gap: 8px;
}

.attach-panel {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.reply-file-input {
  margin-top: 6px;
}

.tools-media-panel,
.tools-transfer-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: var(--card-soft);
}

.sla-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.sla-ticket {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--card);
}

.settings-card {
  display: grid;
  gap: 8px;
}

.settings-theme-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.score-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
}

.score-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e3ecf4;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  border-radius: 999px;
}

.score-fill.load { background: linear-gradient(90deg, #16a34a, #22c55e); }
.score-fill.speed { background: linear-gradient(90deg, #0284c7, #0ea5e9); }
.score-fill.quality { background: linear-gradient(90deg, #d97706, #f59e0b); }

html[data-theme="dark"] .app-header {
  border-bottom-color: rgba(40, 57, 74, 0.92);
  background: rgba(10, 16, 24, 0.92);
}

html[data-theme="dark"] .avatar {
  border-color: #1f3142;
  background: #1a2a39;
}

html[data-theme="dark"] .menu-toggle span {
  background: #dbe7f4;
}

html[data-theme="dark"] .panel {
  border-color: #2a3d4f;
}

html[data-theme="dark"] a {
  color: #7ec3ff;
}

html[data-theme="dark"] .chat-message {
  border-color: #315679;
  background: linear-gradient(180deg, #17324a, #13283b);
}

html[data-theme="dark"] .chat-message.mine {
  border-color: #286455;
  background: linear-gradient(180deg, #113a31, #0f2f29);
}

html[data-theme="dark"] .chat-meta-top,
html[data-theme="dark"] .chat-meta-bottom,
html[data-theme="dark"] .chat-media-missing {
  color: #a5bdd1;
}

html[data-theme="dark"] .sender-pill {
  border-color: #3f6687;
  background: #183650;
  color: #c3def7;
}

html[data-theme="dark"] .chat-file {
  border-color: #3a607e;
  background: #163249;
  color: #b5dcff;
}

html[data-theme="dark"] .ticket-closed-banner {
  border-color: #2f8667;
  background: #153c32;
  color: #caf3de;
}

html[data-theme="dark"] .ticket {
  border-color: #36516a;
  background: linear-gradient(180deg, #162433, #13202e);
}

html[data-theme="dark"] .ticket:hover {
  border-color: #5d87ac;
}

html[data-theme="dark"] .ticket.active {
  border-color: #5fb9ff;
  box-shadow: 0 0 0 3px rgba(95, 185, 255, 0.35);
  background: linear-gradient(180deg, #1b2f43, #173044);
}

html[data-theme="dark"] .ticket .small.muted {
  color: #d4e2ef;
}

html[data-theme="dark"] .customer-mini {
  background: #162230;
  border-color: #34495f;
}

html[data-theme="dark"] .presence-chip.dot-offline {
  border-color: #42576a;
  background: #1b2936;
  color: #b5c9db;
}

html[data-theme="dark"] .score-track {
  background: #273748;
}

html[data-ui-mode="compact"] .shell {
  grid-template-columns: 300px 1fr 330px;
}

html[data-ui-mode="compact"] .panel {
  border-radius: 16px;
  padding: 10px;
}

html[data-ui-mode="compact"] .ticket,
html[data-ui-mode="compact"] .card {
  border-radius: 10px;
  padding: 8px;
}

html[data-ui-mode="compact"] .chat-message {
  max-width: min(88%, 680px);
}

html[data-ui-mode="focus"] #left-panel,
html[data-ui-mode="focus"] #right-panel {
  display: none;
}

html[data-ui-mode="focus"] .shell {
  grid-template-columns: 1fr;
}

html[data-theme="dark"] .ticket .channel-chip {
  border-color: #4b7ea8;
  background: #1a3a56;
  color: #cde9ff;
}

html[data-theme="dark"] .ticket .status-chip.open {
  border-color: #4f8dbc;
  background: #16334a;
  color: #c6e6ff;
}

html[data-theme="dark"] .ticket .status-chip.active {
  border-color: #f2bf72;
  background: #4a3412;
  color: #ffedcf;
}

html[data-theme="dark"] .ticket .status-chip.waiting_user {
  border-color: #7aa2c5;
  background: #173752;
  color: #e1f1ff;
}

html[data-theme="dark"] .ticket .status-chip.closed {
  border-color: #66bf91;
  background: #143f2d;
  color: #dcfbe8;
}

html[data-theme="dark"] .chat-message.internal-comment {
  background: linear-gradient(180deg, #4a3a18, #3f3215);
  border-color: #e2bc75;
}

html[data-theme="dark"] .internal-pill {
  background: #5a451c;
  border-color: #e0b96f;
  color: #ffebc8;
}

html[data-theme="dark"] .chat-media-toolbar .btn-link,
html[data-theme="dark"] .chat-media-toolbar button {
  background: #1a2b3b;
  border-color: #3d556a;
  color: #d5e8fa;
}

@media (max-width: 1360px) {
  .shell {
    grid-template-columns: 320px 1fr;
  }

  #right-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) {
  .app-header {
    position: static;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  nav {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(155, 182, 204, 0.5);
  }

  nav.open {
    display: flex;
  }

  nav a,
  nav form,
  nav button,
  #live-indicator {
    width: 100%;
  }

  nav a,
  nav button {
    display: block;
    text-align: left;
  }

  .shell {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 10px;
  }

  .panel {
    border-radius: 16px;
    padding: 8px;
    max-height: none;
    overflow: visible;
  }

  .card,
  .ticket,
  .staff-card {
    border-radius: 12px;
    padding: 9px;
    margin-bottom: 8px;
  }

  #center-panel {
    order: 1;
  }

  #left-panel {
    order: 2;
  }

  #right-panel {
    order: 3;
  }

  .chat-wrap {
    min-height: calc(100vh - 92px);
    height: auto;
    max-height: none;
    grid-template-rows: auto auto auto minmax(220px, 1fr) auto;
  }

  .queue-filters-card {
    max-width: 100%;
    border-radius: 12px;
    padding: 8px;
  }

  .queue-filters-head {
    margin-bottom: 0;
  }

  .filters-body {
    margin-top: 8px;
    max-height: min(48vh, 320px);
    overflow: auto;
    padding-right: 2px;
  }

  .chat-head {
    flex-direction: column;
  }

  .actions button,
  .chat-compose-actions button,
  .chat-compose-row button,
  .chat-search button,
  .tabs button,
  .toolbar button {
    flex: 1 1 calc(50% - 8px);
  }

  .grid2 > * {
    flex: 1 1 100%;
  }

  .chat-stream {
    min-height: 60vh;
    max-height: 68vh;
    padding: 10px 8px;
  }

  .chat-compose {
    position: sticky;
    bottom: 0;
    z-index: 10;
    border-radius: 14px;
    padding: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    backdrop-filter: blur(8px);
  }

  .chat-message {
    max-width: 100%;
    padding: 8px 9px;
  }

  .chat-media {
    max-height: 240px;
  }

  .chat-audio {
    width: 100%;
  }

  .chat-summary {
    font-size: 13px;
    padding: 8px 10px;
  }

  .chat-search {
    gap: 6px;
  }

  .chat-search input {
    font-size: 15px;
  }

  .templates-row {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-tools {
    margin-bottom: 8px;
    padding: 6px 8px;
  }

  .chat-compose-actions,
  .chat-compose-row {
    gap: 6px;
  }

  .dropzone {
    padding: 12px;
    font-size: 13px;
  }

  textarea,
  input,
  select {
    font-size: 16px;
  }

  .sla-grid {
    grid-template-columns: 1fr;
  }

  body.mobile-show-list #center-panel,
  body.mobile-show-list #right-panel {
    display: none;
  }

  body.mobile-show-side #left-panel,
  body.mobile-show-side #center-panel {
    display: none;
  }

  body:not(.mobile-show-list):not(.mobile-show-side) #left-panel,
  body:not(.mobile-show-list):not(.mobile-show-side) #right-panel {
    display: none;
  }

  .chat-compose-actions button,
  .chat-compose-row button {
    min-height: 44px;
  }
}
