/* Минималистичная белая админка */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-sidebar: #fafbfc;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #1f2937;
  --text-muted: #6b7280;
  --accent: #111827;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --green: #059669;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(15,23,42,0.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-soft);
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
  flex: 1;
}
.sidebar nav a {
  text-decoration: none;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  transition: background .15s;
}
.sidebar nav a:hover { background: #eef2f7; }
.sidebar nav a.active {
  background: var(--accent);
  color: #fff;
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer .logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}
.sidebar-footer .logout:hover { color: var(--danger); }
.status-line { display: flex; align-items: center; justify-content: space-between; }

/* CONTENT */
.content {
  flex: 1;
  padding: 28px 40px;
  max-width: 1100px;
}
.content.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 600; margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* CARD */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.card.highlight { border-color: #c7d2fe; background: #f8faff; }
.card.danger-zone { border-color: #fecaca; background: #fff5f5; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid.two { grid-template-columns: 1fr; } }

.mt { margin-top: 16px; }
.muted { color: var(--text-muted); font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  font-family: inherit;
}
.btn:hover { background: var(--bg-soft); border-color: #d1d5db; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: #000; }
.btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn.danger:hover { background: #b91c1c; }
.btn.warn {
  background: var(--warn);
  color: #fff;
  border-color: var(--warn);
}
.btn.warn:hover { background: #b45309; }
.btn.ghost { background: transparent; }
.btn.block { display: block; width: 100%; justify-content: center; }

/* TOGGLES (auto-reply) */
.toggles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 600px) { .toggles { grid-template-columns: 1fr; } }
.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  color: var(--text);
  text-align: left;
}
.toggle:hover { border-color: #cbd5e1; transform: translateY(-1px); }
.toggle.on { border-color: #a7f3d0; background: #f0fdf4; }
.toggle.off { border-color: var(--border); background: var(--bg); }
.toggle .dot { font-size: 14px; }
.toggle .state {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
}
.badge.on { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.badge.off { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.error, .badge.critical { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge.info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }

/* LIST */
.list-clean { list-style: none; padding: 0; margin: 0 0 12px; }
.list-clean li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.list-clean li:last-child { border-bottom: none; }

/* INPUTS */
input[type=text], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 100px; }
textarea.mono { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
label input, label textarea, label select { margin-top: 4px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs .tab {
  padding: 9px 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* LOGIN */
.login-card {
  width: 360px;
  padding: 32px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .muted { margin-bottom: 20px; }
.login-card form button { margin-top: 4px; }

/* FLASH / ERROR */
.flash {
  padding: 10px 14px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.error {
  padding: 10px 14px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* PRE / OUTPUT */
.prewrap {
  white-space: pre-wrap;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--bg-soft);
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  overflow-x: auto;
  max-height: 480px;
}
.output {
  white-space: pre-wrap;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  max-height: 480px;
  margin: 8px 0 0;
}
details summary { cursor: pointer; font-weight: 500; padding: 8px 0; font-size: 13px; }

/* LOGS TABLE */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 130px; }
.filters input[type=text] { width: 280px; }
table.logs {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.logs th, table.logs td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}
table.logs th {
  background: var(--bg-soft);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.logs .nowrap { white-space: nowrap; color: var(--text-muted); font-size: 11px; }
.logs .src { color: var(--text-muted); font-family: monospace; font-size: 11px; }
.logs .msg {
  white-space: pre-wrap;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  margin: 0;
  max-height: 200px;
  overflow-y: auto;
}
.logs tr.lvl-error, .logs tr.lvl-critical { background: #fffafa; }
.logs tr.lvl-warning { background: #fffdf7; }
.empty { text-align: center; padding: 40px; }
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

/* HTMX SPINNER */
.htmx-indicator {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #f8faff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  margin-top: 16px;
  color: #4338ca;
  font-size: 13px;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: flex; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c7d2fe;
  border-top-color: #4338ca;
  border-radius: 50%;
  animation: spin .9s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.htmx-request.btn { opacity: 0.6; pointer-events: none; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.result-card { animation: fadeIn .25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* METRICS (dashboard / report) */
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.metric-value {
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.1;
}
.metric small {
  font-size: 11px;
  margin-top: 6px;
  color: var(--text-muted);
}
