:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --line: #d9e1ef;
  --line-strong: #c7d2e5;
  --text: #17233c;
  --muted: #6b7890;
  --blue: #2b459f;
  --blue-dark: #203783;
  --blue-soft: #eef3ff;
  --green: #16845f;
  --green-soft: #eaf8f2;
  --red: #c0362c;
  --red-soft: #fff0ef;
  --amber: #b66b00;
  --amber-soft: #fff7e6;
  --shadow: 0 12px 28px rgba(29, 48, 87, .08);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #eef4ff 0, rgba(238, 244, 255, 0) 260px),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

.shell {
  min-height: 100vh;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 32px;
  border-bottom: 1px solid rgba(199, 210, 229, .72);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  color: var(--blue);
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 34% 35%, #ffffff 0 18%, transparent 19%),
    linear-gradient(135deg, #4d6be9, var(--blue));
  box-shadow: 0 8px 18px rgba(43, 69, 159, .25);
}

.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 28px 44px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

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

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-height: 126px;
  display: grid;
  align-content: space-between;
  box-shadow: var(--shadow);
}

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

.stat b {
  display: block;
  font-size: 34px;
  line-height: 1.05;
  margin: 12px 0 7px;
  color: var(--text);
}

.stat small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.login {
  width: min(430px, calc(100vw - 32px));
  margin: 11vh auto;
}

h1, h2 {
  margin: 0 0 16px;
  letter-spacing: 0;
  color: var(--text);
}

h1 { font-size: 24px; }
h2 { font-size: 17px; }

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

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #4d5d78;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 14px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

input, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 69, 159, .14);
}

.actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, 132px);
  gap: 8px;
  align-items: center;
}

.row-actions button {
  width: 132px;
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
}

button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  border-radius: 6px;
  padding: 9px 13px;
  min-height: 38px;
  cursor: pointer;
  font-weight: 750;
  font-size: 13px;
  transition: background .16s ease, border-color .16s ease, box-shadow .16s ease, transform .08s ease;
  box-shadow: 0 6px 14px rgba(43, 69, 159, .14);
}

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

button:active {
  transform: translateY(1px);
}

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

button.secondary {
  color: var(--blue);
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: none;
}

button.secondary:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 6px 14px rgba(192, 54, 44, .13);
}

button.danger:hover {
  background: #a92d25;
  border-color: #a92d25;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

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

.table th {
  color: #61708a;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--panel-soft);
  border-top: 1px solid var(--line);
}

.table th:first-child {
  border-top-left-radius: 6px;
}

.table th:last-child {
  border-top-right-radius: 6px;
}

.table tr:hover td {
  background: #fbfdff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: var(--blue-soft);
  color: var(--blue);
  white-space: nowrap;
}

.badge.online { background: var(--green-soft); color: var(--green); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.queued { background: var(--amber-soft); color: var(--amber); }
.badge.running { background: var(--blue-soft); color: var(--blue); }

.notice {
  border: 1px solid #ffd28a;
  background: #fff9ed;
  color: #8d5000;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-weight: 700;
}

.refresh-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin: -3px 0 16px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
}

.refresh-note::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 132, 95, .12);
}

.warn-text {
  color: var(--amber);
  font-size: 13px;
  font-weight: 650;
}

.code {
  display: block;
  overflow: auto;
  white-space: nowrap;
  background: #13213a;
  color: #edf4ff;
  padding: 12px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.meter {
  width: 160px;
  max-width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf6;
  margin-bottom: 7px;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--green);
}

.meter.progress span {
  background: var(--blue);
}

.toast {
  margin-top: 10px;
  color: var(--muted);
  min-height: 22px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
}

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

@media (max-width: 1100px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }
}

@media (max-width: 900px) {
  .grid, .row, .dash { grid-template-columns: 1fr; }
  .wrap { padding: 16px; }
  .panel { overflow-x: auto; }
  .table { min-width: 1080px; }
}
