/* === TextWriter: базовая сетка и типографика === */
:root {
  --bg: #0f172a;
  --bg-soft: #111a31;
  --surface: #1b2540;
  --surface-2: #243154;
  --border: #2b3a66;
  --text: #e8ecf8;
  --text-muted: #9aa7c7;
  --primary: #6366f1;
  --primary-hover: #7c7ff3;
  --accent: #22c55e;
  --accent-hover: #34d479;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: linear-gradient(180deg, #0b1226 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }

.muted { color: var(--text-muted); }
.hidden { display: none !important; }
.grow { flex: 1 1 auto; }

/* === Layout === */
.container { width: 100%; max-width: none; margin: 0; padding: 0 20px; }
.main-area { padding: 24px 0 60px; min-width: 0; }

.topbar {
  background: rgba(10, 16, 36, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: 700; font-size: 13px;
}
.topnav a { color: var(--text-muted); margin-left: 22px; }
.topnav a:hover { color: var(--text); text-decoration: none; }
.topnav-user { display: flex; align-items: center; gap: 16px; }
.topnav-user a { margin-left: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  padding-top: 18px;
  width: 100%;
}
.app-shell-guest { display: block; }
.app-shell-guest .main-area {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 40px;
}

.sidebar {
  position: sticky;
  top: 76px;
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
}

/* Отдельный визуальный режим для меню admin в разделе настроек. */
.sidebar.sidebar-admin-settings {
  background: #2a365c;
  border-color: #415487;
}
.sidebar.sidebar-admin-settings .side-link:hover {
  background: #32436f;
}
.sidebar.sidebar-admin-settings .side-link.active {
  background: rgba(148, 163, 255, 0.24);
  border-color: rgba(170, 184, 255, 0.62);
  color: #e6ebff;
}

.side-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.side-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-link.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.5);
  color: #cfd5ff;
  font-weight: 600;
}

/* Cards & grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

.hero {
  display: flex; justify-content: space-between; align-items: center;
  background: radial-gradient(1200px 300px at 30% 0%, rgba(99,102,241,0.18), transparent),
              var(--surface);
  border: 1px solid var(--border);
  padding: 24px; border-radius: var(--radius);
  margin-bottom: 24px;
}
.hero-actions { display: flex; gap: 10px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit; font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 80px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

.form-stack > * + * { margin-top: 0; }
.form-row { display: flex; gap: 14px; align-items: flex-start; }
.form-row > label { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px; font-weight: 500;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #2c3a63; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #0b1320; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table th { color: var(--text-muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table.compact th, .data-table.compact td { padding: 6px 8px; font-size: 13px; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table .actions { text-align: right; white-space: nowrap; }

/* Alerts & toasts */
.alert {
  padding: 12px 16px; border-radius: 8px; border: 1px solid;
  margin-bottom: 16px;
}
.alert-danger { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #ffb4b4; }

.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 12px 14px; border-radius: 8px;
  min-width: 240px; box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.toast-text {
  white-space: pre-wrap;
}
.toast-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.toast-close:hover {
  color: var(--text);
}
.toast.success { border-left: 3px solid var(--ok); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Article view */
.article-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.article-content {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  white-space: pre-wrap; word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; line-height: 1.65;
  max-height: 640px; overflow: auto;
}

/* HTML-режим просмотра статьи: обычная типографика и компактные отступы списков. */
#article-content-html {
  white-space: normal;
  font-family: inherit;
}
#article-content-html h1,
#article-content-html h2,
#article-content-html h3,
#article-content-html h4,
#article-content-html h5,
#article-content-html h6 {
  margin-top: 0.2em;
  margin-bottom: 0.45em;
}
#article-content-html ul,
#article-content-html ol {
  margin-top: 0.3em;
  margin-bottom: 0.8em;
  padding-left: 1.4em;
}
#article-content-html li {
  margin: 0.2em 0;
}

/* Editor layout */
.editor-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 1200px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-main textarea#f-content { min-height: 480px; font-size: 14px; }
.editor-main { min-width: 0; }

.editor-actions-line {
  margin-bottom: 12px;
}
.editor-actions-buttons {
  margin-top: 0;
  margin-bottom: 6px;
}

.editor-reports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
.editor-report-card {
  margin-bottom: 0;
  padding: 14px;
}

@media (max-width: 1000px) {
  .editor-reports-grid {
    grid-template-columns: 1fr;
  }
}

.effective-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px; margin: 14px 0 18px;
}
.effective-item {
  padding: 10px 12px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px;
}
.effective-item .k { color: var(--text-muted); font-size: 12px; }
.effective-item .v { color: var(--text); font-weight: 500; word-break: break-all; }

.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.task-list li:last-child { border-bottom: none; }

