/* ==========================================================================
   AI Founder Office — Design System (Sprint 5.4)
   Ориентиры: Linear (стиль), Palantir (плотность), Apple (типографика).
   Единый источник стиля — дизайн-токены (CSS Variables).
   Dark theme — только переопределение токенов, отдельного CSS нет.
   ========================================================================== */

/* ---------- Design Tokens: Light Theme ---------- */

:root {
  /* surfaces */
  --bg: #f4f6f9;
  --surface: #fcfdfe;
  --surface-elevated: #ffffff;
  --surface-sunken: #eef1f6;

  /* borders */
  --border: #e2e7ee;
  --border-strong: #cbd3de;

  /* text */
  --text: #14181f;
  --text-secondary: #3d4654;
  --text-muted: #6b7484;

  /* accent — спокойный глубокий синий */
  --accent: #1e40af;
  --accent-strong: #1d4ed8;
  --accent-soft: #eaf1fd;
  --accent-soft-border: #c3d5f7;

  /* semantic */
  --success: #15803d;
  --success-soft: #e8f7ee;
  --success-soft-border: #bbe6c9;
  --warning: #b45309;
  --warning-soft: #fdf3e3;
  --warning-soft-border: #f3ddb0;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --danger-soft-border: #f3c2c2;
  --info: #5b21b6;
  --info-soft: #f1ebfb;
  --info-soft-border: #ddd0f3;
  --neutral-soft: #eef0f4;

  /* states */
  --focus: rgba(30, 64, 175, 0.35);
  --hover: rgba(15, 23, 42, 0.045);
  --selected: #eaf1fd;

  /* elevation — минимум теней */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 2px 8px rgba(16, 24, 40, 0.07);

  /* shape */
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* typography */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-h1: 20px;
  --fs-value: 30px;

  /* layout */
  --topbar-h: 64px;
  --space-page: 16px 20px 26px;
}

/* ---------- Design Tokens: Dark Theme ---------- */

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161a21;
  --surface-elevated: #1b2029;
  --surface-sunken: #12161c;

  --border: #262d38;
  --border-strong: #333c4a;

  --text: #e6e9ee;
  --text-secondary: #b6bdc9;
  --text-muted: #8a93a3;

  --accent: #5b8def;
  --accent-strong: #74a1f2;
  --accent-soft: #1c2a45;
  --accent-soft-border: #2b3c5e;

  --success: #3fb27f;
  --success-soft: #142a20;
  --success-soft-border: #1f4534;
  --warning: #d9a13b;
  --warning-soft: #2b2314;
  --warning-soft-border: #4a3a1c;
  --danger: #e06565;
  --danger-soft: #2e1a1a;
  --danger-soft-border: #522a2a;
  --info: #a78bfa;
  --info-soft: #241d38;
  --info-soft-border: #3a2f5a;
  --neutral-soft: #1e242e;

  --focus: rgba(91, 141, 239, 0.4);
  --hover: rgba(255, 255, 255, 0.05);
  --selected: #1c2a45;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* ---------- Base / Typography ---------- */

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

[data-theme="dark"] html,
html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: var(--fs-md);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent-strong);
}

/* ---------- Header ---------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------- Pills ---------- */

.role-pill,
.org-pill,
.user-pill,
.agent-badge,
.source-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 3px 11px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.role-pill {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
}

.role-noaccess {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
}

.org-pill {
  color: var(--info);
  background: var(--info-soft);
  border-color: var(--info-soft-border);
}

.user-pill {
  color: var(--text);
  font-weight: 700;
  border: none;
  padding: 3px 0;
}

.agent-badge {
  color: var(--info);
  background: var(--info-soft);
}

.source-dashboard {
  color: var(--text-secondary);
  background: var(--neutral-soft);
}

.source-chatgpt {
  color: var(--success);
  background: var(--success-soft);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
}

.system-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  min-width: 82px;
  text-align: center;
}

/* ---------- Buttons (Primary / Secondary / Ghost / Text) ---------- */

/* Primary: ai-form button, login submit, admin-form button, ai-run-btn */
.ai-form button,
.login-form button,
.admin-form button,
.ai-run-btn {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

.ai-form button:hover,
.login-form button:hover,
.admin-form button:hover,
.ai-run-btn:hover {
  background: var(--accent-strong);
}

.ai-form button:active,
.login-form button:active,
.admin-form button:active,
.ai-run-btn:active {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
}

.ai-form button:focus-visible,
.login-form button:focus-visible,
.admin-form button:focus-visible,
.ai-run-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.ai-run-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Secondary: sync-btn */
.sync-btn {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: #fff;
  background: var(--info);
  border: 1px solid var(--info);
  border-radius: var(--radius-md);
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.sync-btn:hover {
  filter: brightness(1.1);
}

.sync-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Ghost: logout-btn, edit-btn, inline-save/cancel, audit apply, filters */
.logout-btn,
.edit-btn,
.inline-save,
.inline-cancel,
.admin-filters button,
.admin-action {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease,
    background-color 0.12s ease;
}

.logout-btn:hover,
.edit-btn:hover,
.admin-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.inline-save {
  color: var(--success);
  border-color: var(--success);
}

.inline-cancel {
  color: var(--danger);
}

/* Danger ghost: admin-danger, blocker-close */
.admin-danger,
.blocker-close {
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  cursor: pointer;
}

.admin-danger:hover,
.blocker-close:hover {
  background: var(--danger-soft);
}

/* Text: admin-link, admin-open */
.admin-link,
.admin-open {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--info);
  background: var(--info-soft);
  border: 1px solid var(--info-soft-border);
  border-radius: var(--radius-sm);
  padding: 4px 11px;
  text-decoration: none;
  white-space: nowrap;
  display: inline-block;
}

.admin-open {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
}

/* Special: next-button (disabled CTA) */
.next-button {
  margin-top: auto;
  font-size: var(--fs-md);
  font-weight: 700;
  color: #fff;
  background: var(--success);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  cursor: not-allowed;
  opacity: 0.5;
}

/* Theme toggle */
[data-theme-toggle] {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  cursor: pointer;
  white-space: nowrap;
}

[data-theme-toggle]:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- Layout ---------- */

.dashboard {
  padding: var(--space-page);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: grid;
  gap: 14px;
}

.row-focus {
  grid-template-columns: minmax(260px, 1fr) 2fr;
}

.row-lists {
  grid-template-columns: repeat(3, 1fr);
}

/* ---------- Cards (unified) ---------- */

.card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 12px;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card ul {
  margin: 0;
  padding-left: 20px;
}

.card li {
  margin-bottom: 6px;
}

.card li:last-child {
  margin-bottom: 0;
}

/* Важные карточки — визуально тяжелее */
.snapshot-card {
  border-left: 4px solid var(--info);
  box-shadow: var(--shadow-md);
}

.next-card {
  background: var(--success-soft);
  border: 1px solid var(--success-soft-border);
  border-left: 5px solid var(--success);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: var(--shadow-md);
}

.next-card h2 {
  color: var(--success);
}

.next-text {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.3;
}

.blockers-card {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  border-left: 5px solid var(--danger);
}

.blockers-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.blockers-head h2 {
  margin: 0;
  color: var(--danger);
  font-size: var(--fs-lg);
}

.blockers-icon {
  font-size: 17px;
}

.blockers-count {
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 1px 8px;
}

.blockers-list {
  margin: 0;
  padding-left: 20px;
  color: var(--danger);
  font-weight: 600;
}

.blockers-list li {
  margin-bottom: 4px;
}

.blockers-list li::marker {
  color: var(--danger);
}

.blocker-text {
  margin-right: 8px;
  color: var(--text);
}

/* Goal strip — вторичный, спокойный */
.goal-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: var(--fs-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-label {
  font-weight: 700;
  flex-shrink: 0;
}

.goal-text {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Progress (ring + bars) ---------- */

.progress-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.progress-card h2 {
  align-self: flex-start;
}

.ring-wrap {
  position: relative;
  width: 150px;
  height: 150px;
}

.ring {
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--neutral-soft);
  stroke-width: 9;
}

.ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.ring-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-value);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.ring-caption {
  margin: 10px 0 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Тонкий современный progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--neutral-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar.small {
  height: 5px;
  min-width: 80px;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.25s ease;
}

.fill-in-progress { background: var(--accent); }
.fill-blocked { background: var(--danger); }
.fill-not-started { background: var(--border-strong); }
.fill-done { background: var(--success); }

/* ---------- Badges (единая система статусов) ---------- */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-in-progress,
.ai-badge-running {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-blocked,
.ai-badge-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-not-started,
.ai-badge-new,
.ai-badge-cancelled {
  background: var(--neutral-soft);
  color: var(--text-secondary);
}

.badge-done,
.ai-badge-completed {
  background: var(--success-soft);
  color: var(--success);
}

.ai-badge-waiting {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-ok {
  color: var(--success);
  font-weight: 700;
}

.status-off {
  color: var(--text-muted);
}

/* ---------- Workflows ---------- */

.workflow-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.workflow-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px 9px 0;
  background: var(--surface-elevated);
  transition: background-color 0.12s ease;
}

.workflow-row:hover {
  background: var(--hover);
}

.wf-bar {
  align-self: stretch;
  width: 3px;
  border-radius: 3px 0 0 3px;
  flex-shrink: 0;
}

.status-in-progress .wf-bar { background: var(--accent); }
.status-blocked .wf-bar { background: var(--danger); }
.status-not-started .wf-bar { background: var(--border-strong); }
.status-done .wf-bar { background: var(--success); }

.wf-icon {
  font-size: 17px;
  flex-shrink: 0;
}

.wf-main {
  flex: 1;
  min-width: 0;
}

.wf-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.wf-name {
  font-weight: 700;
  font-size: var(--fs-md);
}

.wf-desc {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.wf-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ws-status,
.ws-progress-input,
.ai-status,
.admin-form select,
.admin-filters select,
.project-switcher select,
.access-role-select {
  font-size: var(--fs-sm);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
}

.ws-progress-input {
  width: 62px;
  font-variant-numeric: tabular-nums;
}

.ws-status:focus,
.ws-progress-input:focus,
.ai-status:focus,
.inline-edit:focus,
.login-form input:focus,
.admin-form input:focus {
  outline: 3px solid var(--focus);
  outline-offset: 0;
}

.ws-saving {
  opacity: 0.55;
  pointer-events: none;
}

.wf-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 210px;
  flex-shrink: 0;
}

.wf-percent,
.snapshot-progress-value {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.snapshot-progress-value {
  color: var(--accent);
  font-size: var(--fs-lg);
}

/* ---------- Task lists ---------- */

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.task:hover {
  background: var(--hover);
}

.task-checkbox {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.task-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.task-text {
  font-size: var(--fs-md);
}

.task-done .task-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.list-title {
  font-size: var(--fs-lg);
}

/* ---------- Snapshot ---------- */

.snapshot-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.snapshot-head h2 {
  margin: 0 0 2px;
}

.snapshot-phase {
  font-size: var(--fs-sm);
  color: var(--info);
  font-weight: 700;
}

.snapshot-goal {
  font-size: var(--fs-md);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.snapshot-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.snapshot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.snapshot-block {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.snapshot-block-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.snapshot-block p {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}

.snapshot-next {
  background: var(--success-soft);
  border: 1px solid var(--success-soft-border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: var(--fs-md);
  margin-bottom: 10px;
}

.snapshot-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ---------- AI Task Center ---------- */

.ai-center-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.ai-center-head h2 {
  margin: 0;
}

.ai-metrics {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.metric {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
}

.metric b {
  color: var(--text);
}

.metric-ok b {
  color: var(--success);
}

.metric-err b {
  color: var(--danger);
}

.ai-form,
.admin-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.ai-form input[type="text"],
.admin-form input {
  flex: 1;
  min-width: 150px;
  font-size: var(--fs-sm);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
}

.ai-task-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ai-task {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  background: var(--surface-elevated);
}

.ai-task.status-running { border-left-color: var(--accent); }
.ai-task.status-waiting { border-left-color: var(--warning); }
.ai-task.status-completed { border-left-color: var(--success); }
.ai-task.status-failed { border-left-color: var(--danger); }
.ai-task.status-cancelled { opacity: 0.65; }

.ai-task-main {
  flex: 1;
  min-width: 0;
}

.ai-task-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-title {
  font-weight: 700;
}

.ai-time {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.ai-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.ai-result {
  font-size: var(--fs-sm);
  color: var(--success);
  background: var(--success-soft);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-top: 6px;
}

.ai-error {
  font-size: var(--fs-sm);
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-top: 6px;
}

.ai-sync {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.ai-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ai-result-btn {
  font-size: var(--fs-xs);
  border: 1px solid var(--success);
  color: var(--success);
  background: var(--surface-elevated);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  cursor: pointer;
  white-space: nowrap;
}

.ai-result-btn:hover {
  background: var(--success-soft);
}

.ai-empty,
.ev-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ---------- Activity feeds ---------- */

.ai-activity-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-activity-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
  flex-wrap: wrap;
}

.ai-activity-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ev-agent,
.ev-project {
  font-weight: 700;
  color: var(--info);
  flex-shrink: 0;
}

.ev-task {
  color: var(--text-muted);
}

.ev-task::before {
  content: "· ";
}

.ev-time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ---------- Inline editing ---------- */

.inline-edit {
  flex: 1;
  min-width: 200px;
  font-size: var(--fs-sm);
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.toast-ok {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

/* ---------- Admin Console ---------- */

.admin-nav {
  display: flex;
  gap: 4px;
  padding: 8px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.admin-tab {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
}

.admin-tab:hover {
  background: var(--hover);
}

.admin-tab.active {
  color: var(--accent);
  background: var(--selected);
}

.admin-main {
  padding: 18px 20px 30px;
}

.admin-section h2 {
  margin: 0 0 14px;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.admin-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* Компактные таблицы без визуального шума */
.admin-table table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--fs-sm);
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: none;
}

.admin-table tbody tr:hover {
  background: var(--hover);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.temp-password {
  background: var(--warning-soft);
  border: 1px solid var(--warning-soft-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  margin-bottom: 12px;
}

.temp-password code {
  font-size: var(--fs-md);
  font-weight: 700;
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.progress-cell .progress-bar {
  flex: 1;
}

/* Access matrix */
.access-matrix td,
.access-matrix th {
  text-align: center;
}

.access-matrix td.access-user {
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

.access-role-select {
  font-size: var(--fs-xs);
  padding: 3px 6px;
}

.access-has-role .access-role-select {
  border-color: var(--accent-soft-border);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ---------- Login ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 360px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  margin-bottom: 20px;
}

.login-title {
  margin: 0 0 16px;
}

.login-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--fs-sm);
  margin-bottom: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.login-form input {
  font-size: var(--fs-md);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
}

.login-form button {
  padding: 11px;
}

.login-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .row-focus,
  .row-lists {
    grid-template-columns: 1fr;
  }

  .snapshot-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .wf-progress {
    width: 160px;
  }
}

@media (max-width: 700px) {
  .topbar {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .dashboard {
    padding: 10px 12px 20px;
  }

  .snapshot-grid {
    grid-template-columns: 1fr;
  }

  .workflow-row,
  .ai-task {
    flex-wrap: wrap;
  }

  .wf-controls,
  .ai-controls,
  .wf-progress {
    width: 100%;
  }

  .goal-strip {
    white-space: normal;
  }
}
