:root {
  font-family: Inter, "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: #191822;
  background: #f4f3f7;
  --purple: #6857f5;
  --purple-dark: #4d3bc9;
  --ink: #191822;
  --muted: #716d7b;
  --line: #e4e1e9;
  --soft: #f7f6fa;
  --green: #157654;
  --green-bg: #e8f7f0;
  --amber: #93610b;
  --amber-bg: #fff4d9;
  --red: #a3382b;
  --red-bg: #fff0ec;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, #eeeaff 0, transparent 28rem),
    #f5f4f8;
}
button, input, textarea, select { font: inherit; }
button, a { transition: .18s ease; }
.hidden { display: none !important; }

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e8e5ed;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(18px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .05em;
  text-decoration: none;
}
.brand b, .eyebrow { color: var(--purple); }
.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
}
.header-context, .header-actions { display: flex; align-items: center; gap: 8px; }
.owner-mode {
  padding: 6px 9px;
  border-radius: 999px;
  color: #5547bc;
  background: #eeeaff;
  font-size: 11px;
  font-weight: 850;
}

main { max-width: 1500px; margin: auto; }
.eyebrow {
  margin: 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--red) !important; }

.auth-view {
  min-height: calc(100vh - 60px);
  padding: 44px 20px;
  display: grid;
  align-content: center;
  gap: 34px;
}
.auth-copy h1 {
  max-width: 820px;
  margin: 15px 0;
  font-size: clamp(43px, 13vw, 80px);
  line-height: .98;
  letter-spacing: -.055em;
}
.lede { max-width: 680px; color: var(--muted); font-size: 17px; line-height: 1.7; }
.principles { display: flex; flex-wrap: wrap; gap: 8px; }
.principles span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 750;
}
.card, .dialog-card, .module, .owner-summary {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 60px rgba(44,36,64,.04);
}
.auth-card { padding: 26px; }
.auth-card h2, .dialog-card h2 { margin: 7px 0 20px; font-size: 27px; }
.auth-card .button { width: 100%; margin-top: 7px; }

label { display: block; margin: 10px 0; color: #514d59; font-size: 13px; font-weight: 750; }
input, textarea, select {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  border: 1px solid #d8d4df;
  border-radius: 10px;
  color: var(--ink);
  background: #fbfafc;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 3px solid #6d5dfc22; border-color: var(--purple); }
.button {
  display: inline-block;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 820;
  text-align: center;
  text-decoration: none;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .44; transform: none; }
.primary { color: #fff; background: var(--purple); }
.subtle { color: #504a59; background: #efedf4; }
.danger { color: var(--red); background: var(--red-bg); }
.small { padding: 8px 10px; font-size: 12px; }
.full { width: 100%; }
.message { min-height: 20px; color: var(--red); font-size: 13px; }

.app-view { display: flex; min-height: calc(100vh - 60px); flex-direction: column; }
.operations-view { display: none; }
.app-view.operations-mode .owner-view { display: none; }
.app-view.operations-mode .operations-view { display: block; }
.app-view:not(.operations-mode) .internal-nav { display: none; }
.workspace-main { order: 1; min-width: 0; padding: 12px; }
.sidebar {
  order: 2;
  padding: 10px 12px 22px;
  border-top: 1px solid var(--line);
  background: #faf9fc;
}
.nav-panel {
  margin-top: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.nav-panel > summary {
  padding: 13px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}
#workspaceNav { display: grid; gap: 6px; padding: 0 10px 10px; }
.workspace-link {
  padding: 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-weight: 750;
  text-align: left;
}
.workspace-link.active { color: #5141c2; background: #eae5ff; }
.nav-panel .full { width: calc(100% - 20px); margin: 0 10px 10px; }
.credit {
  display: inline-block;
  margin: 0 12px 8px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #5545cb;
  background: #efeaff;
  font-size: 12px;
  font-weight: 800;
}
.readiness { padding: 0 12px 14px; color: var(--muted); font-size: 12px; }
.readiness > strong { display: block; margin: 10px 0 5px; color: var(--ink); }
.empty { max-width: 760px; margin: 24px auto; padding: 38px 25px; }
.empty h2 { margin: 10px 0; font-size: 34px; }

.morning-board {
  min-height: calc(100svh - 84px);
  padding: 20px 16px 16px;
  overflow: hidden;
  border: 1px solid #ded9e8;
  border-radius: 24px;
  color: #f8f7fb;
  background:
    radial-gradient(circle at 92% 0%, rgba(119,96,255,.44), transparent 22rem),
    linear-gradient(150deg, #23202d 0%, #17151e 74%);
  box-shadow: 0 28px 80px rgba(29,24,42,.18);
}
.morning-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.morning-title h1 {
  margin: 4px 0 0;
  font-size: clamp(34px, 11vw, 54px);
  line-height: 1;
  letter-spacing: -.05em;
}
.workspace-name { margin: 7px 0 0; color: #bdb8c9; font-size: 12px; }
.evidence-label {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  color: #d9d5e2;
  font-size: 10px;
}
.morning-overview {
  margin: 18px 0 12px;
  max-width: 860px;
  color: #fff;
  font-size: clamp(18px, 5.7vw, 28px);
  font-weight: 780;
  line-height: 1.35;
  letter-spacing: -.02em;
}
.dual-readiness { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.dual-readiness.compact { grid-template-columns: 1fr; margin: 6px 0 12px; }
.track-state {
  display: flex;
  min-width: 0;
  padding: 9px 10px;
  gap: 3px;
  flex-direction: column;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 11px;
  color: #c9c5d1;
  background: rgba(255,255,255,.055);
  font-size: 10px;
  line-height: 1.35;
}
.track-state b { color: #fff; font-size: 11px; }
.track-state.is-ready { border-color: rgba(83,218,159,.34); background: rgba(26,133,91,.18); }
.track-state.is-blocked { border-color: rgba(255,187,92,.24); background: rgba(169,104,9,.12); }
.readiness .track-state { color: var(--muted); border-color: var(--line); background: var(--soft); }
.readiness .track-state b { color: var(--ink); }

.approval-zone { margin-top: 18px; }
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.section-title h2 { margin: 3px 0 0; font-size: 21px; }
.section-title > span { color: #c9c4d2; font-size: 12px; }
.approval-rail {
  display: grid;
  margin: 10px -16px 0;
  padding: 0 16px 8px;
  grid-auto-columns: min(88vw, 390px);
  grid-auto-flow: column;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.redline-card, .all-clear {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255,126,101,.28);
  border-radius: 15px;
  background: rgba(112,40,30,.18);
  scroll-snap-align: start;
}
.redline-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.redline-kind {
  padding: 5px 8px;
  border-radius: 999px;
  color: #ffd8d1;
  background: rgba(255,132,108,.14);
  font-size: 10px;
  font-weight: 850;
}
.redline-head strong { font-size: 12px; }
.proposal { margin-top: 10px; }
.proposal small { color: #aaa4b5; }
.proposal p { margin: 4px 0 0; color: #fff; font-size: 15px; font-weight: 760; line-height: 1.45; }
.approval-why { margin: 10px 0; color: #d7d2dd; font-size: 12px; line-height: 1.5; }
.approval-why b { color: #fff; }
.approval-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.approval-actions .button { min-width: 0; padding: 9px 7px; font-size: 11px; }
.capability-note { display: block; margin-top: 8px; color: #96909f; font-size: 9px; line-height: 1.45; }
.all-clear { display: flex; align-items: center; gap: 12px; border-color: rgba(69,210,145,.22); background: rgba(24,130,85,.14); }
.all-clear > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #9cf0c9; background: rgba(64,208,143,.15); font-weight: 900; }
.all-clear strong, .all-clear small { display: block; }
.all-clear small { margin-top: 3px; color: #aaa5b2; }

.morning-bottom { display: grid; margin-top: 13px; gap: 10px; }
.completed-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 13px;
  background: rgba(255,255,255,.045);
}
.completed-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.completed-head .button { padding: 5px 7px; color: #aaa4b3; background: rgba(255,255,255,.08); font-size: 9px; }
.completed-box ul { max-height: 82px; margin: 7px 0; padding-left: 17px; overflow: auto; color: #d1ccd7; font-size: 11px; line-height: 1.5; }
.completed-box small { color: #918b99; font-size: 9px; }
.accepted-summary { margin: 9px 0; padding: 8px 9px; border-radius: 9px; color: #cfc7ff; background: rgba(104,87,245,.14); font-size: 10px; }
.accepted-summary ul { max-height: 54px; margin: 4px 0; color: #c7c0d8; }
.accepted-summary small { display: block; color: #a49db5; }
.blocked-summary { margin: 9px 0; padding: 8px 9px; border-radius: 9px; color: #ffcf9b; background: rgba(169,104,9,.14); font-size: 10px; }
.blocked-summary ul { max-height: 54px; margin: 4px 0 0; color: #d9c5ac; }
.key-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key-number { padding: 12px 8px; border-radius: 13px; color: var(--ink); background: #fff; }
.key-number b { display: block; font-size: clamp(21px, 7vw, 30px); letter-spacing: -.04em; }
.key-number span { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.3; }

.secondary-dock { display: grid; margin: 12px 0; gap: 8px; }
.secondary-panel, .operations-console {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.86);
}
.secondary-panel > summary {
  display: flex;
  padding: 15px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  list-style: none;
}
.secondary-panel > summary::-webkit-details-marker { display: none; }
.secondary-panel > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-size: 20px; font-weight: 500; }
.secondary-panel[open] > summary::after { content: "−"; }
.secondary-panel > summary small { color: var(--muted); font-size: 10px; font-weight: 600; }
.secondary-grid { display: grid; gap: 10px; padding: 0 10px 10px; }
.owner-summary { min-width: 0; padding: 16px; box-shadow: none; }
.owner-summary h2 { margin: 7px 0; font-size: 19px; line-height: 1.4; }
.owner-summary p { color: var(--muted); }
.boundary-list { display: flex; flex-wrap: wrap; gap: 6px; }
.boundary-list span { padding: 6px 8px; border-radius: 999px; color: #585261; background: #f0eef4; font-size: 10px; font-weight: 750; }
.history-reports { padding: 0 12px 12px; }

.operations-console { margin-bottom: 28px; background: #f0eff3; }
.operations-heading { display: flex; margin: 8px 0 16px; padding: 6px 3px; align-items: flex-start; justify-content: space-between; gap: 16px; }
.operations-heading h1 { margin: 5px 0; font-size: clamp(30px, 7vw, 48px); letter-spacing: -.04em; }
.operations-heading p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; }
.operations-warning { margin: 0 12px 12px; padding: 10px 12px; border-radius: 10px; color: #6d6572; background: #e5e2e9; font-size: 11px; }
.modules { display: grid; padding: 0 10px 10px; gap: 10px; }
.module { min-width: 0; padding: 17px; box-shadow: none; }
.module-head { display: flex; margin-bottom: 14px; align-items: flex-start; justify-content: space-between; gap: 10px; }
.module h2 { margin: 3px 0; font-size: 20px; }
.module p { color: var(--muted); }
.inline-form { display: grid; gap: 8px; }
.inline-form.three { grid-template-columns: 1fr; }
.inline-form label { margin: 0; }
.inline-form .button { align-self: end; }
.form-grid { display: grid; gap: 8px; }
.form-grid > .wide, .form-grid > .button { grid-column: 1 / -1; }
.checks { display: grid; gap: 7px; margin: 14px 0; }
.checks label, .checks span { display: flex; align-items: center; gap: 7px; }
.checks input { width: auto; margin: 0; }

.list { display: grid; gap: 8px; margin-top: 12px; }
.list-item {
  display: flex;
  min-width: 0;
  padding: 12px;
  align-items: flex-start;
  flex-direction: column;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.list-item > div { min-width: 0; }
.list-item strong, .list-item small { display: block; }
.list-item small { margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.list-item > .actions { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  white-space: nowrap;
  color: #615b69;
  background: #efedf3;
  font-size: 10px;
  font-weight: 850;
}
.badge.ready, .badge.completed, .badge.published, .badge.uploaded, .badge.packaged,
.badge.artifact_ready, .badge.active, .badge.online, .badge.deployment_ready { color: var(--green); background: var(--green-bg); }
.badge.failed, .badge.rejected, .badge.packaging_failed, .badge.checkout_failed,
.badge.attention_required { color: var(--red); background: #ffe8e2; }
.badge.blocked, .badge.unavailable, .badge.awaiting_approval, .badge.pending, .badge.partial,
.badge.materials_required, .badge.awaiting_vendor_payment, .badge.filing_materials_required,
.badge.face_verification_required, .badge.filing_authorization_required,
.badge.deployment_authorization_required, .badge.deployment_exact_authorization_required,
.badge.deployment_blocked, .badge.canary_failed, .badge.pause_pending, .badge.archive_partial { color: var(--amber); background: var(--amber-bg); }
.badge.queued, .badge.building, .badge.crawling, .badge.reconstructing, .badge.validating,
.badge.packaging, .badge.provisioning, .badge.probing, .badge.deploying, .badge.verifying,
.badge.checkout_creating, .badge.fulfillment_pending, .badge.filing_pending,
.badge.filing_under_review, .badge.activating, .badge.requesting, .badge.submitted,
.badge.draft_ready, .badge.authorized, .badge.publishing { color: #5141c2; background: #ece9ff; }
.badge.revoked, .badge.cancelled, .badge.archived, .badge.paused { color: #615b69; background: #efedf3; }
.report { margin-top: 9px; padding: 13px; border-left: 4px solid var(--purple); border-radius: 0 11px 11px 0; background: #f7f5ff; }
.report p { margin: 7px 0; }
.report .accepted-text { color: #5545a8; }
.report .blocked-text { color: var(--amber); }
.exception { margin: 8px 0; padding: 13px; border: 1px solid #f1d59c; border-radius: 11px; background: #fff7e5; }
.link { color: #5545cb; font-weight: 750; text-decoration: none; }

dialog { width: min(720px, 96vw); max-height: 90vh; border: 0; background: transparent; }
dialog::backdrop { background: rgba(23,19,31,.72); backdrop-filter: blur(7px); }
.dialog-card { position: relative; max-height: 88vh; padding: 28px 22px; overflow: auto; }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border: 0; border-radius: 50%; cursor: pointer; font-size: 22px; }
.toast { position: fixed; right: 14px; bottom: 14px; z-index: 30; max-width: calc(100vw - 28px); padding: 13px 16px; border-radius: 11px; color: #fff; background: var(--ink); box-shadow: 0 15px 50px rgba(0,0,0,.25); }

@media (min-width: 760px) {
  .header { height: 68px; padding: 0 3vw; }
  .owner-mode { font-size: 12px; }
  .auth-view { min-height: calc(100vh - 68px); grid-template-columns: 1.2fr .8fr; padding: 7vh 7vw; gap: 7vw; }
  .auth-copy h1 { font-size: clamp(56px, 7vw, 92px); }
  .app-view { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 220px 1fr; }
  .sidebar { position: sticky; top: 68px; order: initial; height: calc(100vh - 68px); padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line); overflow: auto; }
  .workspace-main { order: initial; padding: 24px; }
  .morning-board { min-height: calc(100vh - 116px); padding: 28px; }
  .approval-rail { margin-right: -28px; margin-left: -28px; padding-right: 28px; padding-left: 28px; grid-auto-columns: min(390px, 48vw); }
  .morning-bottom { grid-template-columns: minmax(0, 1.1fr) minmax(330px, .9fr); }
  .secondary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 14px 14px; }
  .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 14px 14px; gap: 14px; }
  .module.wide { grid-column: 1 / -1; }
  .inline-form { grid-template-columns: 1fr auto; align-items: end; }
  .inline-form.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inline-form.three > .wide { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .list-item { align-items: center; flex-direction: row; justify-content: space-between; }
  .list-item > .actions { width: auto; justify-content: flex-end; }
  .dialog-card { padding: 34px; }
}

@media (min-width: 1120px) {
  .app-view { grid-template-columns: 245px 1fr; }
  .workspace-main { padding: 32px; }
  .morning-board { padding: 32px; }
  .approval-rail { margin-right: -32px; margin-left: -32px; padding-right: 32px; padding-left: 32px; grid-auto-columns: minmax(340px, 1fr); }
  .secondary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
