:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --line: #dfe5ec;
  --line-strong: #cbd5e1;
  --text: #172033;
  --muted: #667085;
  --subtle: #8a94a6;
  --accent: #d92d3a;
  --accent-hover: #b92330;
  --accent-soft: #fff1f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #087f5b;
  --green-soft: #eaf8f2;
  --amber: #b54708;
  --amber-soft: #fff7e8;
  --danger: #c4320a;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --sidebar-width: 224px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 1px;
}
button:disabled { cursor: not-allowed; opacity: 0.58; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #172033;
  color: #e7ebf1;
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 20px; }
.brand img { border-radius: 8px; display: block; flex: 0 0 auto; }
.brand strong { display: block; font-size: 17px; line-height: 1.35; color: #fff; }
.brand span { display: block; margin-top: 2px; font-size: 12px; color: #aeb8c7; }
.side-nav { display: grid; gap: 5px; }
.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #bec7d4;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: #222d42; color: #fff; }
.nav-item.active { background: #fff; color: #18243a; font-weight: 700; }
.sidebar-footer { margin-top: auto; display: grid; gap: 9px; }
.environment-line { padding: 10px 12px; color: #aeb8c7; font-size: 12px; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #37b27e; box-shadow: 0 0 0 3px rgba(55,178,126,.14); }

.main-shell { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 74px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 28px;
}
.page-heading { min-width: 0; }
.page-heading p { margin: 0 0 3px; font-size: 12px; color: var(--muted); }
.page-heading h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.api-status { height: 30px; display: inline-flex; align-items: center; gap: 7px; padding: 0 10px; border-radius: 6px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.api-status span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.user-chip { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--muted); }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.mobile-only { display: none; }

.view-root { padding: 24px 28px 50px; max-width: 1680px; margin: 0 auto; }
.view-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.view-head h2 { margin: 0; font-size: 19px; }
.view-head p { margin: 5px 0 0; color: var(--muted); }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 12px; font-weight: 800; }

.button {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { background: #fff; border-color: var(--line); }
.button.secondary:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.button.blue { color: #fff; background: var(--blue); }
.button.small { min-height: 30px; padding: 0 10px; font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 17px; display: flex; align-items: center; gap: 13px; }
.metric-icon { width: 42px; height: 42px; border-radius: 7px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); flex: 0 0 auto; }
.metric-card:nth-child(2) .metric-icon { color: var(--green); background: var(--green-soft); }
.metric-card:nth-child(3) .metric-icon { color: var(--accent); background: var(--accent-soft); }
.metric-card:nth-child(4) .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { display: block; margin-top: 4px; font-size: 25px; line-height: 1; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.panel-head { min-height: 54px; padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h3 { margin: 0; font-size: 15px; }
.panel-head span { color: var(--muted); font-size: 12px; }
.empty-state { min-height: 220px; padding: 36px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state svg { width: 30px; height: 30px; margin-bottom: 10px; color: var(--subtle); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 5px; }

.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { background: var(--surface-muted); color: var(--muted); font-size: 12px; font-weight: 700; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfe; }
.dashboard-grid > .panel:first-child .data-table { min-width: 0; table-layout: fixed; }
.dashboard-grid > .panel:first-child .data-table th:first-child { width: 38%; }
.dashboard-grid > .panel:first-child .data-table th:nth-child(2) { width: 10%; }
.dashboard-grid > .panel:first-child .data-table th:nth-child(3),
.dashboard-grid > .panel:first-child .data-table th:nth-child(4) { width: 19%; }
.dashboard-grid > .panel:first-child .data-table th:nth-child(6) { width: 14%; }
.dashboard-grid > .panel:first-child .data-table th:nth-child(5),
.dashboard-grid > .panel:first-child .data-table td:nth-child(5) { display: none; }
.dashboard-grid > .panel:first-child .table-title { min-width: 0; }
.table-title { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.table-thumb { width: 42px; height: 42px; border-radius: 6px; background: #edf1f5; object-fit: cover; flex: 0 0 auto; }
.table-title strong { display: block; max-width: 340px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.table-title span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.table-actions { display: flex; gap: 7px; }
.status-badge { min-height: 24px; border-radius: 5px; padding: 3px 8px; display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; background: #eef2f6; color: #475467; }
.status-badge.success { background: var(--green-soft); color: var(--green); }
.status-badge.running { background: var(--blue-soft); color: var(--blue); }
.status-badge.warning { background: var(--amber-soft); color: var(--amber); }
.status-badge.danger { background: #fff0ed; color: var(--danger); }

.activity-list { list-style: none; padding: 4px 16px 10px; margin: 0; }
.activity-item { position: relative; padding: 13px 0 13px 20px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-item::before { content: ""; position: absolute; left: 1px; top: 19px; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.activity-item strong { display: block; font-size: 13px; }
.activity-item p { margin: 4px 0; color: var(--muted); line-height: 1.5; }
.activity-item time { color: var(--subtle); font-size: 11px; }

.project-editor { display: grid; gap: 16px; }
.editor-head { display: flex; align-items: center; gap: 12px; }
.editor-head .button { flex: 0 0 auto; }
.editor-title { min-width: 0; }
.editor-title h2 { margin: 0; font-size: 19px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.editor-title p { margin: 5px 0 0; color: var(--muted); }
.editor-actions { margin-left: auto; display: flex; gap: 8px; }
.editor-layout { display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(340px, .85fr); gap: 16px; align-items: start; }
.media-workspace, .settings-workspace { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.workspace-head { min-height: 54px; border-bottom: 1px solid var(--line); padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.workspace-head h3 { margin: 0; font-size: 15px; }
.video-stage { min-height: 500px; padding: 18px; background: #111722; display: grid; place-items: center; }
.video-stage video { max-width: 100%; max-height: 560px; background: #06090e; border-radius: 5px; display: block; }
.upload-stage { width: min(520px, 100%); min-height: 290px; border: 1px dashed #526077; border-radius: 7px; display: grid; place-items: center; color: #d1d8e3; text-align: center; padding: 30px; }
.upload-stage svg { width: 36px; height: 36px; margin-bottom: 12px; }
.upload-stage strong { display: block; color: #fff; margin-bottom: 7px; }
.upload-stage p { margin: 0 0 16px; color: #aeb8c7; }
.media-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.media-meta div { padding: 12px 14px; border-right: 1px solid var(--line); min-width: 0; }
.media-meta div:last-child { border-right: 0; }
.media-meta span { display: block; color: var(--muted); font-size: 11px; }
.media-meta strong { display: block; margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.settings-content { padding: 16px; display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid label, .field-label { display: grid; gap: 6px; min-width: 0; }
.form-grid label > span, .field-label > span { color: #344054; font-size: 12px; font-weight: 700; }
.form-grid .full { grid-column: 1 / -1; }
input, textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; color: var(--text); padding: 9px 10px; }
input { min-height: 38px; }
textarea { resize: vertical; min-height: 76px; line-height: 1.55; }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); }
.segmented button { min-height: 34px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; font-weight: 700; }
.segmented button.active { background: #fff; color: var(--accent); box-shadow: 0 1px 4px rgba(16,24,40,.1); }
.trim-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settings-divider { height: 1px; background: var(--line); }
.cover-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; align-items: stretch; }
.cover-preview { aspect-ratio: 3 / 4; width: 116px; background: #eef2f6; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; }
.cover-actions { display: grid; align-content: center; gap: 8px; }
.helper { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0; }
.progress-block { border: 1px solid var(--line); border-radius: 7px; padding: 12px; background: var(--surface-muted); }
.progress-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.progress-track { height: 7px; border-radius: 4px; background: #e4e9f0; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--blue); transition: width .3s; }
.error-box { border: 1px solid #fbc5bb; background: #fff6f4; color: var(--danger); border-radius: 6px; padding: 10px 12px; line-height: 1.5; }

.material-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.material-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.material-preview { aspect-ratio: 16 / 10; background: #111722; display: grid; place-items: center; overflow: hidden; }
.material-preview img, .material-preview video { width: 100%; height: 100%; object-fit: cover; }
.material-preview svg { color: #bbc5d3; width: 30px; height: 30px; }
.material-info { padding: 12px; }
.material-info strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.material-info span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }

.modal { width: min(520px, calc(100vw - 30px)); border: 0; border-radius: 8px; padding: 0; color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(16,24,40,.55); }
.modal form { padding: 18px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { background: #172033; color: #fff; border-radius: 7px; padding: 12px 14px; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.error { background: #8f1d28; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.login-page { min-height: 100vh; display: grid; place-items: center; background: #eef1f5; padding: 24px; }
.login-shell { width: min(430px, 100%); }
.login-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.brand-login { padding: 0 0 28px; border-bottom: 1px solid var(--line); }
.brand-login strong { color: var(--text); }
.brand-login span { color: var(--muted); }
.login-heading { padding: 25px 0 18px; }
.login-heading h1 { margin: 0; font-size: 24px; }
.login-heading > p:last-child { margin: 7px 0 0; color: var(--muted); }
.login-form { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 7px; }
.login-form label span { font-size: 12px; font-weight: 700; color: #344054; }
.login-form input { min-height: 44px; }
.login-submit { min-height: 44px; margin-top: 3px; }
.form-error { margin: 0; border-radius: 6px; padding: 10px; background: #fff0ed; color: var(--danger); }
.login-footnote { margin: 20px 0 0; text-align: center; color: var(--subtle); font-size: 12px; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .editor-layout { grid-template-columns: 1fr; }
  .material-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: min(82vw, 270px); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 12px 0 40px rgba(16,24,40,.25); }
  .mobile-only { display: inline-grid; }
  .topbar { padding: 10px 14px; min-height: 66px; }
  .api-status, .user-chip { display: none; }
  .view-root { padding: 18px 14px 36px; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .view-actions { justify-content: flex-start; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-head { align-items: flex-start; flex-wrap: wrap; }
  .editor-actions { margin-left: 0; width: 100%; }
  .video-stage { min-height: 360px; }
  .media-meta { grid-template-columns: 1fr 1fr; }
  .media-meta div:nth-child(2) { border-right: 0; }
  .media-meta div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 480px) {
  .metrics, .material-grid { grid-template-columns: 1fr; }
  .form-grid, .trim-grid { grid-template-columns: 1fr; }
  .cover-row { grid-template-columns: 94px minmax(0, 1fr); }
  .cover-preview { width: 94px; }
  .login-panel { padding: 22px; }
}
