:root {
  --bg: #0a0f1a;
  --bg-gradient: linear-gradient(135deg, #0a0f1a 0%, #0d1626 25%, #0b1422 50%, #0d1626 75%, #0a0f1a 100%);
  --felt: #0c1524;
  --panel: rgba(13, 22, 40, 0.95);
  --panel-strong: rgba(13, 22, 40, 0.98);
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.1);
  --gold: #d4af37;
  --gold-light: #f4d03f;
  --gold-dark: #997d1f;
  --green: #10b981;
  --green-light: #34d399;
  --red: #ef4444;
  --red-light: #f87171;
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --violet: #8b5cf6;
  --violet-light: #a78bfa;
  --emerald: #059669;
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --text-subtle: #94a3b8;
  --shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 8px 16px -4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 32px 64px -16px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-gradient),
    radial-gradient(ellipse at 15% 15%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
} 
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

button, .primary-link {
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.95), rgba(153, 125, 31, 0.9));
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #0a0f1a;
  cursor: pointer;
  font-weight: 600;
  min-height: 48px;
  padding: 14px 28px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: relative;
  overflow: hidden;
}

button:hover, .primary-link:hover {
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(212, 175, 55, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  border-color: rgba(212, 175, 55, 0.4);
  background: linear-gradient(135deg, rgba(244, 208, 63, 1), rgba(212, 175, 55, 0.95));
}

button:active, .primary-link:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button.btn-danger {
  background: linear-gradient(135deg, var(--red) 0%, #dc2626 100%);
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: var(--shadow-sm), 0 0 20px rgba(239, 68, 68, 0.3);
  color: white;
}

button.btn-danger:hover {
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
  border-color: rgba(239, 68, 68, 0.6);
}

button.btn-success {
  background: linear-gradient(135deg, var(--green) 0%, #16a34a 100%);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: var(--shadow-sm), 0 0 20px rgba(34, 197, 94, 0.3);
  color: white;
}

button.btn-success:hover {
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.5);
  border-color: rgba(16, 185, 129, 0.6);
}

button.btn-secondary {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  border-color: rgba(107, 114, 128, 0.4);
  box-shadow: var(--shadow-sm);
  color: white;
}

button.btn-secondary:hover {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  box-shadow: var(--shadow);
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.5), rgba(10, 14, 23, 0.7));
  color: var(--text);
  outline: none;
  padding: 14px 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 14px;
  backdrop-filter: blur(8px);
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(59, 130, 246, 0.4);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.6), rgba(10, 14, 23, 0.8));
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.08),
    inset 0 0 12px rgba(59, 130, 246, 0.06);
}

input::placeholder, textarea::placeholder {
  color: rgba(203, 213, 225, 0.7);
  font-weight: 400;
  letter-spacing: 0.01em;
}

textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
select option { background: #1a1a2e; color: var(--text); }

label {
  color: var(--text-muted);
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.login-panel, .panel, .stat-card, .sidebar, .mobile-topbar {
  backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(18, 24, 38, 0.95), rgba(11, 15, 26, 0.9));
  box-shadow: var(--shadow), 0 0 20px rgba(59, 130, 246, 0.1);
}

.login-panel {
  border-radius: 16px;
  max-width: 440px;
  padding: 40px;
  width: 100%;
}

.brand {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  transition: all 0.3s ease;
}

.brand:hover {
  transform: scale(1.02);
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, #ffd700, #ffed4a);
  border-radius: 12px;
  color: #0a0e17;
  display: flex;
  font-size: 24px;
  font-weight: 900;
  height: 52px;
  justify-content: center;
  width: 52px;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
}

.brand-logo {
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.brand-logo-desktop {
  height: 42px;
  width: 42px;
}

.brand-logo-mobile {
  height: 36px;
  width: 36px;
}

.brand strong {
  color: #ffd700;
  display: block;
  font-size: 20px;
  font-weight: 800;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  letter-spacing: 1px;
}

.brand.compact {
  gap: 10px;
}

.brand.compact .brand-mark {
  height: 36px;
  width: 36px;
  font-size: 18px;
}

.brand.compact strong {
  font-size: 16px;
}

.brand.compact small {
  font-size: 11px;
}

.login-brand, .brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.login-brand small, .brand small {
  color: var(--text-muted);
  display: block;
  font-size: 12px;
}

.login-form, .broadcast-form, .stack-form {
  display: grid;
  gap: 14px;
}

.alert, .success {
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: 12px;
  color: #fecaca;
  margin: 12px 0;
  padding: 14px 16px;
  font-size: 14px;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.success {
  border-color: rgba(34, 197, 94, 0.5);
  color: #86efac;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.2);
}

.app-shell {
  display: grid;
  grid-template-columns: 274px 1fr;
  min-height: 100vh;
}

.mobile-topbar { display: none; }

.sidebar {
  border-bottom: 0;
  border-left: 0;
  border-top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  padding: 18px;
  position: sticky;
  top: 0;
  margin: 16px 0 16px 16px;
  border-radius: 20px;
  backdrop-filter: blur(24px) saturate(160%);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(10, 14, 23, 0.85) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  max-height: calc(100vh - 32px);
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a, .logout button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  min-height: 48px;
  padding: 13px 15px;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  position: relative;
  overflow: hidden;
  gap: 10px;
}

.nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, #ffd700, #ffed4a);
  border-radius: 0 3px 3px 0;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.nav a:hover {
  border-color: rgba(59, 130, 246, 0.2);
  color: var(--blue-light);
  background: rgba(59, 130, 246, 0.06);
  transform: translateX(3px);
  box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.04);
}

.nav a:hover::before {
  height: 60%;
}

.nav a.active {
  border-color: rgba(255, 215, 0, 0.3);
  color: #ffd700;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.04));
  box-shadow: 
    0 0 20px rgba(255, 215, 0, 0.2),
    inset 0 0 12px rgba(255, 215, 0, 0.08);
  font-weight: 600;
  transform: translateX(2px);
}

.nav a.active::before {
  height: 80%;
}

.nav a b {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
  border-radius: 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.nav a.active b {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.25), rgba(255, 215, 0, 0.15));
  color: #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.logout { margin-top: auto; }
.logout button {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
  background: transparent;
}

.logout button:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  transform: translateX(4px);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.main { padding: 32px 40px; position: relative; z-index: 1; }

.page-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0 0 8px 0;
  text-transform: uppercase;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, p { margin-top: 0; }
h1 { 
  font-size: 40px; 
  line-height: 1.1; 
  margin-bottom: 12px; 
  font-weight: 700; 
  letter-spacing: -0.02em;
  color: var(--text);
}
h2 { 
  font-size: 20px; 
  font-weight: 600; 
  letter-spacing: 0.01em;
  color: var(--text);
  margin-bottom: 16px;
}

.stat-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 40px;
}

.stat-card {
  border-radius: 20px;
  overflow: hidden;
  padding: 32px 24px;
  position: relative;
  background: linear-gradient(145deg, rgba(18, 26, 45, 0.7), rgba(10, 18, 32, 0.85));
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-card.hot { 
  border-color: rgba(34, 197, 94, 0.25);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(34, 197, 94, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.stat-card.hot:hover {
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(34, 197, 94, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.stat-card.danger { 
  border-color: rgba(239, 68, 68, 0.25);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(239, 68, 68, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.stat-card.danger:hover {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(239, 68, 68, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.stat-card span { 
  display: block; 
  color: var(--text-muted); 
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.status-strip span, .empty, .empty-row { color: var(--text-muted); }
.stat-card strong { 
  display: block; 
  font-size: 48px; 
  line-height: 1.05; 
  font-weight: 700; 
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card em { 
  color: var(--text-muted); 
  display: block; 
  font-style: normal; 
  margin-top: auto;
  font-size: 13px; 
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

.analytics-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1.4fr 1fr;
  margin-bottom: 40px;
}

.panel {
  border-radius: 20px;
  margin-bottom: 32px;
  padding: 32px;
  transition: all 0.3s ease;
  background: linear-gradient(145deg, rgba(18, 26, 45, 0.6), rgba(10, 18, 32, 0.75));
  backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.panel:hover {
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.status-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 1fr);
}

.status-strip div {
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.status-strip b { display: block; font-size: 24px; }

.meter {
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.meter span {
  background: linear-gradient(90deg, var(--blue), var(--violet));
  display: block;
  height: 100%;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.filter-bar, .form-row {
  align-items: end;
  display: flex;
  gap: 10px;
}

.live-region { position: relative; }

.loading-bar {
  animation: loading-slide 1s ease-in-out infinite;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  height: 2px;
  left: 0;
  position: absolute;
  right: 0;
  top: -8px;
}

@keyframes loading-slide {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(60%); }
}

.table-wrap { 
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, rgba(18, 26, 45, 0.5), rgba(10, 18, 32, 0.7));
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
table { 
  border-collapse: collapse; 
  min-width: 760px; 
  width: 100%; 
  table-layout: auto;
}
th, td { 
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); 
  padding: 18px 20px; 
  text-align: left;
  vertical-align: middle;
  display: table-cell;
}
th { 
  color: var(--text-muted); 
  font-size: 12px; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: 0.06em;
  background: rgba(18, 26, 45, 0.6);
  position: sticky;
  top: 0;
}
th:first-child { border-top-left-radius: 16px; }
th:last-child { border-top-right-radius: 16px; }
td a { 
  color: var(--blue-light); 
  font-weight: 500; 
  transition: color 0.2s ease;
  text-shadow: none;
}
td a:hover {
  color: #93c5fd;
}
tbody tr { 
  transition: background 0.15s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  display: table-row;
}
tbody tr:hover { 
  background: rgba(59, 130, 246, 0.06);
}
tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.01);
}
tbody tr:nth-child(even):hover {
  background: rgba(59, 130, 246, 0.05);
}

.type-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.status {
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 5px 12px;
}
.status.open { color: var(--green); }
.status.processing { color: var(--blue); }
.status.pending { color: var(--gold); }
.status.closed { color: var(--red); }

.ticket-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.ticket-grid-spaced { margin-top: 16px; }
.ticket-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 12px;
  padding: 18px;
  transition: all 0.3s ease;
}

.ticket-card:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line-str, 0 0 15px rgba(59, 130, 246, 0.2)ong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.ticket-card div { align-items: center; display: flex; justify-content: space-between; gap: 8px; }
.ticket-card small { color: var(--text-muted); }

.detail-layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 370px;
}

.chat {
  display: grid;
  gap: 12px;
  max-height: 560px;
  overflow: auto;
  padding: 8px 8px 8px 4px;
  scroll-behavior: smooth;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-panel .chat {
  flex: 1;
  overflow-y: auto;
  min-height: 300px;
  padding-top: 16px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(160deg, rgba(24, 22, 18, 0.82), rgba(8, 10, 8, 0.72));
  border-radius: 0 0 8px 8px;
  padding: 16px;
  margin: 0 -18px -18px -18px;
  z-index: 5;
}

.chat-panel .quick-replies {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  position: sticky;
  bottom: 80px;
  background: linear-gradient(160deg, rgba(24, 22, 18, 0.82), rgba(8, 10, 8, 0.72));
  padding: 12px 18px;
  margin: 0 -18px;
  z-index: 4;
}

.bubble {
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 16px;
  max-width: min(78%, 720px);
  padding: 16px;
  position: relative;
  transition: transform 0.2s ease;
}
.bubble.user { 
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}
.bubble.admin {
  background: linear-gradient(160deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
  border-color: rgba(34, 197, 94, 0.4);
  margin-left: auto;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.2);
}
.bubble-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.bubble-sender {
  color: var(--blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}
.bubble.admin .bubble-sender {
  color: var(--green);
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}
.bubble-time {
  color: var(--text-muted);
  font-size: 11px;
  opacity: 0.9;
}
.bubble small, .details dt, .media-item small, .media-link { color: var(--text-muted); }
.bubble p { margin-bottom: 0; overflow-wrap: anywhere; line-height: 1.6; }
.bubble-media {
  border-radius: 8px;
  display: block;
  margin: 8px 0;
  max-height: 300px;
  object-fit: contain;
  width: min(100%, 420px);
}
.bubble-file {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 8px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.3s ease;
}

.bubble-file:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
  border-color: var(--line-strong);
}

.live-pill {
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: 999px;
  color: var(--green-light);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.3);
}

.reply-box {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
}

.quick-replies {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
}

.quick-replies button, .action-grid button {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  color: var(--blue);
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.3s ease;
  text-transform: none;
  letter-spacing: 0;
}

.quick-replies button:hover, .action-grid button:hover {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

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

.action-grid form:last-child { grid-column: 1 / -1; }

.checkbox-line {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  text-transform: none;
}

.checkbox-line input {
  width: auto;
}

.side-stack { display: grid; gap: 16px; align-content: start; }
.details { display: grid; gap: 8px; grid-template-columns: 110px 1fr; }
.details dt { text-transform: uppercase; }
.details dd { margin: 0; overflow-wrap: anywhere; }

.media-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.035);
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  padding: 10px;
}
.media-preview img, .media-preview video {
  border-radius: 8px;
  display: block;
  max-height: 260px;
  object-fit: contain;
  width: 100%;
}

.media-item { display: grid; gap: 4px; }
.media-link { font-weight: 700; color: var(--blue-light); transition: color 0.3s ease; text-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
.media-link:hover { color: var(--blue-light); }

.inline-form { align-items: center; display: flex; gap: 8px; }

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

.content-grid textarea {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  min-height: 220px;
}

.content-actions {
  grid-column: 1 / -1;
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; padding-top: 74px; }
  .mobile-topbar {
    align-items: center;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    display: flex;
    height: 74px;
    justify-content: space-between;
    left: 0;
    padding: 14px 20px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 10;
  }
  .sidebar {
    bottom: 20px;
    height: auto;
    left: 20px;
    max-height: calc(100vh - 114px);
    max-width: 340px;
    position: fixed;
    top: 94px;
    transform: translateX(-105%);
    transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
    width: 85vw;
    z-index: 20;
    margin: 0;
    border-radius: 20px;
    padding: 18px;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .main { padding: 28px 24px; }
  .stat-grid, .analytics-grid, .status-strip, .detail-layout, .content-grid { grid-template-columns: 1fr; }
  .stat-grid { gap: 20px; margin-bottom: 32px; }
  .panel-head, .filter-bar, .form-row, .page-head { align-items: stretch; flex-direction: column; gap: 16px; }
  .bubble { max-width: 100%; }
  h1 { font-size: 32px; }
  .panel { padding: 24px; margin-bottom: 28px; }
}

@media (max-width: 768px) {
  .main { padding: 24px 20px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 32px; }
  .stat-card { padding: 24px 20px; min-height: 140px; }
  .stat-card strong { font-size: 36px; }
  h1 { font-size: 28px; }
  .analytics-grid { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
  .detail-layout { grid-template-columns: 1fr; gap: 24px; }
  .ticket-grid { grid-template-columns: 1fr; gap: 16px; }
  .table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
  .content-grid { grid-template-columns: 1fr; gap: 20px; }
  
  button, .primary-link {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 13px;
  }
  
  .page-head { flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 32px; }
  .page-head .status { align-self: flex-start; margin-top: 8px; }
  .panel { padding: 24px; margin-bottom: 28px; }
  .bubble { padding: 16px; }
  .bubble-media { max-height: 220px; }
  .details { grid-template-columns: 1fr; gap: 8px; }
  .details dt { font-size: 11px; }
  .action-grid { grid-template-columns: 1fr; gap: 12px; }
  .status-strip { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .sidebar { left: 16px; right: 16px; width: auto; max-width: none; bottom: 16px; top: 90px; }
}

@media (max-width: 480px) {
  .main { padding: 20px 16px; }
  .login-panel { padding: 24px 20px; }
  .stat-grid { grid-template-columns: 1fr; gap: 16px; margin-bottom: 28px; }
  .stat-card { padding: 24px 20px; min-height: 140px; }
  .stat-card strong { font-size: 40px; }
  h1 { font-size: 26px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
  .page-head .status { align-self: flex-start; margin-top: 8px; }
  .bubble { padding: 16px; }
  .bubble-media { max-height: 200px; }
  .details { grid-template-columns: 1fr; gap: 8px; }
  .details dt { font-size: 11px; }
  .action-grid { grid-template-columns: 1fr; gap: 12px; }
  .status-strip { grid-template-columns: 1fr; gap: 14px; }
  
  button, .primary-link {
    min-height: 44px;
    padding: 12px 18px;
    font-size: 13px;
    width: 100%;
  }
  
  .panel { padding: 20px 16px; margin-bottom: 24px; }
  .panel-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .chat { min-height: 280px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  th, td { padding: 16px 14px; }
  .sidebar { left: 12px; right: 12px; bottom: 12px; top: 86px; border-radius: 16px; padding: 16px; }
}

.media-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
}

.media-modal-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 80vh;
}

.media-modal-content img,
.media-modal-content video {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
}

.media-modal-close {
  position: absolute;
  top: 20px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s;
}

.media-modal-close:hover {
  color: var(--gold);
}

/* Production polish layer: shared layout, readability, realtime, and chat refinements. */
html {
  scrollbar-color: rgba(148, 163, 184, 0.35) rgba(15, 23, 42, 0.45);
}

.app-shell {
  width: 100%;
  max-width: 100vw;
}

.main {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.page-head,
.panel,
.stat-card,
.ticket-card,
.media-preview {
  min-width: 0;
}

.panel {
  border-radius: 18px;
  overflow: hidden;
}

.panel-head h2,
.panel h2 {
  margin-bottom: 0;
}

.page-subtitle,
.empty,
.empty-row,
.help-text,
.details dt,
.media-item small,
.bubble-time {
  color: #cbd5e1;
}

input,
select,
textarea {
  min-height: 46px;
  color: #f8fafc;
  caret-color: var(--gold-light);
}

textarea {
  min-width: 0;
  max-width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: rgba(203, 213, 225, 0.68);
}

button,
.primary-link {
  border-radius: 10px;
}

.nav a span,
.ticket-card p,
.details dd,
td,
th {
  overflow-wrap: anywhere;
}

.table-wrap {
  max-width: 100%;
}

table {
  color: #e5edf8;
}

th {
  color: #cbd5e1;
}

td {
  color: #e2e8f0;
}

tbody tr:hover {
  background: rgba(96, 165, 250, 0.08);
}

.badge-pulse,
.nav a b.badge-pulse {
  animation: badge-pulse 500ms ease-out;
}

@keyframes badge-pulse {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); box-shadow: 0 0 22px rgba(212, 175, 55, 0.45); }
  100% { transform: scale(1); }
}

.socket-offline .mobile-topbar::after,
.socket-reconnecting .mobile-topbar::after {
  border-radius: 999px;
  color: #0f172a;
  content: "Reconnecting";
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: auto;
  padding: 5px 9px;
  text-transform: none;
  background: #fbbf24;
}

.socket-offline .live-pill {
  border-color: rgba(251, 191, 36, 0.5);
  color: #fcd34d;
}

.is-fresh {
  animation: table-fresh 700ms ease-out;
}

@keyframes table-fresh {
  0% { box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.45), 0 0 28px rgba(52, 211, 153, 0.18); }
  100% { box-shadow: none; }
}

.detail-layout {
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 370px);
}

.chat-panel {
  min-height: min(760px, calc(100vh - 112px));
  padding: 0;
  overflow: hidden;
}

.chat-panel > .panel-head {
  margin: 0;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.52));
}

.chat {
  background:
    linear-gradient(180deg, rgba(10, 15, 26, 0.54), rgba(8, 13, 23, 0.78)),
    radial-gradient(circle at 20% 10%, rgba(59, 130, 246, 0.05), transparent 30%),
    radial-gradient(circle at 80% 90%, rgba(16, 185, 129, 0.04), transparent 30%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding: 22px 24px;
  scroll-behavior: smooth;
}

.chat .empty {
  align-self: center;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  margin: auto;
  padding: 10px 16px;
}

.bubble {
  border: 0;
  border-radius: 18px;
  color: #eef5ff;
  max-width: min(76%, 680px);
  padding: 10px 12px 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.bubble.user {
  align-self: flex-start;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.bubble.admin {
  align-self: flex-end;
  background: linear-gradient(145deg, rgba(20, 83, 75, 0.96), rgba(15, 118, 110, 0.88));
  border: 1px solid rgba(94, 234, 212, 0.18);
  margin-left: 0;
}

.bubble-header {
  gap: 12px;
  margin-bottom: 6px;
}

.bubble-sender {
  color: #93c5fd;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.bubble.admin .bubble-sender {
  color: #bff7e9;
}

.bubble p {
  color: #f8fafc;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
}

.bubble-media {
  border-radius: 12px;
  margin: 6px 0 8px;
  max-height: 320px;
  width: min(100%, 460px);
}

.bubble-file {
  color: #e2e8f0;
}

.quick-replies,
.quick-replies-bar {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin: 0;
  padding: 12px 24px;
  background: rgba(10, 18, 32, 0.78);
}

.quick-replies form {
  margin: 0;
}

.quick-replies button,
.quick-reply-chip {
  min-height: 36px;
  border-radius: 999px;
  color: #dbeafe;
  text-transform: none;
  letter-spacing: 0;
}

.reply-box {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin: 0;
  padding: 16px 24px 20px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(10, 15, 26, 0.98));
  z-index: 3;
}

.reply-box textarea {
  min-height: 48px;
  max-height: 150px;
  resize: vertical;
}

.reply-box button {
  align-self: end;
  min-width: 128px;
  min-height: 48px;
  white-space: nowrap;
}

.side-stack {
  min-width: 0;
}

.side-stack .panel {
  padding: 24px;
}

.details {
  grid-template-columns: minmax(88px, 0.36fr) minmax(0, 1fr);
}

.details dd {
  color: #e5edf8;
}

.ticket-card {
  border-radius: 14px;
}

.ticket-card p {
  color: #dbe5f3;
  margin-bottom: 0;
}

.ticket-card small {
  color: #cbd5e1;
}

@media (max-width: 1200px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat {
    max-height: 62vh;
  }
}

@media (max-width: 768px) {
  .main {
    overflow-x: hidden;
  }

  .chat-panel > .panel-head,
  .chat,
  .quick-replies,
  .quick-replies-bar,
  .reply-box {
    padding-left: 16px;
    padding-right: 16px;
  }

  .chat {
    min-height: 360px;
    max-height: 58vh;
  }

  .bubble {
    max-width: 92%;
  }

  .reply-box {
    grid-template-columns: 1fr;
  }

  .reply-box button {
    width: 100%;
  }
}

.lightbox-open {
  overflow: hidden;
}

.media-lightbox {
  align-items: center;
  background: rgba(3, 7, 18, 0.92);
  backdrop-filter: blur(14px);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 80px 28px 28px;
  position: fixed;
  z-index: 2000;
}

.media-lightbox.open {
  display: flex;
}

.media-lightbox-stage {
  align-items: center;
  display: flex;
  height: 100%;
  justify-content: center;
  overflow: auto;
  width: 100%;
}

.media-lightbox img {
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
  display: block;
  max-height: 88%;
  max-width: 94%;
  object-fit: contain;
  transition: transform 160ms ease, max-width 160ms ease, max-height 160ms ease;
}

.media-lightbox.zoomed img {
  max-height: none;
  max-width: none;
  transform: scale(1.35);
}

.media-lightbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  left: 16px;
  position: absolute;
  right: 16px;
  top: 18px;
  z-index: 1;
}

.media-lightbox-toolbar button,
.media-lightbox-toolbar a {
  align-items: center;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(226, 232, 240, 0.18);
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  color: #f8fafc;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  letter-spacing: 0;
  min-height: 38px;
  padding: 9px 14px;
  text-transform: none;
  text-decoration: none;
  transition: all 0.2s ease;
}

.media-lightbox-toolbar button:hover,
.media-lightbox-toolbar a:hover {
  background: rgba(30, 41, 59, 0.95);
  transform: translateY(-1px);
  color: #f8fafc;
}
