:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #20242c;
  --muted: #667085;
  --line: #d9dee8;
  --accent: #2563eb;
  --green: #198754;
  --red: #c2410c;
  --yellow: #a16207;
  --blue: #1d4ed8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button, input, select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111827;
  color: white;
  padding: 20px 14px;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  margin: 4px 8px 24px;
}

.nav {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 11px 12px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 4px;
}

.nav:hover, .nav.active {
  background: #243044;
  color: white;
}

main {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 26px;
}

h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

p {
  margin: 0;
  color: var(--muted);
}

#content {
  padding: 24px 26px 40px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.card .label {
  color: var(--muted);
  font-size: 13px;
}

.card .value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.hint, .empty {
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

button.danger {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

button {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}

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

input {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  min-width: 220px;
}

select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: white;
  min-width: 220px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tableWrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
}

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

th {
  background: #eef2f7;
  color: #344054;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #e5e7eb;
}

.progressText {
  font-size: 13px;
  color: #344054;
  margin-bottom: 6px;
  white-space: nowrap;
}

.progressBar {
  width: 180px;
  max-width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

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

.ok { color: var(--green); }
.bad { color: var(--red); }
.warn { color: var(--yellow); }
.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
  word-break: break-all;
}

.logbox {
  background: #0f172a;
  color: #d1d5db;
  border-radius: 8px;
  padding: 12px;
  height: 520px;
  overflow: auto;
  font-family: Consolas, monospace;
  font-size: 13px;
}

.logline {
  margin-bottom: 6px;
}

.auth {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.authStatus {
  font-size: 12px;
  min-width: 48px;
}

.formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.field input {
  width: 100%;
}

.field select {
  width: 100%;
}

.checkboxField {
  align-content: start;
}

.checkboxField input {
  min-width: 0;
  width: 20px;
  height: 20px;
}

.picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.pickerHead {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  background: #eef2f7;
  padding: 10px;
  flex-wrap: wrap;
}

.pickerList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 10px;
}

.pickerList button {
  text-align: left;
}

.libraryLayout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.folderPane {
  position: sticky;
  top: 18px;
}

.folderActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.breadcrumb {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.breadcrumb button {
  padding: 4px 8px;
}

.folderList {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.folderItem {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 10px 12px;
}

.folderName {
  font-weight: 600;
}

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

.libraryFiles {
  min-width: 0;
}

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

.liveList {
  display: grid;
  gap: 12px;
}

.liveCard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcff;
}

.liveCard.active {
  border-color: #93c5fd;
  background: #eff6ff;
}

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

.liveLabel {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.liveCard h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
  word-break: break-word;
}

.liveFile {
  margin-top: 12px;
  padding: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.liveMeta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.liveEmpty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
}

details.panel summary {
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
}

details.panel[open] summary {
  margin-bottom: 12px;
}

.panelHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panelHead h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    padding: 12px;
  }
  .brand {
    margin: 0 4px 12px;
  }
  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav {
    width: auto;
    white-space: nowrap;
    margin-bottom: 0;
    flex: 0 0 auto;
  }
  .topbar {
    display: block;
    padding: 14px 16px;
  }
  h1 {
    font-size: 21px;
  }
  #content {
    padding: 14px 14px 28px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .card, .panel {
    padding: 12px;
  }
  .card .value {
    font-size: 22px;
  }
  .actions {
    gap: 8px;
  }
  .actions button, .actions input {
    flex: 1 1 150px;
  }
  input, select {
    min-width: 0;
    width: 100%;
  }
  .auth {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
  }
  .libraryLayout {
    grid-template-columns: 1fr;
  }
  .folderPane {
    position: static;
  }
  .folderList {
    max-height: none;
  }
  .liveCardHead {
    display: grid;
  }
  .liveCard h3 {
    font-size: 17px;
  }
  .liveMeta {
    gap: 8px;
  }
  .panelHead {
    display: grid;
  }
  .progressBar {
    width: 140px;
  }
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .actions button, .actions input {
    flex-basis: 100%;
  }
  .folderActions button {
    flex: 1 1 120px;
  }
  .breadcrumb {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .breadcrumb button, .breadcrumb span {
    flex: 0 0 auto;
  }
}
