/* Палитра из выбранного варианта B: светлая тема по умолчанию, тёмная — data-theme="dark" на <html>. */
:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f3f6fa;
  --line: #dde3ee;
  --text: #152033;
  --muted: #5f6b7f;
  --accent: #14a37f;
  --accent-2: #0f8a6b;
  --green: #14a37f;
  --red: #d64545;
  --amber: #b7791f;
  --radius: 16px;
  --input-bg: #ffffff;
  --pre-bg: #f3f6fa;
  --hover-tint: rgba(0, 0, 0, .03);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #161922;
  --panel-2: #1d212c;
  --line: #272c3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #2bbf8f;
  --accent-2: #3fd6a6;
  --green: #2fbf71;
  --red: #ef5b5b;
  --amber: #f5b544;
  --radius: 16px;
  --input-bg: #11141b;
  --pre-bg: #0b0d12;
  --hover-tint: rgba(255, 255, 255, .02);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }

code, pre {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

pre {
  background: var(--pre-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
}

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
  margin-bottom: 4px;
}

.brand span { color: var(--accent-2); }
.ws-name { color: var(--muted); font-size: 12px; margin-bottom: 18px; word-break: break-word; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
}

.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: rgba(20, 163, 127, .16); color: var(--text); font-weight: 600; }
.nav-lbl { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ico {
  width: 18px; height: 18px; flex: 0 0 18px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--muted);
}
.nav a:hover .ico, .nav a.active .ico { color: var(--accent-2); }
.nav a:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 2px 0 0; font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { border-color: #3a4155; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--red); border-color: rgba(239, 91, 91, .4); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=url], input[type=number], input[type=datetime-local], input[type=date],
input[type=time], input[type=search], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  outline: none;
}

input[type=checkbox], input[type=radio] { accent-color: var(--accent); }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 163, 127, .25);
}
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
textarea { min-height: 110px; resize: vertical; }

.field { margin-bottom: 14px; }
.field .hint { display: block; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.field .field-error { display: none; margin-top: 5px; font-size: 12.5px; color: var(--red); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.field.has-error .field-error { display: block; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.4; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td { max-width: 300px; overflow-wrap: break-word; }
td.nowrap, td:empty { white-space: nowrap; }
td .mono, td a[href^="tel:"] { white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover-tint); }
@media (max-width: 1280px) {
  th, td { padding: 6px 6px; }
  td { max-width: 220px; }
}

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.flash.success { background: rgba(47, 191, 113, .12); border-color: rgba(47, 191, 113, .4); }
.flash.error { background: rgba(239, 91, 91, .12); border-color: rgba(239, 91, 91, .4); }
.flash.info { background: rgba(20, 163, 127, .12); border-color: rgba(20, 163, 127, .4); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.pill.green { color: var(--green); border-color: rgba(47, 191, 113, .45); }
.pill.red { color: var(--red); border-color: rgba(239, 91, 91, .45); }
.pill.amber { color: var(--amber); border-color: rgba(245, 181, 68, .45); }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.auth-card h1 { font-size: 21px; }

.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty h3 { color: var(--text); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

.sidebar { position: sticky; }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px; }
}

/* Узкие экраны (телефон, ~390 px): таблицы скроллятся по горизонтали, а не ломают страницу. */
@media (max-width: 560px) {
  .main { padding: 14px 12px 40px; }
  .page-head { margin-bottom: 16px; }
  h1 { font-size: 21px; }
  .card { padding: 14px; }
  .nav { gap: 4px; }
  .nav a { padding: 7px 9px; font-size: 13px; }
  .nav-lbl { gap: 6px; }
  .btn { padding: 8px 12px; }
  .row > * { flex: 1 1 100%; }
  .copy-row { flex-direction: column; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  td { max-width: none; overflow-wrap: normal; }
  td .muted, td .small { overflow-wrap: normal; }
  .auth-card { padding: 20px; }
  /* Колонки сеток не должны расти от содержимого таблиц и форм. */
  .split, .grid, .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .split > *, .grid > *, .card, .stat, .row, .row > * { min-width: 0; }
  .shell, .main { max-width: 100vw; }
}

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { position: relative; padding: 0 0 16px 34px; counter-increment: step; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(20, 163, 127, .2); color: var(--accent-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 9px; align-items: baseline; }
.checklist li:last-child { border-bottom: none; }
.checklist .ok { color: var(--green); }
.checklist .todo { color: var(--muted); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
