:root {
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-alt: #f7f9fb;
  --text: #1e2933;
  --muted: #617180;
  --line: #d8e0e7;
  --primary: #176b87;
  --primary-strong: #0f536b;
  --accent: #d4562f;
  --success: #1f8a5b;
  --warning: #a76a00;
  --danger: #ba3434;
  --shadow: 0 18px 40px rgba(30, 41, 51, .08);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

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

.login-panel,
.upload-panel,
.queue-panel,
.dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
}

.app-view {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.panel-title,
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

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

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  min-height: 36px;
  padding: 7px 14px;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tab[hidden] {
  display: none;
}

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

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

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

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.upload-panel,
.queue-panel {
  padding: 18px;
}

.upload-panel {
  display: grid;
  gap: 15px;
}

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

label {
  display: grid;
  gap: 7px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.toggle-row span {
  color: var(--text);
}

label span,
.file-input > span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  outline: none;
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, .12);
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.file-input input {
  padding: 9px;
  background: var(--surface-alt);
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  white-space: nowrap;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

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

.button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.button.ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.button.wide {
  width: 100%;
}

.button:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.icon {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  font-weight: 700;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--text);
  font-size: 24px;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  line-height: 1.35;
}

.mono {
  font-family: Consolas, "Liberation Mono", monospace;
}

.hash {
  max-width: 220px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  min-height: 24px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.pill.neutral {
  background: #e8edf1;
  color: #4e5d6a;
}

.pill.created,
.pill.expired {
  background: #fff1d8;
  color: var(--warning);
}

.pill.claimed,
.pill.processing,
.pill.verifying {
  background: #ddf1f5;
  color: var(--primary);
}

.pill.success {
  background: #dff3e8;
  color: var(--success);
}

.pill.failed {
  background: #f8dddd;
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.settings-form {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: var(--surface-alt);
}

.worker-queue {
  display: grid;
  gap: 12px;
}

.worker-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-alt);
}

.worker-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf1;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.worker-meta,
.worker-events {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.worker-event {
  display: grid;
  grid-template-columns: 150px 52px minmax(0, 1fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 5px;
}

.app-summary {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #e8edf1;
  object-fit: cover;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 700;
}

.link-button.danger {
  color: var(--danger);
}

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: var(--muted);
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
}

.dialog::backdrop {
  background: rgba(30, 41, 51, .46);
}

.dialog-head {
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.dialog-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  max-height: calc(100vh - 150px);
  padding: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px 14px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.event {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--surface-alt);
}

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

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

  .worker-card-head {
    flex-direction: column;
  }

  .worker-event {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .app-view {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

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

  h1 {
    font-size: 22px;
  }

  .login-panel {
    padding: 22px;
  }
}
