:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #152033;
  --muted: #667085;
  --line: #d9e1ec;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --success: #147a4a;
  --danger: #bd2d35;
  --warning: #a45f08;
  --shadow: 0 18px 48px rgba(21, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.admin-shell {
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-box {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.dashboard {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.topbar,
.panel-header,
.account-bar,
.hint-row,
.tabbar {
  display: flex;
  align-items: center;
}

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

.account-bar {
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 17px;
}

.login-form,
.stack-form {
  display: grid;
  gap: 16px;
}

.login-form {
  margin-top: 26px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 14px;
}

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

label span {
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

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

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.primary-button,
.ghost-button,
.small-button,
.tab-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #ffffff;
}

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

.primary-button.compact {
  min-width: 128px;
}

.ghost-button,
.small-button,
.tab-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

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

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.ready {
  border-color: rgba(20, 122, 74, 0.3);
  color: var(--success);
  background: rgba(20, 122, 74, 0.08);
}

.status-pill.error {
  border-color: rgba(189, 45, 53, 0.35);
  color: var(--danger);
  background: rgba(189, 45, 53, 0.08);
}

.tabbar {
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
}

.tab-button {
  flex: 0 0 auto;
  min-width: 88px;
  padding: 0 14px;
}

.tab-button.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-strong);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
}

.stat-tile,
.work-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-tile {
  min-height: 86px;
  padding: 15px;
  display: grid;
  align-content: space-between;
}

.stat-button {
  width: 100%;
  border: 1px solid var(--line);
  color: inherit;
  text-align: left;
}

.stat-button:hover,
.stat-button:focus-visible {
  border-color: rgba(37, 99, 235, 0.42);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  outline: none;
}

.stat-tile span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.stat-tile strong {
  font-size: 26px;
  line-height: 1;
}

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

.admins-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.feedback-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
}

.work-panel {
  padding: 18px;
}

.narrow-panel {
  width: min(760px, 100%);
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.hint-row {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
  background: #ffffff;
}

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

th {
  color: #42526b;
  background: var(--panel-soft);
  font-size: 13px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-dot.ok {
  color: var(--success);
  background: rgba(20, 122, 74, 0.1);
}

.status-dot.off {
  color: var(--danger);
  background: rgba(189, 45, 53, 0.1);
}

.status-dot.pending {
  color: var(--warning);
  background: rgba(164, 95, 8, 0.12);
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td,
.clickable-row:focus-visible td,
.clickable-row.active td {
  background: rgba(37, 99, 235, 0.07);
}

.clickable-row:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: -3px;
}

.link-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.feedback-preview {
  display: block;
  max-width: 280px;
  white-space: normal;
}

.feedback-detail {
  display: grid;
  gap: 16px;
}

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

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  word-break: break-word;
}

.detail-section h3 {
  margin: 0 0 8px;
  color: #344054;
  font-size: 14px;
}

.feedback-message {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

.json-block {
  margin-top: 0;
  max-height: 240px;
  overflow: auto;
}

pre {
  margin: 16px 0 0;
  min-height: 92px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101828;
  color: #d7e4ff;
  padding: 14px;
  font-size: 13px;
  line-height: 1.55;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--success);
  font-size: 14px;
}

.form-message.error,
pre.error {
  color: #e5484d;
}

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

  .two-column,
  .admins-grid,
  .feedback-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .admin-shell {
    padding: 16px;
  }

  .login-box,
  .work-panel {
    padding: 18px;
  }

  .topbar,
  .account-bar,
  .hint-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .detail-list div {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }
}
