:root {
  --bg: #0e1420;
  --panel: #162235;
  --text: #ebf3ff;
  --muted: #9fb3cb;
  --ok: #29c26f;
  --warn: #ffb020;
  --danger: #e44c4c;
  --line: #2d3f5b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, #1c365f 0%, var(--bg) 60%);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.actions {
  display: flex;
  gap: 10px;
}

button,
.link-btn {
  background: #1f3555;
  color: var(--text);
  border: 1px solid #31527e;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
}

button.danger {
  border-color: #834040;
  background: #4a2020;
}

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

.grid.single {
  grid-template-columns: 1fr;
  max-width: 760px;
  margin: 20px auto;
}

.panel {
  background: linear-gradient(180deg, #182a42 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.panel h2 {
  margin-top: 0;
}

.wide {
  min-height: 300px;
}

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

.resource-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #0f1b2d;
}

.resource-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.resource-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.hp-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #243552;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #f25d5d, #ffcc52);
}

.kv {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kv li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed #2b3d5a;
}

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

.kv-editable {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: #243e64;
  border: 1px solid #3f6a9f;
  border-radius: 6px;
  color: var(--text);
  padding: 2px 8px;
  line-height: 1.2;
}

.entry-box {
  display: flex;
  gap: 10px;
}

.text-input {
  flex: 1;
  background: #0f1b2d;
  color: var(--text);
  border: 1px solid #31527e;
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}

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

.car-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.car-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, #101f33 0%, #0f1b2d 100%);
}

.car-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.car-id {
  font-family: Consolas, monospace;
  font-size: 15px;
}

.car-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #3d5677;
  color: #cfe0fb;
}

.car-badge.active {
  border-color: #6a5a1f;
  color: #ffe29a;
  background: #3a3010;
}

.car-badge.idle {
  border-color: #3b5f88;
  color: #b8d7ff;
  background: #1c3658;
}

.car-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.car-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.car-name-editor {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.car-name-editor .text-input {
  min-width: 0;
}

.car-team-select {
  background: #1f3555;
  color: var(--text);
  border: 1px solid #31527e;
  border-radius: 6px;
  padding: 5px 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.settings-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: grid;
  place-items: center;
}

.hidden {
  display: none;
}

.modal-content {
  width: min(960px, 94vw);
  max-height: 80vh;
  background: #101a2a;
  border: 1px solid #334e74;
  border-radius: 12px;
  overflow: hidden;
}

.modal-content.small {
  width: min(420px, 92vw);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #2b3e5a;
}

.modal-body {
  padding: 12px;
}

.home-float-card {
  border-color: #44699a;
}

.home-float-title {
  margin: 0 0 10px;
  font-size: 18px;
}

.home-float-text {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
}

.home-float-actions {
  justify-content: flex-end;
}

.log-list {
  max-height: calc(80vh - 60px);
  overflow: auto;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.log-row {
  padding: 8px 12px;
  border-bottom: 1px solid #1f2f47;
}

.log-row .time {
  color: #8eb7ff;
  margin-right: 8px;
}

.log-row .level {
  margin-right: 8px;
  color: var(--warn);
}

.log-row .msg {
  color: #d7e6ff;
}

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

  .resource-list {
    grid-template-columns: 1fr;
  }
}
