:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-muted: #f0f3f1;
  --line: #d9ded8;
  --text: #17211b;
  --muted: #667066;
  --green: #16845b;
  --green-dark: #0e5f43;
  --blue: #2357a5;
  --red: #b42318;
  --amber: #946200;
  --shadow: 0 16px 45px rgba(31, 42, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

.topbar p,
.panel-header p {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

.panel {
  padding: 18px;
  min-width: 0;
}

.control-panel {
  align-self: start;
  position: sticky;
  top: 104px;
}

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

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

.grid-2,
.grid-3,
.grid-1,
.metric-grid {
  display: grid;
  gap: 12px;
}

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

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

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

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

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 25px;
  line-height: 1;
}

.field {
  display: grid;
  gap: 7px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  min-height: 40px;
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 132, 91, 0.14);
}

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

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  min-height: 40px;
  font-weight: 720;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 13px;
}

.secondary-button:hover,
.text-button:hover,
.icon-button:hover {
  background: #e5ebe7;
}

.text-button,
.icon-button {
  background: transparent;
  color: var(--blue);
  padding: 0 10px;
}

.icon-button {
  width: 42px;
  color: var(--text);
  font-size: 18px;
}

.status-row,
.button-row,
.inline-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button-row > * {
  flex: 1;
}

.inline-form {
  align-items: end;
}

.inline-form input:first-child {
  max-width: 145px;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.ok,
.tag.active {
  background: #dff3e8;
  color: var(--green-dark);
}

.status-pill.warn,
.tag.paused {
  background: #fff0cc;
  color: var(--amber);
}

.tag.blocked {
  background: #fde5e2;
  color: var(--red);
}

.code-block {
  margin: 0;
  overflow-x: auto;
  background: #121713;
  color: #eaf4ee;
  border-radius: 8px;
  padding: 15px;
  line-height: 1.5;
  font-size: 13px;
}

.key-result {
  margin-top: 12px;
  border: 1px solid #b8dcc9;
  background: #ecf8f1;
  border-radius: 8px;
  padding: 12px;
}

.hidden {
  display: none;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

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

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

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

.subtext {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  background: #17211b;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .control-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar,
  .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar,
  .inline-form,
  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .grid-2,
  .grid-3,
  .grid-1,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .inline-form input:first-child {
    max-width: none;
  }
}
