:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d9e2ef;
  --blue: #2f6bff;
  --navy: #1f3a5f;
  --teal: #00a6a6;
  --green: #20a464;
  --amber: #f59e0b;
  --red: #dc2626;
  --radius: 8px;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #17243a;
  color: white;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.target-card small,
.target-card span {
  color: #b9c6d8;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #d8e3f2;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: #253754;
  color: white;
}

.target-card {
  margin-top: auto;
  background: #203451;
  border: 1px solid #334b70;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.target-card strong {
  font-size: 16px;
  color: #ffffff;
  line-height: 1.25;
  white-space: nowrap;
}

.target-card strong span {
  color: #ffffff;
  font-size: 16px;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

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

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

label {
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

.button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 9px 13px;
  cursor: pointer;
  white-space: nowrap;
}

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

.button.ghost {
  background: white;
  color: var(--text);
}

.button:hover,
.text-button:hover,
.icon-button:hover {
  filter: brightness(0.97);
}

.import-label input {
  display: none;
}

.name-field input {
  min-width: 180px;
}

.user-badge {
  min-height: 38px;
  min-width: 150px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 6px 10px;
  display: grid;
  gap: 1px;
}

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

.user-badge strong {
  font-size: 14px;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background:
    linear-gradient(90deg, rgb(5 18 42 / 0.18), rgb(5 18 42 / 0.08)),
    url("./assets/login-bg.png") center / cover no-repeat;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-overlay.visible {
  display: flex;
}

.auth-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 8px;
  border: 1px solid rgb(255 255 255 / 0.36);
  box-shadow: 0 28px 90px rgb(15 23 42 / 0.34);
  padding: 22px;
}

.auth-head h2 {
  margin: 0;
  font-size: 26px;
}

.auth-head p {
  margin: 6px 0 18px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card {
  padding: 16px;
  display: grid;
  gap: 6px;
}

.clickable-card {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.clickable-card:hover {
  transform: translateY(-2px);
  border-color: #b9ccf3;
  box-shadow: 0 12px 28px rgb(15 23 42 / 0.12);
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 30px;
}

.metric-card.warning strong {
  color: var(--amber);
}

.metric-card.danger strong {
  color: var(--red);
}

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

.panel {
  padding: 16px;
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2,
.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.text-button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
}

.progress-list,
.risk-list {
  display: grid;
  gap: 12px;
}

.progress-row {
  display: grid;
  gap: 6px;
}

.progress-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.bar {
  height: 10px;
  background: #e7edf6;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.risk-item,
.mini-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 120px 110px 1fr;
  gap: 10px;
  align-items: center;
}

.risk-item {
  grid-template-columns: minmax(180px, 1fr) 90px 110px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--text);
  white-space: nowrap;
}

.pill.done {
  background: #dcfce7;
  color: #166534;
}

.pill.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.warn {
  background: #fef3c7;
  color: #92400e;
}

.pill.bad {
  background: #fee2e2;
  color: #991b1b;
}

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(120px, 1fr) minmax(120px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.compact-filters {
  grid-template-columns: minmax(180px, 1.4fr) minmax(130px, 1fr) minmax(130px, 1fr) auto;
}

.action-panel {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.action-panel p {
  margin: 6px 0 0;
  color: var(--muted);
}

.table-panel {
  overflow: hidden;
}

.market-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

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

.table-tools label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.page-size-select {
  min-height: 34px;
  min-width: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 6px 8px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 260px);
}

.script-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 14px;
}

.pagination-bar {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.script-card {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  display: grid;
  gap: 12px;
  min-height: 210px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.script-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgb(15 23 42 / 0.14);
}

.script-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
}

.script-card.ai-card {
  background: linear-gradient(180deg, #eef5ff 0%, #ffffff 42%);
  border-color: #bfd4ff;
}

.script-card.ai-card::before {
  background: linear-gradient(90deg, #2f6bff, #00a6a6);
}

.script-card.ppt-card {
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 42%);
  border-color: #fed7aa;
}

.script-card.ppt-card::before {
  background: linear-gradient(90deg, #f59e0b, #20a464);
}

.script-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  color: #10233f;
  padding-top: 3px;
}

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

.type-chip {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.type-chip.ai-chip {
  color: #ffffff;
  background: #2f6bff;
  border: 1px solid #2f6bff;
}

.type-chip.ppt-chip {
  color: #ffffff;
  background: #20a464;
  border: 1px solid #20a464;
}

.script-card .cn-title {
  color: var(--muted);
  margin-top: 4px;
  min-height: 20px;
}

.script-card-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.script-card-meta div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgb(255 255 255 / 0.72);
  border: 1px solid rgb(217 226 239 / 0.8);
  border-radius: 8px;
  padding: 8px 9px;
}

.script-card-meta strong {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.script-card-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.script-card-actions .small-button.primary {
  grid-column: 3;
}

.script-card-actions .claim-button {
  grid-column: 3;
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

.script-card-actions .claim-button:not(:disabled):hover {
  background: #bfdbfe;
}

.script-card-actions .claim-button:disabled {
  color: #64748b;
  background: #e5e7eb;
  border-color: #d1d5db;
  opacity: 1;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  grid-column: 1 / -1;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

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

th {
  position: sticky;
  top: 0;
  background: #eef4ff;
  z-index: 1;
  color: #28466f;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fbff;
}

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

.settings-panel {
  max-width: 980px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
}

.rules-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.rules-grid p {
  color: var(--muted);
  margin-bottom: 0;
}

.dialog {
  width: min(980px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgb(15 23 42 / 0.24);
}

.dialog::backdrop {
  background: rgb(15 23 42 / 0.38);
}

.dialog form {
  padding: 18px;
}

.dialog-body {
  padding: 18px;
}

.compact-dialog {
  width: min(620px, calc(100vw - 32px));
}

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

.dialog-head h2,
.dialog-head p {
  margin: 0;
}

.dialog-head p {
  color: var(--muted);
  margin-top: 4px;
}

.icon-button {
  font-size: 28px;
  color: var(--muted);
}

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

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: 1 / -1;
}

.simplified-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.simplified-form textarea {
  margin-top: 0;
}

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

.form-warning {
  margin-top: 12px;
  color: #991b1b;
  background: #fee2e2;
  border-radius: 8px;
  padding: 10px;
  display: none;
}

.form-success {
  margin-top: 12px;
  color: #166534;
  background: #dcfce7;
  border-radius: 8px;
  padding: 10px;
  display: none;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}

.compact-actions {
  grid-template-columns: 1fr auto auto;
}

.danger-text {
  color: var(--red) !important;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}

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

.small-button.online-fanfan {
  color: #ffffff;
  background: #2f6bff;
  border-color: #2f6bff;
}

.small-button.online-h5 {
  color: #ffffff;
  background: #20a464;
  border-color: #20a464;
}

.small-button.danger-button {
  color: #b91c1c;
  background: #fee2e2;
  border-color: #fecaca;
}

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

.video-link-content {
  min-height: 120px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
  line-height: 1.7;
  color: var(--text);
}

.pill.fanfan-online {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.h5-online {
  background: #dcfce7;
  color: #15803d;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.review-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.review-meta {
  color: var(--muted);
  font-size: 13px;
}

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

  .sidebar {
    position: static;
  }

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

  .target-card {
    margin-top: 0;
  }

  .metric-grid,
  .content-grid,
  .filters,
  .compact-filters,
  .script-card-grid,
  .form-grid,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .panel.wide {
    grid-column: auto;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }
}
