:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef2f6;
  --text: #111827;
  --muted: #667085;
  --line: #d9e0e8;
  --accent: #d21f3c;
  --accent-soft: rgba(210, 31, 60, 0.09);
  --green: #0f8f62;
  --yellow: #9b6a00;
  --blue: #2366c9;
  --red: #ba1a2e;
  --radius: 8px;
  --shadow: 0 14px 36px rgba(17, 24, 39, 0.08);
}

html.dark {
  --bg: #111418;
  --surface: #181c22;
  --surface-soft: #222833;
  --text: #f6f7f9;
  --muted: #a7b0bd;
  --line: rgba(255, 255, 255, 0.12);
  --accent-soft: rgba(236, 72, 93, 0.16);
  --shadow: none;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

#app {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

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

.topbar h1,
.panel h2,
.state h1 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 32px;
  line-height: 1.15;
}

.panel h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
}

.text-button {
  margin-left: 10px;
  padding: 6px 9px;
  border-radius: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.text-button:disabled {
  color: var(--muted);
  cursor: wait;
  opacity: 0.7;
}

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

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

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

.panel {
  overflow: hidden;
}

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

.panel-head.compact {
  padding-bottom: 12px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  line-height: 1.45;
}

.request-cell {
  max-width: 300px;
  white-space: normal;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-soft);
  color: var(--muted);
}

.status-done {
  color: var(--green);
  background: rgba(15, 143, 98, 0.11);
}

.status-error {
  color: var(--red);
  background: rgba(186, 26, 46, 0.11);
}

.status-processing,
.status-ready {
  color: var(--blue);
  background: rgba(35, 102, 201, 0.11);
}

.status-needs_confirmation,
.status-draft {
  color: var(--yellow);
  background: rgba(155, 106, 0, 0.12);
}

.side-panel {
  padding-bottom: 8px;
}

.search {
  display: block;
  width: calc(100% - 28px);
  margin: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.chat-item {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.chat-item strong {
  font-size: 13px;
}

.chat-item span {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.empty.large {
  padding: 32px 18px;
}

.state {
  display: grid;
  min-height: calc(100vh - 80px);
  place-items: center;
}

.state-box {
  width: min(520px, 100%);
  padding: 24px;
}

.state-box h1 {
  font-size: 26px;
}

.state-box p:last-child {
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1100px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  #app {
    width: min(100vw - 20px, 1480px);
    padding-top: 18px;
  }

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

  .topbar h1 {
    font-size: 27px;
  }
}
