:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --ink: #17201d;
  --muted: #65706c;
  --line: #dfe5e1;
  --panel: #ffffff;
  --canvas: #f4f6f4;
  --green: #24745b;
  --green-dark: #18533f;
  --green-soft: #e6f2ed;
  --amber: #996515;
  --amber-soft: #fff3d8;
  --red: #a33b36;
  --red-soft: #fae9e7;
  --blue: #315f8f;
  --blue-soft: #e9f0f8;
  --violet: #655387;
  --violet-soft: #f0edf7;
  --shadow: 0 16px 40px rgba(20, 31, 27, 0.14);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #edf3f0;
  background: #17201d;
  border-right: 1px solid #2b3632;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 26px;
  font-size: 17px;
  font-weight: 700;
}

.brand-mark {
  width: 27px;
  height: 27px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  transform: rotate(45deg);
}

.brand-mark i { display: block; border-radius: 2px; background: #6eb89c; }
.brand-mark i:nth-child(2) { background: #e2b45f; }
.brand-mark i:nth-child(3) { grid-column: 1 / span 2; background: #edf3f0; }

.primary-nav { display: grid; gap: 5px; }

.nav-button {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: #bfc9c5;
  background: transparent;
  text-align: left;
}

.nav-button:hover { color: #fff; background: #25302c; }
.nav-button.active { color: #fff; background: #2e3d37; }
.nav-glyph { width: 18px; color: #82bba5; text-align: center; }

.account-panel {
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid #33403b;
}

.account-name { display: block; color: #fff; font-weight: 600; }
.account-role { display: block; margin-top: 4px; color: #9eaaa5; font-size: 12px; }
.account-panel .text-button { margin-top: 6px; }

.text-button {
  padding: 8px 0;
  color: #8fc7b1;
  background: none;
  border: 0;
}

.workspace { min-width: 0; }

.topbar {
  height: 86px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 30px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { margin: 2px 0 0; font-size: 21px; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.mode-indicator {
  padding: 5px 9px;
  color: #53605b;
  background: #eef1ef;
  border: 1px solid #d9dfdc;
  border-radius: 999px;
  font-size: 12px;
}

.primary-button, .secondary-button, .danger-button, .ghost-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 5px;
  padding: 8px 14px;
  font-weight: 600;
}

.primary-button { color: #fff; background: var(--green); border: 1px solid var(--green); }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { color: var(--ink); background: #fff; border: 1px solid #cbd3cf; }
.secondary-button:hover { background: #f6f8f7; }
.danger-button { color: #fff; background: var(--red); border: 1px solid var(--red); }
.ghost-button { color: var(--green-dark); background: transparent; border: 1px solid transparent; }
.icon-button { width: 38px; height: 38px; border: 1px solid #d6ddda; border-radius: 5px; background: #fff; }
.mobile-only { display: none; }

.content { padding: 24px 30px 40px; }

body.logged-out .app-shell { display: block; }
body.logged-out .sidebar, body.logged-out .topbar { display: none; }
body.logged-out .content { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf1ee; }

.auth-shell {
  width: min(440px, 100%);
  overflow: hidden;
  background: #fff;
  border: 1px solid #dbe2de;
  border-radius: 7px;
  box-shadow: 0 18px 50px rgba(20, 31, 27, 0.12);
}
.auth-header { padding: 24px 26px 20px; color: #fff; background: #17201d; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }
.auth-header p { margin: 13px 0 0; color: #b9c5c0; }
.auth-body { padding: 24px 26px 26px; }
.auth-body h1 { margin: 0 0 6px; font-size: 20px; }
.auth-body > p { margin: 0 0 20px; color: var(--muted); }
.auth-form { display: grid; gap: 15px; }
.auth-form .primary-button { width: 100%; margin-top: 4px; }
.auth-links { display: flex; justify-content: center; margin-top: 16px; }
.auth-links .text-button { color: var(--green-dark); }
.setup-code { font-family: Consolas, monospace; font-size: 15px; letter-spacing: 0; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 7px; font-size: 24px; font-weight: 700; }
.metric small { color: var(--muted); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.search-box { position: relative; flex: 1; max-width: 360px; }
.search-box span { position: absolute; left: 11px; top: 9px; color: #7d8883; }
.search-box input { width: 100%; height: 40px; padding: 8px 12px 8px 34px; border: 1px solid #cfd7d3; border-radius: 5px; background: #fff; }
.toolbar select { height: 40px; min-width: 145px; padding: 7px 10px; border: 1px solid #cfd7d3; border-radius: 5px; background: #fff; }

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

.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th {
  padding: 12px 14px;
  color: #5d6863;
  background: #f7f8f7;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
.data-table td { padding: 14px; border-bottom: 1px solid #e8ecea; vertical-align: middle; }
.data-table select { min-height: 36px; padding: 6px 8px; border: 1px solid #cbd4d0; border-radius: 5px; background: #fff; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbfa; }
.data-table .project-cell { font-weight: 600; }
.subtext { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
.cell-actions { display: flex; justify-content: flex-end; gap: 6px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pending { color: var(--amber); background: var(--amber-soft); }
.status-auditing, .status-checking { color: var(--blue); background: var(--blue-soft); }
.status-missing, .status-revision { color: var(--red); background: var(--red-soft); }
.status-ready, .status-complete { color: var(--green-dark); background: var(--green-soft); }
.status-designing { color: var(--violet); background: var(--violet-soft); }
.status-neutral { color: #5f6a66; background: #edf0ee; }

.progress-line { width: 100%; height: 5px; overflow: hidden; background: #e7ebe9; border-radius: 999px; }
.progress-line i { display: block; height: 100%; background: var(--green); border-radius: inherit; }

.empty-state { padding: 62px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--ink); font-size: 16px; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 26px 0 12px; }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; }
.detail-main, .detail-side { min-width: 0; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 17px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.meta-grid dt { color: var(--muted); font-size: 12px; }
.meta-grid dd { margin: 5px 0 0; font-weight: 600; }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding-bottom: 18px; }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 1px; background: #d7dfdb; }
.timeline li:last-child::after { display: none; }
.timeline-dot { width: 13px; height: 13px; margin-top: 2px; border-radius: 50%; border: 2px solid #aab5b0; background: #fff; }
.timeline li.done .timeline-dot { border-color: var(--green); background: var(--green); }
.timeline li.current .timeline-dot { border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.timeline strong { display: block; font-size: 13px; }
.timeline time, .timeline small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.finding-list { display: grid; gap: 8px; }
.finding {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px 12px;
  border-left: 3px solid var(--red);
  background: #fdf7f6;
}
.finding.ok { border-left-color: var(--green); background: #f3f8f6; }
.finding strong { font-size: 13px; }
.finding p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.file-list { display: grid; gap: 7px; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 10px; background: #f7f9f8; border: 1px solid #e3e8e5; border-radius: 5px; }
.file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name small { display: block; margin-top: 3px; color: var(--muted); }

.alert { padding: 12px 14px; border-radius: 5px; color: #6e4b13; background: var(--amber-soft); border: 1px solid #efd59b; }
.alert.danger { color: #7e2c28; background: var(--red-soft); border-color: #efc8c4; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(16, 24, 21, 0.58); z-index: 100; }
.modal { width: min(680px, 100%); max-height: calc(100vh - 44px); overflow: auto; background: #fff; border-radius: 7px; box-shadow: var(--shadow); }
.modal.narrow { width: min(480px, 100%); }
.modal-header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; background: #fff; border-bottom: 1px solid var(--line); z-index: 2; }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 20px; background: #f8faf9; border-top: 1px solid var(--line); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid > .full { grid-column: 1 / -1; }
.form-field { min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.required::after { content: " *"; color: var(--red); }
.form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd4d0; border-radius: 5px; background: #fff; }
.form-field textarea { min-height: 90px; resize: vertical; }
.form-field input[type="file"] { padding: 8px; background: #f8faf9; }
.field-help { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.form-error { margin-top: 6px; color: var(--red); font-size: 12px; }

.toast-root { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { min-width: 260px; max-width: 380px; padding: 12px 14px; color: #fff; background: #23302b; border-radius: 5px; box-shadow: var(--shadow); }

.system-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.system-item { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.system-item strong { display: flex; align-items: center; justify-content: space-between; }
.system-item p { margin: 8px 0 0; color: var(--muted); }
.health-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .detail-layout { grid-template-columns: 1fr; }
  .system-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 250px; transition: transform 180ms ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { height: 76px; padding: 0 16px; }
  .topbar h1 { font-size: 18px; }
  .mode-indicator { display: none; }
  .primary-button { padding-inline: 11px; }
  .content { padding: 18px 14px 32px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .metric { padding: 14px; }
  .metric strong { font-size: 21px; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .search-box { max-width: none; flex-basis: 100%; }
  .toolbar select { min-width: 0; flex: 1; }
  .table-shell { overflow-x: auto; }
  .data-table { min-width: 760px; }
  .form-grid, .meta-grid { grid-template-columns: 1fr; }
  .form-field.full, .form-grid > .full { grid-column: auto; }
  .modal-backdrop { padding: 10px; align-items: end; }
  .modal { max-height: calc(100vh - 20px); }
  .modal-header, .modal-body, .modal-footer { padding-left: 15px; padding-right: 15px; }
}
