:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --bg: #071221;
  --panel: rgba(11, 29, 52, 0.82);
  --panel-strong: rgba(14, 36, 64, 0.96);
  --line: rgba(80, 178, 255, 0.38);
  --text: #ecf6ff;
  --muted: #8da7c4;
  --cyan: #35c9ff;
  --blue: #2682ff;
}

* {
  box-sizing: border-box;
}

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

input,
select,
button {
  font: inherit;
}

input[type="hidden"] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 72%, rgba(37, 172, 255, 0.22), transparent 34%),
    linear-gradient(90deg, #06101f 0%, #071b34 48%, #041020 100%);
}

.login-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(360px, 0.85fr);
  gap: 48px;
  align-items: center;
  padding: 56px 8vw;
}

.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(70, 177, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 177, 255, 0.08) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(90deg, black, transparent 80%);
}

.brand-panel,
.login-card,
footer {
  position: relative;
  z-index: 1;
}

.brand-panel {
  align-self: stretch;
  padding-top: 48px;
}

.brand-mark {
  width: 72px;
  height: 72px;
  border: 4px solid var(--cyan);
  border-radius: 16px;
  box-shadow: 0 0 28px rgba(53, 201, 255, 0.65);
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  margin-right: 24px;
}

.brand-mark span {
  width: 34px;
  height: 42px;
  border-top: 6px solid var(--cyan);
  border-bottom: 6px solid var(--blue);
  display: block;
}

.brand-panel h1 {
  display: inline-block;
  font-size: clamp(36px, 5vw, 58px);
  margin: 0;
  letter-spacing: 0;
}

.brand-panel p {
  color: #6dd3ff;
  font-size: 20px;
  margin: 12px 0 0 100px;
}

.factory-visual {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  height: 46vh;
  min-height: 340px;
  opacity: 0.95;
}

.conveyor {
  position: absolute;
  left: -8vw;
  right: -8vw;
  bottom: 32px;
  height: 150px;
  transform: perspective(520px) rotateX(62deg);
  background: linear-gradient(90deg, rgba(24, 79, 134, 0.35), rgba(31, 180, 255, 0.36), rgba(16, 42, 79, 0.18));
  border-top: 2px solid rgba(88, 204, 255, 0.65);
  box-shadow: 0 0 46px rgba(28, 173, 255, 0.45);
}

.conveyor i {
  position: absolute;
  top: 24px;
  width: 190px;
  height: 82px;
  border: 1px solid rgba(105, 217, 255, 0.68);
  background: rgba(116, 216, 255, 0.16);
  box-shadow: 0 0 28px rgba(80, 202, 255, 0.55);
}

.conveyor i:nth-child(1) { left: 18%; }
.conveyor i:nth-child(2) { left: 40%; }
.conveyor i:nth-child(3) { left: 62%; }
.conveyor i:nth-child(4) { left: 84%; }

.hud {
  border: 1px solid rgba(63, 184, 255, 0.6);
  background: rgba(7, 28, 54, 0.62);
  box-shadow: inset 0 0 28px rgba(32, 150, 255, 0.12), 0 0 28px rgba(21, 133, 255, 0.24);
  color: #4ccaff;
}

.hud-left {
  position: absolute;
  left: -3vw;
  top: 40px;
  width: 260px;
  padding: 26px;
  display: grid;
  gap: 12px;
  transform: perspective(500px) rotateY(14deg);
}

.hud-center {
  position: absolute;
  left: 48%;
  top: 128px;
  padding: 18px 28px;
  font-weight: 700;
  text-align: center;
}

.arm {
  position: absolute;
  width: 180px;
  height: 18px;
  background: linear-gradient(90deg, #1d6ba7, #8bdfff);
  box-shadow: 0 0 20px rgba(91, 205, 255, 0.45);
}

.arm::before,
.arm::after {
  content: "";
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 8px solid #2a9ee6;
  top: -14px;
}

.arm::before { left: -28px; }
.arm::after { right: -28px; }
.arm-a { left: 31%; top: 56%; transform: rotate(-24deg); }
.arm-b { left: 62%; top: 50%; transform: rotate(22deg); opacity: 0.72; }

.login-card {
  width: min(100%, 520px);
  justify-self: end;
  padding: 48px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(14, 35, 63, 0.88), rgba(5, 18, 35, 0.94));
  box-shadow: 0 0 50px rgba(44, 159, 255, 0.24), inset 0 0 36px rgba(62, 168, 255, 0.08);
}

.card-heading {
  text-align: center;
  margin-bottom: 34px;
}

.card-heading h2 {
  margin: 0;
  font-size: 34px;
}

.card-heading p {
  margin: 12px 0 0;
  color: var(--muted);
}

.flash,
.notice {
  padding: 12px 14px;
  border: 1px solid rgba(255, 180, 80, 0.32);
  background: rgba(255, 180, 80, 0.08);
  color: #ffd89d;
  margin-bottom: 16px;
}

.login-form,
.stack-form {
  display: grid;
  gap: 18px;
}

.login-form label,
.stack-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.login-form input,
.inline-form input,
.stack-form input,
.stack-form select {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(117, 170, 225, 0.35);
  border-radius: 8px;
  background: rgba(8, 24, 45, 0.88);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.check {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}

.check input {
  width: 18px;
  min-height: 18px;
}

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

.field-label > span {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.field-label > em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

a {
  color: #45c6ff;
  text-decoration: none;
}

button,
.ghost-btn {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 22px;
  color: white;
  background: linear-gradient(90deg, #287dff, #3cc8ff);
  cursor: pointer;
  font-weight: 700;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  background: rgba(50, 136, 255, 0.15);
  border: 1px solid rgba(83, 178, 255, 0.32);
}

footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  text-align: center;
  color: rgba(222, 237, 255, 0.72);
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  background: #07111f;
}

.sidebar {
  border-right: 1px solid rgba(99, 176, 255, 0.18);
  background: #07182c;
  padding: 24px;
}

.side-brand {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 32px;
}

.sidebar nav {
  display: grid;
  gap: 10px;
}

.sidebar a {
  padding: 12px 14px;
  border-radius: 8px;
  color: #b8c9df;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(53, 201, 255, 0.12);
  color: white;
}

.workspace {
  padding: 28px;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.theme-picker select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.topbar h1 {
  margin: 0 0 8px;
}

.topbar p,
.meta,
.empty {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(88, 158, 230, 0.2);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 20px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
}

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

.project-card,
.task-item {
  border: 1px solid rgba(86, 156, 226, 0.24);
  border-radius: 8px;
  background: rgba(4, 17, 34, 0.62);
  padding: 16px;
}

.project-card {
  display: grid;
  gap: 10px;
  color: var(--text);
}

.project-card span,
.project-card em,
.task-item span {
  color: var(--muted);
  font-style: normal;
}

.projects-hero {
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.72);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 6px;
  color: #93c5fd;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.project-command-panel,
.project-board {
  margin-bottom: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(22, 33, 51, 0.96));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}

.project-command-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(360px, 1.3fr);
  gap: 22px;
  align-items: end;
}

.project-command-panel h2,
.project-board h2 {
  margin: 0;
  font-size: 22px;
}

.project-command-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.project-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.project-create-form label {
  display: grid;
  gap: 7px;
}

.project-create-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.project-create-form input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.project-create-form input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.project-create-form button {
  min-height: 44px;
  white-space: nowrap;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.project-count {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.refined-project-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.refined-project-card {
  position: relative;
  min-height: 172px;
  padding: 16px;
  border-color: rgba(96, 165, 250, 0.24);
  background: rgba(15, 23, 42, 0.38);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.refined-project-card:hover {
  background: rgba(15, 23, 42, 0.62);
}

.project-card-link {
  display: grid;
  gap: 10px;
  color: inherit;
  min-height: 124px;
}

.project-card-top,
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-card-top strong {
  overflow: hidden;
  color: var(--text);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #475569;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}

.status-completed {
  border-color: rgba(52, 211, 153, 0.5);
  background: #047857;
  color: #ecfdf5;
}

.status-failed,
.status-canceled {
  border-color: rgba(248, 113, 113, 0.56);
  background: #b91c1c;
  color: #fef2f2;
}

.status-queued,
.status-running,
.status-uploaded {
  border-color: rgba(96, 165, 250, 0.55);
  background: #1d4ed8;
  color: #eff6ff;
}

.status-draft {
  border-color: rgba(203, 213, 225, 0.36);
  background: #64748b;
  color: #f8fafc;
}

.project-meta-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.project-meta-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-footer {
  margin-top: auto;
  padding-top: 14px;
  color: #bfdbfe;
  font-size: 13px;
  font-weight: 800;
}

.project-card-footer b {
  font-size: 18px;
}

.project-delete-form {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 0;
}

.project-delete-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(239, 68, 68, 0.42);
  border-radius: 7px;
  background: transparent;
  color: #fca5a5;
  font-size: 12px;
}

.project-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ffffff;
}

.project-empty {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.task-list {
  display: grid;
  gap: 14px;
}

.task-item {
  display: grid;
  gap: 12px;
}

.task-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.task-summary-main {
  display: grid;
  min-width: 0;
  gap: 10px;
}

.task-detail-toggle {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.task-detail-toggle:hover {
  background: var(--panel-strong);
}

.task-detail {
  display: none;
  gap: 12px;
}

.task-item.expanded .task-detail {
  display: grid;
}

.task-error {
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.1);
  color: #fecaca;
  font-size: 13px;
  line-height: 1.5;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.task-actions form {
  margin: 0;
}

.inline-log-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.log-file-btn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.danger-btn {
  background: linear-gradient(90deg, #d33b54, #ff7a45);
  min-width: 120px;
}

progress {
  width: 100%;
  height: 12px;
  accent-color: var(--cyan);
}

.progress-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.progress-row progress {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}

.progress-percent {
  flex: 0 0 auto;
  min-width: 72px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.task-log {
  display: none;
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  background: #030b16;
  border: 1px solid rgba(74, 157, 255, 0.24);
  color: #cce9ff;
  white-space: pre-wrap;
}

.downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(67, 190, 255, 0.2);
  border-radius: 8px;
  background: rgba(53, 201, 255, 0.06);
}

.downloads strong {
  width: 100%;
  color: #eaf8ff;
}

.download-placeholder {
  color: #7faec6;
  font-size: 13px;
}

.download-warning {
  margin: -2px 0 12px;
  color: #ff5d6c;
  font-size: 14px;
  font-weight: 800;
}

.download-choice {
  display: inline-grid;
  grid-template-columns: minmax(120px, auto) 78px 64px;
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 4px 5px 4px 10px;
  border: 1px solid rgba(67, 190, 255, 0.22);
  border-radius: 7px;
  background: rgba(7, 31, 55, 0.78);
}

.download-choice span {
  color: #dff6ff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.download-choice select {
  height: 28px;
  border: 1px solid rgba(67, 190, 255, 0.28);
  border-radius: 5px;
  background: #07182b;
  color: #dff6ff;
  font-size: 12px;
}

.download-choice a {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.downloads a,
.download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(67, 190, 255, 0.32);
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(40, 125, 255, 0.22), rgba(60, 200, 255, 0.16));
  color: #b9ecff;
  font-weight: 700;
}

.download-btn:not(.secondary) {
  min-height: 38px;
  background: linear-gradient(90deg, #287dff, #36d2ff);
  color: #ffffff;
  box-shadow: 0 0 18px rgba(54, 210, 255, 0.18);
}

.support-downloads {
  background: rgba(255, 255, 255, 0.03);
}

.download-btn.secondary {
  font-weight: 500;
  color: #9fd7ef;
}

.task-item.open .task-log {
  display: block;
}

@media (max-width: 900px) {
  .login-page,
  .dashboard,
  .two-column,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .login-card {
    justify-self: stretch;
  }

  .factory-visual {
    position: relative;
    height: 320px;
    bottom: auto;
    margin-top: 28px;
  }

  .sidebar {
    position: static;
  }

  .project-command-panel,
  .project-create-form {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Compact dashboard refinement for daily production use */
.compact-dashboard {
  grid-template-columns: 210px 1fr;
}

.compact-dashboard .sidebar {
  padding: 20px 18px;
}

.compact-dashboard .side-brand {
  font-size: 20px;
  margin-bottom: 24px;
}

.compact-dashboard .sidebar nav {
  gap: 6px;
}

.compact-dashboard .sidebar a {
  padding: 10px 12px;
  font-size: 14px;
}

.compact-dashboard .workspace {
  padding: 18px;
}

.compact-topbar {
  margin-bottom: 16px;
}

.compact-topbar h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.compact-topbar p {
  margin: 0;
  font-size: 14px;
}

.compact-topbar .ghost-btn {
  min-height: 36px;
  padding: 0 16px;
  font-size: 14px;
}

.compact-grid {
  gap: 14px;
}

.compact-panel {
  padding: 16px 18px;
  margin-bottom: 14px;
}

.compact-panel h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.compact-form {
  gap: 12px;
}

.compact-form input,
.compact-form select,
.compact-form button {
  min-height: 40px;
  font-size: 14px;
}

.compact-form input[type="file"] {
  padding: 7px 10px;
}

.compact-form input,
.compact-form select {
  padding: 0 12px;
}

.compact-panel .meta {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.file-meta {
  word-break: break-all;
}

.compact-task {
  gap: 10px;
  padding: 12px 14px;
}

.task-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.task-head strong {
  color: #ffffff;
  font-size: 16px;
}

.task-head span {
  font-size: 13px;
}

.task-head .task-model {
  color: #7faec6;
}

.task-head .task-status {
  color: #9fd7ef;
}

.task-head .task-time {
  color: #94a3b8;
  font-size: 12px;
  white-space: nowrap;
}

.status-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 5px;
  font-weight: 900;
  line-height: 1;
}

.status-mark.success {
  color: #22c55e;
}

.status-mark.error {
  color: #ef4444;
}

.task-status.status-success {
  color: #86efac;
}

.task-status.status-error {
  color: #fca5a5;
}

.compact-task progress {
  height: 8px;
}

.compact-task .task-actions {
  gap: 10px;
}

.compact-task .task-actions button {
  min-height: 36px;
  font-size: 14px;
}

.compact-task .danger-btn {
  min-width: 100px;
}

.compact-task .downloads {
  padding: 8px;
  gap: 6px;
}

.compact-task .downloads strong {
  font-size: 13px;
}

.compact-task .download-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.compact-task .download-btn:not(.secondary) {
  min-height: 32px;
}

.compact-task .task-log {
  max-height: 240px;
  padding: 10px;
  font-size: 12px;
}

.episode-list {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(67, 190, 255, 0.2);
  border-radius: 8px;
  background: rgba(9, 24, 43, 0.58);
}

.episode-list > strong {
  color: #eaf8ff;
  font-size: 13px;
  margin-bottom: 2px;
}

.episode-row {
  display: grid;
  grid-template-columns: 72px 90px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.episode-name {
  font-weight: 800;
  color: #ffffff;
}

.episode-status {
  color: #9fd7ef;
  font-size: 13px;
}

.episode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.episode-actions > a,
.episode-actions .download-choice > a {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(67, 190, 255, 0.25);
  border-radius: 6px;
  background: rgba(40, 125, 255, 0.14);
  color: #b9ecff;
  font-size: 12px;
  font-weight: 700;
}

.compact-choice {
  grid-template-columns: minmax(78px, auto) 70px 48px;
  padding-left: 8px;
}

.compact-choice span {
  font-size: 12px;
}

@media (max-width: 900px) {
  .compact-dashboard {
    grid-template-columns: 1fr;
  }

  .task-summary {
    grid-template-columns: 1fr;
  }

  .compact-task .task-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .episode-row {
    grid-template-columns: 1fr;
  }

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

/* Professional SaaS refinement */
:root {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-strong: #334155;
  --line: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #60a5fa;
  --blue: #3b82f6;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 10px;
}

body {
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.dashboard {
  background: var(--bg);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #111827;
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--panel-strong);
  color: var(--text);
}

.panel,
.project-card,
.task-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

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

.project-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.62);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
}

button,
.ghost-btn,
.download-btn,
.downloads a,
.episode-actions > a,
.episode-actions .download-choice > a {
  border-radius: 8px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button,
.download-btn {
  border: 1px solid transparent;
  background: var(--primary);
  color: #ffffff;
  box-shadow: none;
}

button:hover,
.download-btn:not(.secondary):hover,
.downloads a:not(.secondary):hover,
.episode-actions .download-choice > a:hover {
  background: var(--primary-hover);
}

.ghost-btn,
.download-btn.secondary,
.task-actions .log-toggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.ghost-btn:hover,
.download-btn.secondary:hover,
.task-actions .log-toggle:hover {
  background: var(--panel-strong);
  border-color: var(--muted);
}

.danger-btn {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.46);
  color: #fecaca;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--danger);
  color: #ffffff;
}

.login-form input,
.inline-form input,
.stack-form input,
.stack-form select,
.download-choice select {
  background: #0f172a;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
}

.stack-form select option,
.download-choice select option {
  background: #0f172a;
  color: #f8fafc;
}

.login-form input:focus,
.inline-form input:focus,
.stack-form input:focus,
.stack-form select:focus,
.download-choice select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

progress {
  accent-color: var(--primary);
}

.upload-dropzone {
  position: relative;
  width: 100%;
}

.upload-dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.upload-dropzone label {
  display: flex;
  min-height: 136px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 20px;
  background: rgba(15, 23, 42, 0.72);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.upload-dropzone label:hover,
.upload-dropzone.dragging label {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  color: #bfdbfe;
}

.upload-icon {
  width: 32px;
  height: 32px;
  margin-bottom: 4px;
  color: var(--primary);
}

.upload-dropzone strong {
  color: var(--text);
  font-size: 15px;
}

.file-name-display {
  color: var(--muted);
  font-size: 13px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.full-width-btn {
  width: 100%;
  margin-top: 12px;
}

.text-primary {
  color: #93c5fd;
}

.downloads,
.episode-list {
  border-color: var(--line);
  background: rgba(15, 23, 42, 0.45);
}

.download-choice {
  border-color: var(--line);
  background: #0f172a;
}

.download-choice span,
.downloads strong,
.episode-list > strong {
  color: var(--text);
}

.download-choice a,
.episode-actions .download-choice > a {
  border-color: transparent;
  background: var(--primary);
  color: #ffffff;
}

.episode-row {
  background: rgba(15, 23, 42, 0.62);
}

.task-log {
  background: #020617;
  border-color: var(--line);
  color: #dbeafe;
}

.download-warning {
  color: #fb7185;
}

.episode-matrix-container {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.45);
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.matrix-header strong {
  color: var(--text);
  font-size: 13px;
}

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.matrix-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.running { background: var(--primary); }
.status-dot.success { background: var(--success); }
.status-dot.error { background: var(--danger); }

.episode-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 6px;
}

.matrix-cell {
  min-width: 30px;
  width: 100%;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.matrix-cell .status-mark {
  margin-right: 3px;
  font-size: 11px;
}

.matrix-cell span {
  line-height: 1;
}

.matrix-cell:hover,
.matrix-cell.selected {
  transform: translateY(-1px);
  border-color: #bfdbfe;
  color: #ffffff;
}

.matrix-cell.queued {
  background: rgba(148, 163, 184, 0.1);
}

.matrix-cell.running {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--primary);
  color: #93c5fd;
}

.matrix-cell.success {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--success);
  color: #6ee7b7;
}

.matrix-cell.error {
  background: rgba(239, 68, 68, 0.16);
  border-color: var(--danger);
  color: #fca5a5;
}

.episode-detail {
  min-height: 54px;
  padding: 10px;
  border: 1px solid rgba(51, 65, 85, 0.72);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.28);
  color: var(--muted);
}

.episode-detail-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.episode-download-template {
  display: none;
}

.empty-detail {
  display: flex;
  align-items: center;
  font-size: 13px;
}

.log-console {
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #020617;
}

.task-item.open .log-console {
  display: block;
}

.log-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: #0f172a;
  color: var(--muted);
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 12px;
}

.copy-log-btn {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: #bfdbfe;
  font-size: 12px;
}

.copy-log-btn:hover {
  background: rgba(59, 130, 246, 0.14);
}

.task-log {
  display: block;
  height: 250px;
  max-height: 250px;
  border: 0;
  border-radius: 0;
  font-family: "Fira Code", "Consolas", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.task-item.open .task-log {
  display: block;
}

.login-form input,
.inline-form input,
.stack-form input,
.stack-form select,
.download-choice select {
  background: rgba(255, 255, 255, 0.045);
  border-color: transparent;
}

.login-form input:focus,
.inline-form input:focus,
.stack-form input:focus,
.stack-form select:focus,
.download-choice select:focus {
  background: rgba(255, 255, 255, 0.075);
  border-color: var(--primary);
}

@media (max-width: 900px) {
  .download-choice,
  .compact-choice {
    grid-template-columns: 1fr 74px 56px;
    width: 100%;
  }

  .matrix-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-strong: #e8eef7;
  --line: #d7e0ee;
  --text: #0f172a;
  --muted: #64748b;
  --cyan: #2563eb;
  --blue: #2563eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
}

html[data-theme="light"] body,
html[data-theme="light"] .dashboard {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="light"] .sidebar {
  background: #ffffff;
  border-right-color: var(--line);
}

html[data-theme="light"] .side-brand,
html[data-theme="light"] .panel h2,
html[data-theme="light"] .topbar h1,
html[data-theme="light"] .task-head strong,
html[data-theme="light"] .episode-name {
  color: var(--text);
}

html[data-theme="light"] .sidebar a {
  color: #475569;
}

html[data-theme="light"] .sidebar a:hover,
html[data-theme="light"] .sidebar a.active {
  background: #eef4ff;
  color: #1d4ed8;
}

html[data-theme="light"] .panel,
html[data-theme="light"] .project-card,
html[data-theme="light"] .task-item,
html[data-theme="light"] .project-command-panel,
html[data-theme="light"] .project-board,
html[data-theme="light"] .downloads,
html[data-theme="light"] .episode-matrix-container,
html[data-theme="light"] .episode-detail {
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .download-choice,
html[data-theme="light"] .episode-row,
html[data-theme="light"] .refined-project-card,
html[data-theme="light"] .matrix-cell.queued {
  background: #f8fafc;
  border-color: var(--line);
}

html[data-theme="light"] .refined-project-card:hover {
  background: #eef4ff;
}

html[data-theme="light"] .download-choice span,
html[data-theme="light"] .downloads strong,
html[data-theme="light"] .episode-list > strong,
html[data-theme="light"] .matrix-header strong,
html[data-theme="light"] .episode-detail-title {
  color: var(--text);
}

html[data-theme="light"] .login-form input,
html[data-theme="light"] .inline-form input,
html[data-theme="light"] .project-create-form input,
html[data-theme="light"] .stack-form input,
html[data-theme="light"] .stack-form select,
html[data-theme="light"] .download-choice select,
html[data-theme="light"] .theme-picker select {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="light"] .stack-form select option,
html[data-theme="light"] .download-choice select option {
  background: #ffffff;
  color: var(--text);
}

html[data-theme="light"] .upload-dropzone label {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--muted);
}

html[data-theme="light"] .upload-dropzone label:hover,
html[data-theme="light"] .upload-dropzone.dragging label {
  background: #eff6ff;
  border-color: var(--primary);
}

html[data-theme="light"] .ghost-btn,
html[data-theme="light"] .download-btn.secondary,
html[data-theme="light"] .task-actions .log-toggle,
html[data-theme="light"] .task-detail-toggle,
html[data-theme="light"] .copy-log-btn {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="light"] .ghost-btn:hover,
html[data-theme="light"] .download-btn.secondary:hover,
html[data-theme="light"] .task-actions .log-toggle:hover,
html[data-theme="light"] .task-detail-toggle:hover,
html[data-theme="light"] .copy-log-btn:hover {
  background: #eef4ff;
}

html[data-theme="light"] .task-log,
html[data-theme="light"] .log-console {
  background: #0f172a;
  color: #dbeafe;
}

html[data-theme="light"] .log-toolbar {
  background: #e8eef7;
  color: #475569;
}

html[data-theme="light"] .download-warning {
  color: #e11d48;
}

html[data-theme="light"] .task-head .task-model,
html[data-theme="light"] .task-head .task-time,
html[data-theme="light"] .progress-percent,
html[data-theme="light"] .matrix-legend,
html[data-theme="light"] .project-create-form label span,
html[data-theme="light"] .empty-detail,
html[data-theme="light"] .meta,
html[data-theme="light"] .empty {
  color: var(--muted);
}

html[data-theme="light"] .task-head .task-status {
  color: #2563eb;
}

html[data-theme="light"] .task-status.status-success {
  color: #059669;
}

html[data-theme="light"] .task-status.status-error {
  color: #dc2626;
}

html[data-theme="light"] .project-delete-btn {
  border-color: rgba(220, 38, 38, 0.34);
  color: #dc2626;
}

html[data-theme="light"] .project-delete-btn:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
}

html[data-theme="light"] .status-completed {
  border-color: rgba(5, 150, 105, 0.42);
  background: #059669;
  color: #ffffff;
}

html[data-theme="light"] .status-failed,
html[data-theme="light"] .status-canceled {
  border-color: rgba(220, 38, 38, 0.42);
  background: #dc2626;
  color: #ffffff;
}

html[data-theme="light"] .status-queued,
html[data-theme="light"] .status-running,
html[data-theme="light"] .status-uploaded {
  border-color: rgba(37, 99, 235, 0.42);
  background: #2563eb;
  color: #ffffff;
}

html[data-theme="light"] .status-draft {
  border-color: rgba(71, 85, 105, 0.38);
  background: #64748b;
  color: #ffffff;
}

.audit-panel {
  overflow: hidden;
}

.audit-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.32);
}

.audit-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}

.audit-table th,
.audit-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  text-align: left;
  vertical-align: top;
}

.audit-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(15, 23, 42, 0.46);
}

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

.audit-time,
.audit-target,
.audit-ip {
  color: var(--muted);
  white-space: nowrap;
}

.audit-message {
  max-width: 520px;
  line-height: 1.55;
  word-break: break-word;
}

.audit-action {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.14);
  color: var(--primary);
  white-space: nowrap;
}

.audit-action-login_failed,
.audit-action-task_failed,
.audit-action-delete_project {
  background: rgba(239, 68, 68, 0.14);
  color: var(--danger);
}

.audit-action-task_completed,
.audit-action-login_success {
  background: rgba(16, 185, 129, 0.14);
  color: var(--success);
}

html[data-theme="light"] .audit-table-wrap {
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .audit-table th {
  background: rgba(241, 245, 249, 0.9);
}
