:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #6b7785;
  --line: #e1e6eb;
  --accent: #0b7a75;
  --accent-text: #ffffff;
  --danger: #c23a32;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --in: #eef2f5;
  --out: #dff3f1;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c;
    --card: #1b232b;
    --text: #e3e9ef;
    --muted: #91a0ae;
    --line: #2c3742;
    --accent: #2bb3ab;
    --accent-text: #08201f;
    --danger: #ef6b62;
    --ok: #4cc27f;
    --warn: #e0a84a;
    --in: #24303a;
    --out: #173a38;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 4px 0 8px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.top nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); }
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }

.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.empty { color: var(--muted); text-align: center; padding: 40px 20px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-text { color: var(--danger); }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.flash.error { border-color: var(--danger); color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.ok { color: var(--ok); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
form.inline { display: inline; margin: 0; }
div.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 4px; }
.pager { display: flex; gap: 8px; justify-content: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.badge.ok, .badge.s-active { color: var(--ok); border-color: var(--ok); }
.badge.bad, .badge.s-blocked, .badge.s-removed_by_moderator { color: var(--danger); border-color: var(--danger); }
.badge.s-moderated, .badge.s-new, .badge.s-limited, .badge.s-unpaid { color: var(--warn); border-color: var(--warn); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; text-align: center; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list th { font-size: 13px; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }

label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
label.check { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.label { margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input[type=checkbox] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
fieldset { border: 0; border-top: 1px solid var(--line); padding: 16px 0 4px; margin: 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-weight: 600; padding-right: 8px; }
.grid2, .grid3 { display: grid; gap: 0 16px; }
.grid2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); align-items: end; }
.grid2 .wide { grid-column: 1 / -1; margin-bottom: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.picker select { width: auto; min-width: 200px; }
.form-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-x { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; }

.threads .thread {
  display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); color: var(--text);
}
.threads .thread:last-child { border-bottom: 0; }
.threads .thread:hover { background: var(--bg); text-decoration: none; }
.threads .thread.unread strong { color: var(--accent); }
.thread-main { min-width: 0; flex: 1; }
.thread-meta { text-align: right; flex-shrink: 0; }

.messages { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 75%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; text-align: right; }
.bubble { padding: 10px 14px; border-radius: 12px; background: var(--in); text-align: left; white-space: normal; overflow-wrap: anywhere; }
.msg.out .bubble { background: var(--out); }
.reply { display: flex; gap: 12px; align-items: flex-end; }
.reply textarea { flex: 1; }

.brand { white-space: nowrap; }
.turbo-progress-bar { height: 3px; background: var(--accent); }
form[aria-busy="true"] button { opacity: .6; pointer-events: none; } /* Turbo ставит aria-busy на время отправки */
@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  .top nav .muted { display: none; }
  .msg { max-width: 92%; }
  .reply { flex-direction: column; align-items: stretch; }
}
