:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-soft: #f8f7f4;
  --text: #202422;
  --muted: #707974;
  --line: #e6e2dc;
  --primary: #3b6f68;
  --primary-dark: #294f4a;
  --primary-soft: #e9f2ef;
  --green: #277a58;
  --orange: #b56622;
  --red: #b84b55;
  --blue: #426f9e;
  --sidebar: rgba(255, 255, 255, .88);
  --shadow: 0 14px 36px rgba(37, 44, 40, .08);
  --shadow-soft: 0 5px 16px rgba(37, 44, 40, .05);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: var(--text);
  background: var(--sidebar);
  border-right: 1px solid rgba(230, 226, 220, .85);
  backdrop-filter: blur(14px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 22px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}
.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
}
.current-project {
  margin: 2px 6px 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfaf7;
}
.current-project span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.current-project strong { display: block; margin-top: 4px; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a {
  padding: 11px 12px;
  border-radius: 12px;
  color: #59635e;
  text-decoration: none;
  font-weight: 700;
}
.sidebar nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }
.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding: 12px;
  color: var(--muted);
}
.link-button { border: 0; background: none; color: var(--primary); cursor: pointer; }

.page {
  min-height: 100vh;
  margin-left: 232px;
  padding: 30px 38px 64px;
}
.topline {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 12px;
}
.topline a { margin-right: auto; color: var(--primary); text-decoration: none; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-header h1 { margin: 0 0 5px; font-size: 30px; letter-spacing: -.55px; }
.page-header p, .muted { margin: 0; color: var(--muted); }
.eyebrow { display: none; }

.primary, .secondary, .danger, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary { background: #fff; color: var(--primary-dark); border-color: #cfddd8; }
.secondary:hover { background: var(--primary-soft); }
.danger { background: #fbeaec; color: var(--red); }
.danger:hover { background: #f5dadd; }
.wide { width: 100%; }

.notice {
  padding: 12px 15px;
  margin-bottom: 16px;
  border: 1px solid;
  border-radius: 10px;
}
.notice.success { border-color: #c8e5d8; background: #edf8f2; color: #176445; }
.notice.error { border-color: #efcdd0; background: #fff1f2; color: #922d34; }

.panel, .row-card, .project-card, .asset-card, .report-card, .metric-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel { padding: 20px; margin: 16px 0; }
.panel > h2 { margin-top: 0; }
.panel > summary, .form-panel summary {
  color: #303733;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.production-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.production-tools .panel { margin-top: 0; }

.tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.tabs a {
  padding: 10px 2px 11px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}
.tabs a.active { border-color: var(--primary); color: var(--primary-dark); font-weight: 800; }
.tabs b {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  margin-left: 4px;
  place-items: center;
  border-radius: 7px;
  background: #ecefeb;
  color: #5e6862;
  font-size: 11px;
}

.inline-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 15px;
}
.stack-form { display: grid; gap: 12px; }
.stack-form.compact { margin: 12px 0; }
.inline-form label, .stack-form label, .filter-bar label {
  display: grid;
  gap: 6px;
  color: #4f5853;
  font-size: 12px;
}
input, select, textarea {
  width: 100%;
  min-width: 130px;
  padding: 9px 10px;
  border: 1px solid #cfd5d0;
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: #5b8b7d;
  box-shadow: 0 0 0 3px rgba(36, 107, 88, .1);
}
textarea { resize: vertical; }
.check { display: flex !important; align-items: center; gap: 7px; }
.check input { width: auto; min-width: 0; }
.grow { flex: 1; min-width: 0; }

.list-cards { display: grid; gap: 12px; }
.compact-list { max-height: 680px; overflow: auto; }
.row-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}
.row-card:hover, .task-card:hover, .project-card:hover {
  transform: translateY(-1px);
  border-color: #d9d2c8;
  box-shadow: var(--shadow);
}
.row-card h3 { margin: 0 0 5px; font-size: 16px; }
.row-card p { margin: 5px 0; color: var(--muted); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vertical-actions { display: grid; min-width: 108px; gap: 7px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }
.badge, .tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef0ed;
  color: #56605a;
  font-size: 11px;
  font-weight: 700;
}
.badge.green { background: #e4f3eb; color: #176445; }
.badge.orange { background: #fff0df; color: #925113; }
.badge.blue { background: #e7eef6; color: #2e5a88; }
.tag { background: #f4eee8; color: #7c5431; }
.script-content {
  padding: 14px;
  margin-top: 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  line-height: 1.8;
  white-space: normal;
}
.warning-text { color: #9a5719 !important; }
.row-card details, .asset-card details, .report-card details { margin-top: 10px; }
.row-card summary, .asset-card summary, .report-card summary { color: var(--primary); cursor: pointer; }

.filter-bar, .bulk-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 13px;
  margin-bottom: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.filter-bar span { margin-left: auto; color: var(--muted); }
.bulk-bar { position: sticky; top: 8px; z-index: 8; box-shadow: var(--shadow); }
.bulk-bar select { width: auto; min-width: 180px; flex: 1; }
.select-all { margin-right: 4px; color: #39423d; font-weight: 700; }
.file-button input { display: none; }
.review-card > input[type=checkbox] {
  width: 19px;
  height: 19px;
  min-width: 19px;
  accent-color: var(--primary);
}
.video-thumb {
  position: relative;
  display: grid;
  flex: 0 0 136px;
  width: 136px;
  height: 92px;
  overflow: hidden;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #171d1b;
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #171d1b;
}
.video-thumb span {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(18, 24, 22, .72);
  color: #fff;
  font-size: 11px;
  text-align: center;
}
.empty-thumb {
  background: #f1eee8;
  color: var(--muted);
}
.empty-thumb span {
  position: static;
  background: transparent;
  color: var(--muted);
}
.compact-metrics { max-width: 620px; margin: 10px 0; }
.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0;
}
.mini-metrics.large, .compact-metrics { grid-template-columns: repeat(4, 1fr); }
.mini-metrics div { padding: 11px; border-radius: 9px; background: var(--surface-soft); text-align: center; }
.mini-metrics strong { display: block; font-size: 19px; }
.mini-metrics span { color: var(--muted); font-size: 11px; }
.raw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 7px;
  margin-top: 10px;
}
.raw-grid div { padding: 9px; border-radius: 8px; background: var(--surface-soft); }
.raw-grid span, .raw-grid strong { display: block; }
.raw-grid span { color: var(--muted); font-size: 10px; }
.raw-grid strong { margin-top: 4px; word-break: break-all; }

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-lane {
  min-width: 0;
  max-width: none;
  min-height: 650px;
  padding: 11px;
  border: 1px solid #e0e4df;
  border-radius: 13px;
  background: rgba(255, 255, 255, .54);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.65);
}
.kanban-lane h2 { margin: 5px 4px 12px; font-size: 14px; }
.kanban-lane h2 span { float: right; padding: 2px 7px; border-radius: 7px; background: #fff; }
.task-card {
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.task-card p { color: var(--muted); }
.task-card dl div { display: flex; justify-content: space-between; margin: 5px 0; font-size: 12px; }
.task-card dt { color: var(--muted); }
.task-card dd { margin: 0; }
.task-card summary { color: var(--primary); cursor: pointer; font-size: 12px; }
.lane-empty { padding: 30px 10px; color: #8a938e; text-align: center; }

.project-grid, .asset-grid, .report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.project-card, .asset-card, .report-card { padding: 20px; }
.project-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.project-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: #f2e7db;
  color: #785333;
  font-size: 18px;
  font-weight: 800;
}
.project-card h2 { margin: 16px 0 4px; }
.project-card p { color: var(--muted); }
.card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.report-card h3, .asset-card h3 { margin: 14px 0 5px; }
.report-content {
  max-height: 540px;
  overflow: auto;
  padding: 14px;
  border-radius: 9px;
  background: var(--surface-soft);
  white-space: normal;
}

.markdown-body {
  color: var(--text);
  line-height: 1.75;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body p { margin: 8px 0; color: inherit; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 16px 0 8px;
  color: var(--text);
  line-height: 1.35;
}
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 18px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
  margin: 8px 0;
}
.markdown-body li { margin: 4px 0; }
.markdown-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #ece8e0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}
.markdown-body pre {
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #242927;
  color: #f6f3ed;
}
.markdown-body pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  white-space: pre;
}
.markdown-body blockquote {
  margin: 10px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--primary);
  background: #f3f1ea;
  color: var(--muted);
}
.markdown-table-wrap {
  width: 100%;
  margin: 10px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.markdown-body table {
  min-width: 520px;
  margin: 0;
  border-collapse: collapse;
}
.markdown-body th,
.markdown-body td {
  min-width: 120px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: normal;
  vertical-align: top;
}
.markdown-body th {
  background: #f5f3ee;
  color: var(--text);
  font-weight: 800;
}
.markdown-body tr:last-child td { border-bottom: 0; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.metric-card { padding: 18px; color: inherit; text-decoration: none; }
.metric-card:hover { border-color: #c6d5ce; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 9px 0; color: var(--primary-dark); font-size: 28px; }
.section-title { margin: 25px 0 12px; font-size: 18px; }

.two-col, .settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.soft-alert {
  padding: 12px;
  margin: 8px 0;
  border-left: 3px solid var(--primary);
  border-radius: 7px;
  background: var(--primary-soft);
}
.ai-settings-head {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px;
  border-radius: 11px;
  background: var(--surface-soft);
}
.ai-provider-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.provider-card {
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.provider-card h3 { margin: 0; }
.provider-card .check { color: var(--muted); font-size: 11px; }
.prompt-create-form { padding: 14px; border-radius: 11px; background: var(--surface-soft); }
.config-list div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.config-list dt { color: var(--muted); font-size: 11px; }
.config-list dd { margin: 5px 0 0; word-break: break-all; }

.table-wrap { overflow: auto; }
table { width: 100%; margin-top: 12px; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; }
.empty {
  grid-column: 1 / -1;
  padding: 70px 24px;
  border: 1px dashed #cdd3ce;
  border-radius: 14px;
  background: #fafbf9;
  color: var(--muted);
  text-align: center;
}

.action-pop { position: relative; }
.action-pop > summary { list-style: none; }
.action-pop > summary.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.popover-form {
  position: absolute;
  top: 44px;
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 290px;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(31, 41, 37, .14);
}
.edit-script-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf9;
}

.prompt-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 34, 29, .2);
}
.prompt-dialog::backdrop { background: rgba(24, 31, 28, .46); backdrop-filter: blur(2px); }
.prompt-dialog form { padding: 24px; }
.prompt-dialog h2 { margin: 3px 0 4px; }
.dialog-kicker { color: var(--primary); font-size: 12px; font-weight: 800; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.loading-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 31, 28, .52);
  backdrop-filter: blur(3px);
}
.loading-card {
  width: min(440px, 100%);
  padding: 30px;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(23, 34, 29, .22);
  text-align: center;
}
.loading-card h2 { margin: 14px 0 5px; font-size: 21px; }
.loading-card p { margin: 0; color: var(--muted); }
.loading-orbit {
  position: relative;
  width: 46px;
  height: 46px;
  margin: 0 auto;
  border: 3px solid #dfe9e4;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.loading-orbit span {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #e9a469;
}
.loading-track {
  height: 7px;
  margin: 21px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece9;
}
.loading-track span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .45s ease;
}
.loading-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef0ec;
}
.login-card {
  width: min(420px, 92vw);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 65px rgba(31, 41, 37, .12);
}
.login-card h1 { margin: 12px 0 5px; text-align: center; }
.login-card > p { margin-bottom: 25px; color: var(--muted); text-align: center; }
.login-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: auto;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
}
.login-access { margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: var(--surface-soft); text-align: center; }
.login-access span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.login-access strong { color: var(--primary); word-break: break-all; }
.setup-card { width: min(460px, 92vw); }
.setup-note { margin-top: 18px; color: var(--muted); font-size: 12px; }

@media (max-width: 1150px) {
  .ai-provider-grid { grid-template-columns: 1fr; }
  .production-tools { grid-template-columns: 1fr; }
}
@media (max-width: 950px) {
  .sidebar { position: static; width: auto; }
  .sidebar nav { display: flex; overflow: auto; }
  .sidebar-foot { display: none; }
  .page { margin-left: 0; padding: 20px; }
  .two-col, .settings-grid { grid-template-columns: 1fr; }
  .mini-metrics.large { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(4, minmax(250px, 1fr)); }
}
