:root {
  --blue: #1769e0;
  --deep: #0f2f63;
  --line: #dbe4f0;
  --soft: #f6f9fd;
  --ok: #0f9f6e;
  --warn: #e58a00;
  --bad: #dc2626;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; gap: 24px; align-items: stretch; }
.login-brand { background: linear-gradient(135deg, #0f4fb8, #1683ef); color: white; border-radius: 8px; padding: 38px; display: flex; gap: 18px; align-items: flex-start; min-height: 360px; }
.login-brand h1 { font-size: 34px; line-height: 1.18; font-weight: 800; margin: 8px 0 12px; letter-spacing: 0; }
.login-brand p { color: #d8ebff; font-size: 16px; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.16); font-weight: 900; font-size: 28px; border: 1px solid rgba(255,255,255,.24); flex: none; }
.brand-mark.small { width: 42px; height: 42px; font-size: 21px; }
.login-card { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 28px; box-shadow: 0 18px 50px rgba(15,47,99,.12); }
.role-tabs { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 20px; }
.role-tabs button { border: 1px solid var(--line); background: #fff; color: #335; border-radius: 6px; padding: 10px 6px; }
.role-tabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
label { display: grid; gap: 8px; color: #45556b; font-weight: 700; margin-bottom: 15px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 11px; background: white; outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,224,.12); }
.primary, .ghost, .danger, .ok { border: 0; border-radius: 6px; padding: 10px 13px; font-weight: 800; }
.primary { background: var(--blue); color: white; }
.ghost { background: #eef4fc; color: #164071; }
.danger { background: #fee2e2; color: #991b1b; }
.ok { background: #dcfce7; color: #166534; }

#appPage { min-height: 100vh; display: grid; grid-template-columns: 246px 1fr; }
#sidebar { background: var(--deep); color: white; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; }
.side-brand strong, .side-brand span { display: block; }
.side-brand span { color: #aac6ec; font-size: 12px; margin-top: 3px; }
#nav { display: grid; gap: 6px; }
#nav button { width: 100%; text-align: left; border: 0; background: transparent; color: #d9e7fb; padding: 11px 12px; border-radius: 6px; font-weight: 700; }
#nav button.active, #nav button:hover { background: rgba(255,255,255,.13); color: white; }
main { min-width: 0; }
#topbar { height: 72px; display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 0 24px; background: white; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#topbar h2 { font-size: 22px; margin: 0; font-weight: 900; }
#topbar p { margin: 3px 0 0; color: #667085; font-size: 13px; }
#menuBtn { display: none; border: 1px solid var(--line); background: white; border-radius: 6px; width: 40px; height: 40px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
#userBadge { color: #164071; background: #eef4fc; padding: 8px 10px; border-radius: 6px; font-weight: 800; white-space: nowrap; }
#content { padding: 22px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.grid-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.grid-cards.boss { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.metric span { color: #667085; font-size: 13px; }
.metric strong { display: block; font-size: 27px; margin-top: 8px; color: #0f2f63; }
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 14px; align-items: start; margin-bottom: 16px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.progress-list { display: grid; gap: 10px; }
.progress-row { display: grid; grid-template-columns: 96px 1fr 46px; gap: 10px; align-items: center; font-size: 13px; }
.progress-track { height: 9px; border-radius: 999px; background: #e9eef7; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--blue); }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; gap: 12px; }
.section-title h3 { margin: 0; font-size: 17px; font-weight: 900; }
.table-wrap { background: white; border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #edf1f7; font-size: 13px; vertical-align: top; }
th { background: #f7faff; color: #42526b; font-weight: 900; white-space: nowrap; }
td.actions { white-space: nowrap; }
.mini { padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line); background: white; color: #164071; font-weight: 800; margin: 2px; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 800; background: #eaf2ff; color: #1752a4; }
.status-未分配 { background: #fff1d6; color: #a15c00; }
.status-已分配, .status-渠道已接收 { background: #eaf2ff; color: #1752a4; }
.status-已反馈, .status-谈判中 { background: #ecfdf3; color: #08734d; }
.status-已完结 { background: #f0fdf4; color: #166534; }
.alert { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; font-weight: 800; }
.chart { height: 210px; display: flex; align-items: end; gap: 10px; padding-top: 18px; }
.bar { flex: 1; background: linear-gradient(180deg, #1683ef, #0f4fb8); border-radius: 6px 6px 0 0; min-width: 22px; position: relative; }
.bar span { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #475467; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.42); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal.hidden, .hidden { display: none !important; }
.modal-box { width: min(880px, 100%); max-height: 88vh; overflow: auto; background: white; border-radius: 8px; box-shadow: 0 28px 80px rgba(15,23,42,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: white; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 900; }
#modalClose { border: 0; background: #eef4fc; color: #164071; border-radius: 6px; width: 34px; height: 34px; font-size: 22px; }
#modalBody { padding: 18px; }
#toast { position: fixed; top: 16px; right: 16px; z-index: 40; display: grid; gap: 8px; }
.toast { background: #0f2f63; color: white; padding: 11px 14px; border-radius: 8px; box-shadow: 0 14px 34px rgba(15,47,99,.22); font-weight: 800; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 24px; }
  .login-brand h1 { font-size: 26px; }
  #appPage { grid-template-columns: 1fr; }
  #sidebar { position: fixed; left: -270px; top: 0; width: 246px; z-index: 30; transition: .2s; }
  #sidebar.open { left: 0; }
  #menuBtn { display: inline-grid; place-items: center; flex: none; }
  #topbar { padding: 0 14px; }
  #topbar h2 { font-size: 18px; }
  #pageSub, #userBadge { display: none; }
  #content { padding: 14px; }
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cards.boss { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .grid-cards { grid-template-columns: 1fr; }
  .grid-cards.boss { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
  .role-tabs { grid-template-columns: 1fr; }
  .toolbar .grow { min-width: 100%; }
}
