:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #1d2430;
  --muted: #647084;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --red: #b42318;
  --amber: #b45309;
  --green: #15803d;
  --shadow: 0 12px 35px rgba(20, 27, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 12px;
  cursor: pointer;
}

button:hover {
  border-color: #aeb8c8;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-strong);
}

button.danger {
  border-color: #f2b8b5;
  color: var(--red);
}

button.mini {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
}

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #172033;
  color: #f8fafc;
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 20px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand strong {
  font-size: 18px;
}

.brand span,
.profile span {
  color: #b7c2d6;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #f8fafc;
  text-align: left;
}

.nav button.active {
  background: #e9f8f5;
  color: #0f3f3a;
}

.profile {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.content {
  min-width: 0;
  padding: 24px;
}

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

.topline h2 {
  margin: 0;
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 370px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.panel-head h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 16px;
}

.project-list {
  display: grid;
  gap: 8px;
}

.project-row {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.project-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.row-title {
  font-weight: 700;
  line-height: 1.25;
}

.row-meta,
.muted,
.quality-line {
  color: var(--muted);
  font-size: 13px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #edf2f7;
  color: #334155;
}

.badge.draft {
  background: #eef2ff;
  color: #3730a3;
}

.badge.review {
  background: #e0f2fe;
  color: #075985;
}

.badge.changes_requested {
  background: #fff7ed;
  color: #9a3412;
}

.badge.ready {
  background: #dcfce7;
  color: #166534;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

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

.image-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.image-tile button {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  min-height: 32px;
}

.section {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.section:first-child {
  border-top: 0;
}

.section h3,
.section h4 {
  margin: 0;
}

.characteristics {
  display: grid;
  gap: 8px;
}

.characteristic {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1fr) 120px 120px;
  gap: 8px;
  align-items: end;
}

.notice {
  border: 1px solid #f7c873;
  background: #fffaf0;
  color: #7c2d12;
  border-radius: 8px;
  padding: 12px;
}

.confidence {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.meter {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.meter strong {
  font-size: 18px;
}

.meter.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.meter.warn {
  border-color: #fed7aa;
  background: #fff7ed;
}

.ai-console,
.copy-variants {
  border: 1px solid #c9e7e2;
  background: #f7fcfb;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 14px;
}

.ai-console-head,
.telegram-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.ai-console-head strong,
.telegram-head h3 {
  display: block;
  margin: 0 0 4px;
}

.ai-console-head span,
.telegram-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.ai-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.ai-facts > div,
.option-card,
.variant-card,
.review-row {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px;
}

.ai-facts span,
.option-card span,
.variant-card span,
.review-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.ai-facts b,
.option-card b,
.variant-card b {
  display: block;
  margin-bottom: 8px;
}

.decision-block {
  display: grid;
  gap: 8px;
}

.option-grid,
.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.option-card,
.variant-card {
  display: grid;
  gap: 8px;
  align-content: start;
}

.variant-card h4,
.variant-card p,
.variant-card ul,
.review-row ul {
  margin: 0;
}

.variant-card ul,
.review-row ul {
  padding-left: 18px;
}

.review-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.review-guidance {
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #14532d;
}

.review-guidance.warn {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #7c2d12;
}

.review-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.telegram-panel {
  margin-bottom: 16px;
}

.telegram-commands {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  margin: 14px 0;
}

.telegram-commands code {
  color: var(--accent-strong);
  font-weight: 700;
}

.comments {
  display: grid;
  gap: 10px;
}

.comment {
  border-left: 3px solid var(--accent);
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
}

.comment p {
  margin: 6px 0 0;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.empty {
  color: var(--muted);
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

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

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .grid-2,
  .grid-3,
  .characteristic,
  .review-row,
  .telegram-commands {
    grid-template-columns: 1fr;
  }
}
