body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #18212b;
}

a { color: #0b5fff; text-decoration: none; }
a:hover { text-decoration: underline; }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #cfd7e3;
  background: #fff;
  color: #18212b;
  text-decoration: none;
}
.button-link:hover { background: #f3f7ff; text-decoration: none; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #101923;
  color: #eef4fb;
  padding: 20px;
}
.sidebar a { color: #eef4fb; display: block; padding: 8px 0; }
.content { padding: 24px; }
.card {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(16, 25, 35, 0.08);
  margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(5, minmax(120px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.support-layout { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr); align-items: start; }
.grid.db-layout { grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #e7ebf0; vertical-align: top; }
input, textarea, select, button {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid #cfd7e3;
  padding: 10px 12px;
  font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
button {
  background: #0b5fff;
  color: #fff;
  border: none;
  cursor: pointer;
}
button.secondary { background: #dde7ff; color: #0b2c7a; }
button.danger { background: #c62828; }
.inline-form { display: inline-block; margin: 0; }
.inline-form button,
.inline-form input { width: auto; }
label { display: flex; gap: 8px; align-items: center; }
label input[type="checkbox"] { width: auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.mono { font-family: ui-monospace, SFMono-Regular, monospace; white-space: pre-wrap; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-card { width: 420px; max-width: calc(100vw - 32px); }
.muted { color: #617085; }
.tag { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #eef3ff; color: #2647a8; font-size: 12px; }
.tabs { display: flex; gap: 12px; flex-wrap: wrap; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #eef3ff;
  color: #2647a8;
}
.tabs a.active { background: #0b5fff; color: #fff; }
.inline-balance-form { display: flex; gap: 8px; align-items: center; }
.inline-balance-form input { min-width: 110px; }
.chat-thread {
  display: grid;
  gap: 14px;
  max-height: 72vh;
  overflow: auto;
  padding-right: 6px;
}
.chat-bubble {
  max-width: 82%;
  border-radius: 18px;
  padding: 14px 16px;
  background: #edf3fb;
  border: 1px solid #d7e3f2;
}
.chat-bubble.user { justify-self: start; }
.chat-bubble.admin {
  justify-self: end;
  background: #dce8ff;
  border-color: #bfd2ff;
}
.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.db-table-list { display: grid; gap: 8px; }
.db-table-link {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: #f6f8fb;
  color: inherit;
}
.db-table-link.active {
  background: #dce8ff;
  border: 1px solid #bfd2ff;
}
.html-editor { display: grid; gap: 14px; }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.editor-toolbar button { width: auto; }
.editor-preview-card,
.editor-guide-card {
  margin: 0;
}
.editor-guide {
  display: grid;
  gap: 10px;
  font-size: 14px;
  color: #314256;
}
.editor-guide p { margin: 0; }
.html-preview {
  min-height: 140px;
  border-radius: 12px;
  border: 1px dashed #bfd2ff;
  background: #f8fbff;
  padding: 14px;
  line-height: 1.5;
}
.html-preview.compact {
  min-height: 0;
  margin-top: 10px;
}
.tg-spoiler {
  background: #1a2029;
  color: transparent;
  border-radius: 6px;
  padding: 0 4px;
}
.tg-spoiler:hover {
  color: #fff;
}
.version-preview {
  display: grid;
  gap: 10px;
}
.notice {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #cfd7e3;
}
.notice-success {
  background: #e9f8ef;
  border-color: #b8e1c7;
  color: #1a5f2a;
}
.notice-warn {
  background: #fff4e9;
  border-color: #ffd3a2;
  color: #7b4310;
}
.notice-info {
  background: #ecf3ff;
  border-color: #c8dcff;
  color: #1f3e86;
}
.csv-toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}
.form-field {
  display: grid;
  gap: 6px;
}
.form-field > span {
  color: #617085;
  font-size: 12px;
}
.table-wrap {
  overflow: auto;
}
.csv-table th,
.csv-table td {
  white-space: nowrap;
}
.csv-row-added {
  background: #f5f8f6;
}
.csv-action-cell {
  min-width: 220px;
}
.csv-add-form {
  display: grid;
  gap: 8px;
}
.tag-success {
  background: #e9f8ef;
  color: #1f6d34;
}
.pagination {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.log-filters {
  grid-template-columns: 2fr 180px 140px 170px 140px auto;
  align-items: end;
}
.log-meta {
  margin-top: 12px;
}
.log-actions {
  margin-top: 8px;
}
.log-viewer {
  max-height: 72vh;
  overflow: auto;
  white-space: pre;
  line-height: 1.4;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .grid.stats, .grid.two, .grid.support-layout, .grid.db-layout { grid-template-columns: 1fr; }
  .csv-toolbar { grid-template-columns: 1fr; }
  .log-filters { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 100%; }
}
