/* MARS Local — тёмная тема без внешних зависимостей. */
:root {
  color-scheme: dark;
  --bg: #0a0d14;
  --bg-soft: #0e121b;
  --panel: #121722;
  --panel-2: #171d2b;
  --panel-3: #1b2231;
  --line: #242d40;
  --line-soft: #1a2130;
  --text: #e7ecf6;
  --text-dim: #a2adc2;
  --muted: #7c879c;
  --accent: #8b8cff;
  --accent-strong: #6d6ef7;
  --accent-soft: rgba(139, 140, 255, 0.12);
  --info: #5aa9ff;
  --ok: #3ddc97;
  --warn: #f4b860;
  --err: #ff6b81;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(109, 110, 247, 0.12), transparent 62%),
    radial-gradient(900px 520px at 108% 4%, rgba(61, 220, 151, 0.055), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  font-family: inherit;
}

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

h1,
h2,
h3,
p {
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #2a3448 transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #252e42;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* --- Кнопки и управление ------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #1d2536;
  border-color: #34405a;
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: none;
}

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.is-busy {
  opacity: 0.65;
  cursor: progress;
}

.btn-primary {
  border-color: #7f80ff;
  background: linear-gradient(180deg, #7a7bff, #5b5ce6);
  color: #fff;
  box-shadow: 0 6px 18px rgba(93, 94, 230, 0.22);
}

.btn-primary:hover:not(:disabled) {
  border-color: #a1a2ff;
  background: linear-gradient(180deg, #8a8bff, #6a6bf2);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: #ff8a99;
  background: linear-gradient(180deg, #ff7285, #e54860);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  border-color: #ffb0bb;
  background: linear-gradient(180deg, #ff8294, #ee5570);
}

.btn-danger-ghost {
  border-color: rgba(255, 107, 129, 0.3);
  background: rgba(255, 107, 129, 0.06);
  color: var(--err);
}

.btn-danger-ghost:hover:not(:disabled) {
  border-color: rgba(255, 107, 129, 0.55);
  background: rgba(255, 107, 129, 0.12);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 12px 18px;
  font-size: 14px;
}

.btn-mini {
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

/* --- Формы -------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: #0c111a;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: #5b6578;
}

.textarea {
  min-height: 76px;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

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

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

.form-foot .check {
  margin-right: auto;
}

.form-error {
  padding: 8px 10px;
  border: 1px solid rgba(255, 107, 129, 0.25);
  border-radius: 8px;
  background: rgba(255, 107, 129, 0.08);
  color: #ffb3bf;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-strong);
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

/* --- Чипы и карточки ---------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.chip.is-muted {
  border-color: rgba(124, 135, 156, 0.18);
  background: rgba(124, 135, 156, 0.09);
  color: var(--muted);
}

.chip.is-accent {
  border-color: rgba(139, 140, 255, 0.28);
  background: var(--accent-soft);
  color: #b7b8ff;
}

.chip.is-info {
  border-color: rgba(90, 169, 255, 0.26);
  background: rgba(90, 169, 255, 0.1);
  color: #a9d0ff;
}

.chip.is-ok {
  border-color: rgba(61, 220, 151, 0.26);
  background: rgba(61, 220, 151, 0.1);
  color: #93f0c4;
}

.chip.is-warn {
  border-color: rgba(244, 184, 96, 0.28);
  background: rgba(244, 184, 96, 0.1);
  color: #ffd79b;
}

.chip.is-err {
  border-color: rgba(255, 107, 129, 0.28);
  background: rgba(255, 107, 129, 0.1);
  color: #ffb3bf;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%), var(--panel);
}

.pad {
  padding: 18px;
}

/* --- Экран входа -------------------------------------------------------- */
.login-view {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px 18px;
  overflow: hidden;
}

.login-view::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(139, 140, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 140, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, #000, transparent 72%);
  mask-image: radial-gradient(circle at 50% 42%, #000, transparent 72%);
  pointer-events: none;
}

.login-view::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  top: -220px;
  right: -160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 110, 247, 0.22), transparent 65%);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(18, 23, 34, 0.94);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.login-card h1 {
  margin: 2px 0 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #8b8cff, #4f50c9);
  box-shadow: 0 8px 20px rgba(109, 110, 247, 0.35);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
}

.brand-word {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.32em;
}

.login-foot {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}

/* --- Каркас приложения -------------------------------------------------- */
.app-view {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 18px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #0d1119, #0a0d14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px;
}

.brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.34em;
}

.brand-sub {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-close {
  display: none;
  margin-left: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #3b4460, #252c40);
  color: #dfe5f2;
  font-size: 13px;
  font-weight: 700;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-role {
  color: var(--muted);
  font-size: 11px;
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.project-item:hover {
  background: rgba(255, 255, 255, 0.035);
}

.project-item.is-active {
  border-color: rgba(139, 140, 255, 0.28);
  background: linear-gradient(90deg, rgba(139, 140, 255, 0.14), rgba(139, 140, 255, 0.04));
}

.project-initial {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1b2231;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
}

.project-item.is-active .project-initial {
  border-color: rgba(139, 140, 255, 0.35);
  background: rgba(139, 140, 255, 0.18);
  color: #d4d4ff;
}

.project-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.project-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.project-slug {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.role-mini {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-empty {
  padding: 14px 10px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.side-version {
  color: #4e586b;
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.admin-nav {
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.nav-item::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #3c465c;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.nav-item.is-active {
  border-color: rgba(139, 140, 255, 0.24);
  background: rgba(139, 140, 255, 0.12);
  color: #cfd0ff;
}

.nav-item.is-active::before {
  background: var(--accent);
}

.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.main {
  flex: 1;
  min-height: 0;
  padding: 30px 34px 70px;
  overflow-y: auto;
}

.mobile-bar {
  display: none;
}

.sidebar-scrim {
  display: none;
}

.page,
.hero {
  max-width: 1180px;
  margin: 0 auto;
}

/* --- Шапка страницы и вкладки ------------------------------------------ */
.page-head {
  margin-bottom: 24px;
}

.crumbs {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.crumbs .sep {
  margin: 0 4px;
  opacity: 0.5;
}

.title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.title-row h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.page-desc {
  max-width: 780px;
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-line;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.tab {
  position: relative;
  padding: 10px 14px 12px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--info));
}

/* --- Секции ------------------------------------------------------------- */
.section {
  margin-top: 26px;
}

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

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.section-sub {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.count {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Задачи ------------------------------------------------------------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.task-row:hover {
  border-color: #35415c;
  background: #151b29;
  transform: translateY(-1px);
}

.task-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.task-title {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.task-metrics {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

/* --- Карта этапов ------------------------------------------------------- */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.stage-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 112px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stage-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: #556074;
  opacity: 0.75;
}

.stage-card:hover {
  border-color: #37435e;
  transform: translateY(-1px);
}

.stage-card.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.stage-card:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.stage-card:disabled:hover {
  transform: none;
  border-color: var(--line);
}

.stage-not_started::before {
  background: #556074;
}

.stage-in_progress::before {
  background: var(--info);
}

.stage-done::before {
  background: var(--ok);
}

.stage-blocked::before {
  background: var(--err);
}

.stage-done {
  background: linear-gradient(180deg, rgba(61, 220, 151, 0.06), transparent 60%), var(--panel);
}

.stage-in_progress {
  background: linear-gradient(180deg, rgba(90, 169, 255, 0.07), transparent 60%), var(--panel);
}

.stage-blocked {
  background: linear-gradient(180deg, rgba(255, 107, 129, 0.07), transparent 60%), var(--panel);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-ord {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.stage-status {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stage-done .stage-status {
  color: var(--ok);
}

.stage-in_progress .stage-status {
  color: var(--info);
}

.stage-blocked .stage-status {
  color: var(--err);
}

.stage-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
}

.stage-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  color: var(--muted);
  font-size: 10.5px;
}

.stage-foot code {
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #0d121b;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
}

.stage-req {
  color: var(--muted);
  font-size: 10.5px;
}

/* --- Память ------------------------------------------------------------- */
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.memory-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.memory-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.memory-key {
  font-size: 12.5px;
  font-weight: 600;
}

.memory-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

.memory-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.memory-value {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-foot {
  margin-top: 6px;
  color: var(--muted);
  font-size: 10.5px;
}

/* --- Таблицы ------------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

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

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.018);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.small {
  font-size: 11px;
}

.nowrap {
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.row-error td {
  background: rgba(255, 107, 129, 0.05);
}

.row-error-detail td {
  background: rgba(255, 107, 129, 0.035);
}

/* --- Карточка задачи ---------------------------------------------------- */
.task-stamp {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

.task-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.task-tools .task-stamp {
  margin-top: 10px;
}

.prompt-panel summary {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: live-pulse 1.6s infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(61, 220, 151, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0);
  }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.back-link:hover {
  color: var(--text);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 10px;
  margin: 18px 0 22px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.stat-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.stat-hint {
  color: var(--muted);
  font-size: 11px;
}

.bar {
  height: 5px;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #0c111a;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--info));
  transition: width 0.3s ease;
}

.bar-fill.is-hot {
  background: linear-gradient(90deg, var(--warn), var(--err));
}

.banner {
  padding: 12px 14px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 107, 129, 0.3);
  border-radius: 12px;
  background: rgba(255, 107, 129, 0.07);
}

.banner h3 {
  margin: 0 0 4px;
  color: var(--err);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.banner p {
  margin: 0;
  color: #ffc0c9;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.approval {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  margin-bottom: 22px;
  border-color: rgba(244, 184, 96, 0.3);
  background: linear-gradient(180deg, rgba(244, 184, 96, 0.06), transparent 70%), var(--panel);
}

.approval h2 {
  margin: 0;
  font-size: 15px;
}

.approval p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.approval .actions {
  justify-content: flex-end;
}

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

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

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14.5px;
}

.empty {
  margin: 0;
  padding: 10px 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

/* Сообщения */
.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  padding: 10px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0f141e;
}

.msg-user {
  border-color: rgba(139, 140, 255, 0.25);
  background: rgba(139, 140, 255, 0.05);
}

.msg-assistant {
  border-color: rgba(61, 220, 151, 0.18);
  background: rgba(61, 220, 151, 0.035);
}

.msg-system {
  border-color: rgba(244, 184, 96, 0.18);
  background: rgba(244, 184, 96, 0.03);
}

.msg-tool {
  border-color: rgba(90, 169, 255, 0.18);
}

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

.msg-role {
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.msg-time {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

.msg-body {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Гейты */
.gate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #0f141e;
}

.gate.is-fail {
  border-color: rgba(255, 107, 129, 0.25);
}

.gate-state {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}

.gate.is-pass .gate-state {
  background: rgba(61, 220, 151, 0.12);
  color: var(--ok);
}

.gate.is-fail .gate-state {
  background: rgba(255, 107, 129, 0.12);
  color: var(--err);
}

.gate-name {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
}

.gate-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.gate-log {
  grid-column: 2 / -1;
}

.gate-log summary {
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

/* Вердикты */
.verdict-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.verdict {
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: #0f141e;
}

.verdict-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.verdict-head .muted {
  margin-left: auto;
}

.reasons {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}

.reasons li {
  margin: 2px 0;
}

details summary {
  cursor: pointer;
}

.payload summary {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

/* JSON и текст */
.json,
.text-block {
  max-height: 420px;
  margin: 6px 0 0;
  padding: 11px 13px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #0b0f18;
  color: #c6d0e2;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Результат */
.result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-entry {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: #0f141e;
}

.result-entry .result-key {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-entry.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

details.result-entry summary {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}

/* --- Приветствие -------------------------------------------------------- */
.hero {
  padding-top: 8vh;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid rgba(139, 140, 255, 0.28);
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c3c4ff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 640px;
  margin: 14px 0 12px;
  font-size: 38px;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.hero .lead {
  max-width: 620px;
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  max-width: 920px;
  margin-top: 44px;
}

.feature {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.feature-num {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
}

.feature h3 {
  margin: 8px 0 4px;
  font-size: 13.5px;
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* --- Пустые состояния и скелетоны -------------------------------------- */
.empty-state {
  padding: 26px 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.012);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 5px;
  font-size: 14px;
}

.empty-state p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.empty-state .btn {
  margin: 0 auto;
}

.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton {
  height: 64px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: linear-gradient(90deg, #10151f 25%, #161d2a 37%, #10151f 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.skeleton-grid .skeleton {
  height: 112px;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* --- Админ: метрики и провайдеры --------------------------------------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.metric-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metric-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-hint {
  color: var(--muted);
  font-size: 11px;
}

.status-table td:first-child {
  width: 240px;
}

.event-type {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid rgba(139, 140, 255, 0.2);
  border-radius: 6px;
  background: rgba(139, 140, 255, 0.08);
  color: #c3c4ff;
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.inline-details summary {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
}

/* --- Модальные окна ----------------------------------------------------- */
body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 10, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade-in 0.15s ease;
}

.modal {
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, var(--panel), rgba(18, 23, 34, 0.94));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
}

.modal-body {
  padding: 20px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* --- Тосты -------------------------------------------------------------- */
.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #151c2a;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  animation: toast-in 0.18s ease;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin-top: 1px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}

.toast-info .toast-icon {
  background: rgba(90, 169, 255, 0.15);
  color: var(--info);
}

.toast-success .toast-icon {
  background: rgba(61, 220, 151, 0.15);
  color: var(--ok);
}

.toast-warn .toast-icon {
  background: rgba(244, 184, 96, 0.15);
  color: var(--warn);
}

.toast-error .toast-icon {
  background: rgba(255, 107, 129, 0.16);
  color: var(--err);
}

.toast-error {
  border-color: rgba(255, 107, 129, 0.35);
}

.toast-warn {
  border-color: rgba(244, 184, 96, 0.3);
}

.toast-success {
  border-color: rgba(61, 220, 151, 0.28);
}

.toast-text {
  flex: 1;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-line;
  word-break: break-word;
}

.toast-close {
  padding: 2px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.toast-close:hover {
  color: var(--text);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* --- Адаптивность ------------------------------------------------------- */
@media (max-width: 980px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 290px;
    border-right: 1px solid var(--line);
    transform: translateX(-104%);
    transition: transform 0.2s ease;
  }

  .app-view.sidebar-open .sidebar {
    transform: none;
  }

  .app-view.sidebar-open .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    background: rgba(3, 5, 10, 0.6);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-soft);
    background: rgba(10, 13, 20, 0.92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .mobile-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.3em;
  }

  .main {
    padding: 20px 16px 60px;
  }

  .hero {
    padding-top: 4vh;
  }

  .hero h1 {
    font-size: 30px;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .task-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .task-metrics {
    display: none;
  }

  .title-row h1 {
    font-size: 23px;
  }

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

  .gate {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  .gate-meta {
    display: none;
  }
}

@media (max-width: 640px) {
  .login-card {
    padding: 24px;
  }

  .tabs {
    overflow-x: auto;
  }

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

  .memory-actions {
    width: 100%;
    margin-left: 0;
  }

  .toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .approval .actions {
    justify-content: stretch;
  }

  .approval .actions .btn {
    flex: 1;
  }

  .table {
    min-width: 560px;
  }
}
