:root {
  color-scheme: light;
  --bg: #f5f7f2;
  --surface: #ffffff;
  --ink: #162321;
  --muted: #68736f;
  --line: #d8ded5;
  --teal: #0f7c73;
  --teal-soft: #dff2ee;
  --amber: #b96f13;
  --amber-soft: #fff0d6;
  --red: #b13d39;
  --red-soft: #ffe3df;
  --green: #287a46;
  --green-soft: #ddf2e4;
  --shadow: 0 18px 50px rgba(22, 35, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--teal);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.model-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #0c5b55;
  font-weight: 800;
  white-space: nowrap;
}

.app-grid {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 16px;
  padding-bottom: 32px;
}

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

.nav-panel {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
  align-self: start;
  padding: 8px;
}

.tab {
  height: 44px;
  font-weight: 800;
}

.tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 24px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.view {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 620px;
}

.view.active {
  display: block;
}

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

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.chart-card {
  min-height: 250px;
}

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

.chart-head h3 {
  margin-bottom: 0;
}

.live-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  padding: 0 10px;
}

.live-chip.active {
  animation: pulse 1s ease-in-out infinite;
}

.live-chip.muted {
  background: #eef1ef;
  color: var(--muted);
}

canvas {
  width: 100%;
  display: block;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(40, 122, 70, 0.18);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(40, 122, 70, 0);
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: #f0f4ee;
  color: #34413d;
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.pill.normal {
  background: var(--green-soft);
  color: var(--green);
}

.pill.review {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.blocked {
  background: var(--red-soft);
  color: var(--red);
}

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

.schema-example {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 12px;
  margin-bottom: 14px;
}

.schema-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.schema-card h3 {
  margin-bottom: 8px;
}

.schema-card pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: #14211f;
  color: #e9f2ed;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feature-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  background: #fff;
  color: #34413d;
  font-size: 12px;
  font-weight: 800;
}

.log-grid {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 140px;
  gap: 8px;
  align-items: start;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #394743;
  font-size: 12px;
  font-weight: 800;
}

.field.check {
  align-content: end;
}

.field.check input {
  width: 18px;
  min-height: 18px;
}

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

.inset {
  box-shadow: none;
  padding: 14px;
  min-height: 360px;
}

.accent-red {
  border-top: 4px solid var(--red);
}

.accent-green {
  border-top: 4px solid var(--green);
}

.red-blue-log {
  margin-top: 16px;
}

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

.compact {
  gap: 8px;
}

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

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 900;
}

.meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.bot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.bot-admin {
  display: grid;
  gap: 16px;
}

.bot-lock {
  min-height: 160px;
}

.hidden {
  display: none !important;
}

.bot-card {
  min-height: 180px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  min-height: 42px;
  display: none;
  align-items: center;
  border-radius: 8px;
  background: #172421;
  color: #fff;
  padding: 0 14px;
  box-shadow: var(--shadow);
}

.toast.show {
  display: flex;
}

.inline-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

@media (max-width: 920px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

  .nav-panel {
    position: static;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .stats,
  .chart-grid,
  .schema-example,
  .form-grid,
  .bot-grid,
  .split,
  .log-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1420px);
  }

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

  .section-head,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
