:root {
  color-scheme: light;
  --bg: #f2f4f1;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --ink: #1f2a33;
  --muted: #65727d;
  --line: #d9e0d8;
  --line-strong: #c5d0c7;
  --accent: #236750;
  --accent-strong: #174735;
  --accent-soft: #e7f3ed;
  --warn: #9a5a24;
  --warn-soft: #fff3e4;
}

* {
  box-sizing: border-box;
}

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

button,
textarea,
input {
  font: inherit;
}

button,
.link-button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  text-decoration: none;
}

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

button.secondary,
button.ghost,
.tab {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

button.secondary {
  width: 100%;
}

button.ghost {
  min-height: 34px;
  padding: 0 12px;
}

button.secondary:hover,
button.ghost:hover,
.tab:hover {
  border-color: var(--accent);
  background: #fff;
}

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

.shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.brand {
  padding: 4px 2px 10px;
}

.brand h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.15;
}

.muted,
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.status,
.side-card,
.setup-card,
.tool-card,
.metric,
.message,
.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
}

.side-card {
  padding: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warn);
}

.dot.ok {
  background: var(--accent);
}

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

label,
h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 750;
  color: #34434f;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fff;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 103, 80, 0.12);
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  padding: 18px clamp(20px, 4vw, 48px);
}

.metric {
  padding: 16px 18px;
}

.metric span {
  display: block;
  font-size: 28px;
  font-weight: 800;
}

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

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 clamp(20px, 4vw, 48px) 14px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 0 18px;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.panel {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.panel.active {
  display: grid;
}

#chatPanel {
  grid-template-rows: minmax(0, 1fr) auto;
}

.messages {
  overflow-y: auto;
  padding: 26px clamp(20px, 4vw, 48px);
}

.message {
  max-width: 940px;
  margin: 0 auto 14px;
  padding: 16px 18px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  border-color: #a9c6b9;
  background: #eef8f3;
}

.message.sources {
  font-size: 14px;
  color: var(--muted);
}

.composer {
  border-top: 1px solid var(--line);
  background: #fbfcfb;
  padding: 18px clamp(20px, 4vw, 48px);
}

.composer textarea {
  display: block;
  max-width: 940px;
  min-height: 88px;
  margin: 0 auto 12px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 940px;
  margin: 0 auto;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.toggle input {
  width: auto;
  min-height: auto;
}

#dataPanel,
#telegramPanel,
#calendarPanel {
  overflow-y: auto;
  padding: 24px clamp(20px, 4vw, 48px) 40px;
  align-content: start;
  gap: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head.compact {
  margin-bottom: 10px;
}

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

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

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

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(420px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.setup-card,
.tool-card {
  min-width: 0;
  padding: 18px;
}

.setup-card {
  grid-row: span 2;
}

.tool-card {
  display: grid;
  gap: 12px;
}

.setup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.setup-head h3,
.tool-card h3 {
  margin: 0 0 6px;
}

.notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid #bdd5ca;
  border-radius: 8px;
  background: var(--accent-soft);
}

.notice strong {
  grid-column: 1 / -1;
  font-size: 13px;
}

code {
  padding: 8px 10px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.steps {
  margin: 14px 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.warning {
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid #e6b17e;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none;
}

.button-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
}

.button-row .secondary {
  width: auto;
}

.data-grid section {
  min-width: 0;
}

.data-grid h3 {
  margin: 0 0 10px;
}

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

.item {
  padding: 14px;
}

.item-title {
  margin: 0 0 6px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.item-meta,
.item-body {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

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

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand,
  .status {
    grid-column: 1 / -1;
  }

  .workspace {
    height: auto;
    min-height: 720px;
  }
}

@media (max-width: 760px) {
  .sidebar,
  .topbar,
  .data-grid,
  .data-grid.two,
  .calendar-layout,
  .button-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }

  .section-head,
  .setup-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
