:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-strong: #eef5f3;
  --ink: #20272e;
  --muted: #66727f;
  --line: #dce2e7;
  --brand: #1b7f70;
  --brand-dark: #12675b;
  --accent: #b45b35;
  --warn: #a86d00;
  --danger: #b33a3a;
  --shadow: 0 18px 45px rgba(25, 41, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

button,
label.file-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.16s ease,
    border 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

button:active,
label.file-button:active {
  transform: translateY(1px);
}

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

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

.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.ghost:hover {
  border-color: #b7c1ca;
  background: #f8fafb;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.app-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 76px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1,
.topbar p,
.sidebar h2,
.panel-head h2,
.panel-head p,
.dialog-form h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.25;
}

.topbar p,
.panel-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button input {
  display: none;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 18px 14px;
  min-height: calc(100vh - 76px);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 12px;
}

.device-head {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.side-head h2,
.panel-head h2,
.dialog-form h2 {
  font-size: 16px;
}

.region-list,
.device-list {
  display: grid;
  gap: 8px;
}

.device-button {
  width: 100%;
  border-color: transparent;
  background: transparent;
  min-height: 56px;
  padding: 9px 10px;
  justify-content: flex-start;
  color: var(--ink);
}

.device-button:hover,
.device-button.is-active {
  background: var(--panel-strong);
  border-color: #cae0db;
}

.device-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.device-main strong,
.device-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-main strong {
  font-size: 14px;
}

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

.device-badge {
  margin-left: auto;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.content {
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.search-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 190px 180px auto;
  gap: 12px;
  align-items: end;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27, 127, 112, 0.14);
}

.status-strip {
  min-height: 76px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 5px;
  min-width: 0;
}

.status-item strong {
  font-size: 14px;
}

.status-item span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status-item.ok {
  border-color: #b9d8c7;
  background: #f5fbf7;
}

.status-item.warn {
  border-color: #e4c891;
  background: #fff9ec;
}

.status-item.info {
  border-color: #bdd6e5;
  background: #f2f8fb;
}

.split-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.version-table-panel,
.detail-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  min-height: 0;
  box-shadow: var(--shadow);
}

.version-table-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

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

.segmented {
  height: 34px;
  display: inline-grid;
  grid-template-columns: repeat(3, auto);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.segment.is-active {
  background: var(--brand);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfd;
  position: sticky;
  top: 0;
  z-index: 1;
}

th:nth-child(1),
td:nth-child(1) {
  width: 10%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 15%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 11%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 10%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 18%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 18%;
}

th:nth-child(7),
td:nth-child(7),
th:nth-child(8),
td:nth-child(8) {
  width: 8%;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f5faf9;
}

.version-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.tag {
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
}

.tag.latest {
  border-color: #a8cfbf;
  color: var(--brand-dark);
  background: #edf8f4;
}

.tag.test {
  border-color: #e7c29f;
  color: var(--accent);
  background: #fff6ee;
}

.cell-text {
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-panel {
  padding: 16px;
  overflow: auto;
}

.detail-empty {
  height: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.detail-title h2 {
  margin: 0;
  font-size: 18px;
}

.detail-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.detail-section {
  margin-top: 16px;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.issue-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.issue-list li {
  overflow-wrap: anywhere;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.path-text {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(18, 31, 41, 0.22);
}

dialog::backdrop {
  background: rgba(19, 28, 36, 0.38);
}

.dialog-form {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.dialog-form header,
.dialog-form menu {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-form menu span {
  flex: 1;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #17212b;
  color: #fff;
  min-height: 42px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 14px;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(20, 31, 42, 0.2);
  z-index: 20;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .search-panel {
    grid-template-columns: minmax(220px, 1fr) 170px 170px;
  }

  .search-panel button {
    grid-column: 1 / -1;
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    min-height: 280px;
  }
}

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

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

  .sidebar {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .region-list,
  .device-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .content {
    padding: 12px;
  }

  .search-panel,
  .status-strip,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }

  table {
    min-width: 1080px;
  }
}
