:root {
  --bg: #eef4f8;
  --bg-soft: #e8f0f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #14202e;
  --ink-strong: #081420;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #dbe4ee;
  --line-strong: #c7d3e1;
  --brand: #0f766e;
  --brand-2: #0d9488;
  --brand-dark: #0b3b42;
  --nav: #071923;
  --nav-2: #0b2a33;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warn: #b54708;
  --warn-soft: #fff4d6;
  --ok: #087443;
  --ok-soft: #dcfae6;
  --blue: #175cd3;
  --blue-soft: #e8f1ff;
  --shadow-sm: 0 1px 2px rgba(8, 20, 32, 0.06), 0 12px 24px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 16px 38px rgba(15, 23, 42, 0.11);
  --shadow-lg: 0 28px 90px rgba(8, 20, 32, 0.18);
  --glow-teal: 0 18px 42px rgba(13, 148, 136, 0.22);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% -10%, rgba(45, 212, 191, 0.20), transparent 28rem),
    radial-gradient(circle at 88% 0%, rgba(23, 92, 211, 0.13), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }

.telegram-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(13, 148, 136, 0.55);
  transition: color 0.16s ease, border-color 0.16s ease;
}

.telegram-link:hover,
.telegram-link:focus-visible {
  color: var(--brand);
  border-bottom-color: currentColor;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4);
}

.layout {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.main {
  min-width: 0;
  padding: 30px;
}

.main > h2,
.main .row.space > h2 {
  color: var(--ink-strong);
  font-size: 24px;
  font-weight: 750;
  letter-spacing: 0;
}

.main > p,
.main .row.space + p {
  margin-top: var(--space-2);
  margin-bottom: var(--space-5);
  color: var(--muted);
}

.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(209, 222, 235, 0.9);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.card + .card,
.list + .card {
  margin-top: var(--space-3);
}

.row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.row.wrap { flex-wrap: wrap; }
.space { justify-content: space-between; }

input,
select,
button,
textarea {
  width: auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

input,
select,
textarea {
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.nav-link:focus-visible,
.conv-item:focus-visible {
  outline: none;
  border-color: rgba(13, 148, 136, 0.65);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.16);
}

button {
  border: 0;
  background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--glow-teal);
}

button:hover {
  background: linear-gradient(180deg, #14a99d, #0f766e);
  transform: translateY(-1px);
}

button:active { transform: translateY(0); }

button:disabled,
button.is-disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.76;
  transform: none;
}

button.secondary {
  background: #223447;
  box-shadow: 0 10px 20px rgba(34, 52, 71, 0.14);
}

button.secondary:hover { background: #172535; }

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

button.ghost:hover {
  background: var(--panel-soft);
  border-color: #afbdca;
}

textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

label input,
label select {
  width: 100%;
  margin-top: var(--space-1);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 14px 16px 20px;
  background:
    radial-gradient(circle at 24px 40px, rgba(45, 212, 191, 0.22), transparent 9rem),
    radial-gradient(circle at 100% 18%, rgba(56, 189, 248, 0.16), transparent 11rem),
    linear-gradient(180deg, #061823 0%, #092636 48%, #061923 100%);
  color: #e6edf3;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08), 22px 0 60px rgba(2, 8, 23, 0.08);
}

.sidebar h2 {
  order: 0;
  margin: 0 0 14px;
  padding: 2px 8px 16px;
  border-bottom: 1px solid rgba(230, 237, 243, 0.12);
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar h2::after {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2dd4bf, #38bdf8);
}

.sidebar-brand {
  order: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 12px;
  padding: 0 0 14px;
  border-bottom: 1px solid rgba(230, 237, 243, 0.12);
}

.topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.sidebar-logo {
  display: block;
  max-width: 260px;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.topbar-logo .sidebar-logo {
  max-width: 64px;
  width: clamp(44px, 13vw, 64px);
}

.nav-link {
  order: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 42px;
  margin-bottom: var(--space-2);
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #d9e6ee;
  text-decoration: none;
  font-weight: 650;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.22), rgba(56, 189, 248, 0.10));
  border-color: rgba(94, 234, 212, 0.30);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #2dd4bf, 0 12px 26px rgba(0, 0, 0, 0.13);
}

.sidebar [data-operator-name] {
  order: 4;
  margin: var(--space-4) 0 0;
  padding: var(--space-3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1 !important;
}

.lang-switcher {
  max-width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.sidebar .lang-switcher {
  order: 1;
  width: 100%;
  margin: 0 0 var(--space-4);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.94);
}

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px var(--space-4);
  background: rgba(7, 25, 35, 0.98);
  color: #e6edf3;
  box-shadow: 0 10px 30px rgba(8, 20, 32, 0.22);
}

.topbar-title {
  font-weight: 800;
  letter-spacing: 0;
}

.menu-btn {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(230, 237, 243, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(20, 184, 166, 0.14);
  color: #e6edf3;
  box-shadow: none;
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 62px;
  left: 10px;
  right: 10px;
  z-index: 35;
  padding: var(--space-3);
  border: 1px solid rgba(230, 237, 243, 0.14);
  border-radius: var(--radius);
  background: rgba(7, 25, 35, 0.98);
  box-shadow: var(--shadow-lg);
}

.mobile-menu.open {
  display: flex;
  flex-direction: column;
}
.mobile-menu .nav-link { margin-bottom: var(--space-2); }
.mobile-menu .lang-switcher {
  order: 0;
  width: 100%;
  margin-bottom: var(--space-3);
}
.mobile-menu .nav-link { order: 1; }

.mobile-menu .operator-line {
  order: 3;
  padding: var(--space-3) var(--space-2) var(--space-1);
  color: #cbd5e1;
  font-size: 13px;
}

.dashboard-summary {
  order: 5;
  margin-top: 14px;
}

.page-summary {
  margin: 0 0 18px;
}

.summary-title {
  margin-bottom: 10px;
  color: #d7f7f1;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-summary .summary-title {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

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

.summary-chip {
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  color: #dbeafe;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.page-summary .summary-chip {
  border-color: rgba(203, 213, 225, 0.72);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  color: var(--ink);
}

.summary-chip span {
  display: block;
  color: inherit;
  opacity: 0.74;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.summary-chip strong {
  display: block;
  margin-top: 4px;
  color: #ffffff;
  font-size: 23px;
  line-height: 1;
}

.page-summary .summary-chip strong {
  color: var(--ink-strong);
}

.summary-chip.emerald { background: linear-gradient(135deg, rgba(16, 185, 129, 0.20), rgba(13, 148, 136, 0.11)); }
.summary-chip.cyan { background: linear-gradient(135deg, rgba(34, 211, 238, 0.20), rgba(14, 116, 144, 0.10)); }
.summary-chip.blue { background: linear-gradient(135deg, rgba(59, 130, 246, 0.20), rgba(29, 78, 216, 0.10)); }
.summary-chip.amber { background: linear-gradient(135deg, rgba(245, 158, 11, 0.26), rgba(180, 83, 9, 0.10)); }

.list {
  display: grid;
  gap: var(--space-3);
}

.conv-item {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  overflow: hidden;
}

.conv-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, #14b8a6, #38bdf8);
  opacity: 0.88;
}

.conv-item:hover {
  border-color: rgba(13, 148, 136, 0.35);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.conv-item:has(.badge.needs_review) {
  border-color: rgba(245, 158, 11, 0.45);
  background:
    linear-gradient(90deg, rgba(255, 247, 237, 0.88), rgba(255, 255, 255, 0.96) 44%),
    #ffffff;
}

.conv-item .meta {
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.badge.needs_review {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #fedf89;
}

.badge.active {
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #a6f4c5;
}

.badge.operator_joined,
.badge.answered {
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid #bfd7ff;
}

.badge.closed {
  background: #eef2f6;
  color: #475467;
  border: 1px solid #d0d5dd;
}
.badge.sla-on_track,
.badge.sla-responded { background: var(--ok-soft); color: var(--ok); border: 1px solid #a6f4c5; }
.badge.sla-none { background: #eef2f6; color: #475467; border: 1px solid #d0d5dd; }
.badge.sla-warning { background: var(--warn-soft); color: var(--warn); border: 1px solid #fedf89; }
.badge.sla-overdue { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdca; }

.toolbar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin: 10px 0 14px; }
.filter-pills { display:flex; flex-wrap:wrap; gap:8px; }
.filter-pill {
  padding: 8px 12px; border:1px solid var(--line-strong); border-radius:999px; background:#fff; color:var(--ink); cursor:pointer; font-weight:700;
}
.filter-pill.active { border-color: rgba(13,148,136,.4); color: var(--brand); background: rgba(20,184,166,.08); }
.search-group { display:flex; gap:8px; flex-wrap:wrap; }
.search-group input { min-width: 220px; }

.workload-grid { display:grid; gap:10px; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); margin-bottom: 12px; }
.workload-item { border:1px solid var(--line); border-radius:12px; padding:10px; background:#fff; }
.load-badge.green { color: var(--ok); }
.load-badge.amber { color: var(--warn); }
.load-badge.red { color: var(--danger); }
.history-block { margin-top:10px; }

.notif-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 20px;
  margin-left: var(--space-2);
  padding: 2px 7px;
  border-radius: 999px;
  background: #f04438;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.13);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 20px;
  margin-left: var(--space-2);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.nav-badge-neutral {
  background: #e2e8f0;
  color: #334155;
  box-shadow: 0 0 0 2px rgba(226, 232, 240, 0.35);
}

.nav-badge-success {
  background: #12b76a;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(18, 183, 106, 0.24);
}

.nav-badge-danger {
  background: #f04438;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(240, 68, 56, 0.22);
}

.needs-review-pulse {
  animation: needsPulse 1.15s ease-in-out 2;
}

@keyframes needsPulse {
  0%, 100% { box-shadow: none; }
  45% { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.24), 0 0 28px rgba(245, 158, 11, 0.35); }
}

#timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 320px;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.08), transparent 18rem),
    linear-gradient(180deg, #ffffff, #f8fafc);
}

.msg {
  width: fit-content;
  max-width: 78%;
  margin-bottom: 0;
  padding: 12px 14px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.msg strong {
  display: inline-block;
  margin-bottom: 3px;
  color: var(--ink-strong);
  font-size: 12px;
  letter-spacing: 0;
}

.msg.user {
  background: #f1f5f9;
  border: 1px solid #d9e0ea;
}

.msg.ai {
  background: linear-gradient(135deg, #e0f2fe, #e8f1ff);
  border: 1px solid #c7dbff;
}

.msg.operator {
  margin-left: auto;
  background: linear-gradient(135deg, #d1fae5, #ccfbf1);
  border: 1px solid #99f6e4;
}

.msg.system {
  max-width: 92%;
  margin-inline: auto;
  background: var(--warn-soft);
  border: 1px solid #fedf89;
  color: #7a2e0e;
  text-align: center;
  font-weight: 700;
}

.msg .small {
  margin-top: 5px;
  color: #667085;
  font-size: 12px;
}

.notice,
.success {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.notice { color: var(--danger); }
.success { color: var(--ok); }

.table-wrap {
  overflow: auto;
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f8fafc, #eef4f8);
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 24px));
}

.toast-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.22s ease-out;
}

.toast-card-strong {
  border-color: rgba(244, 63, 94, 0.45);
  box-shadow: 0 30px 90px rgba(180, 35, 24, 0.20), 0 0 0 4px rgba(244, 63, 94, 0.08);
}

.toast-card-strong .toast-icon {
  background: linear-gradient(135deg, #f43f5e, #f59e0b);
  animation: alertPulse 0.9s ease-in-out 3;
}

.toast-out {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(245, 158, 11, 0.24);
}

.toast-copy strong {
  color: var(--ink-strong);
  font-size: 15px;
}

.toast-copy p {
  margin: 3px 0 10px;
  color: var(--muted);
}

.toast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toast-actions a,
.toast-actions button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
  text-decoration: none;
}

.toast-actions a {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #0f766e, #0d9488);
  color: #ffffff;
  font-weight: 800;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes alertPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.sound-alert-control {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 82;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #223447, #0f766e);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

tr:hover td { background: #fbfdff; }

.reports-mobile { display: none; }

.filter-grid {
  align-items: end;
}

.filter-grid label {
  min-width: 160px;
}

.auth-card {
  width: 100%;
  max-width: min(470px, 100vw);
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.login-page {
  position: relative;
}

.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("/hakxd/public/logo/logo.png");
  background-position: center 36%;
  background-repeat: no-repeat;
  background-size: min(120vw, 1600px);
  opacity: 0.28;
}

.login-page .auth-card {
  position: relative;
  z-index: 1;
}

.auth-card .card {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-card h2 {
  min-width: 0;
  margin-bottom: 0;
  color: var(--ink-strong);
  font-size: 25px;
  overflow-wrap: anywhere;
}

.auth-card p {
  margin: 8px 0 var(--space-5);
}

.auth-card input,
.auth-card button {
  width: 100%;
}

.operator-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  width: 100%;
}

.settings-grid {
  display: grid;
  gap: 24px;
}

.settings-grid h3 {
  margin: 0 0 12px;
  color: var(--ink-strong);
}

.operator-form-grid label {
  display: grid;
  gap: 6px;
}

#convInfo .row.wrap {
  gap: var(--space-3) var(--space-5);
}

#convInfo strong {
  color: var(--ink-strong);
}

.conversation-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: 248px minmax(0, 1fr); }
  .main { padding: var(--space-5); }
  .operator-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-summary .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  body { background: var(--bg); }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; }
  .main {
    width: 100%;
    padding: var(--space-4);
  }
  .main > h2,
  .main .row.space > h2 { font-size: 21px; }
  .row.space {
    align-items: flex-start;
    gap: var(--space-3);
    flex-wrap: wrap;
  }
  .row.space > div { flex-wrap: wrap; }
  .card { padding: var(--space-4); }
  .mobile-menu {
    max-height: calc(100vh - 76px);
    overflow: auto;
  }
  .sidebar-logo {
    max-width: 220px;
  }
  .topbar-logo {
    min-width: 130px;
    display: flex;
    align-items: center;
  }
  .topbar-logo .sidebar-logo {
    max-width: 130px;
    max-height: 72px;
    width: auto;
    height: auto;
  }
  .login-page::before {
    background-size: 210vw;
    background-position: center 48%;
    opacity: 0.16;
  }
  .summary-grid,
  .page-summary .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .conv-item { width: 100%; }
  .msg {
    max-width: 100%;
    width: auto;
  }
  .msg.operator {
    margin-left: 0;
  }
  .toast-host {
    right: 12px;
    bottom: 12px;
  }
  .sound-alert-control {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }
  .table-wrap { display: none; }
  .reports-mobile {
    display: grid;
    gap: var(--space-3);
  }
  .filter-grid,
  .operator-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .filter-grid label,
  .filter-grid input,
  .filter-grid select,
  .filter-grid button,
  .operator-form-grid label,
  .operator-form-grid input,
  .operator-form-grid select {
    width: 100%;
  }
  .top-links { display: none; }
  .conversation-actions {
    width: 100%;
    justify-content: stretch;
  }
  .conversation-actions button {
    flex: 1 1 calc(50% - 8px);
    min-width: 132px;
  }
  #refreshBtn { flex-basis: 100%; }
  #convInfo .row.wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .auth-card {
    min-height: 100vh;
    max-width: 100%;
    padding: var(--space-4);
  }
  .auth-card .card {
    padding: var(--space-5);
  }
  .auth-card .row.space.wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }
  .auth-card .lang-switcher {
    max-width: 150px;
  }
  .search-group input,
  .search-group button { width: 100%; min-width: 0; }
}

@media (max-width: 430px) {
  body { font-size: 14px; }
  .topbar { padding: 10px 12px; }
  .topbar-title { font-size: 15px; }
  .topbar-logo {
    min-width: 130px;
    display: flex;
    align-items: center;
  }
  .topbar-logo .sidebar-logo {
    max-width: 130px;
    max-height: 72px;
    width: auto;
    height: auto;
  }
  .menu-btn {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 14px;
  }
  .mobile-menu {
    top: 56px;
    left: 8px;
    right: 8px;
  }
  .summary-grid,
  .page-summary .summary-grid {
    grid-template-columns: 1fr;
  }
  .main { padding: var(--space-3); }
  .main h2 { font-size: 20px; }
  .conversation-actions button { flex-basis: 100%; }
  .auth-card {
    padding: var(--space-3);
  }
  .login-page::before {
    background-size: 240vw;
    background-position: center 16%;
    opacity: 0.36;
  }
  .auth-card .card {
    padding: var(--space-4);
  }
  .auth-card .row.space.wrap {
    grid-template-columns: 1fr;
  }
  .auth-card .lang-switcher {
    width: 100%;
    max-width: none;
  }
  .card { border-radius: 10px; }
}

html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] th,
html[dir="rtl"] td { text-align: right; }
html[dir="rtl"] .msg.operator {
  margin-right: auto;
  margin-left: 0;
}
html[dir="rtl"] .notif-dot {
  margin-right: var(--space-2);
  margin-left: 0;
}
html[dir="rtl"] .nav-badge {
  margin-right: var(--space-2);
  margin-left: 0;
}
html[dir="rtl"] .nav-link.active {
  box-shadow: inset -3px 0 0 #2dd4bf;
}
html[dir="rtl"] .conversation-actions {
  justify-content: flex-start;
}

/* Final enterprise polish layer */

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-inline-end: 10px;
  border: 1px solid rgba(94, 234, 212, 0.34);
  border-radius: 12px;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.30), transparent 30%),
    linear-gradient(135deg, #14b8a6, #175cd3);
  color: #ffffff;
  font-size: 17px;
  font-weight: 950;
  box-shadow: 0 16px 35px rgba(20, 184, 166, 0.20);
}

.sidebar h2,
.topbar-title {
  display: flex;
  align-items: center;
}


.sidebar [data-dashboard-summary],
.mobile-menu [data-dashboard-summary] {
  display: none !important;
}

.page-summary {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.page-summary .summary-title {
  margin: 0 0 12px;
  color: var(--muted);
}

.page-summary .summary-grid {
  gap: 16px;
}

.page-summary .summary-chip {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  min-height: 126px;
  padding: 18px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.page-summary .summary-chip:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.summary-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: -0.03em;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.13);
}

.summary-chip.cyan .summary-icon { background: linear-gradient(135deg, #06b6d4, #2563eb); }
.summary-chip.emerald .summary-icon { background: linear-gradient(135deg, #10b981, #0f766e); }
.summary-chip.blue .summary-icon { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.summary-chip.amber .summary-icon { background: linear-gradient(135deg, #f59e0b, #f97316); }

.summary-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.summary-copy strong {
  margin-top: 6px;
  color: var(--ink-strong);
  font-size: 34px;
  letter-spacing: -0.04em;
}

.summary-copy small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

button.danger {
  background: linear-gradient(135deg, #f43f5e, #b42318);
  color: #ffffff;
  box-shadow: 0 18px 38px rgba(180, 35, 24, 0.18);
}

button.danger:hover {
  background: linear-gradient(135deg, #fb7185, #c81e1e);
}

.profile-panel {
  display: grid;
  gap: 18px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(135deg, #38bdf8, #0f766e);
  color: #ffffff;
  font-weight: 950;
}

.profile-hero span,
.profile-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-hero strong {
  display: block;
  margin-top: 3px;
  color: var(--ink-strong);
  font-size: 22px;
}

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

.profile-field {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel-soft);
}

.profile-field.highlight {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.10), rgba(56, 189, 248, 0.08));
  border-color: rgba(20, 184, 166, 0.24);
}

.profile-field strong {
  display: block;
  margin-top: 7px;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
}

.review-callout {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 15px;
  background: var(--warn-soft);
  color: var(--warn);
}

#timeline::before {
  content: attr(data-title);
  display: none;
}

.msg {
  display: flex;
  gap: 10px;
  padding: 0;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none;
}

.msg.operator {
  flex-direction: row-reverse;
}

.msg.system {
  display: block;
  text-align: center;
}

.msg-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 950;
}

.msg.ai .msg-avatar { background: #dbeafe; color: #175cd3; }
.msg.operator .msg-avatar { background: #ccfbf1; color: #0f766e; }
.msg.system .msg-avatar { display: none; }

.msg-body {
  max-width: min(680px, 100%);
  padding: 12px 14px;
  border: 1px solid #d9e0ea;
  border-radius: 16px;
  background: #f1f5f9;
  box-shadow: var(--shadow-sm);
}

.msg.ai .msg-body {
  background: linear-gradient(135deg, #e0f2fe, #e8f1ff);
  border-color: #c7dbff;
}

.msg.operator .msg-body {
  background: linear-gradient(135deg, #d1fae5, #ccfbf1);
  border-color: #99f6e4;
}

.msg.system .msg-body {
  display: inline-block;
  max-width: min(760px, 100%);
  background: var(--warn-soft);
  border-color: rgba(245, 158, 11, 0.30);
  color: var(--warn);
}

.msg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.msg-head span {
  color: var(--muted);
  font-size: 11px;
}

.msg-text {
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 28px;
  padding: 18px 4px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.auth-footer {
  margin-top: 20px;
  padding-top: 14px;
}

.operator-form-grid {
  padding: 4px 0;
}

#operatorsTableWrap table .badge,
.reports-mobile .badge {
  text-transform: capitalize;
}

.filter-grid {
  padding: 4px;
  border-radius: 18px;
}

.toast-card {
  border-color: rgba(20, 184, 166, 0.26);
}

.toast-icon {
  background: linear-gradient(135deg, #14b8a6, #f59e0b);
}

@media (max-width: 768px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .profile-hero {
    align-items: flex-start;
  }
  .page-summary .summary-chip {
    min-height: auto;
  }
  .msg,
  .msg.operator {
    flex-direction: row;
  }
  .msg-body {
    max-width: 100%;
  }
  .app-footer {
    display: grid;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 10px;
    font-size: 14px;
  }
  .page-summary .summary-chip {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 15px;
  }
  .summary-icon {
    width: 40px;
    height: 40px;
    border-radius: 13px;
  }
  .summary-copy strong {
    font-size: 28px;
  }
  .toast-card {
    grid-template-columns: 1fr;
  }
}
