:root {
  --bg-color: #0f172a;
  --bg-elevated: #020617;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --text-primary: #e5e7eb;
  --text-muted: #9ca3af;
  --border-subtle: #1f2937;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.5);
  --radius-large: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text',
    'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #1f2937, #020617 55%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 24px 24px 8px;
}

.app-header__inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-title {
  margin: 0 0 4px;
  font-size: clamp(1.75rem, 2.4vw, 2.3rem);
  letter-spacing: -0.03em;
}

.app-tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.app-header__user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.85rem;
}

.app-header__user-name {
  color: var(--text-muted);
}

.app-header__logout {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 20px;
  font-size: 1rem;
  background: #020617;
  color: var(--text-primary);
  cursor: pointer;
  width: 100%;
}

.app-header__logout:hover {
  background: #111827;
}

.app-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px 16px 32px;
}

.app-section {
  width: 100%;
  max-width: 1200px;
  min-height: 85vh;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--bg-elevated), #020617);
  border-radius: var(--radius-large);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 20px 20px 18px;
}

.app-description {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.6;
}

.app-section__hint {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: radial-gradient(circle at left, var(--accent-soft), transparent);
  border: 1px solid rgba(34, 197, 94, 0.35);
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: row;
  gap: 12px;
}

.app-section__hint p {
  margin: 0;
}

.app-footer {
  padding: 12px 24px 18px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .app-header {
    padding-inline: 18px;
  }

  .app-main {
    padding-inline: 12px;
  }

  .app-section {
    padding-inline: 16px;
  }

  .app-section__hint {
    flex-direction: column;
  }
}

.chat-layout {
  margin-top: 12px;
  display: flex;
  gap: 12px;
}

.chat-layout__header {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.chat-layout__sidebar {
  width: 32%;
  min-width: 220px;
}

.chat-layout__main {
  flex: 1;
}

.chat-contacts {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: #020617;
  max-height: 260px;
  overflow-y: auto;
}

.chat-contact {
  display: block;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.7);
  text-decoration: none;
  color: inherit;
}

.chat-contact:last-child {
  border-bottom: none;
}

.chat-contact__phone {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 2px;
}

.chat-contact__snippet {
  font-size: 0.78rem;
  color: #9ca3af;
}

.chat-contact--active {
  background: rgba(34, 197, 94, 0.08);
  border-left: 2px solid var(--accent);
}

.chat-contact--inactive {
  background: rgba(239, 68, 68, 0.12);
  border-left: 2px solid rgba(239, 68, 68, 0.9);
}

.chat-contact--unread .chat-contact__phone,
.chat-contact--unread .chat-contact__snippet {
  color: #ffffff !important;
}

.chat-contact--empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chat-layout__messages {
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: #020617;
  height: 70vh;
  overflow-y: auto;
  padding: 8px 6px;
}

/* Scrollbars in chat – blend with background */
.chat-layout__messages::-webkit-scrollbar,
.chat-contacts::-webkit-scrollbar {
  width: 8px;
}

.chat-layout__messages::-webkit-scrollbar-track,
.chat-contacts::-webkit-scrollbar-track {
  background: #020617;
}

.chat-layout__messages::-webkit-scrollbar-thumb,
.chat-contacts::-webkit-scrollbar-thumb {
  background: #020617;
  border-radius: 999px;
}

.chat-layout__messages {
  scrollbar-color: #020617 #020617; /* Firefox */
  scrollbar-width: thin;
}

.chat-row {
  display: flex;
  justify-content: flex-start;
  margin: 4px 0;
  font-size: 0.85rem;
}

.chat-row__left {
  max-width: 70%;
  padding: 6px 10px 8px;
  border-radius: 16px;
  background: #020617;
  border: 1px solid var(--border-subtle);
  word-break: break-word;
  position: relative;
}

.chat-row__top {
  font-size: 12px;
  color: #5f5f5f;
  margin-bottom: 6px;
}

.chat-row__body {
  font-size: 16px;
  color: #ffffff;
}

.chat-row__right {
  display: none; /* no second column in bubble layout */
}

.chat-row--incoming .chat-row__left {
  margin-left: 4px;
  border-radius: 16px 16px 16px 4px;
}

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

.chat-row--outgoing .chat-row__left {
  background: linear-gradient(135deg, var(--accent), #4ade80);
  color: #022c22;
  border-color: transparent;
  margin-right: 4px;
  border-radius: 16px 16px 4px 16px;
}


.chat-input-bar {
  margin-top: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input-bar__emoji {
  position: relative;
}

.chat-emoji-toggle {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #020617;
  color: #facc15;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.chat-emoji-picker {
  position: absolute;
  bottom: 44px;
  left: 0;
  max-width: 260px;
  z-index: 10;
}

.chat-input-bar__textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 14px;
  font-size: 0.9rem;
  background: #020617;
  color: var(--text-primary);
  outline: none;
}

.chat-input-bar__textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}

.chat-input-bar__send {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4ade80);
  color: #022c22;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-input-bar__send svg {
  width: 18px;
  height: 18px;
}

.chat-logout {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-menu-toggle {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: #020617;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.chat-menu-toggle:hover {
  background: #111827;
}

.chat-menu-toggle:active {
  transform: translateY(1px) scale(0.97);
}

.chat-menu-toggle__bar {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #e5e7eb;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.chat-menu-toggle__bar + .chat-menu-toggle__bar {
  margin-top: 4px;
}

.chat-menu-toggle--open .chat-menu-toggle__bar:nth-child(1) {
  transform: rotate(45deg);
  position: absolute;
  left: 30%;
}

.chat-menu-toggle--open .chat-menu-toggle__bar:nth-child(2) {
  opacity: 0;
}

.chat-menu-toggle--open .chat-menu-toggle__bar:nth-child(3) {
  transform: rotate(-45deg);
  position: absolute;
  left: 30%;
  top: 40%;
}

.chat-menu-panel {
  position: absolute;
  top: 46px;
  right: 0;
  left: auto;
  min-width: 220px;
  padding: 10px 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), #020617);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform-origin: top right;
  transform: scale(0.9) translateY(-4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 20;
}

.chat-menu-panel--open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.chat-menu-panel__item {
  margin: 0;
}

.chat-menu-panel__item + .chat-menu-panel__item {
  margin-top: 4px;
}

.chat-menu-panel__label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.chat-sender-select {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 20px;
  font-size: 1rem;
  background: #020617;
  color: var(--text-primary);
  outline: none;
}

.chat-sender-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}

.login-banner {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.login-banner--success {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.2), transparent);
  border: 1px solid rgba(34, 197, 94, 0.6);
  color: #bbf7d0;
}

.login-banner--error {
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.2), transparent);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fecaca;
}

.login-banner__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.login-form {
  margin: 14px 0 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.login-form--narrow {
  margin-left: auto;
  margin-right: auto;
  max-width: 360px;
}

.login-form__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-form__field label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-form__field input {
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  font-size: 0.9rem;
  background: #020617;
  color: var(--text-primary);
  outline: none;
}

.login-form__field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.6);
}

.login-form__submit {
  margin-top: 4px;
  border-radius: 999px;
  border: none;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  background: linear-gradient(90deg, var(--accent), #4ade80);
  color: #022c22;
  cursor: pointer;
  align-self: flex-start;
  transition: transform 0.05s ease, box-shadow 0.05s ease, filter 0.1s ease;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.35);
}

.login-form__submit:hover {
  filter: brightness(1.05);
}

.login-form__submit:active {
  transform: translateY(1px);
  box-shadow: 0 8px 22px rgba(34, 197, 94, 0.4);
}

.login-title {
  margin: 0 0 12px;
  font-size: 1.4rem;
  text-align: center;
}

.users-table-wrapper {
  margin: 8px 0 12px;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.users-table th,
.users-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.users-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
}

.users-table__delete {
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.7);
  padding: 4px 10px;
  font-size: 0.78rem;
  background: rgba(127, 29, 29, 0.6);
  color: #fee2e2;
  cursor: pointer;
}

.users-table__delete:hover {
  background: rgba(127, 29, 29, 0.9);
}

