:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #5d6977;
  --line: #d8dee6;
  --accent: #116466;
  --accent-dark: #0b4749;
  --warn: #a45b00;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 42px);
  color: #fff;
  background: #15202b;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.05rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.topbar p {
  margin-top: 6px;
  color: #c9d3df;
}

.status-pill {
  min-width: 160px;
  padding: 10px 12px;
  text-align: center;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px;
  color: #d9f6ee;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions form {
  margin: 0;
}

.logout-button {
  min-width: 96px;
  color: #15202b;
  background: #d9f6ee;
  border-color: #d9f6ee;
}

.logout-button:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

main {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 40px;
}

.band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.metric {
  min-height: 92px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: .85rem;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 18px;
}

.section-title {
  margin: 18px 0 12px;
}

.trial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.trial-panel {
  min-width: 0;
}

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

.mini-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  gap: 8px;
  width: min(190px, 50%);
}

.mini-buttons button {
  min-height: 34px;
  padding: 6px 10px;
}

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

.wide-control {
  grid-column: span 3;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .82rem;
}

input,
select,
button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
}

input,
select {
  padding: 8px 10px;
  background: #fff;
}

button {
  padding: 8px 12px;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

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

.buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.output {
  min-height: 140px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  color: #dce6ef;
  background: #111923;
  border-radius: 4px;
  white-space: pre-wrap;
}

.facts {
  margin: 0;
}

.compact-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0 20px;
  margin-bottom: 14px;
}

.facts div {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.facts div:first-child {
  border-top: 0;
  padding-top: 0;
}

dt {
  color: var(--muted);
  font-size: .82rem;
}

dd {
  margin: 4px 0 0;
}

.tight {
  margin: 12px 0 0;
  padding-left: 20px;
}

.tight li {
  margin: 8px 0;
}

.list,
.activity {
  display: grid;
  gap: 8px;
}

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

.table-wrap.tall {
  max-height: 420px;
}

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

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

th {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 650;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.manual-grid {
  grid-template-columns: 1fr 140px 160px 1.5fr;
}

.item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfd;
}

.item strong {
  display: block;
  margin-bottom: 4px;
}

.item time {
  color: var(--muted);
  font-size: .82rem;
}

.attention {
  border-color: #e0b36b;
  background: #fff8ec;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-page {
  min-height: 100vh;
  background: #15202b;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  width: min(420px, calc(100% - 32px));
  margin: 0 auto;
  place-items: center;
}

.login-panel {
  width: 100%;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login-panel h1 {
  color: var(--ink);
  font-size: 1.7rem;
}

.login-panel p {
  margin: 8px 0 18px;
  color: var(--muted);
}

.login-panel label {
  display: block;
  margin-top: 14px;
}

.login-error {
  min-height: 20px;
  color: #9d1c1c !important;
  font-size: .9rem;
}

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

  .topbar {
    display: grid;
  }

  .top-actions {
    align-items: stretch;
    display: grid;
  }

  .band,
  .control-row,
  .buttons {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: stretch;
    display: grid;
  }

  .mini-buttons {
    width: 100%;
  }

  .wide-control {
    grid-column: auto;
  }
}
