:root {
  --navy: #17324d;
  --navy-2: #214969;
  --ink: #25313b;
  --muted: #6d7882;
  --paper: #f8f5ef;
  --card: #fffdfa;
  --line: #d8e0e6;
  --orange: #d66d4b;
  --green: #28866d;
  --red: #c74646;
  --shadow: 0 18px 55px rgba(26, 47, 65, .12);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(420px, .9fr); }
.auth-intro { background: var(--navy); color: white; padding: 42px 7vw; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-intro::after { content: ""; position: absolute; width: 480px; height: 480px; border: 70px solid rgba(255,255,255,.04); border-radius: 50%; right: -230px; top: -170px; }
.brand-lockup { display: flex; align-items: center; gap: 13px; position: relative; z-index: 1; }
.brand-mark { width: 50px; height: 50px; border: 1px solid rgba(255,255,255,.55); border-radius: 15px; display: grid; place-items: center; font-family: Georgia, serif; font-weight: 700; }
.brand-lockup span { display: block; font-size: 12px; letter-spacing: 1.3px; opacity: .82; }
.brand-lockup strong { display: block; font-size: 22px; margin-top: 2px; }
.auth-copy { position: relative; z-index: 1; max-width: 650px; }
.eyebrow { font-size: 11px; letter-spacing: 2px; color: var(--orange); font-weight: 700; }
.auth-copy h1 { font-size: clamp(42px, 5.2vw, 72px); line-height: 1.08; margin: 18px 0 25px; letter-spacing: -2px; }
.auth-copy p { font-size: 17px; line-height: 1.85; color: rgba(255,255,255,.72); max-width: 590px; }
.auth-points { display: flex; flex-wrap: wrap; gap: 22px; color: rgba(255,255,255,.78); font-size: 13px; position: relative; z-index: 1; }
.auth-points span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); margin-right: 8px; }
.auth-panel { display: grid; place-items: center; padding: 44px; background: #f1eee7; }
.auth-card { width: min(440px, 100%); background: var(--card); border: 1px solid #e5ddd2; border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.validation-badge { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: #f6e8df; color: #a34f34; font-size: 12px; font-weight: 700; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--line); margin: 26px 0; }
.auth-tab { flex: 1; border: 0; background: none; padding: 12px; color: var(--muted); }
.auth-tab.active { color: var(--navy); font-weight: 700; border-bottom: 3px solid var(--navy); }
.auth-form { display: grid; gap: 17px; }
label { display: grid; gap: 7px; font-size: 13px; color: #4e5a64; }
input, select, textarea { width: 100%; border: 1px solid #cfd8df; background: white; color: var(--ink); border-radius: 10px; padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #5d819d; box-shadow: 0 0 0 3px rgba(58, 111, 148, .11); }
textarea { min-height: 90px; resize: vertical; }
.primary-btn, .ghost-btn { border-radius: 10px; padding: 11px 16px; font-weight: 700; border: 1px solid transparent; }
.primary-btn { background: var(--navy); color: white; }
.primary-btn:hover { background: var(--navy-2); }
.primary-btn.small { padding: 9px 13px; font-size: 13px; }
.ghost-btn { background: white; border-color: var(--line); color: var(--ink); }
.danger-btn { background: #fff2f2; color: var(--red); border: 1px solid #f0caca; border-radius: 9px; padding: 8px 11px; }
.form-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.error-text { min-height: 20px; color: var(--red); font-size: 13px; margin: 14px 0 0; }

.app-shell { min-height: 100vh; }
.topbar { height: 76px; background: var(--navy); color: white; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 40; }
.brand-lockup.compact .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.brand-lockup.compact strong { font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 12px; color: rgba(255,255,255,.7); }
.user-chip { border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08); color: white; padding: 9px 12px; border-radius: 10px; }
.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 76px); }
.sidebar { background: #fffdfa; border-right: 1px solid #e3ddd4; padding: 26px 14px; display: flex; flex-direction: column; justify-content: space-between; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item { border: 0; background: transparent; color: #53616d; text-align: left; padding: 12px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; }
.nav-item span { color: #a4afb7; font-size: 11px; }
.nav-item.active { background: var(--navy); color: white; font-weight: 700; }
.nav-item.active span { color: #efab91; }
.sidebar-foot { padding: 14px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.main-content { min-width: 0; padding: 30px; }
.view-section { max-width: 1500px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 6px 0 0; font-size: 28px; color: var(--navy); }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid #e3ddd4; border-radius: 15px; padding: 18px; box-shadow: 0 7px 25px rgba(34, 55, 70, .05); }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; color: var(--navy); font-size: 30px; margin-top: 10px; }
.stat-card.alert strong { color: var(--red); }
.panel { background: var(--card); border: 1px solid #e3ddd4; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 28px rgba(34,55,70,.05); }
.panel-header { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 17px; color: var(--navy); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; background: white; }
.toolbar .search { min-width: 280px; flex: 1; }
.table-wrap { overflow: auto; max-height: calc(100vh - 245px); }
.data-table { border-collapse: separate; border-spacing: 0; min-width: 3550px; width: 100%; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 3; background: var(--navy); color: white; font-weight: 700; padding: 11px 10px; border-right: 1px solid rgba(255,255,255,.15); white-space: nowrap; }
.data-table td { padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; max-width: 210px; min-width: 115px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table tr:hover td { background: #f8fbfc; }
.data-table th:nth-child(1), .data-table td:nth-child(1) { position: sticky; left: 0; z-index: 2; min-width: 125px; }
.data-table td:nth-child(1) { background: #fbfaf7; }
.data-table th:nth-child(5), .data-table td:nth-child(5) { min-width: 190px; }
.data-table td.actions { min-width: 135px; }
.row-link { border: 0; background: none; color: #155e89; padding: 0; text-align: left; }
.tag { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; background: #eaf0f5; color: #36566f; font-size: 11px; }
.tag.high { background: #fff0eb; color: #b44e2d; }
.tag.won { background: #e5f4ef; color: #21715b; }
.tag.lost { background: #f6eeee; color: #9a4a4a; }
.empty-state { padding: 60px 25px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--navy); font-size: 18px; margin-bottom: 8px; }
.compact-list { width: 100%; border-collapse: collapse; }
.compact-list th, .compact-list td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.compact-list th { color: var(--muted); font-size: 11px; }
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-column { background: #efece5; border-radius: 14px; padding: 12px; min-height: 420px; }
.pipeline-column h3 { font-size: 14px; color: var(--navy); display: flex; justify-content: space-between; margin: 4px 3px 12px; }
.customer-card { background: white; border: 1px solid #ded8cf; border-radius: 11px; padding: 12px; margin-bottom: 9px; }
.customer-card strong { display: block; margin-bottom: 7px; }
.customer-card p { margin: 4px 0; color: var(--muted); font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.setting-card { background: var(--card); border: 1px solid #e3ddd4; border-radius: 15px; padding: 22px; }
.setting-card h3 { margin: 0 0 8px; color: var(--navy); }
.setting-card p { color: var(--muted); font-size: 13px; line-height: 1.7; min-height: 45px; }

.modal { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(18, 35, 49, .55); backdrop-filter: blur(3px); }
.editor-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(880px, 94vw); background: #f8f6f1; box-shadow: -20px 0 60px rgba(13,31,45,.24); overflow-y: auto; }
.editor-header { position: sticky; top: 0; z-index: 3; background: var(--navy); color: white; padding: 22px 26px; display: flex; justify-content: space-between; align-items: center; }
.editor-header h2 { margin: 6px 0 0; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: white; font-size: 25px; }
.field-groups { padding: 22px; display: grid; gap: 16px; }
.field-group { background: white; border: 1px solid #e1dbd3; border-radius: 14px; padding: 18px; }
.field-group h3 { margin: 0 0 15px; color: var(--navy); font-size: 15px; }
.fields-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.fields-grid label.wide { grid-column: span 3; }
.editor-footer { position: sticky; bottom: 0; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); padding: 15px 22px; display: flex; justify-content: space-between; align-items: center; gap: 15px; font-size: 12px; color: var(--muted); }
.editor-footer > div { display: flex; gap: 10px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 200; background: var(--navy); color: white; padding: 13px 17px; border-radius: 10px; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-intro { min-height: 280px; padding: 28px; }
  .auth-copy h1 { font-size: 38px; }
  .auth-copy p, .auth-points { display: none; }
  .auth-panel { padding: 24px 16px 50px; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 76px; z-index: 30; padding: 8px; border-right: 0; border-bottom: 1px solid #ddd6cc; overflow-x: auto; }
  .sidebar nav { display: flex; min-width: max-content; }
  .nav-item { padding: 10px 12px; }
  .nav-item span, .sidebar-foot { display: none; }
  .main-content { padding: 18px 12px; }
  .topbar { padding: 0 13px; }
  .save-status, .brand-lockup.compact span, #new-customer-top { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .toolbar .search { min-width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
  .fields-grid { grid-template-columns: 1fr; }
  .fields-grid label.wide { grid-column: span 1; }
  .editor-footer { align-items: flex-start; flex-direction: column; }
  .editor-footer > div { width: 100%; }
  .editor-footer button { flex: 1; }
}
