:root {
  --bg: #08111f;
  --panel: rgba(10, 24, 39, 0.88);
  --panel-2: rgba(18, 38, 58, 0.92);
  --chat: #06111d;
  --line: rgba(148, 177, 204, 0.14);
  --text: #f3f7fb;
  --muted: #8ca1b5;
  --brand: #19c37d;
  --brand-2: #7df9c6;
  --me: linear-gradient(135deg, #19c37d 0%, #109d86 100%);
  --other: rgba(19, 37, 56, 0.96);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(27, 195, 125, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(84, 138, 255, 0.18), transparent 24%),
    linear-gradient(135deg, #07111d 0%, #0b1624 48%, #081421 100%);
  color: var(--text);
  position: relative;
  min-height: 100vh;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(20px);
  opacity: 0.55;
}

body::before {
  width: 320px;
  height: 320px;
  top: -80px;
  left: -110px;
  background: rgba(25, 195, 125, 0.18);
  border-radius: 40px;
  transform: rotate(18deg);
}

body::after {
  width: 420px;
  height: 420px;
  right: -160px;
  bottom: -130px;
  background: rgba(67, 116, 255, 0.16);
  border-radius: 50%;
}

main {
  min-height: 100vh;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  max-width: 420px;
  margin: 80px auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 28px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.login-form { margin-top: 12px; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label { font-size: 0.9rem; }
input, button, select { font: inherit; }
input {
  border: 1px solid var(--line);
  background: rgba(5, 16, 28, 0.72);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

select {
  border: 1px solid var(--line);
  background: rgba(5, 16, 28, 0.72);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  width: 100%;
}

input:focus {
  outline: none;
  border-color: rgba(125, 249, 198, 0.45);
  box-shadow: 0 0 0 4px rgba(25, 195, 125, 0.12);
  transform: translateY(-1px);
}

.btn {
  border: 0;
  background: linear-gradient(135deg, var(--brand) 0%, #109d86 100%);
  color: #041019;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(25, 195, 125, 0.2);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(25, 195, 125, 0.28);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: none;
}

.chat-layout {
  max-width: 1380px;
  margin: 0 auto;
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 380px 1fr;
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
  background: rgba(3, 10, 18, 0.55);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(18, 34, 51, 0.96) 0%, rgba(10, 21, 34, 0.98) 100%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-top {
  padding: 24px 22px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.sidebar-top strong,
.chat-header h2,
.admin-card h2,
.login-card h1 {
  letter-spacing: -0.04em;
  font-weight: 800;
}

.sidebar-top strong {
  font-size: 2rem;
  display: block;
  line-height: 0.95;
}

.badge {
  margin: 16px 18px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(25, 195, 125, 0.18), rgba(9, 84, 81, 0.26));
  border: 1px solid rgba(25, 195, 125, 0.35);
  border-radius: 18px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #d8fff1;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 8px 10px 18px;
  overflow-y: auto;
}

.chat-list li {
  margin: 8px;
  padding: 18px 18px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.chat-list li:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(2px);
}

.chat-list li.active {
  background: linear-gradient(135deg, rgba(35, 58, 84, 0.92), rgba(16, 32, 49, 0.96));
  border-color: rgba(125, 249, 198, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-list li strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.chat-panel {
  background:
    radial-gradient(circle at top, rgba(24, 65, 91, 0.16), transparent 28%),
    linear-gradient(180deg, rgba(7, 17, 29, 0.96) 0%, rgba(4, 12, 21, 0.98) 100%);
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  min-height: 0;
}

.chat-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 34, 51, 0.92), rgba(16, 29, 44, 0.88));
  backdrop-filter: blur(16px);
}

.chat-header h2 {
  margin: 0;
  font-size: 1.6rem;
}

.chat-box {
  padding: 16px 18px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.msg {
  max-width: min(280px, 58%);
  padding: 9px 10px 7px;
  border-radius: 16px;
  white-space: pre-wrap;
  line-height: 1.22;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.msg > :first-child {
  font-size: 0.88rem;
}

.msg .small {
  margin-top: 4px;
  font-size: 0.74rem;
  line-height: 1;
  text-align: right;
  opacity: 0.9;
}

.msg.agent {
  align-self: flex-end;
  background: var(--me);
  color: #03150f;
  border-bottom-right-radius: 8px;
}

.msg.agent .small {
  color: rgba(3, 21, 15, 0.72);
}

.msg.member {
  align-self: flex-start;
  background: var(--other);
  border-bottom-left-radius: 8px;
}

.msg.member .small {
  color: rgba(243, 247, 251, 0.7);
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  background: linear-gradient(180deg, rgba(12, 24, 37, 0.92), rgba(10, 21, 34, 0.98));
}

.admin-view {
  max-width: 1380px;
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.audit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audit-list li {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

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

.small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); margin-top: 10px; }
.hidden { display: none; }

@media (max-width: 940px) {
  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 80vh;
  }

  .chat-header h2 {
    font-size: 1.5rem;
  }

  .sidebar-top strong {
    font-size: 1.6rem;
  }

  .msg {
    max-width: 88%;
  }

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

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