:root {
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: #15313f;
  background: #eef3f4;
  font-synthesis: none;
  --brand: #123f50;
  --brand-deep: #07384a;
  --accent: #0f6d70;
  --page: #eef3f4;
  --line: #d5e0e3;
  --muted: #647780;
  --ink: #15313f;
  --danger: #d84339;
  --danger-soft: #ffeceb;
  --warning: #d97810;
  --warning-soft: #fff3df;
  --success: #118565;
  --success-soft: #e7f6ef;
  --shadow: 0 22px 60px rgba(19, 54, 66, .16);
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--page); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, tr:focus-visible { outline: 3px solid rgba(15,109,112,.25); outline-offset: 1px; }

.login-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(13,36,46,.78); backdrop-filter: blur(8px); }
.login-card { width: min(460px,100%); overflow: hidden; border-radius: 22px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.28); }
.login-head { padding: 29px 30px 25px; color: #fff; background: linear-gradient(125deg,#10384a,#13596a 58%,#0f6d70); }
.login-head small { display: block; margin-bottom: 8px; color: #bfe6e0; font-weight: 800; letter-spacing: .12em; }
.login-head h1 { margin: 0; font-size: 27px; }
.login-head p { margin: 9px 0 0; color: #dceff0; line-height: 1.65; }
.login-form { display: grid; gap: 18px; padding: 26px 30px 30px; }
.login-form label, .form label { display: grid; gap: 8px; color: #3e5964; font-size: 13px; font-weight: 800; }
.login-form input, .form input, .form select, .form textarea { width: 100%; border: 1px solid #cad8dc; border-radius: 9px; outline: 0; color: var(--ink); background: #fff; }
.login-form input, .form input, .form select { min-height: 44px; padding: 0 12px; }
.login-form input { min-height: 52px; background: #fff9e8; font-size: 16px; }
.form textarea { min-height: 96px; padding: 11px 12px; resize: vertical; line-height: 1.55; }
.login-form input:focus, .form input:focus, .form select:focus, .form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,109,112,.12); }
.form-error { min-height: 20px; margin: -5px 0 0; color: #b42318; font-size: 13px; font-weight: 700; }

.crm-shell { min-height: 100vh; display: grid; grid-template-columns: 186px minmax(0,1fr); background: #fff; }
.side-nav { position: sticky; top: 0; z-index: 30; display: flex; flex-direction: column; height: 100vh; color: #fff; background: var(--brand-deep); box-shadow: 8px 0 24px rgba(9,50,66,.08); }
.nav-brand { min-height: 100px; display: flex; flex-direction: column; justify-content: center; padding: 0 22px; border-bottom: 1px solid rgba(255,255,255,.11); }
.nav-brand span { color: #9fd4d3; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.nav-brand strong { margin-top: 5px; font-size: 19px; }
.nav-brand small { margin-top: 2px; color: #b9d2d8; font-size: 11px; }
.nav-list { padding: 10px 0; }
.nav-list button, .nav-list a { position: relative; width: 100%; min-height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 20px; border: 0; color: #d8e8ec; background: transparent; text-align: left; text-decoration: none; font-weight: 700; }
.nav-list button:hover, .nav-list a:hover { background: rgba(255,255,255,.07); }
.nav-list button.active { color: #fff; background: rgba(27,142,146,.34); }
.nav-list button.active::before { position: absolute; inset: 0 auto 0 0; width: 4px; background: #2bd2d1; content: ""; }
.nav-list b { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid rgba(255,255,255,.25); border-radius: 7px; font-size: 10px; }
.nav-spacer { flex: 1; }
.flow-note { display: grid; gap: 5px; margin: 0 15px 13px; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: rgba(255,255,255,.045); }
.flow-note strong { color: #bfe6e0; font-size: 11px; }
.flow-note span { color: #c9dce1; font-size: 10px; line-height: 1.55; }
.user-profile { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 16px 14px 19px; border-top: 1px solid rgba(255,255,255,.1); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #07384a; background: #a8d8d5; font-weight: 900; }
.user-profile div { min-width: 0; display: grid; gap: 2px; }
.user-profile strong, .user-profile small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-profile strong { font-size: 12px; }
.user-profile small { color: #b9d2d8; font-size: 9px; }
.user-profile button { padding: 4px; border: 0; color: #b9d2d8; background: transparent; font-size: 10px; }

.workspace { min-width: 0; min-height: 100vh; background: #fff; }
.quotation-module { width: 100%; height: 100vh; overflow: hidden; background: var(--page); }
.quotation-frame { width: 100%; height: 100%; display: block; border: 0; background: var(--page); }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.98); }
.topbar h1 { margin: 0; color: #0f2b3c; font-size: 27px; letter-spacing: -.02em; }
.topbar p { margin: 5px 0 0; color: #3f5764; font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.search-control, .select-control { min-height: 43px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; color: #738690; background: #fff; }
.search-control { width: min(340px,30vw); }
.search-control span, .select-control span { font-size: 11px; font-weight: 800; white-space: nowrap; }
.search-control input, .select-control select { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.select-control select { min-width: 100px; font-weight: 700; }
.primary-button { min-height: 43px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 17px; border: 1px solid var(--accent); border-radius: 8px; color: #fff; background: var(--accent); font-weight: 800; box-shadow: 0 6px 14px rgba(15,109,112,.13); }
.primary-button:hover { background: #0c5d60; }
.secondary-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--accent); border-radius: 7px; color: var(--accent); background: #fff; font-size: 12px; font-weight: 800; }
.secondary-button:hover { color: #fff; background: var(--accent); }
button:disabled { opacity: .6; cursor: wait; }

.workbench { padding: 20px 28px 30px; }
.summary-cards { display: grid; grid-template-columns: repeat(6,minmax(105px,1fr)); gap: 10px; margin-bottom: 19px; }
.summary-card { padding: 13px 15px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.summary-card span { display: block; color: var(--muted); font-size: 11px; }
.summary-card strong { display: block; margin-top: 4px; color: var(--brand); font-size: 23px; }
.summary-card.danger strong { color: var(--danger); }
.summary-card.warning strong { color: var(--warning); }
.summary-card.success strong { color: var(--success); }
.action-group { margin: 0 0 21px; }
.group-title h2 { position: relative; margin: 0 0 8px; padding-left: 13px; color: var(--ink); font-size: 16px; }
.group-title h2::before { position: absolute; inset: 1px auto 1px 0; width: 3px; border-radius: 2px; background: #81969f; content: ""; }
.group-title h2 span { font-weight: 500; }
.action-group.danger .group-title h2 { color: var(--danger); }
.action-group.danger .group-title h2::before { background: var(--danger); }
.action-group.warning .group-title h2 { color: var(--warning); }
.action-group.warning .group-title h2::before { background: var(--warning); }
.action-group.success .group-title h2 { color: var(--success); }
.action-group.success .group-title h2::before { background: var(--success); }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; min-width: 940px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
th { color: #536973; font-size: 11px; font-weight: 800; }
td { color: #354e5a; font-size: 12px; }
th:nth-child(1),td:nth-child(1){width:15%} th:nth-child(2),td:nth-child(2){width:8%} th:nth-child(3),td:nth-child(3){width:12%} th:nth-child(4),td:nth-child(4){width:18%} th:nth-child(5),td:nth-child(5){width:24%} th:nth-child(6),td:nth-child(6){width:9%} th:nth-child(7),td:nth-child(7){width:8%} th:nth-child(8),td:nth-child(8){width:6%}
tbody tr { cursor: pointer; transition: background .14s ease; }
tbody tr:hover, tbody tr:focus-visible { background: #f3f9f8; }
.customer-name { color: #173849; font-weight: 900; }
.next-action { font-weight: 700; }
.danger .next-action, .danger .due-cell { color: var(--danger); }
.warning .next-action, .warning .due-cell { color: var(--warning); }
.success .next-action { color: var(--success); }
.status-badge { display: inline-flex; justify-content: center; min-width: 46px; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-badge.danger { color: #c7322b; background: var(--danger-soft); }
.status-badge.warning { color: #ad5b05; background: var(--warning-soft); }
.status-badge.success { color: #187e60; background: var(--success-soft); }
.status-badge.neutral { color: #526874; background: #edf2f3; }
.data-stamp { padding-top: 4px; color: #91a1a8; font-size: 11px; text-align: center; }
.loading, .empty-state { padding: 60px 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--brand); font-size: 18px; }

.drawer-scrim { position: fixed; inset: 0 0 0 186px; z-index: 40; background: rgba(9,39,51,.08); }
.detail-drawer { position: fixed; z-index: 50; inset: 40px 0 0 auto; width: min(600px,calc(100vw - 215px)); overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px 0 0 0; background: #fff; box-shadow: var(--shadow); animation: slideIn .2s ease-out; }
.drawer-head { display: flex; justify-content: space-between; gap: 15px; padding: 22px 24px 16px; }
.drawer-head-actions { display: flex; align-items: flex-start; gap: 8px; }
.transfer-button { min-height: 38px; padding: 0 13px; border: 1px solid #c58b27; border-radius: 8px; color: #895300; background: #fff8e8; font-size: 12px; font-weight: 800; white-space: nowrap; }
.transfer-button:hover { color: #fff; background: #a96a08; }
.drawer-title { display: flex; align-items: center; gap: 10px; }
.drawer-title h2 { margin: 0; color: #102d3d; font-size: 25px; }
.level-badge { padding: 5px 10px; border: 1px solid #47a99e; border-radius: 999px; color: #12816f; background: #f3fbf9; font-size: 11px; font-weight: 800; }
.drawer-head p { margin: 10px 0 0; color: #5b707a; font-size: 12px; }
.close-button { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; padding: 0; border: 0; border-radius: 8px; color: #5e737d; background: transparent; font-size: 27px; line-height: 1; }
.close-button:hover { color: var(--ink); background: #f1f5f6; }
.close-button.light { color: #e6f0f2; }
.drawer-tabs { display: grid; grid-template-columns: repeat(5,1fr); padding: 0 18px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { min-height: 49px; padding: 0 4px; border: 0; border-bottom: 3px solid transparent; color: #526874; background: #fff; font-size: 12px; font-weight: 700; }
.drawer-tabs button:hover, .drawer-tabs button.active { color: var(--accent); }
.drawer-tabs button.active { border-bottom-color: var(--accent); }
.drawer-body { min-height: 0; overflow: auto; flex: 1; padding: 0 24px 28px; }
.drawer-action-row { position: sticky; top: 0; z-index: 4; display: flex; justify-content: flex-end; gap: 8px; padding: 10px 0 6px; background: rgba(255,255,255,.97); }
.detail-section { padding: 22px 0; }
.detail-section > h3 { margin: 0 0 16px; color: #173746; font-size: 17px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-top: 1px solid var(--line); }
.detail-grid div { min-width: 0; padding: 14px 10px; border-bottom: 1px solid var(--line); }
.detail-grid dt { color: var(--muted); font-size: 10px; }
.detail-grid dd { margin: 7px 0 0; color: var(--ink); font-size: 12px; font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-block { margin-top: 18px; padding: 14px; border-radius: 8px; color: #506873; background: #f3f7f8; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.timeline { padding-top: 5px; }
.timeline-item { position: relative; min-height: 72px; display: grid; grid-template-columns: minmax(0,1fr) 84px; gap: 10px; padding: 7px 0 14px 30px; }
.timeline-item::before { position: absolute; top: 27px; bottom: -7px; left: 9px; width: 1px; background: #cddfe0; content: ""; }
.timeline-item:last-child::before { display: none; }
.timeline-marker { position: absolute; top: 9px; left: 0; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #118d7b; font-size: 10px; font-weight: 900; }
.timeline-copy h3 { margin: 0; color: #173746; font-size: 13px; }
.timeline-copy p { margin: 6px 0 0; color: #60757e; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.timeline-copy small, .timeline-item time { color: #7b8e96; font-size: 10px; }
.timeline-copy small { display: block; margin-top: 6px; }
.timeline-item time { padding-top: 2px; text-align: right; white-space: nowrap; }
.next-step-card { margin: 4px 0 16px; padding: 15px; border: 1px solid #cfe2e1; border-radius: 8px; background: #eef8f7; }
.next-step-card strong { display: block; color: var(--accent); font-size: 14px; }
.next-step-card p { margin: 7px 0 0; color: #5f747d; font-size: 12px; }
.list-card { margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.list-card header { display: flex; justify-content: space-between; gap: 12px; }
.list-card strong { color: #173746; font-size: 13px; }
.list-card span, .list-card small { color: var(--muted); font-size: 11px; }
.list-card p { margin: 9px 0 0; color: #506873; font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.gate-row { display: grid; grid-template-columns: 86px 70px 1fr; gap: 9px; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.gate-row b { color: var(--success); }
.risk-note { margin-top: 18px; padding: 14px; border-radius: 8px; color: #8a5404; background: #fff7e7; font-size: 12px; line-height: 1.6; }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(8,35,46,.55); backdrop-filter: blur(3px); }
.modal { width: min(620px,100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 12px; background: #fff; box-shadow: 0 28px 80px rgba(9,33,43,.3); }
.modal > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 17px 21px; color: #fff; background: var(--brand); }
.modal > header h2 { margin: 0; font-size: 18px; }
.form { display: grid; gap: 16px; padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.transfer-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding: 12px; border: 1px solid #d7e4e6; border-radius: 8px; background: #f7fafb; }
.transfer-summary div { min-width: 0; padding: 3px 7px; }
.transfer-summary span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.transfer-summary strong { display: block; overflow-wrap: anywhere; color: #173746; font-size: 12px; line-height: 1.45; }
.form-hint { margin: 0; padding: 11px 13px; border-radius: 7px; color: #5f747d; background: #f2f6f7; font-size: 11px; line-height: 1.6; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 3px; }
.form-actions > button:not(.primary-button) { min-height: 43px; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; color: #516873; background: #fff; font-weight: 700; }
.checkbox-label { display: flex !important; grid-column: 1/-1; align-items: center; gap: 8px !important; }
.checkbox-label input { width: 18px !important; min-height: 18px !important; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 120; max-width: 380px; padding: 13px 16px; border-radius: 9px; color: #fff; background: #153f4e; box-shadow: 0 16px 40px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.error { background: #a73029; }
.toast.visible { opacity: 1; transform: translateY(0); }

@keyframes slideIn { from { transform: translateX(34px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }

@media (max-width: 1080px) {
  .crm-shell { grid-template-columns: 76px minmax(0,1fr); }
  .nav-brand { padding: 0 7px; text-align: center; }
  .nav-brand span, .nav-brand small, .nav-list span, .flow-note, .user-profile div, .user-profile button { display: none; }
  .nav-brand strong { font-size: 13px; }
  .nav-list button, .nav-list a { justify-content: center; padding: 0; }
  .user-profile { display: flex; justify-content: center; padding-inline: 0; }
  .drawer-scrim { left: 76px; }
  .detail-drawer { width: min(600px,calc(100vw - 90px)); }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .summary-cards { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 760px) {
  .crm-shell { display: block; }
  .side-nav { position: fixed; inset: auto 0 0; z-index: 60; width: 100%; height: 64px; flex-direction: row; }
  .nav-brand, .nav-spacer, .flow-note, .user-profile { display: none; }
  .nav-list { width: 100%; display: grid; grid-template-columns: repeat(3,1fr); padding: 0; }
  .nav-list button, .nav-list a { min-height: 64px; flex-direction: column; justify-content: center; gap: 3px; padding: 0 4px; font-size: 10px; }
  .nav-list span { display: block; }
  .nav-list b { width: 24px; height: 22px; }
  .workspace { padding-bottom: 68px; }
  .quotation-module { height: calc(100vh - 64px); }
  .topbar { display: block; padding: 16px; }
  .topbar h1 { font-size: 23px; }
  .top-actions { display: grid; grid-template-columns: 1fr auto; margin-top: 14px; }
  .search-control { grid-column: 1/-1; grid-row: 2; width: 100%; }
  .select-control { grid-column: 1; }
  .primary-button { grid-column: 2; grid-row: 1; }
  .workbench { padding: 15px 16px 84px; }
  .summary-cards { grid-template-columns: repeat(3,1fr); }
  .summary-card { padding: 10px; }
  .summary-card strong { font-size: 20px; }
  .drawer-scrim { inset: 0; }
  .detail-drawer { inset: 0; width: 100%; border: 0; border-radius: 0; padding-bottom: 65px; }
  .drawer-head { padding: 17px 16px 13px; }
  .drawer-head-actions { gap: 3px; }
  .transfer-button { padding: 0 9px; }
  .drawer-title h2 { font-size: 21px; }
  .drawer-tabs { overflow-x: auto; display: flex; padding: 0 9px; }
  .drawer-tabs button { min-width: 82px; padding: 0 7px; }
  .drawer-body { padding: 0 16px 22px; }
  .form-grid, .detail-grid, .transfer-summary { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }
