:root {
  --ink: #07111f;
  --navy: #0c2340;
  --navy-2: #14345c;
  --navy-3: #1c4a7a;
  --gold: #c9a24a;
  --gold-2: #e4c36a;
  --gold-dim: rgba(201, 162, 74, 0.16);
  --paper: #f3f1ea;
  --card: #fffdf8;
  --line: #e4ddd0;
  --muted: #6b7280;
  --text: #1c2430;
  --ok: #1f7a56;
  --ok-bg: #e7f6ee;
  --warn: #b45309;
  --warn-bg: #fff4e0;
  --info: #1d4e89;
  --info-bg: #e8f0fa;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --shadow: 0 10px 30px rgba(12, 35, 64, 0.08);
  --radius: 14px;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--paper);
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  background: var(--ink);
}
.login-hero {
  position: relative;
  padding: 56px 64px;
  color: #f6efe0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #0a1220;
}
.seal {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #2a4a72, #0c2340);
  box-shadow: 0 0 0 6px rgba(201,162,74,.12);
}
.seal svg { width: 26px; height: 26px; fill: var(--gold-2); }
.vault-stage { position: relative; z-index: 1; max-width: 460px; }
.sealed-stack { position: relative; height: 210px; margin: 0 0 22px; }
.sealed-card {
  position: absolute; left: 0; right: 40px;
  background: linear-gradient(180deg, #12233a, #0b1829);
  border: 1px solid rgba(201,162,74,.35);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 18px 40px rgba(0,0,0,.28);
}
.sealed-card span {
  display: block; font-size: 12px; letter-spacing: 2px; color: #ead9a4; margin-bottom: 8px;
}
.sealed-card em {
  font-style: normal; font-family: ui-monospace, Menlo, monospace;
  color: #7f8b99; letter-spacing: 3px;
}
.sealed-card.c1 { top: 0; transform: rotate(-6deg); opacity: .72; }
.sealed-card.c2 { top: 38px; transform: rotate(2deg); opacity: .88; }
.sealed-card.c3 { top: 84px; transform: rotate(-1deg); }
.key-row { display: flex; gap: 10px; margin-bottom: 16px; }
.key-row i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--gold);
  background: #1a1408;
  box-shadow: 0 0 0 4px rgba(201,162,74,.12);
  display: block;
}
.vault-caption {
  margin: 0;
  color: #cfc6b4;
  font-size: 14px;
  line-height: 1.7;
  max-width: 420px;
}
.hero-flow {
  position: relative; z-index: 1;
  margin-top: 48px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  color: #cfc6b4; font-size: 12px; letter-spacing: 1px;
}
.hero-flow b {
  color: #0c2340; background: var(--gold-2); padding: 6px 10px; border-radius: 8px; font-weight: 650;
}
.hero-flow i { opacity: .5; font-style: normal; }

.login-panel {
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 36px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card .hint { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.role-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.role-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 13px;
}
.role-tab.active {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--navy-3);
  box-shadow: 0 0 0 3px rgba(20,52,92,.08);
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #16345d; }
.btn-gold { background: linear-gradient(180deg, #e4c36a, #c9a24a); color: #3b2a08; }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-block { width: 100%; }
.login-note { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ========== APP SHELL ========== */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
}
.sidebar {
  background: linear-gradient(180deg, #0b1d35 0%, #081525 100%);
  color: #d7d0c3;
  padding: 20px 14px;
  display: flex; flex-direction: column;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 16px;
}
.side-brand .seal { width: 38px; height: 38px; }
.side-brand .seal svg { width: 18px; height: 18px; }
.side-brand strong { display: block; color: #fff; letter-spacing: 3px; font-size: 18px; }
.side-brand small { color: #b8b09f; font-size: 11px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #cfc6b4;
  padding: 11px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.05); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(201,162,74,.22), rgba(201,162,74,.06));
  color: #f4e3b2;
}
.nav-ico { width: 18px; opacity: .9; }
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #6d6558;
  box-shadow: 0 0 0 3px rgba(201,162,74,0);
}
.nav-item.active .dot {
  background: var(--gold-2);
  box-shadow: 0 0 0 3px rgba(201,162,74,.18);
}
.kpi {
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute; right: -10px; top: -18px;
  width: 70px; height: 70px; border-radius: 50%;
  background: var(--gold-dim);
}
.side-foot {
  margin-top: auto;
  padding: 14px 10px 6px;
  font-size: 11px;
  color: #8d8678;
  line-height: 1.6;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 64px;
  background: rgba(255,253,248,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.crumb { font-size: 14px; color: var(--muted); }
.crumb b { color: var(--text); }
.top-right { display: flex; align-items: center; gap: 10px; }
.chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--gold-dim);
  color: #8a6918;
  border: 1px solid rgba(201,162,74,.3);
}
.userbox {
  display: flex; align-items: center; gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: grid; place-items: center; font-size: 12px;
}
.userbox small { display: block; color: var(--muted); font-size: 11px; margin-top: -2px; }

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

/* ========== COMMON ========== */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: .5px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, 1fr); gap: 14px; }
[hidden] { display: none !important; }
html { min-width: 1180px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card:has(table.data) { overflow-x: auto; }
.card-pad { padding: 18px 18px 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.kpi { padding: 18px 18px 16px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .num { font-size: 28px; font-weight: 680; margin: 8px 0 4px; letter-spacing: -.5px; }
.kpi .sub { font-size: 12px; color: var(--ok); }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.b-bid { background: var(--info-bg); color: var(--info); }
.b-open { background: var(--warn-bg); color: var(--warn); }
.b-eval { background: #f3e8ff; color: #7e22ce; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-wait { background: #eef2f6; color: #475569; }
.b-gold { background: var(--gold-dim); color: #8a6918; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; color: #5b6472;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  background: #faf7f0;
}
table.data td { padding: 12px; border-bottom: 1px solid #eee7da; vertical-align: middle; }
table.data tr:hover td { background: #fffaf0; }
.linkish { color: var(--navy-3); font-weight: 600; background: none; border: 0; padding: 0; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}
.filters select, .filters input {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 8px 10px; font-size: 13px;
}

.stepper {
  display: flex; gap: 0; margin: 6px 0 18px;
}
.step {
  flex: 1; text-align: center; position: relative; padding-top: 6px;
}
.step::before {
  content: "";
  position: absolute; top: 16px; left: 0; right: 0;
  height: 2px; background: #ddd4c4;
}
.step:first-child::before { left: 50%; }
.step:last-child::before { right: 50%; }
.step span {
  position: relative; z-index: 1;
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; border: 2px solid #d4cbb8; color: #8a8374;
  font-size: 12px; font-weight: 700;
}
.step em { display: block; margin-top: 8px; font-style: normal; font-size: 12px; color: var(--muted); }
.step.done span, .step.now span { border-color: var(--navy); background: var(--navy); color: #fff; }
.step.done::before, .step.now::before { background: var(--navy); }

.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #eef2f6; color: #475569; margin-right: 4px; }

/* ========== DASHBOARD ========== */
.hero-banner {
  background:
    radial-gradient(500px 180px at 90% 0%, rgba(201,162,74,.25), transparent 50%),
    linear-gradient(120deg, #0c2340, #16375f 60%, #1c4a7a);
  color: #f6efe0;
  border-radius: 18px;
  padding: 22px 24px;
  display: flex; justify-content: space-between; gap: 20px;
  margin-bottom: 16px;
}
.hero-banner h2 { margin: 0 0 8px; font-size: 22px; }
.hero-banner p { margin: 0; color: #d5cbb6; font-size: 13px; line-height: 1.7; max-width: 640px; }
.banner-stat { text-align: right; }
.banner-stat b { display: block; font-size: 32px; color: var(--gold-2); }
.banner-stat span { font-size: 12px; color: #cfc6b4; }

.project-mini { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eee7da; }
.project-mini:last-child { border-bottom: 0; padding-bottom: 0; }
.timeline { position: relative; padding-left: 16px; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: #e6ddcd;
}
.tl-item { position: relative; padding: 0 0 14px 12px; }
.tl-item::before {
  content: ""; position: absolute; left: -15px; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim);
}
.tl-item strong { display: block; font-size: 13px; }
.tl-item span { font-size: 12px; color: var(--muted); }

/* ========== PUBLISH ========== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ========== UNLOCK CHAMBER ========== */
.chamber {
  background:
    radial-gradient(720px 340px at 50% 28%, rgba(201,162,74,.16), transparent 52%),
    linear-gradient(180deg, #08131f 0%, #0b1b2e 58%, #091018 100%);
  color: #f4ead4;
  border-radius: 22px;
  padding: 22px 22px 20px;
  border: 1px solid rgba(201,162,74,.28);
  overflow: visible;
}
.chamber-top {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-bottom: 8px;
}
.chamber-kicker {
  font-size: 11px; letter-spacing: 3px; color: #e4c36a; margin-bottom: 6px;
}
.chamber-top h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
.chamber-top p { margin: 6px 0 0; color: #b8b09f; font-size: 12px; }
.chamber-count {
  text-align: right; min-width: 90px;
}
.chamber-count b { display: block; font-size: 36px; line-height: 1; color: var(--gold-2); }
.chamber-count span { font-size: 12px; color: #b8b09f; }

.vault-stage-open {
  margin: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.vault-door {
  position: relative;
  width: 250px; height: 250px;
  margin: 8px 0 22px;
  display: grid; place-items: center;
}
.key-dock, .envelopes { width: 100%; }
.vault-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(#e4c36a calc(var(--done) * 72deg), #1a2738 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px));
  transition: background .4s ease;
}
.vault-face {
  position: relative;
  width: calc(100% - 28px); height: calc(100% - 28px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #2a3f5c, #0d1724 70%);
  border: 1px solid rgba(201,162,74,.35);
  box-shadow: inset 0 0 40px rgba(0,0,0,.35), 0 12px 40px rgba(0,0,0,.28);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 16px;
}
.vault-lock {
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  margin-bottom: 10px;
  background: #121c2b;
  border: 1.5px solid rgba(201,162,74,.55);
  color: #e4c36a; font-weight: 700; font-size: 20px;
}
.vault-face strong { font-size: 16px; letter-spacing: 1px; }
.vault-face small { display: block; margin-top: 6px; color: #b8b09f; font-size: 12px; line-height: 1.5; max-width: 180px; }
.chamber.opening .vault-lock { animation: vault-spin .9s ease; }
.chamber.opened .vault-face {
  background: radial-gradient(circle at 35% 30%, #4a3a16, #1d1608 70%);
  border-color: var(--gold);
}
.chamber.opened .vault-lock { background: #3d3012; }

@keyframes vault-spin {
  0% { transform: rotate(0) scale(1); }
  45% { transform: rotate(180deg) scale(.92); }
  100% { transform: rotate(360deg) scale(1); }
}

.key-dock {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  max-width: 880px;
  margin: 0 auto 18px;
}
.key-btn {
  width: 100%;
  background: rgba(8,16,26,.86);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  color: #f4ead4;
  padding: 12px 8px 10px;
  text-align: center;
}
.key-btn:disabled { cursor: default; }
.key-btn.ok {
  border-color: rgba(201,162,74,.75);
  background: rgba(61,48,18,.92);
  box-shadow: 0 0 0 4px rgba(201,162,74,.12);
}
.key-bit {
  display: block; width: 18px; height: 18px; margin: 0 auto 6px;
  border-radius: 50%;
  border: 1.5px solid #8a8374;
  background: #151b24;
  position: relative;
}
.key-bit::after {
  content: "";
  position: absolute; left: 50%; top: 16px;
  width: 2px; height: 8px;
  background: #8a8374;
  transform: translateX(-50%);
}
.key-btn.ok .key-bit,
.key-btn.ok .key-bit::after { border-color: var(--gold-2); background: var(--gold); }
.key-btn.ok .key-bit::after { background: var(--gold-2); }
.key-name { display: block; font-weight: 700; font-size: 13px; }
.key-meta, .key-state { display: block; font-size: 11px; color: #b8b09f; }
.key-btn.ok .key-state { color: #e4c36a; }

.envelopes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 6px 0 16px;
}
.envelope {
  position: relative;
  min-height: 118px;
  perspective: 800px;
}
.env-front, .env-back {
  position: absolute; inset: 0;
  border-radius: 14px;
  padding: 12px 10px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform .7s ease, opacity .4s ease;
}
.env-front {
  background: #0c1622;
  border: 1px dashed rgba(201,162,74,.35);
  color: #9aa7b5;
  font-family: ui-monospace, Menlo, monospace;
}
.env-front span { display: block; color: #ead9a4; letter-spacing: 1px; font-size: 11px; margin-bottom: 10px; }
.env-front em { display: block; font-style: normal; letter-spacing: 2px; font-size: 12px; }
.env-front small { display: block; margin-top: 12px; color: #6d7682; }
.env-back {
  background: #fffdf8;
  border: 1px solid #e4ddd0;
  color: #1c2430;
  transform: rotateY(180deg);
  display: flex; flex-direction: column; justify-content: space-between;
}
.env-back span { font-size: 11px; color: #8a6918; font-weight: 700; }
.env-back b { font-size: 18px; letter-spacing: -.3px; }
.env-back small { color: #5b6472; font-size: 11px; line-height: 1.4; }
.env-back i { font-style: normal; font-size: 11px; color: var(--ok); }
.envelope.revealed .env-front { transform: rotateY(-180deg); }
.envelope.revealed .env-back { transform: rotateY(0); }
.envelope.revealed { transition-delay: var(--d, 0ms); }
.envelope.winner .env-back { border-color: var(--gold); box-shadow: 0 8px 20px rgba(201,162,74,.18); }

.chamber-actions {
  display: flex; justify-content: center; gap: 10px; align-items: center; min-height: 44px;
}
.chamber-actions .btn-ghost {
  background: transparent;
  border-color: rgba(201,162,74,.4);
  color: #e4c36a;
}
.opening-tip { color: #e4c36a; font-size: 13px; letter-spacing: 1px; }

.cipher-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #071018;
  border: 1px dashed rgba(201,162,74,.35);
  border-radius: 12px;
  padding: 14px 16px;
  color: #9aa7b5;
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1.8;
}

.compare-rank { font-weight: 800; color: var(--navy); }
.rank-1 { color: #9a7209; }

/* ========== SUPPLIER ========== */
.supplier-shell .sidebar {
  background: linear-gradient(180deg, #123018, #0c1f12);
}
.encrypt-anim {
  border: 1px dashed #c9b98a;
  background: #fffaf0;
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  color: #6b5720;
}

/* toast */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 80;
  background: var(--navy); color: #fff;
  padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
  transform: translateY(20px); opacity: 0;
  transition: .25s ease;
}
.toast.show { transform: none; opacity: 1; }

.guide {
  position: sticky; top: 64px; z-index: 15;
  background: #fff7dc;
  border-bottom: 1px solid #ead79a;
  color: #7a5b10;
  padding: 9px 24px;
  font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(7,17,31,.45);
  display: grid; place-items: center; z-index: 50;
}
.modal {
  width: min(480px, calc(100vw - 32px));
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  border: 1px solid var(--line);
}
.modal h3 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .envelopes, .key-dock { grid-template-columns: 1fr 1fr; }
  .vault-door { width: 220px; height: 220px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { min-height: 340px; padding: 36px 28px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
