* {
  box-sizing: border-box;
}
body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: #f5f6f8;
  color: #222;
}
input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-family: inherit;
}
button {
  font-size: 14px;
  padding: 9px 16px;
  border: none;
  border-radius: 6px;
  background: #2b6cb0;
  color: #fff;
  cursor: pointer;
}
button:hover {
  opacity: 0.9;
}
.nav {
  background: #2b2f38;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.nav a {
  color: #fff;
  text-decoration: none;
}
.nav a:hover {
  text-decoration: underline;
}
.nav a.active {
  color: #90cdf4;
  font-weight: 600;
}
.nav .right {
  margin-left: auto;
}
.container {
  max-width: 960px;
  margin: 24px auto;
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
textarea.full {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.row-form {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  align-items: center;
  flex-wrap: wrap;
}
table.btn-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
table.btn-table td,
table.btn-table th {
  border-bottom: 1px solid #eee;
  padding: 8px;
  text-align: left;
}
.flash {
  background: #fff3cd;
  padding: 8px 12px;
  border-radius: 4px;
  list-style: none;
}
.login-box {
  max-width: 320px;
  margin: 60px auto;
}
.login-box label {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  color: #555;
}
.login-box input {
  width: 100%;
  padding: 8px;
  margin: 6px 0;
  box-sizing: border-box;
}
.login-box button {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
}
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.bot-card {
  border: 1px solid #e4e7eb;
  border-radius: 8px;
  padding: 16px;
  background: #fafbfc;
}
.bot-card h3 { margin-top: 0; }
.tag {
  display: inline-block;
  font-size: 12px;
  background: #e6fffa;
  color: #276749;
  border-radius: 999px;
  padding: 3px 8px;
}
.button-link {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  background: #2b6cb0;
  color: #fff;
  text-decoration: none;
}
.secondary { background: #718096; }
.status.online { color: #27864b; }
.status.error, .error-text { color: #c53030; }
.error-text { font-size: 13px; word-break: break-word; }
.stack-form {
  display: grid;
  gap: 10px;
  max-width: 620px;
}
.stack-form label { font-size: 14px; color: #4a5568; }
.hint { color: #667085; font-size: 14px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 12px 0;
}
.stat-card {
  border: 1px solid #dbe7f3;
  border-radius: 8px;
  padding: 16px;
  background: #f7fbff;
}
.stat-card span { display: block; color: #667085; font-size: 14px; }
.stat-card strong { display: block; margin-top: 6px; font-size: 30px; color: #245f96; }
.daily-stats { margin-top: 14px; }
.daily-stats summary { cursor: pointer; color: #2b6cb0; font-weight: 600; }
.compact-table { max-width: 480px; }
.format-editor {
  margin: 10px 0 6px;
  padding: 10px;
  border: 1px solid #e1e6eb;
  border-radius: 8px;
  background: #f8fafc;
}
.format-toolbar,
.emoji-insert {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}
.format-toolbar { margin-bottom: 9px; }
.format-toolbar button {
  padding: 6px 10px;
  background: #e8eef5;
  color: #26384a;
  border: 1px solid #d5dee8;
}
.emoji-insert .emoji-id-input { width: 190px; }
.emoji-insert .emoji-fallback-input {
  width: 70px;
  text-align: center;
}
.emoji-insert button { padding: 7px 12px; }
.editor-status { font-size: 13px; color: #27864b; }
.formatted-textarea {
  min-height: 130px;
  line-height: 1.55;
}
.inbox-layout {
  display: flex;
  gap: 24px;
}
.contacts {
  width: 220px;
  border-right: 1px solid #eee;
  flex-shrink: 0;
}
.contacts ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.contacts li {
  border-bottom: 1px solid #f0f0f0;
}
.contacts li.active {
  background: #eef4ff;
}
.contacts a {
  text-decoration: none;
  color: #222;
  display: flex;
  justify-content: space-between;
  padding: 8px;
}
.contacts .time {
  color: #999;
  font-size: 12px;
  white-space: nowrap;
}
.contacts .empty {
  padding: 8px;
  color: #999;
}
.badge {
  display: inline-block;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.chat {
  flex: 1;
  min-width: 0;
}
.history {
  max-height: 420px;
  overflow-y: auto;
  padding: 10px;
  background: #fafafa;
  border-radius: 6px;
}
.msg {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 6px;
  max-width: 70%;
}
.msg span {
  display: block;
}
.msg time {
  font-size: 11px;
  color: #999;
}
.msg.in {
  background: #fff;
  border: 1px solid #eee;
}
.msg.out {
  background: #dcf8c6;
  margin-left: auto;
  text-align: right;
}
.reply-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-end;
}
.reply-form textarea {
  flex: 1;
  min-width: 200px;
  font-family: inherit;
}
.reply-form input[type="file"] {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 6px;
}
.msg-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: pointer;
}

@media (max-width: 720px) {
  .container {
    margin: 0;
    border-radius: 0;
    padding: 16px;
    box-shadow: none;
  }
  .nav {
    padding: 10px 16px;
    gap: 10px 14px;
    flex-wrap: wrap;
  }
  .inbox-layout {
    flex-direction: column;
    gap: 16px;
  }
  .contacts {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    max-height: 260px;
    overflow-y: auto;
  }
  .row-form {
    flex-direction: column;
    align-items: stretch;
  }
  .row-form input,
  .row-form select,
  .row-form button {
    width: 100%;
  }
  .emoji-insert .emoji-id-input,
  .emoji-insert .emoji-fallback-input,
  .emoji-insert button {
    width: 100%;
  }
  table.btn-table th,
  table.btn-table td {
    padding: 6px 4px;
  }
  .reply-form {
    flex-direction: column;
  }
  .login-box {
    margin: 32px auto;
  }
}
.logout-form { margin: 0; }
.nav-logout { background: transparent; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0; }
