:root {
  --bg: #f5f8fb;
  --panel: #ffffff;
  --line: #d9e3ec;
  --text: #111827;
  --muted: #64748b;
  --blue: #0077c8;
  --blue-dark: #075b96;
  --green: #0f9f6e;
  --orange: #d97706;
  --red: #dc2626;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

p {
  margin-top: 6px;
  color: var(--muted);
}

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  background: var(--blue);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

button.secondary {
  background: #e7f2fb;
  color: var(--blue-dark);
}

button.secondary:hover {
  background: #d6e9f8;
}

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

button.danger:hover {
  background: #991b1b;
}

input,
select {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: white;
  color: var(--text);
}

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 6px;
}

.checkbox-label input {
  width: auto;
  min-height: 0;
  margin-top: 0;
}

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

.panel {
  padding: 18px;
}

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

.panel-header h2 {
  margin-bottom: 0;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.list-button {
  display: grid;
  width: 100%;
  min-height: 0;
  justify-items: start;
  gap: 4px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: white;
  color: var(--text);
  text-align: left;
}

.list-button:hover {
  border-color: var(--blue);
  background: #f0f8ff;
}

.result-box {
  min-height: 72px;
  overflow: auto;
  margin: 14px 0 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.result-box.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

.controls {
  display: grid;
  grid-template-columns: 2fr 1.4fr 150px 150px auto;
  gap: 12px;
  align-items: end;
}

.status {
  margin-top: 16px;
  padding: 12px 14px;
  color: var(--muted);
}

.status.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #991b1b;
}

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

.metric {
  padding: 16px;
}

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

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

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

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

.table,
.wide-table {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 30px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 8px;
}

.row:last-child {
  border-bottom: 0;
}

.wide-row {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr 0.8fr 0.8fr 0.8fr;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid #edf2f7;
  padding: 8px 0;
  font-size: 13px;
}

.label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value {
  color: var(--text);
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 70px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eef6;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
  background: var(--blue);
}

.pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7f2fb;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 920px) {
  .topbar,
  .controls,
  .grid.two,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

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