:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #617065;
  --line: #d9dfd7;
  --panel: #ffffff;
  --page: #f6f3ec;
  --accent: #26634f;
  --accent-2: #b7412f;
  --gold: #d7a84b;
  --shadow: 0 16px 40px rgba(23, 32, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: #18231d;
  color: #f9f6ee;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sidebar h1,
.band h2 {
  margin: 0;
  letter-spacing: 0;
}

.sidebar h1 {
  font-size: 30px;
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

nav a {
  color: #f9f6ee;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 6px;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

main {
  padding: 26px;
  display: grid;
  gap: 18px;
  align-content: start;
}

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

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

.section-heading h2 {
  font-size: 22px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 84px;
  display: grid;
  align-content: space-between;
}

.metric span,
label,
.table .row span,
.conversation small {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 24px;
  overflow-wrap: anywhere;
}

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

.ops-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfaf6;
}

.ops-panel h3 {
  margin-top: 0;
}

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

.check-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.check-item span:last-child {
  color: var(--muted);
  text-align: right;
}

.check-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--gold);
}

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

.check-dot.warn {
  background: var(--accent-2);
}

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

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

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

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

.checkbox-label input {
  width: auto;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
  align-self: end;
}

button:hover {
  filter: brightness(0.95);
}

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

.icon-button {
  background: #26342c;
}

.danger-button {
  background: var(--accent-2);
}

.safe-button {
  background: #26342c;
}

.connection-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfaf6;
}

.connection-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.connection-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

.connection-dot {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(97, 112, 101, 0.12);
}

.connection-dot.connected {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(38, 99, 79, 0.16);
}

.connection-dot.needs_credentials {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(215, 168, 75, 0.18);
}

.connection-dot.pairing,
.connection-dot.connecting,
.connection-dot.reconnecting {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(215, 168, 75, 0.18);
}

.connection-dot.logged_out,
.connection-dot.error {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(183, 65, 47, 0.14);
}

.pairing-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #d6bd7a;
  border-radius: 8px;
  background: #fff9e9;
}

.pairing-panel[hidden] {
  display: none;
}

.pairing-panel span,
.pairing-panel p {
  color: var(--muted);
}

.pairing-panel strong {
  display: block;
  margin: 5px 0;
  color: var(--ink);
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: 4px;
}

.pairing-panel p {
  margin: 0;
}

.pairing-panel img {
  width: 180px;
  height: 180px;
  border: 8px solid #fff;
  border-radius: 6px;
}

.connection-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.connection-facts div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.connection-facts dt {
  color: var(--muted);
  font-size: 12px;
}

.connection-facts dd {
  margin: 5px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.connection-error {
  margin: 12px 0;
  padding: 11px 12px;
  border: 1px solid #e3b2a9;
  border-radius: 6px;
  background: #fff3f0;
  color: #8e2f20;
}

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

.row {
  display: grid;
  grid-template-columns: 90px 1fr 140px 120px;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.row strong,
.row code {
  overflow-wrap: anywhere;
}

.status {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 8px;
  background: #edf5f1;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.status.failed {
  background: #f8e8e4;
  color: var(--accent-2);
}

h3 {
  margin: 18px 0 10px;
  font-size: 17px;
}

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

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

.conversation p {
  margin: 8px 0 0;
}

.conversation-admin {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
  display: grid;
  gap: 10px;
}

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

.mini-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.mini-form-reply {
  grid-template-columns: 1fr auto;
}

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

.preview-box {
  min-height: 80px;
  white-space: pre-wrap;
  background: #f6f3ec;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0 0 16px;
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  background: #17201a;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
    gap: 20px;
  }

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

  .metric-grid,
  .operations-grid,
  .form-grid,
  .form-grid-wide {
    grid-template-columns: 1fr 1fr;
  }

  .row {
    grid-template-columns: 70px 1fr;
  }

  .mini-form,
  .mini-form-reply {
    grid-template-columns: 1fr;
  }

  .connection-facts {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  main {
    padding: 14px;
  }

  nav,
  .metric-grid,
  .operations-grid,
  .form-grid,
  .form-grid-wide {
    grid-template-columns: 1fr;
  }

  .connection-facts {
    grid-template-columns: 1fr;
  }

  .pairing-panel {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

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