:root {
  --surface-0: #f5f7f8;
  --surface-1: #ffffff;
  --surface-2: #eef2f4;
  --surface-3: #e4e9eb;
  --surface-4: #cad4d8;
  --accent: #147d70;
  --accent-dim: #0f675d;
  --text: #1c282e;
  --text-muted: #586a70;
  --danger: #bd463a;
  --radius: 8px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", "Microsoft YaHei UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  line-height: 1.6;
  background: var(--surface-0);
  color: var(--text);
  padding: var(--space-lg);
}
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; margin: var(--space-lg) 0 var(--space-md); }
h3 { font-size: 16px; font-weight: 600; margin: var(--space-md) 0 var(--space-sm); }
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: var(--space-xs) var(--space-md);
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
  transition: background 0.15s;
}
button:hover { background: var(--accent-dim); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--surface-3); color: var(--text); }
button.secondary:hover { background: var(--surface-4); }
button.quiet { background: transparent; color: var(--accent); padding: var(--space-xs) var(--space-sm); }
button.quiet:hover { background: var(--surface-3); }
button.danger { background: var(--danger); color: white; }
button.quiet.danger { background: transparent; color: var(--danger); }
button.quiet.danger:hover { background: rgba(239, 68, 68, 0.1); }
button.active { background: var(--accent); color: #ffffff; }
input, select, textarea {
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--surface-4);
  border-radius: var(--radius);
  padding: var(--space-xs) var(--space-sm);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; }
.field { display: grid; gap: var(--space-xs); }
.field > span { font-size: 0.9em; color: var(--text-muted); font-weight: 500; }
.check { display: flex; align-items: center; gap: var(--space-xs); }
.check input { width: auto; }
.mono { font-family: "SF Mono", Monaco, Consolas, monospace; font-size: 0.9em; }
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); text-align: center; padding: var(--space-lg); }
#app { max-width: 1400px; margin: 0 auto; }
#header {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0 var(--space-lg);
  border-bottom: 1px solid var(--surface-3);
  margin-bottom: var(--space-lg);
}
#nav { display: flex; gap: var(--space-sm); }
#nav button { background: transparent; color: var(--text-muted); }
#nav button.active { background: var(--accent); color: white; }
#revision { font-size: 0.85em; color: var(--text-muted); }
#toast {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  background: var(--surface-4);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 1000;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--surface-3);
}
.section-head > span { font-size: 0.9em; color: var(--text-muted); }
.table-wrap { overflow-x: auto; margin-bottom: var(--space-lg); }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-1);
  border-radius: var(--radius);
}
th, td { padding: var(--space-sm) var(--space-md); text-align: left; }
th { font-weight: 600; font-size: 0.9em; color: var(--text-muted); border-bottom: 1px solid var(--surface-3); }
td { border-bottom: 1px solid var(--surface-2); }
tr:last-child td { border: none; }
td strong { display: block; margin-bottom: 2px; }
td small { display: block; font-size: 0.85em; color: var(--text-muted); }
.url-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.device-line { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); padding: 4px 0; }
dialog {
  margin: auto;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--surface-4);
  border-radius: var(--radius);
  max-width: 700px;
  width: 90vw;
  max-height: 85vh;
  padding: 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
dialog::backdrop { background: rgba(25,39,43,0.45); }
#dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--surface-3);
}
#editor-body { padding: var(--space-lg); overflow-y: auto; max-height: calc(85vh - 140px); }
#dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--surface-3);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: var(--space-md); margin-bottom: var(--space-md); }
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: var(--space-lg) 0 var(--space-md);
}
.toolbar-actions { display: flex; gap: var(--space-sm); }
#remote-picker {
  display: flex;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--surface-3);
  border-radius: var(--radius);
}
#remote-picker select { flex: 1; }
#model-list { display: grid; gap: var(--space-md); }
.model-row {
  background: var(--surface-3);
  border-radius: var(--radius);
  padding: var(--space-md);
}
.model-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}
.custom-fields[hidden] { display: none; }
.effort-fields { display: grid; gap: var(--space-sm); }
.field-title { font-size: 0.9em; color: var(--text-muted); font-weight: 500; }
.effort-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.effort-list label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--space-sm);
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.9em;
  cursor: pointer;
}
.effort-list input { width: auto; }
.default-effort { margin-top: var(--space-xs); }
.config-checks {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.config-checks label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-sm);
  align-items: start;
  padding: var(--space-sm);
  background: var(--surface-2);
  border-radius: var(--radius);
  cursor: pointer;
}
.config-checks input { width: auto; margin-top: 2px; }
.config-checks span { display: block; }
.config-checks small { display: block; font-size: 0.85em; color: var(--text-muted); margin-top: 2px; }
.toggle-field { display: flex; align-items: center; gap: var(--space-md); }
.advanced { margin-top: var(--space-md); }
.advanced summary {
  cursor: pointer;
  padding: var(--space-xs);
  color: var(--text-muted);
  font-size: 0.9em;
}
.advanced[open] summary { margin-bottom: var(--space-md); }
.model-row .advanced .check { margin: 8px 0; }
.model-row textarea { min-height: 96px; resize: vertical; }
.release { margin-top: var(--space-lg); padding: var(--space-md) 0; border-top: 1px solid var(--surface-3); }
.release summary { font-weight: 600; margin-bottom: var(--space-md); }
.release-grid { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-md); align-items: end; }
.release-grid button { grid-column: 2; }
#login {
  max-width: 400px;
  margin: 10vh auto;
  padding: var(--space-xl);
  background: var(--surface-1);
  border-radius: var(--radius);
}
#login h1 { margin-bottom: var(--space-lg); }
#login-form { display: grid; gap: var(--space-md); }
#login-error { color: var(--danger); font-size: 0.9em; }
@media (max-width: 760px) {
  body { padding: 12px; }
  #header { grid-template-columns: 1fr auto; gap: 8px; }
  #nav { grid-column: 1 / -1; grid-row: 2; }
  #revision { display: none; }
  #refresh, #logout { grid-row: 3; }
  .release-grid { grid-template-columns: 1fr; }
  .release-grid button { grid-column: 1; }
  .toolbar { align-items: flex-start; gap: 8px; flex-wrap: wrap; }
}
