:root {
  color-scheme: light;
  --navy: #0a2f5e;
  --blue: #1767b1;
  --deep-blue: #08428a;
  --bright-blue: #43b2ed;
  --mid-blue: #2583c5;
  --pale-blue: #f0f8fd;
  --line: #cbddea;
  --divider: #dce8f2;
  --muted: #607c96;
  --ink: #142b43;
  --canvas: #f5f8fb;
  --white: #fff;
  --danger: #d45555;
  --warning: #d88b2c;
  --success: #1b8a6b;
  --shadow: 0 12px 36px rgba(10, 47, 94, 0.08);
}

* { box-sizing: border-box; }
html { font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif; background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px 20px; background: linear-gradient(180deg, #082b56 0%, #0a3569 58%, #08294f 100%); color: #fff; display: flex; flex-direction: column; z-index: 10; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 40px; height: 40px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 3px; padding: 8px; border-radius: 11px; background: linear-gradient(145deg, #2583c5, #43b2ed); box-shadow: 0 9px 22px rgba(25,129,198,.32); }
.brand-mark span { display: block; border-radius: 2px 2px 0 0; background: #fff; }
.brand-mark span:nth-child(1) { height: 45%; opacity: .75; }
.brand-mark span:nth-child(2) { height: 72%; opacity: .9; }
.brand-mark span:nth-child(3) { height: 100%; }
.brand-copy { display: flex; flex-direction: column; }
.brand-copy strong { font-size: 18px; letter-spacing: .04em; }
.brand-copy small { font-size: 9px; letter-spacing: .22em; color: #9bccec; margin-top: 3px; }

.nav-list { display: grid; gap: 7px; padding-top: 24px; }
.nav-item { border: 0; color: #bbd5e8; background: transparent; min-height: 46px; border-radius: 9px; padding: 0 12px; display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; text-align: left; transition: .18s ease; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-item.is-active { color: #fff; background: linear-gradient(90deg, rgba(67,178,237,.34), rgba(37,131,197,.16)); box-shadow: inset 3px 0 #43b2ed; }
.nav-icon { width: 22px; text-align: center; font-size: 18px; }
.nav-badge { min-width: 22px; padding: 2px 6px; text-align: center; border-radius: 12px; background: rgba(67,178,237,.2); color: #bde8ff; font-size: 11px; }
.nav-badge.warning { color: #ffe1a8; background: rgba(216,139,44,.2); }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding: 18px 8px 0; }
.security-note { display: flex; align-items: center; gap: 10px; }
.security-note div { display: flex; flex-direction: column; gap: 2px; }
.security-note strong { font-size: 12px; }
.security-note small, .sidebar-foot p { color: #89b3d0; font-size: 10px; line-height: 1.7; }
.security-dot { width: 9px; height: 9px; border-radius: 50%; background: #57d8a9; box-shadow: 0 0 0 4px rgba(87,216,169,.12); }

.workspace { min-width: 0; }
.topbar { height: 72px; padding: 0 30px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--divider); display: flex; align-items: center; justify-content: space-between; gap: 24px; position: sticky; top: 0; z-index: 8; backdrop-filter: blur(12px); }
.mobile-menu { display: none; border: 0; background: transparent; color: var(--navy); font-size: 23px; }
.search-wrap { width: min(440px, 42vw); display: flex; align-items: center; gap: 9px; border: 1px solid transparent; background: #f1f6fa; border-radius: 10px; padding: 0 12px; color: var(--muted); transition: .18s; }
.search-wrap:focus-within { background: #fff; border-color: #8ec5e8; box-shadow: 0 0 0 3px rgba(67,178,237,.12); }
.search-wrap input { flex: 1; min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-wrap input::placeholder { color: #86a0b5; }
kbd { font-family: inherit; font-size: 10px; color: #758da1; padding: 3px 6px; border: 1px solid #d3e0e9; border-radius: 5px; background: #fff; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.sync-state { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sync-state > span { width: 7px; height: 7px; border-radius: 50%; background: #39b98a; }
.icon-button { position: relative; width: 36px; height: 36px; border: 1px solid var(--divider); border-radius: 9px; background: #fff; color: var(--muted); }
.notification-dot { position: absolute; width: 6px; height: 6px; background: #e86b61; border-radius: 50%; right: 7px; top: 7px; border: 1px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--bright-blue)); font-size: 14px; font-weight: 700; }
.user-chip > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.user-chip strong { font-size: 12px; }
.user-chip small { color: var(--muted); font-size: 10px; }

.content { padding: 30px clamp(20px, 3vw, 42px) 48px; max-width: 1780px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.eyebrow { color: var(--blue); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
h1, h2, p { margin-top: 0; }
.page-heading h1 { margin: 5px 0 7px; font-size: clamp(27px, 2.2vw, 38px); color: var(--navy); letter-spacing: -.035em; }
.page-heading p, .panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; gap: 10px; }
.primary-button, .secondary-button { min-height: 40px; border-radius: 8px; padding: 0 16px; border: 1px solid transparent; font-weight: 700; font-size: 12px; }
.primary-button { color: #fff; background: linear-gradient(135deg, var(--blue), var(--deep-blue)); box-shadow: 0 8px 18px rgba(23,103,177,.18); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(23,103,177,.25); }
.primary-button.wide { width: 100%; min-height: 46px; }
.secondary-button { color: var(--deep-blue); background: #fff; border-color: var(--line); }
.secondary-button:hover { background: var(--pale-blue); }
.compact-button { min-height: 32px; padding: 0 10px; font-size: 10px; white-space: nowrap; }
.logout-button { padding: 8px 0; white-space: nowrap; }
.status-banner { margin: -8px 0 18px; padding: 11px 14px; border-radius: 8px; color: #81551d; background: #fff7e8; border: 1px solid #f1d39f; font-size: 12px; }
.status-banner.error { color: #923d3d; background: #fff0f0; border-color: #efc2c2; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-height: 134px; padding: 19px 20px 17px; background: #fff; border: 1px solid var(--divider); border-radius: 12px; box-shadow: 0 4px 18px rgba(10,47,94,.035); position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; right: -30px; top: -34px; background: rgba(67,178,237,.08); }
.metric-card.primary { border-top: 3px solid var(--blue); }
.metric-card.danger-card { border-top: 3px solid #dd7972; }
.metric-top { color: var(--muted); font-size: 11px; display: flex; align-items: center; justify-content: space-between; }
.metric-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--blue); background: var(--pale-blue); font-weight: 700; }
.metric-card > strong { display: block; margin: 10px 0 7px; font-size: clamp(25px, 2vw, 34px); color: var(--navy); letter-spacing: -.04em; }
.metric-card p { margin: 0; font-size: 10px; color: #8298aa; }
.trend { color: var(--blue); margin-right: 4px; }
.trend.positive { color: var(--success); }
.trend.danger { color: var(--danger); }

.panel { background: #fff; border: 1px solid var(--divider); border-radius: 13px; box-shadow: var(--shadow); }
.pipeline-panel { padding: 20px 20px 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 17px; }
.panel-heading h2 { margin-bottom: 5px; color: var(--navy); font-size: 17px; }
.panel-heading.compact { margin-bottom: 13px; }
.panel-tools { display: flex; align-items: center; gap: 14px; }
.data-date { color: var(--muted); background: #f4f8fb; padding: 6px 9px; border-radius: 6px; font-size: 10px; }
.text-button { border: 0; background: transparent; color: var(--blue); font-size: 11px; font-weight: 700; }
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(172px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 5px; scrollbar-color: #b9cddd transparent; }
.stage-column { min-width: 172px; background: #f7fafc; border: 1px solid #e5edf3; border-radius: 10px; overflow: hidden; }
.stage-head { padding: 12px 12px 10px; border-top: 3px solid var(--stage-color, var(--blue)); display: flex; justify-content: space-between; align-items: center; }
.stage-head strong { font-size: 11px; color: var(--navy); }
.stage-head span { width: 21px; height: 21px; border-radius: 7px; display: grid; place-items: center; font-size: 10px; color: var(--stage-color, var(--blue)); background: color-mix(in srgb, var(--stage-color, var(--blue)) 10%, white); }
.stage-body { padding: 0 8px 9px; display: grid; gap: 8px; min-height: 154px; align-content: start; }
.deal-card { padding: 11px; border: 1px solid #dfeaf2; border-radius: 8px; background: #fff; transition: .18s; }
.deal-card:hover { transform: translateY(-2px); border-color: #9ec7e3; box-shadow: 0 7px 18px rgba(10,47,94,.08); }
.deal-card h3 { margin: 0 0 5px; font-size: 11px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-card .deal-title { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-amount { margin: 9px 0 6px; color: var(--navy); font-size: 13px; font-weight: 800; }
.deal-meta, .deal-next { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 9px; color: #758b9e; }
.deal-next { margin-top: 8px; padding-top: 7px; border-top: 1px solid #edf2f6; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.probability { color: var(--blue); font-weight: 700; }
.empty-stage { color: #9bafbd; font-size: 10px; text-align: center; padding: 36px 8px; }
.loading-state { grid-column: 1 / -1; display: grid; justify-items: center; padding: 54px; color: var(--muted); font-size: 11px; }
.loading-state span { width: 26px; height: 26px; border: 3px solid #dbe9f2; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.lower-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 18px; margin-top: 18px; }
.focus-panel, .storage-panel { padding: 20px; }
.date-pill { color: var(--blue); background: var(--pale-blue); border-radius: 8px; padding: 7px 9px; font-size: 10px; }
.focus-list { display: grid; gap: 8px; }
.focus-item { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: center; min-height: 51px; padding: 8px 10px 8px 0; border-bottom: 1px solid #edf2f6; }
.focus-item:last-child { border-bottom: 0; }
.focus-bar { height: 34px; border-radius: 3px; background: var(--focus-color, var(--blue)); }
.focus-copy strong { display: block; font-size: 11px; margin-bottom: 3px; }
.focus-copy span { color: var(--muted); font-size: 9px; }
.focus-date { color: var(--warning); font-size: 9px; white-space: nowrap; }
.storage-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #edf2f6; }
.storage-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: #fff; font-size: 11px; font-weight: 800; }
.storage-icon.database { background: linear-gradient(145deg, var(--blue), var(--bright-blue)); }
.storage-icon.object { background: linear-gradient(145deg, var(--navy), var(--mid-blue)); }
.storage-copy { display: flex; flex-direction: column; gap: 3px; }
.storage-copy strong { font-size: 11px; }
.storage-copy span { color: var(--muted); font-size: 9px; }
.healthy { color: var(--success); background: #ebf8f3; border-radius: 10px; padding: 4px 7px; font-size: 9px; }
.storage-tip { margin-top: 12px; padding: 10px; border-radius: 8px; background: var(--pale-blue); color: #4c718e; font-size: 9px; line-height: 1.6; }
.storage-tip span { color: var(--blue); font-weight: 800; margin-right: 5px; }
.template-list { display: grid; max-height: 190px; overflow: auto; }
.template-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #edf2f6; }
.template-item > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.template-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.template-item span { color: var(--muted); font-size: 8px; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions a, .row-actions button { border: 0; background: transparent; color: var(--blue); font-size: 9px; text-decoration: none; padding: 2px; }
.row-actions button { color: var(--danger); }
.compact-empty { padding: 18px 8px; }

.auth-screen { min-height: 100vh; display: grid; place-content: center; gap: 26px; padding: 28px; background: radial-gradient(circle at 78% 14%, rgba(67,178,237,.18), transparent 30%), linear-gradient(145deg, #061f3f 0%, #0a3569 60%, #0d477b 100%); }
.auth-brand { color: #fff; display: flex; align-items: center; justify-content: center; gap: 12px; }
.auth-card { width: min(430px, calc(100vw - 28px)); padding: 34px; border: 1px solid rgba(255,255,255,.72); border-radius: 18px; background: rgba(255,255,255,.97); box-shadow: 0 28px 90px rgba(2,20,42,.36); }
.auth-card h1 { color: var(--navy); margin: 6px 0 8px; font-size: 29px; }
.auth-card > p { color: var(--muted); font-size: 11px; line-height: 1.7; }
.auth-form { display: grid; gap: 16px; margin-top: 24px; }
.auth-grid { padding: 0; gap: 13px; }
.auth-message { margin-top: 14px; padding: 10px 12px; border-radius: 8px; color: #78501c; background: #fff5e5; font-size: 11px; }
.auth-message.error { color: #923d3d; background: #fff0f0; }
.auth-message.success { color: #166b52; background: #eaf8f3; }
.auth-card .auth-foot { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--divider); text-align: center; font-size: 9px; }

.account-dialog { width: min(900px, calc(100vw - 28px)); }
.account-body { padding: 22px 26px 28px; display: grid; grid-template-columns: minmax(250px, .75fr) minmax(380px, 1.25fr); gap: 24px; }
.account-create { align-content: start; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; padding: 18px; border-radius: 11px; background: #f5f9fc; }
.account-create .full, .account-create button { grid-column: 1 / -1; }
.user-list { display: grid; align-content: start; gap: 8px; }
.account-row { display: grid; grid-template-columns: minmax(160px, 1fr) 105px auto auto; gap: 8px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--divider); }
.account-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.account-main strong { font-size: 11px; }
.account-main span { color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row select { min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 7px 5px; color: var(--ink); background: #fff; font-size: 9px; }

.lead-dialog { border: 0; padding: 0; border-radius: 14px; width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; box-shadow: 0 24px 80px rgba(5,31,61,.28); }
.lead-dialog::backdrop { background: rgba(5,28,54,.48); backdrop-filter: blur(4px); }
.dialog-card { padding: 0; }
.dialog-card header { position: sticky; top: 0; z-index: 2; padding: 24px 26px 18px; border-bottom: 1px solid var(--divider); background: #fff; display: flex; justify-content: space-between; gap: 20px; }
.dialog-card h2 { margin: 4px 0 6px; color: var(--navy); font-size: 23px; }
.dialog-card header p { margin: 0; color: var(--muted); font-size: 11px; }
.dialog-close { border: 0; background: #f1f6fa; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; font-size: 21px; }
.form-grid { padding: 22px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 6px; color: #3b5871; font-size: 11px; font-weight: 700; }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); padding: 10px 11px; outline: 0; font-weight: 400; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--bright-blue); box-shadow: 0 0 0 3px rgba(67,178,237,.12); }
.field textarea { resize: vertical; }
.dialog-card footer { position: sticky; bottom: 0; z-index: 2; padding: 16px 26px 22px; border-top: 1px solid var(--divider); background: #fff; display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .sync-state { display: none; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: 232px; transition: .2s; box-shadow: 16px 0 50px rgba(2,23,45,.3); }
  .app-shell.menu-open .sidebar { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { padding: 0 14px; gap: 10px; }
  .search-wrap { width: auto; flex: 1; }
  .search-wrap kbd, .icon-button, .user-chip > span:last-child { display: none; }
  .content { padding: 22px 14px 36px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions button { flex: 1; }
  .metric-grid, .lower-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 118px; }
  .pipeline-panel { padding: 16px 12px; }
  .panel-tools .data-date { display: none; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .field.full { grid-column: auto; }
  .dialog-card header, .dialog-card footer { padding-left: 18px; padding-right: 18px; }
  .auth-screen { padding: 14px; }
  .auth-card { padding: 26px 20px; }
  .auth-grid, .account-body, .account-create { grid-template-columns: 1fr; }
  .auth-grid .full, .account-create .full, .account-create button { grid-column: auto; }
  .account-body { padding: 18px; }
  .account-row { grid-template-columns: 1fr auto; }
  .account-main { grid-column: 1 / -1; }
  .top-actions { gap: 8px; }
  .top-actions .compact-button { display: none; }
}

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