:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #182026;
  --muted: #66717c;
  --line: #d9e0e4;
  --accent: #0f7b6c;
  --accent-strong: #0a5f53;
  --warn: #b75f11;
  --danger: #b3261e;
  --blue: #1f5f99;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

.meta,
.muted {
  color: var(--muted);
  font-size: 12px;
}

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

.layout {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr) minmax(360px, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel-title {
  min-height: 28px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-panel {
  grid-column: span 2;
}

.log-panel {
  grid-column: span 2;
}

.reports-panel {
  grid-column: span 2;
}

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

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

select,
input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

button,
.link-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.link-button:hover {
  border-color: #a8b5bd;
}

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

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

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

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.command-row {
  margin-top: 14px;
}

.badge {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.neutral {
  color: #34404a;
  background: #edf1f3;
  border-color: #dde4e8;
}

.running {
  color: #7a4108;
  background: #fff4e5;
  border-color: #f2d5aa;
}

.ok {
  color: #07594f;
  background: #e5f4f0;
  border-color: #bee1d8;
}

.error {
  color: var(--danger);
  background: #fdeceb;
  border-color: #f4c7c3;
}

.accent {
  color: #ffffff;
  background: var(--blue);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 72px;
}

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

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

.latest-list,
.report-list,
.upgrade-list {
  display: grid;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 54px;
}

.item a {
  color: var(--blue);
  text-decoration: none;
  word-break: break-all;
}

.item a:hover {
  text-decoration: underline;
}

.item .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

pre {
  width: 100%;
  min-height: 260px;
  max-height: 460px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #d8e3ea;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.login-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 32, 0.45);
}

.login-backdrop.hidden {
  display: none;
}

.login-box {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 45px rgba(16, 24, 32, 0.18);
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

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

  .control-panel,
  .log-panel,
  .reports-panel {
    grid-column: span 1;
  }

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    padding: 10px;
  }

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

  .command-row {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .link-button {
    width: 100%;
  }
}
