:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --ink: #1d2522;
  --muted: #68726e;
  --line: #dedbd2;
  --surface: #ffffff;
  --accent: #0f7b63;
  --accent-strong: #085743;
  --danger: #b42318;
  --warning: #b76100;
  --shadow: 0 18px 50px rgba(34, 39, 37, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: #ece9df;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.35);
}

button.danger:hover {
  background: #fff0ed;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

.login-panel {
  width: min(880px, 100%);
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 56px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 54px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 750;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.02;
}

h2 {
  font-size: 20px;
}

.muted,
.section-head p {
  color: var(--muted);
  line-height: 1.6;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(15, 123, 99, 0.2);
  border-color: var(--accent);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.topbar,
.section-head,
.status-strip,
.workspace,
.metrics {
  animation: rise 360ms ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

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

.user-chip {
  color: var(--muted);
  font-size: 14px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #222724;
  color: #fff;
  border-radius: 8px;
  overflow: hidden;
}

.status-strip div {
  padding: 18px 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.status-strip div:last-child {
  border-right: 0;
}

.status-strip span,
.metrics span,
.run-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-strip span {
  color: rgba(255, 255, 255, 0.62);
}

.status-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.notice {
  margin: 18px 0 0;
  padding: 13px 16px;
  border-radius: 7px;
  color: #613900;
  background: #fff3d7;
  border: 1px solid #efd097;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 24px;
  margin-top: 24px;
}

.main-column,
.side-column {
  min-width: 0;
}

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

.section-head p {
  margin: 7px 0 0;
  font-size: 14px;
}

.section-head.compact {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
}

.metrics div {
  background: var(--surface);
  padding: 16px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

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

.run-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.run-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.run-title {
  font-weight: 700;
}

.run-status {
  color: var(--accent);
  font-weight: 700;
}

.run-status.needs_attention,
.run-status.error,
.run-status.partial {
  color: var(--warning);
}

.run-items {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.run-item {
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.qr-box {
  min-height: 420px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.qr-box img {
  width: min(100%, 420px);
  max-height: 640px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}

.qr-placeholder {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.side-actions {
  align-items: stretch;
  flex-direction: column;
  margin-top: 12px;
}

.side-actions button {
  width: 100%;
}

.image-dialog {
  width: min(96vw, 760px);
  max-width: 760px;
  border: 0;
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(12, 18, 16, 0.72);
}

.image-dialog button {
  float: right;
  margin-bottom: 12px;
}

.image-dialog img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  display: block;
  clear: both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

  .login-panel,
  .workspace {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 30px;
  }

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

  .topbar,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions,
  .actions {
    justify-content: space-between;
  }
}
