:root {
  color-scheme: light;
  --ink: #28384d;
  --muted: #65758a;
  --line: #dfd2c1;
  --line-soft: #ebe3d8;
  --paper: #fffdfa;
  --wash: #f6f2eb;
  --wash-strong: #f0e8dc;
  --accent: #ad7942;
  --accent-dark: #87592e;
  --accent-soft: #f3e6d4;
  --green: #28765a;
  --amber: #9a650f;
  --red: #a63c35;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-width: 1180px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--wash);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
[hidden] { display: none !important; }

.app-shell {
  width: min(1440px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 44px;
}

.app-topbar {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  gap: 24px;
  margin-bottom: 30px;
  padding: 0 4px 16px;
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-brand > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.topbar-brand strong { font-size: 15px; }
.topbar-brand small { color: var(--muted); font-size: 11px; }
.topbar-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font: 700 12px/1 Georgia, serif;
  letter-spacing: .08em;
}

.workspace-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(255, 253, 250, .72);
}
.workspace-nav-item {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.workspace-nav-item:hover { color: var(--ink); background: var(--wash-strong); }
.workspace-nav-item[aria-selected="true"] {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 2px 6px rgba(91, 55, 23, .16);
}
.workspace-nav-item:focus-visible,
.button:focus-visible,
.file-label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.workspace-panel { min-height: 620px; }
.brand, .section-heading { margin: 0 0 18px; }
.section-heading .eyebrow { margin-bottom: 7px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 31px;
  line-height: 1.2;
  letter-spacing: .01em;
}
h2 { color: var(--ink); }
.section-heading > p:last-child,
.lede { max-width: 860px; margin: 8px 0 0; color: var(--muted); line-height: 1.6; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  align-items: stretch;
  gap: 18px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 5px 18px rgba(60, 43, 24, .055);
}
.upload-card, .project-card, .progress-card, .desktop-panel-card, .login-card {
  padding: 24px 26px;
}
.upload-card h2, .progress-head h2, .project-card h2, .login-card h2,
.desktop-panel-card h2 { margin: 0; font-size: 19px; }
.upload-card > p, .project-card > p, .desktop-panel-card > p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.file-picker {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 20px 0 18px;
  padding: 15px;
  border: 1px dashed #c8ad8b;
  border-radius: 8px;
  background: #fbf7f1;
}
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-label {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid #d3b48e;
  border-radius: 7px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 700;
  cursor: pointer;
}
#selected-file { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--ink); border-color: var(--line); background: #fffdfa; }
.button.secondary:hover { border-color: #c9b59b; background: #fbf7f1; }
.button.danger { border-color: #dfb3af; color: var(--red); }
.button.primary.danger { border-color: var(--red); background: var(--red); color: #fff; }
.start-button { width: auto; min-width: 132px; }
.status-line { min-height: 20px; margin: 11px 0 0; color: var(--muted); font-size: 13px; }

.project-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 20px; }
.text-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid #cfbea9;
  border-radius: 7px;
  color: var(--ink);
  background: #fffdfa;
}
.text-input:focus { outline: 2px solid rgba(173, 121, 66, .18); border-color: var(--accent); }
.field-label { display: block; margin: 16px 0 6px; font-weight: 700; }

.login-shell { width: min(1440px, calc(100% - 48px)); padding-top: 20px; }
.login-topbar { grid-template-columns: 1fr; }
.login-shell .brand { text-align: center; }
.login-shell .lede { margin-left: auto; margin-right: auto; }
.login-card { width: min(520px, 100%); margin: 22px auto 0; }
.login-card .start-button { width: 100%; margin-top: 22px; }

.desktop-panel-card { padding-top: 20px; }
.create-user-form {
  display: grid;
  grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr) 150px auto;
  align-items: end;
  gap: 10px;
  margin: 0 0 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.create-user-form h2 { grid-column: 1 / -1; margin-bottom: 2px; }

.data-table-head {
  min-height: 44px;
  color: #526278;
  background: #f3ede4 !important;
  font-size: 12px;
  font-weight: 750;
}
.admin-user-list, .admin-usage-list, .admin-project-list, .admin-trash-list {
  display: grid;
  gap: 0;
  margin: 0 0 20px;
}
.admin-user-row {
  display: grid;
  grid-template-columns: minmax(150px, .65fr) minmax(240px, 1fr) minmax(300px, auto);
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 8px 15px;
  border: 1px solid var(--line-soft);
  border-bottom: 0;
  background: #fffdfa;
}
.admin-user-list .admin-user-row:last-child { border-bottom: 1px solid var(--line-soft); }
.admin-user-identity { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.admin-user-identity small { color: var(--muted); }
.admin-usage-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 9px 15px;
  border: 1px solid var(--line-soft);
  border-bottom: 0;
  background: #fffdfa;
}
.admin-usage-list .admin-usage-row:last-child { border-bottom: 1px solid var(--line-soft); }
.admin-usage-identity { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.admin-usage-identity small { color: var(--muted); overflow-wrap: anywhere; }
.admin-trash-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  align-items: center;
  gap: 14px;
  min-height: 54px;
  padding: 8px 15px;
  border: 1px solid var(--line-soft);
  border-bottom: 0;
  background: #fffdfa;
}
.admin-project-list .admin-trash-row:last-child,
.admin-trash-list .admin-trash-row:last-child { border-bottom: 1px solid var(--line-soft); }
.admin-trash-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.compact-control-form {
  display: grid;
  grid-template-columns: auto 110px auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 0 0 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.compact-number { width: 96px; }
.desktop-panel-card > h2 { margin: 24px 0 10px; }
.desktop-panel-card > h2:first-child { margin-top: 0; }
.status-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}
.status-badge.success { color: var(--green); background: #e8f3ee; }
.status-badge.failure { color: var(--red); background: #f8e9e7; }

.progress-card { margin-top: 18px; }
.progress-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.progress-head p { margin: 6px 0 0; color: var(--muted); }
.progress-actions { display: flex; align-items: center; gap: 12px; }
.elapsed { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.stage-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}
.progress-stage {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fffdfa;
}
.stage-number { color: #9a8d7d; font: 700 12px ui-monospace, monospace; }
.stage-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.stage-copy small { color: var(--muted); }
.progress-stage.done { border-color: #b9d9ca; background: #f0f8f4; }
.progress-stage.done .stage-number, .progress-stage.done small { color: var(--green); }
.progress-stage.active { border-color: #c6a477; box-shadow: inset 3px 0 var(--accent); }
.progress-stage.active .stage-number, .progress-stage.active small { color: var(--accent-dark); }
.progress-stage.paused { border-color: #e0c389; background: #fff8e9; }
.progress-stage.paused .stage-number, .progress-stage.paused small { color: var(--amber); }
.progress-stage.failed { border-color: #e4b1ad; background: #fff3f2; }
.progress-stage.failed .stage-number, .progress-stage.failed small { color: var(--red); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 40, 52, .48);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: min(620px, calc(100vw - 80px));
  max-height: min(720px, calc(100vh - 80px));
  overflow: auto;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 22px 64px rgba(28, 34, 43, .24);
}
.modal-card h2 { margin: 0 0 12px; }
.modal-card p { color: var(--muted); line-height: 1.6; }
.modal-detail { padding: 10px 12px; border-radius: 7px; background: var(--wash); }
.issue-list { margin: 12px 0; padding-left: 22px; color: #425166; line-height: 1.6; }
.issue-list li + li { margin-top: 7px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }

.app-footer { margin-top: 34px; text-align: center; color: var(--muted); font-size: 12px; }
.captcha-row { display: flex; align-items: center; gap: 10px; }
.captcha-row .text-input { flex: 1; min-width: 0; }
.captcha-image { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 0; cursor: pointer; line-height: 0; }

@media (prefers-reduced-motion: no-preference) {
  .workspace-panel { animation: arrive .18s ease-out both; }
  @keyframes arrive { from { opacity: 0; transform: translateY(4px); } }
}
