:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --text: #18201b;
  --muted: #68736c;
  --panel: #ffffff;
  --line: #d9ded7;
  --accent: #0b6b57;
  --accent-strong: #06483b;
  --warm: #b65f27;
  --soft: #eef3ed;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

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

.topbar,
.panel-heading,
.filters,
.metric-row,
.history-item {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.top-actions,
.tabs,
.connection-actions,
.connection-meta,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

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

.status {
  min-width: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 9px 12px;
  color: var(--muted);
  text-align: center;
}

.status.ok {
  color: var(--accent-strong);
}

.status.error {
  color: #9b1c1c;
}

.tabs {
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 750;
}

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

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.4fr);
  gap: 16px;
  align-items: start;
}

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

.panel-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-strong);
  cursor: pointer;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

.primary-button {
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: white;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--accent-strong);
  text-decoration: none;
}

.icon-button:hover {
  border-color: var(--accent);
}

form,
label {
  display: grid;
  gap: 8px;
}

form {
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--text);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

.two-col,
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.filters {
  grid-template-columns: minmax(160px, 1.2fr) 1fr 1fr;
  margin-bottom: 14px;
}

.filters.compact {
  display: flex;
  margin: 0;
}

.filters.compact label {
  min-width: 180px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric-row div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

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

.metric-row strong {
  display: block;
  margin-top: 8px;
  color: var(--accent-strong);
  font-size: 24px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.video-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.video-cell img {
  width: 54px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--soft);
}

.history-panel {
  margin-top: 16px;
}

.history-panel.flush {
  margin-top: 0;
}

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

.history-item {
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfcfa;
}

.history-main {
  min-width: 0;
}

.history-main strong,
.history-main span {
  display: block;
}

.history-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-main span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

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

a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 12px;
}

.notice.error {
  border-color: #e2b8b8;
  background: #fff5f5;
  color: #9b1c1c;
}

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

.connection-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 14px;
}

.connection-title strong,
.connection-title span {
  display: block;
}

.connection-title span,
.connection-meta span {
  color: var(--muted);
  font-size: 13px;
}

.connection-meta {
  justify-content: space-between;
}

.connection-actions {
  flex-wrap: wrap;
}

.inline-form input {
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.good {
  background: #e5f3ec;
  color: #07543d;
}

.badge.warn {
  background: #fff4df;
  color: #86520c;
}

.badge.bad {
  background: #fff0f0;
  color: #9b1c1c;
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--accent-strong);
}

@media (max-width: 960px) {
  .grid,
  .two-col,
  .filters,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-heading,
  .history-item,
  .top-actions,
  .connection-meta,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

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

  .history-links,
  .filters.compact {
    justify-content: start;
  }
}
