:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --side: #1f2a22;
  --side-text: #c9d6cc;
  --accent: #3a9d5d;
  --text: #1d2420;
  --muted: #7a857d;
  --border: #e3e8e4;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); display: flex; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; padding: 8px 16px;
}
button:hover { filter: brightness(1.08); }
input {
  font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; min-width: 0;
}
input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }

aside {
  width: 240px; flex-shrink: 0; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 20px; font-weight: 700; padding: 22px 20px; color: #fff; }
.brand small { font-size: 12px; font-weight: 400; color: var(--side-text); margin-left: 4px; }
nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; flex: 1; }
nav a { color: var(--side-text); padding: 10px 12px; border-radius: 8px; display: flex; gap: 10px; }
nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
nav a.active { background: var(--accent); color: #fff; }
nav .ico { width: 20px; text-align: center; }
.logout { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.logout button { background: transparent; color: var(--side-text); border: 1px solid rgba(255,255,255,.2); padding: 4px 10px; }

main { flex: 1; padding: 28px 36px; min-width: 0; }
main.full { padding: 0; height: 100vh; overflow: hidden; }
h1 { margin: 0 0 24px; font-size: 26px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin: 6px 0 4px; }
.stat .sub { color: var(--muted); font-size: 13px; }

.search { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.search input { width: 320px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #fafbfa; color: var(--muted); font-weight: 600; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf8; }
tr.muted td { color: var(--muted); }
td.num, th.num { text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #eef0ee; color: var(--muted); }
.badge.ok { background: #e3f4e8; color: #23733f; }
.badge.star { background: #fff4d6; color: #8a6400; }
.post-photo { display: block; max-width: 240px; max-height: 180px; border-radius: 8px; margin-bottom: 6px; }
.post-params { font-size: 13px; line-height: 1.6; max-width: 220px; }
.err-text { color: #b42318; font-size: 13px; }
.btn-row { display: grid; grid-template-columns: 180px 1fr 1fr; gap: 8px; margin-top: 6px; }
.field { display: flex; flex-direction: column; font-weight: 600; font-size: 14px; }
.field small, label small { font-weight: 400; color: var(--muted); }
.interval { display: inline-flex; gap: 6px; margin-left: 6px; }
.interval input { width: 90px; }
label.check { flex-direction: row; display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; }
.test-form { display: flex; gap: 6px; margin-top: 8px; }
.test-form input { width: 130px; padding: 5px 8px; font-size: 13px; }
td form.inline + form.inline { margin-left: 0; }
td > form.inline { display: block; margin-top: 6px; }
td > form.inline:first-child { margin-top: 0; }
.range { flex-wrap: wrap; }
.range label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.range input[type=date] { width: auto; }
.range a { padding: 6px 12px; border-radius: 8px; background: #eef0ee; color: #4b554e; font-size: 13px; text-decoration: none; }
.range a.active { background: var(--accent); color: #fff; }
.stats-small { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.stats-small .stat { padding: 12px 14px; color: inherit; text-decoration: none; }
.stats-small .stat:hover { border-color: var(--accent); }
.stats-small .stat.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f3faf5; }
.stats-small .value { font-size: 22px; }
.stats-small .sub { font-size: 12px; }
.chart { width: 100%; height: 240px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px; box-sizing: border-box; }
.chart rect { fill: var(--accent); }
.chart g:hover rect { fill: #23733f; }
.chart text { font-size: 11px; fill: #8a948d; }
.chart text.v { fill: #4b554e; font-weight: 600; }
.chart line { stroke: #e3e7e3; }
.table-scroll { overflow-x: auto; margin-top: 18px; border-radius: 12px; }
.stats-table th { white-space: normal; min-width: 70px; font-size: 12px; vertical-align: bottom; }
.stats-table td.zero { color: #c3cac5; }
.stats-table tr.weekend td:first-child { color: #b42318; }
tr.untagged td { background: #fafbfa; border-top: 1px dashed var(--border); }
tfoot td { background: #fafbfa; font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: #eef0ee; padding: 1px 5px; border-radius: 4px; }
.ref-links { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.ref-links code { user-select: all; width: fit-content; }
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; }
.tabs a { padding: 6px 14px; border-radius: 8px; background: #eef0ee; color: #4b554e; text-decoration: none; font-size: 14px; }
.tabs a.active { background: var(--accent); color: #fff; }
.pager { display: flex; gap: 16px; align-items: center; margin-top: 14px; color: var(--muted); }

h2 { font-size: 19px; margin: 32px 0 14px; }
.lead { margin: 0 0 18px; color: #4b554e; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.flash.ok { background: #e3f4e8; color: #23733f; }
.flash.err { background: #fdecec; color: #b42318; }
.badge.err { background: #fdecec; color: #b42318; }
.muted-text { color: var(--muted); font-size: 13px; }
td.wrap { white-space: normal; word-break: break-all; max-width: 260px; }
td { vertical-align: middle; }
form.inline { display: inline; margin: 0; }
button.switch { background: #eef0ee; color: #4b554e; padding: 6px 12px; font-size: 13px; }
button.switch.on { background: var(--accent); color: #fff; }
button.switch:disabled { opacity: .45; cursor: not-allowed; }
a.edit-link { display: inline-block; color: #4b554e; border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; font-size: 13px; text-decoration: none; font-weight: 400; }
a.edit-link:hover { background: #eef0ee; }
h2 a.edit-link { margin-left: 10px; vertical-align: middle; }
td.row-actions { white-space: nowrap; }
td.row-actions form.inline { display: inline; margin-left: 6px; }
button.danger { background: transparent; color: #b42318; border: 1px solid #f3c4c0; padding: 6px 12px; font-size: 13px; }
.card-form { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.card-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.card-form small { font-size: 12px; }
.card-form button { align-self: flex-start; }
.card-form p { margin: 0; }
textarea { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.ad-preview { max-width: 380px; }
.ad-msg { background: #fff; border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; padding: 8px 10px; white-space: pre-wrap; font-size: 14px; line-height: 1.38; }
.ad-msg blockquote { margin: 4px 0; padding: 2px 8px; border-left: 3px solid var(--accent); background: #f2f8f3; }
.ad-msg tg-spoiler, .ad-msg .tg-spoiler { background: #c9d0cb; color: transparent; border-radius: 3px; }
.ad-kb { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ad-kb span, .ad-kb a { text-align: center; background: rgba(58, 157, 93, .12); color: #23733f; padding: 5px 8px; border-radius: 8px; font-size: 13px; }
.ad-kb a { background: rgba(58, 157, 93, .25); font-weight: 600; }
td.ad-stats { font-size: 13px; color: var(--muted); }
td.ad-stats b { color: var(--text); font-size: 16px; }
select { font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

.stub { background: var(--panel); border: 1px dashed var(--border); border-radius: 12px; padding: 60px 20px; text-align: center; color: var(--muted); }
.stub-icon { font-size: 44px; }

body.login { align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 14px; }
.card .brand { color: var(--text); padding: 0 0 4px; text-align: center; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.error { background: #fdecec; color: #b42318; padding: 8px 12px; border-radius: 8px; font-size: 14px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; }
  nav { flex-direction: row; flex-wrap: wrap; padding-bottom: 10px; }
  main { padding: 20px 14px; overflow-x: auto; }
  .search input { width: 100%; }
}
