:root {
  --bg:        #f6f7f9;
  --surface:   #ffffff;
  --line:      #ececf0;
  --line-2:    #e3e4e9;
  --text:      #14161a;
  --text-2:    #3a3f46;
  --muted:     #6b7280;
  --hover:     #f3f4f6;
  --ink:       #16181d;   /* тёмные (primary) кнопки */
  --gold:      #e3a713;   /* фирменный акцент */
  --gold-soft: #fff6e0;
  --pos:       #16a34a;   /* положительная динамика */
  --pos-soft:  #ecfdf3;
  --danger:    #dc2626;
  --danger-soft:#fef2f2;
  --blue:      #2563eb;
  --blue-soft: #eff4ff;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 8px 30px rgba(16,24,40,.10);
  --radius:    14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--gold); }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 16px; font-weight: 650; margin: 0 0 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* ---------- Верхняя шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1220px; margin: 0 auto;
  height: 64px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 14px; position: relative; }
.brand { font-size: 18px; font-weight: 750; letter-spacing: -.01em; color: var(--text); white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-sub { color: var(--muted); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 14px; }

/* Бургер */
.burger {
  width: 42px; height: 42px; padding: 0;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 11px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.burger:hover { background: var(--hover); }
.burger span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--text); transition: transform .2s, opacity .2s; }
.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Выпадающее меню */
.nav-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0;
  min-width: 230px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 2px;
}
.nav-dropdown[hidden] { display: none; }
.nav-dropdown a {
  padding: 10px 12px; border-radius: 9px; color: var(--text-2); font-size: 14.5px; font-weight: 500;
}
.nav-dropdown a:hover { background: var(--hover); color: var(--text); }
.nav-dropdown a.active { background: var(--gold-soft); color: #8a6400; font-weight: 650; }

/* ---------- Контент ---------- */
.content { padding: 28px 24px 60px; }
.container { max-width: 1220px; margin: 0 auto; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.note { margin-top: 18px; font-size: 13px; }

/* ---------- Метрики (обзор) ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.metric .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.metric .value { font-size: 32px; font-weight: 750; letter-spacing: -.03em; margin-top: 8px; line-height: 1; }
.metric .value-sub { font-size: 20px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.metric .sub { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.metric .delta { font-size: 12.5px; font-weight: 600; margin-top: 10px; }
.metric .delta.pos { color: var(--pos); }

/* ---------- Панели / карточки ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; color: var(--text); }
ul.cols { columns: 2; margin: 8px 0 0; padding-left: 18px; }
.panel ul { margin: 6px 0 0; padding-left: 18px; }
.panel li { margin: 2px 0; }

/* ---------- Таблицы ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; min-width: 520px; }
.tbl th, .tbl td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl thead th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; background: #fbfbfd; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #fafbfc; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }
.panel > .tablewrap { margin: 0 -6px; }

/* Плашки-статусы */
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--hover); color: var(--muted); }
.tag.ok  { background: var(--pos-soft);   color: var(--pos); }
.tag.off { background: var(--danger-soft); color: var(--danger); }
.tag.tg  { background: var(--blue-soft);  color: var(--blue); }
.tag.web { background: var(--gold-soft);  color: #8a6400; }

/* ---------- Кнопки ---------- */
button, .btn {
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; line-height: 1.2;
  transition: filter .15s, background .15s, border-color .15s;
}
button:hover, .btn:hover { filter: brightness(1.15); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: var(--surface); border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover { background: var(--hover); color: var(--text); filter: none; }
.btn.danger, button.danger { background: var(--surface); border-color: #f0c2c2; color: var(--danger); }
.btn.danger:hover, button.danger:hover { background: var(--danger-soft); filter: none; }

/* ---------- Формы ---------- */
input, textarea, select {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; width: 100%; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input[type=checkbox] { width: auto; }
label { display: block; margin-bottom: 14px; color: var(--muted); font-size: 13px; font-weight: 500; }
label input, label textarea, label select { margin-top: 6px; }
.formrow { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.formrow label { margin-bottom: 0; }
.formrow label.chk { display: flex; align-items: center; gap: 7px; }
details.create { margin-bottom: 18px; }
details.create summary { cursor: pointer; color: var(--text); font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.create summary::-webkit-details-marker { display: none; }
details.create summary::before { content: "＋"; color: var(--gold); font-weight: 700; }
details.create[open] summary::before { content: "－"; }
details.create[open] summary { margin-bottom: 14px; }
.searchbar { display: flex; gap: 10px; margin-bottom: 18px; max-width: 560px; }
.searchbar input { flex: 1; }
.pager { display: flex; gap: 14px; align-items: center; margin-top: 8px; }

/* ---------- Флеш-сообщения ---------- */
.flashes { margin-bottom: 18px; }
.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; border: 1px solid transparent; }
.flash.ok { background: var(--pos-soft); border-color: #bbf7d0; color: #15803d; }
.flash.error { background: var(--danger-soft); border-color: #fecaca; color: #b91c1c; }

/* ---------- Логин ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 34px 32px; width: 350px; box-shadow: var(--shadow-md); }
.login-card .brand { display: block; text-align: center; font-size: 22px; margin-bottom: 6px; }
.login-card .brand-sub { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.login-card .lead { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.login-card label { color: var(--text-2); }
.login-card button[type=submit] { width: 100%; margin-top: 6px; padding: 11px; }

/* ---------- Рассылка ---------- */
.bcstatus { font-size: 15px; }
.bcstatus.running { color: var(--gold); font-weight: 600; }

/* ---------- Адаптив ---------- */
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .topbar-inner { padding: 0 16px; height: 58px; }
  .content { padding: 20px 16px 48px; }
  .who { display: none; }
  h1 { font-size: 22px; }
  .metric .value { font-size: 28px; }
  dl { grid-template-columns: 120px 1fr; }
  ul.cols { columns: 1; }
  .nav-dropdown { min-width: 210px; }
}
