:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #16201f;
  --muted: #66736f;
  --line: #d8e0dd;
  --teal: #128477;
  --teal-dark: #0b5f56;
  --amber: #c77916;
  --danger: #b42318;
  --soft-danger: #fff0ed;
  --soft-teal: #e7f4f1;
  --shadow: 0 12px 36px rgba(27, 46, 44, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
  padding: 0 12px;
}

button:hover {
  border-color: var(--teal);
}

button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

button.danger {
  border-color: #f4b5ad;
  background: var(--soft-danger);
  color: var(--danger);
}

button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

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

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

input {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 360px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(18, 132, 119, 0.14);
}

label {
  display: grid;
  gap: 6px;
  color: #344340;
  font-weight: 750;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

dd {
  margin: 0;
  font-weight: 750;
}

.app-shell {
  min-height: 100vh;
}

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

.login-panel {
  display: grid;
  gap: 18px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.brand.compact {
  min-width: 160px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 7px solid var(--teal);
  border-right-color: #e99a2c;
  border-bottom-color: #e66b55;
  border-radius: 8px;
  background: #ffffff;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p,
.section-head p,
.form-message,
.muted,
.empty {
  margin: 0;
  color: var(--muted);
}

.workspace {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
}

.topbar-actions,
.button-row,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-user {
  color: var(--muted);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 60px);
}

.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.nav-item {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  margin-bottom: 8px;
  border-color: transparent;
  background: transparent;
  color: #41504d;
}

.nav-item.is-active {
  background: var(--soft-teal);
  color: var(--teal-dark);
}

.content {
  min-width: 0;
  padding: 22px;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 18px;
}

.section-head,
.panel-head {
  justify-content: space-between;
}

.section-head h1 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.2;
}

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

.status-panel,
.table-panel,
.detail-panel,
.import-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.status-panel h2,
.table-panel h2,
.detail-panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.douyin-status {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft-teal);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  background: #fff5e6;
  color: var(--amber);
}

.badge.danger {
  background: var(--soft-danger);
  color: var(--danger);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

th {
  background: #f7faf9;
  color: #40504c;
  font-size: 12px;
}

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

tr.is-selected td {
  background: #f0faf8;
}

.split {
  display: grid;
  grid-template-columns: minmax(380px, 0.92fr) minmax(420px, 1.08fr);
  gap: 16px;
  align-items: start;
}

.detail-panel {
  display: grid;
  gap: 16px;
}

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

.metric {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

.result-box {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111817;
  color: rgba(255, 255, 255, 0.86);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.import-panel {
  display: grid;
  gap: 14px;
  max-width: 920px;
}

.form-message.is-error {
  color: var(--danger);
  font-weight: 750;
}

@media (max-width: 1080px) {
  .layout,
  .split,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: flex;
    height: auto;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .content {
    padding: 14px;
  }

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

  .status-panel,
  .table-panel,
  .detail-panel,
  .import-panel,
  .login-panel {
    padding: 14px;
  }
}
