:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --ink: #1e2522;
  --muted: #68736d;
  --line: #dfe5df;
  --green: #2f7d53;
  --green-dark: #215d3c;
  --teal: #207f86;
  --red: #b84a4a;
  --amber: #a66a21;
  --blue: #376aa5;
  --shadow: 0 18px 50px rgba(31, 41, 35, 0.08);
}

/* Final premium CRM overrides */
body {
  background: linear-gradient(180deg, #f8fbff 0, #f4f7fb 320px), #f4f7fb;
  color: #172033;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: linear-gradient(180deg, #10213d 0%, #142849 100%);
  color: #dbe8f8;
}

.sidebar .brand {
  padding: 6px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .brand strong {
  color: #fff;
}

.sidebar .brand small {
  color: #9fb0c9;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 10px;
  color: #cbd8ea;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: #2f6ecf;
}

.nav-group-title {
  margin: 14px 10px 6px;
  color: #8fa3bf;
  font-size: 12px;
  font-weight: 800;
}

.main {
  padding: 26px 30px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -26px -30px 24px;
  padding: 20px 30px;
  border-bottom: 1px solid rgba(219, 227, 238, 0.86);
  background: rgba(248, 251, 255, 0.94);
  backdrop-filter: blur(16px);
}

.page-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #1e5aa8;
  font-size: 11px;
  font-weight: 900;
}

.user-chip,
.search,
.panel,
.account-card,
.deal-card,
.record-detail,
.table-wrap {
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 31, 58, 0.06);
}

.primary-btn {
  border-color: #1d5fb7;
  background: linear-gradient(180deg, #276fc8, #1d5aa8);
  color: #fff;
  box-shadow: 0 10px 22px rgba(30, 90, 168, 0.22);
}

.ghost-btn,
.segment,
.icon-btn,
.notification-btn {
  border: 1px solid #dbe3ee;
  background: #fff;
  color: #22304a;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid #d7e3f2;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(30, 90, 168, 0.12), rgba(31, 138, 91, 0.08)), #fff;
  box-shadow: 0 18px 45px rgba(15, 31, 58, 0.08);
}

.dashboard-hero h2 {
  margin-top: 12px;
  font-size: 24px;
}

.hero-actions {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.metric-card,
.kpi-card {
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(15, 31, 58, 0.06);
}

.metric-card strong,
.kpi-card strong {
  color: #101828;
  font-size: 30px;
}

th {
  background: #f3f7fb;
  color: #42526b;
}

th,
td {
  padding: 14px 16px;
  border-bottom-color: #e8eef5;
}

.deal-card {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr) minmax(250px, 0.7fr);
}

.progress span {
  background: linear-gradient(90deg, #276fc8, #1f8a5b);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    gap: 12px;
  }

  .nav {
    display: none;
  }

  .mobile-nav-field {
    display: grid;
  }

  .main {
    padding: 20px;
  }

  .topbar {
    position: static;
    margin: -20px -20px 20px;
    padding: 18px 20px;
  }

  .dashboard-hero,
  .dashboard-grid,
  .deal-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .login-card {
    padding: 30px 22px;
  }

  .login-logo-wrap {
    gap: 12px;
  }

  .login-logo {
    width: 58px;
    height: 58px;
  }

  .login-logo-wrap strong {
    font-size: 21px;
  }

  .login-card h1 {
    font-size: 32px;
  }

  .login-card .login-values {
    font-size: 21px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: none;
  }

  .topbar-menu.open .topbar-actions {
    display: grid;
  }

  .mobile-actions-toggle {
    display: flex;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard reference-style local redesign */
.app-shell {
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  padding: 22px 14px;
  background:
    radial-gradient(circle at 30% 0%, rgba(47, 111, 207, 0.22), transparent 28%),
    linear-gradient(180deg, #10213f 0%, #0c1f39 100%);
}

.sidebar .brand {
  gap: 10px;
  padding: 6px 8px 22px;
}

.sidebar .brand strong {
  font-size: 15px;
  letter-spacing: .04em;
}

.sidebar .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  box-shadow: none;
}

.nav-item {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #d9e6f8;
}

.nav-item.active {
  background: linear-gradient(180deg, #2f80ed, #2368d8);
  box-shadow: 0 12px 22px rgba(35, 104, 216, 0.28);
}

.nav-icon {
  width: 24px;
  height: 24px;
  background: rgba(255,255,255,.13);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(360px, auto) minmax(520px, 1fr);
  align-items: center;
  gap: 20px;
  min-height: 78px;
  background: rgba(255,255,255,.96);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-btn {
  width: 38px;
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #0f1f3a;
  font-size: 20px;
  box-shadow: none;
}

.page-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.page-heading h1 {
  font-size: 23px;
}

.page-heading p {
  margin-top: 0;
  color: #172033;
  font-weight: 700;
}

.dashboard-select {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  background: #fff;
  color: #607087;
  font-weight: 700;
}

.topbar-actions {
  justify-content: flex-end;
  gap: 14px;
}

.search {
  width: min(520px, 38vw);
  min-width: 360px;
  height: 46px;
  border-radius: 9px;
}

.notification-btn {
  position: relative;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #0f1f3a;
  box-shadow: none;
  font-size: 14px;
}

.notification-btn.has-badge::after {
  content: "12";
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  line-height: 17px;
}

.user-chip {
  min-width: 110px;
  grid-template-columns: 1fr;
  border: 0;
  box-shadow: none;
  background: transparent;
}

.save-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f8ef;
  color: #15804f;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.save-status[data-state="saving"] {
  background: #eaf2ff;
  color: #2563eb;
}

.save-status[data-state="error"] {
  background: #ffe4e7;
  color: #c5313d;
}

.save-status[data-state="local"] {
  background: #f1f5f9;
  color: #64748b;
}

.dashboard-command {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.dashboard-command h2 {
  font-size: 22px;
}

.dashboard-command p {
  margin-top: 8px;
  color: #657287;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-actions .primary-btn,
.dashboard-actions .ghost-btn {
  min-height: 40px;
  padding: 0 16px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.metric-card {
  min-height: 150px;
  padding: 22px;
}

.metric-card.clickable {
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.metric-card.clickable:hover,
.metric-card.clickable:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, .28);
  box-shadow: 0 18px 36px rgba(15, 31, 58, .12);
  outline: none;
}

.metric-card::after {
  display: none;
}

.metric-card span {
  color: #243047;
}

.metric-card strong {
  margin-top: 16px;
  font-size: 34px;
}

.metric-card small {
  color: #66748a;
}

.metric-blue strong { color: #2563eb; }
.metric-green strong { color: #159265; }
.metric-purple strong { color: #4f5fb8; }
.metric-orange strong { color: #ea7a21; }

.metric-spark {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 72px;
  height: 36px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  color: #2f80ed;
}

.metric-green .metric-spark { color: #1fba7a; }
.metric-purple .metric-spark { color: #6c63ff; }
.metric-orange .metric-spark { color: #f59e0b; }

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1.05fr 1.4fr .62fr;
  gap: 18px;
  margin-bottom: 18px;
}

.dashboard-lower-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 18px;
}

.ai-dashboard-card {
  min-height: 260px;
}

.ai-summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.ai-summary-metrics span,
.setting-card {
  padding: 14px;
  border-radius: 10px;
  background: #f4f7fb;
  color: #64748b;
  font-weight: 700;
}

.ai-summary-metrics strong,
.setting-card strong {
  display: block;
  color: #0f1f3a;
  font-size: 24px;
}

.ai-news-list,
.ai-list {
  display: grid;
  gap: 12px;
}

.ai-news-mini {
  width: 100%;
  padding: 12px;
  border: 1px solid #e1e8f2;
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.ai-news-mini strong,
.ai-news-mini small {
  display: block;
}

.ai-radar-toolbar {
  justify-content: space-between;
  align-items: center;
}

.ai-radar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.ai-item-card {
  padding: 18px;
  border: 1px solid #e1e8f2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(15, 31, 58, .08);
}

.ai-item-card h3 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.ai-score-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(70px, 1fr));
  gap: 8px;
  min-width: 260px;
}

.ai-score-stack span {
  padding: 10px;
  border-radius: 8px;
  background: #f6f8fb;
  color: #64748b;
  font-size: 12px;
}

.ai-score-stack strong {
  display: block;
  color: #0f1f3a;
  font-size: 18px;
}

.ai-action-line,
.ai-edit-row,
.source-form,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ai-edit-row input {
  flex: 1 1 280px;
}

.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.keyword-chip {
  padding: 10px 12px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: #fff;
  color: #34435a;
  font-weight: 800;
  cursor: pointer;
}

.keyword-chip.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.keyword-chip small {
  margin-left: 8px;
  color: #64748b;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.ai-job-log {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e1e8f2;
}

.dashboard-main-grid .panel,
.dashboard-lower-grid .panel {
  min-height: 300px;
}

.dashboard-table {
  overflow-x: auto;
}

.dashboard-table table {
  min-width: 680px;
}

.dashboard-table td,
.dashboard-table th {
  padding: 12px 10px;
  font-size: 13px;
}

.risk-badge {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.risk-低 { background: #e8f8ef; color: #15804f; }
.risk-中 { background: #fff2d8; color: #a86100; }
.risk-高 { background: #ffe4e7; color: #c5313d; }

.todo-list {
  display: grid;
  gap: 14px;
}

.todo-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #26344d;
  text-align: left;
}

.todo-item::before {
  content: "✓";
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: #edf5ff;
  color: #2563eb;
}

.todo-item strong {
  display: grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: #fff1f2;
  color: #ef4444;
}

.todo-red::before { background: #fff1f2; color: #ef4444; }
.todo-cyan::before { background: #e6fbff; color: #0891b2; }
.todo-purple::before { background: #f1edff; color: #6d5bd0; }
.todo-indigo::before { background: #eaf0ff; color: #3f5fc9; }

.dashboard-activity-list {
  display: grid;
  gap: 14px;
}

.dashboard-activity {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 12px;
  align-items: start;
  color: #41516b;
}

.dashboard-activity p {
  margin-top: 4px;
  color: #66748a;
  line-height: 1.45;
}

.dashboard-activity time {
  color: #8895a9;
  font-size: 12px;
}

.avatar-dot {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #e8f0fb;
  color: #1e5aa8;
  font-weight: 900;
}

.funnel-chart {
  gap: 8px;
}

.funnel-row {
  grid-template-columns: 110px 1fr 130px;
  gap: 12px;
  padding: 4px 0;
}

.funnel-bar {
  height: 30px;
  border-radius: 4px;
  background: #eef3f8;
}

.funnel-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4285f4, #26b7a0);
  color: #fff;
  text-align: right;
  padding-right: 10px;
  font-weight: 900;
}

.pipeline {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 360px;
  overflow: auto;
}

.pipeline-column {
  min-height: 130px;
}

.owner-overview-panel {
  margin-bottom: 18px;
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .dashboard-main-grid,
  .dashboard-lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }
}

@media (max-width: 720px) {
  .dashboard-command {
    display: grid;
  }

  .dashboard-actions {
    justify-content: stretch;
  }

  .dashboard-actions > * {
    width: 100%;
  }

  .search {
    width: 100%;
    min-width: 0;
  }

  .pipeline {
    grid-template-columns: 1fr;
  }
}

/* Typography and visual polish pass */
:root {
  --font-sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  --font-number: "Segoe UI", "DIN Alternate", "Arial", sans-serif;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-sans);
  letter-spacing: 0;
}

body {
  font-size: 14px;
  line-height: 1.55;
}

h1,
h2,
h3,
strong {
  letter-spacing: 0;
}

.page-heading h1 {
  color: #0e1a2f;
  font-size: 24px;
  font-weight: 850;
}

.page-heading p {
  color: #334155;
  font-size: 14px;
  font-weight: 650;
}

.dashboard-command h2 {
  color: #0f172a;
  font-size: 22px;
  font-weight: 850;
}

.dashboard-command p,
.panel-head span,
.muted {
  color: #64748b;
  font-size: 13px;
}

.panel-head h2 {
  color: #0f172a;
  font-size: 16px;
  font-weight: 850;
}

.sidebar {
  border-right: 0;
}

.nav-item {
  font-size: 14px;
  font-weight: 750;
}

.nav-icon {
  font-size: 13px;
}

.topbar {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.04);
}

.dashboard-select,
.search,
.user-chip,
.notification-btn,
.primary-btn,
.ghost-btn,
.segment {
  border-radius: 8px;
}

.primary-btn {
  min-height: 42px;
  padding-inline: 16px;
  font-size: 14px;
}

.ghost-btn {
  min-height: 42px;
  padding-inline: 16px;
}

.panel,
.metric-card,
.account-card,
.deal-card,
.record-detail,
.table-wrap {
  border-color: #e2e8f0;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 14px 36px rgba(15, 23, 42, 0.06);
}

.panel {
  padding: 22px;
}

.metrics-grid {
  gap: 20px;
}

.metric-card {
  min-height: 154px;
  padding: 22px 24px;
  border-radius: 12px;
}

.metric-card span {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  margin-top: 15px;
  font-family: var(--font-number);
  font-size: 36px;
  font-weight: 850;
  line-height: 1;
}

.metric-card small {
  margin-top: 14px;
  color: #64748b;
  font-size: 13px;
  font-weight: 650;
}

.metric-spark {
  opacity: .9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

table {
  font-size: 13px;
}

th {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

td {
  color: #334155;
}

td strong {
  color: #111827;
  font-weight: 850;
}

.status-pill,
.risk-badge {
  font-size: 12px;
  font-weight: 850;
}

.dashboard-main-grid,
.dashboard-lower-grid {
  gap: 20px;
}

.todo-item {
  border: 1px solid transparent;
  font-weight: 750;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.todo-item:hover {
  transform: translateY(-1px);
  border-color: #dbeafe;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}

.todo-item strong {
  font-family: var(--font-number);
  font-weight: 850;
}

.dashboard-activity strong {
  color: #1e293b;
  font-size: 13px;
  font-weight: 850;
}

.dashboard-activity p {
  font-size: 13px;
}

.forecast-summary strong {
  font-family: var(--font-number);
  font-weight: 850;
}

.pipeline-column h3 span,
.pipeline-column h3 strong {
  font-weight: 850;
}

.mini-deal {
  border-radius: 9px;
}

.mini-deal strong {
  color: #172033;
}

.form-grid label span,
.maintenance-form label span,
.modal label span {
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

input,
select,
textarea {
  min-height: 42px;
  color: #172033;
}

/* Dashboard proportional refinement */
#dashboard .panel {
  border-radius: 12px;
}

#dashboard .panel-head {
  margin-bottom: 18px;
}

#dashboard .link-btn {
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
}

#dashboard .dashboard-table {
  margin: -4px -6px 0;
}

#dashboard .dashboard-table table {
  border-spacing: 0;
}

#dashboard .dashboard-table th {
  background: transparent;
  color: #94a3b8;
  border-bottom: 1px solid #edf2f7;
}

#dashboard .dashboard-table td {
  border-bottom: 1px solid #f1f5f9;
}

#dashboard .dashboard-table tr:last-child td {
  border-bottom: 0;
}

.funnel-stage strong {
  color: #0f172a;
  font-weight: 850;
}

.funnel-stage span {
  color: #94a3b8;
  font-size: 12px;
}

.funnel-values span {
  color: #64748b;
  font-size: 12px;
}

.funnel-values strong {
  display: block;
  color: #334155;
  font-family: var(--font-number);
}

.forecast-line-chart {
  margin-top: 8px;
}

.forecast-line {
  stroke: #1f8a9a;
  stroke-width: 4;
}

.forecast-area {
  fill: rgba(31, 138, 154, .10);
}

.forecast-point circle {
  fill: #fff;
  stroke: #1f8a9a;
  stroke-width: 4;
}

.chart-label {
  fill: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.chart-grid line {
  stroke: #e6edf4;
  stroke-width: 1;
}

.forecast-summary {
  display: grid;
  gap: 4px;
}

.forecast-summary span {
  color: #64748b;
  font-size: 13px;
  font-weight: 750;
}

.forecast-summary strong {
  color: #0f172a;
  font-size: 30px;
}

.forecast-summary small {
  color: #64748b;
  font-weight: 650;
}

.dashboard-command {
  padding-top: 4px;
}

.dashboard-actions .primary-btn {
  box-shadow: 0 10px 20px rgba(37, 99, 235, .20);
}

.dashboard-actions .ghost-btn {
  color: #475569;
}

/* Premium CRM UI refresh - local preview only */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --surface-3: #eef4fb;
  --ink: #172033;
  --muted: #657287;
  --line: #dbe3ee;
  --green: #1f8a5b;
  --green-dark: #116344;
  --teal: #158a92;
  --red: #c2414b;
  --amber: #c47a1c;
  --blue: #1e5aa8;
  --indigo: #253f7a;
  --navy: #0f1f3a;
  --shadow: 0 18px 45px rgba(15, 31, 58, 0.08);
  --shadow-sm: 0 8px 22px rgba(15, 31, 58, 0.06);
  --radius: 12px;
}

body {
  background:
    linear-gradient(180deg, #f8fbff 0, #f4f7fb 280px),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
  background: transparent;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  gap: 22px;
  padding: 22px 18px;
  border-right: 1px solid #e3e9f2;
  background: linear-gradient(180deg, #10213d 0%, #142849 100%);
  color: #dbe8f8;
  box-shadow: 12px 0 32px rgba(15, 31, 58, 0.08);
}

.brand {
  align-items: center;
  padding: 6px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .brand strong {
  color: #fff;
  font-size: 17px;
  letter-spacing: 0;
}

.sidebar .brand small {
  color: #9fb0c9;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #fff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.nav {
  gap: 6px;
}

.nav-group-title {
  margin: 14px 10px 6px;
  color: #8fa3bf;
  font-size: 12px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #cbd8ea;
  font-weight: 700;
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8e7ff;
  font-size: 14px;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: #2f6ecf;
  color: #fff;
}

.main {
  padding: 26px 30px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  align-items: flex-start;
  margin: -26px -30px 24px;
  padding: 20px 30px;
  border-bottom: 1px solid rgba(219, 227, 238, 0.86);
  background: rgba(248, 251, 255, 0.92);
  backdrop-filter: blur(16px);
}

.page-heading {
  min-width: 240px;
}

.page-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

h1 {
  color: #111827;
  font-size: 26px;
  line-height: 1.18;
}

h2 {
  color: #162033;
  font-size: 17px;
}

.topbar p,
.panel-head span,
.muted {
  color: var(--muted);
}

.topbar-actions {
  align-items: stretch;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.user-chip,
.search,
.panel,
.account-card,
.deal-card,
.record-detail,
.table-wrap,
.login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.user-chip {
  min-width: 136px;
  padding: 10px 12px;
}

.user-chip strong {
  font-size: 15px;
}

.search {
  min-width: 350px;
  padding: 10px 14px;
  box-shadow: none;
}

.search span {
  color: #7b8798;
  font-size: 12px;
}

.search input {
  color: var(--ink);
}

.primary-btn,
.ghost-btn,
.segment,
.icon-btn,
.notification-btn {
  min-height: 40px;
  border-radius: 10px;
  font-weight: 800;
}

.primary-btn {
  border: 1px solid #1d5fb7;
  background: linear-gradient(180deg, #276fc8, #1d5aa8);
  color: #fff;
  box-shadow: 0 10px 22px rgba(30, 90, 168, 0.22);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #2d7bdc, #1f60b5);
}

.ghost-btn,
.segment,
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #22304a;
}

.ghost-btn:hover,
.segment:hover {
  border-color: #adc2db;
  background: #f5f8fc;
}

.notification-btn {
  width: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--amber);
  box-shadow: none;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid #d7e3f2;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(30, 90, 168, 0.12), rgba(31, 138, 91, 0.08)),
    #fff;
  box-shadow: var(--shadow);
}

.dashboard-hero h2 {
  margin-top: 12px;
  font-size: 24px;
}

.dashboard-hero p {
  margin-top: 8px;
  color: var(--muted);
}

.hero-actions {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.hero-actions span {
  color: var(--muted);
  font-weight: 700;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.metric-card,
.kpi-card {
  position: relative;
  min-height: 138px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.metric-card::after,
.kpi-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.metric-card span,
.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong,
.kpi-card strong {
  display: block;
  margin-top: 10px;
  color: #101828;
  font-size: 30px;
  line-height: 1.08;
}

.metric-card small,
.kpi-card small {
  display: block;
  margin-top: 10px;
  color: var(--green-dark);
  font-weight: 800;
}

.panel {
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 16px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.8fr);
  gap: 18px;
}

.attention-list {
  display: grid;
  gap: 12px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.attention-item {
  border-radius: 12px;
  border: 1px solid #f2d8ad;
  background: #fff8ec;
  box-shadow: none;
}

.attention-item.clickable:hover,
.clickable-row:hover,
.account-card:hover,
.deal-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.status-pill {
  border-radius: 999px;
  background: #edf4f1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.warning {
  background: #fff1d8;
  color: #a85f00;
}

.status-pill.hot {
  background: #ffe6e8;
  color: #a42f3c;
}

.status-pill.blue {
  background: #e7f0ff;
  color: var(--blue);
}

.table-wrap {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: #f3f7fb;
  color: #42526b;
  font-size: 12px;
  font-weight: 900;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid #e8eef5;
  line-height: 1.45;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.clickable-row {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.section-toolbar {
  margin-bottom: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  width: fit-content;
}

.segment.active {
  border-color: #1d5fb7;
  background: #eaf2ff;
  color: var(--blue);
}

.cards-grid,
.deal-list {
  gap: 14px;
}

.account-card,
.deal-card {
  border-radius: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.deal-card {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr) minmax(250px, 0.7fr);
  align-items: center;
  gap: 18px;
}

.deal-title-line h2 {
  font-size: 19px;
}

.detail-list span,
.detail-kpis span,
.account-deal-metrics span {
  border-radius: 10px;
  background: #f6f9fc;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #e7edf4;
}

.progress span {
  border-radius: inherit;
  background: linear-gradient(90deg, #276fc8, #1f8a5b);
}

.funnel-chart,
.pipeline,
.owner-board,
.forecast-bars {
  gap: 12px;
}

.pipeline-column,
.funnel-row,
.owner-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
}

.record-detail .detail-hero {
  border: 1px solid #d7e3f2;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff, #f4f8fd);
}

.detail-back-btn {
  border-color: #1d5fb7;
  color: var(--blue);
}

.maintenance-form label,
.task-composer input,
.task-composer select,
.modal label {
  color: #40506a;
}

input,
select,
textarea {
  border-color: var(--line);
  border-radius: 10px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(30, 90, 168, 0.14);
  border-color: #6a9edb;
}

.modal {
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(15, 31, 58, 0.24);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
  }

  .sidebar .brand {
    border-bottom: 0;
    padding-bottom: 6px;
  }

  .nav {
    display: none;
  }

  .mobile-nav-field {
    display: grid;
    min-width: 220px;
    margin-left: auto;
  }

  .main {
    padding: 20px;
  }

  .topbar {
    position: static;
    margin: -20px -20px 20px;
    padding: 18px 20px;
  }

  .dashboard-hero,
  .dashboard-grid,
  .deal-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar {
    display: grid;
    gap: 12px;
  }

  .mobile-nav-field {
    width: 100%;
    margin-left: 0;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: none;
    width: 100%;
  }

  .topbar-actions.open {
    display: grid;
  }

  .mobile-actions-toggle {
    display: inline-flex;
  }

  .search,
  .user-chip,
  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    padding: 18px;
  }

  .dashboard-hero h2 {
    font-size: 20px;
  }

  th,
  td {
    padding: 12px;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

.is-hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 125, 83, 0.12), rgba(32, 127, 134, 0.08)),
    var(--bg);
}

.login-card {
  display: grid;
  width: min(520px, 100%);
  gap: 22px;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  margin-bottom: 8px;
}

.login-logo-wrap strong {
  color: #101828;
  font-size: 27px;
  font-weight: 900;
  line-height: 1.2;
}

.login-logo {
  width: 76px;
  height: 76px;
  object-fit: contain;
  object-position: left center;
}

.login-card h1 {
  font-size: 38px;
  line-height: 1.15;
}

.login-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.login-card .login-values {
  margin-top: 10px;
  color: #1f7a4d;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0;
}

.login-card .primary-btn {
  width: 100%;
}

.login-error {
  min-height: 22px;
  color: var(--red) !important;
  font-weight: 700;
}

.login-hint {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: #f1f5f0;
  color: var(--muted);
  font-size: 13px;
}

.login-hint strong {
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
  padding: 4px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted,
.panel-head span {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.mobile-nav-field,
.mobile-actions-toggle {
  display: none;
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: #c8dccd;
  background: var(--surface-2);
  color: var(--green-dark);
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.topbar-menu {
  display: contents;
}

.topbar-actions,
.section-toolbar,
.panel-head,
.inline-field,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: grid;
  gap: 2px;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.user-chip strong {
  color: var(--ink);
  font-size: 14px;
}

.link-btn {
  width: fit-content;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.link-btn:hover {
  color: var(--green-dark);
  text-decoration: underline;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 320px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search span,
label span {
  color: var(--muted);
  font-size: 13px;
}

.search input,
label input,
label select,
label textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.search input {
  border: 0;
  outline: 0;
}

.primary-btn,
.ghost-btn,
.segment,
.icon-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.primary-btn {
  padding: 0 16px;
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover {
  background: var(--green-dark);
}

.compact-btn {
  min-height: 36px;
  padding: 0 14px;
}

.danger-btn {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid #d6b4b4;
  border-radius: 8px;
  background: #fff;
  color: var(--red);
  font-weight: 700;
}

.danger-btn:hover {
  border-color: var(--red);
  background: #fff5f5;
}

.ghost-btn,
.icon-btn {
  background: #fff;
  color: var(--ink);
}

.icon-btn {
  width: 40px;
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.account-card,
.deal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}

.metric small {
  color: var(--green);
  font-weight: 700;
}

.owner-overview-panel {
  margin-bottom: 18px;
}

.owner-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.owner-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
}

.owner-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.owner-card strong {
  font-size: 22px;
}

.owner-card small,
.owner-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.owner-card.active,
.owner-card:hover,
.owner-card:focus {
  border-color: #a8cdb2;
  background: #f2faf5;
  outline: 0;
  box-shadow: 0 12px 26px rgba(33, 92, 58, 0.1);
}

.owner-card.active span,
.owner-card.active em {
  color: var(--green-dark);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 18px;
}

.market-tab {
  display: none;
}

.market-tab.active {
  display: grid;
  gap: 18px;
}

.table-wrap tr.clickable:hover {
  background: #f3faf5;
}

.view > .panel + .panel {
  margin-top: 18px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel select,
.inline-field select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.forecast-bars {
  display: grid;
  gap: 12px;
}

.forecast-summary {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.forecast-summary span,
.forecast-summary small {
  color: var(--muted);
}

.forecast-summary strong {
  font-size: clamp(28px, 4vw, 42px);
}

.forecast-line-chart {
  width: 100%;
  min-height: 230px;
  overflow: visible;
}

.chart-grid line {
  stroke: #e6ece6;
  stroke-width: 1;
}

.forecast-area {
  fill: rgba(32, 132, 129, 0.11);
}

.forecast-line {
  fill: none;
  stroke: var(--teal);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.forecast-point circle {
  fill: #fff;
  stroke: var(--teal);
  stroke-width: 4;
}

.chart-label {
  fill: var(--muted);
  font-size: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 100px;
  align-items: center;
  gap: 12px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece7;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.attention-list,
.deal-list,
.cards-grid {
  display: grid;
  gap: 12px;
}

.attention-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #f0dfc4;
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: #fff8ed;
}

.attention-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.attention-title span {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ffe8c2;
  color: #8b571d;
  font-size: 12px;
  font-weight: 800;
}

.attention-item > span,
.attention-item > small:not(.open-hint) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attention-item > span {
  color: var(--muted);
}

.attention-item .open-hint,
.mini-deal .open-hint {
  margin-top: 2px;
  color: var(--green);
  font-weight: 700;
}

.funnel-chart {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 96px minmax(180px, 1fr) 220px;
  align-items: center;
  gap: 14px;
}

.funnel-stage {
  display: grid;
  gap: 4px;
}

.funnel-stage strong {
  font-size: 15px;
}

.funnel-stage span,
.funnel-values span {
  color: var(--muted);
  font-size: 12px;
}

.funnel-bar {
  min-height: 38px;
  overflow: hidden;
  border-radius: 8px;
  background: #e8ece8;
}

.funnel-fill {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 46px;
  height: 100%;
  padding: 0 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green), var(--teal));
  color: #fff;
  font-weight: 800;
}

.funnel-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.funnel-values strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  overflow-x: auto;
}

.pipeline-column {
  min-height: 190px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbf8;
}

.pipeline-column h3 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 15px;
}

.mini-deal {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.section-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  padding: 0 12px;
  background: transparent;
}

.segment.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f1f5f0;
  color: #4c5851;
  font-size: 13px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover,
.clickable-row:focus {
  background: #f6faf6;
  outline: 2px solid #c8dccd;
  outline-offset: -2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e8f2eb;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.warning {
  background: #fff1d6;
  color: var(--amber);
}

.status-pill.hot {
  background: #ffe8e8;
  color: var(--red);
}

.cards-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.account-card,
.deal-card {
  padding: 16px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.detail-list strong {
  color: var(--ink);
}

.deal-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(160px, 0.8fr) minmax(160px, 0.7fr);
  align-items: center;
  gap: 16px;
}

.deal-card.pinned {
  border-color: #b7d7c0;
  background: #fbfefb;
  box-shadow: 0 14px 30px rgba(33, 92, 58, 0.12);
}

.deal-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff1d6;
  color: #946000;
  font-size: 12px;
  font-weight: 800;
}

.pin-btn {
  width: 100%;
  margin-top: 10px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef5f1;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
}

.clickable {
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.clickable:hover,
.clickable:focus {
  border-color: #a8cdb2;
  outline: 0;
  transform: translateY(-1px);
}

.open-hint {
  display: block;
  margin-top: 8px;
  color: var(--green);
  font-weight: 700;
}

.record-detail,
.deal-detail {
  display: grid;
  gap: 18px;
}

.detail-hero {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-back-btn {
  width: 100%;
  border: 1px solid var(--green);
  color: var(--green);
  font-weight: 700;
  background: #f4fbf7;
}

.detail-back-btn:hover {
  border-color: var(--green-dark);
  color: var(--green-dark);
  background: #eef8f2;
}

.detail-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.detail-hero h2 {
  margin-top: 10px;
  font-size: 26px;
}

.detail-hero p {
  margin-top: 8px;
  color: var(--muted);
}

.detail-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-kpis span {
  padding: 10px;
  border-radius: 8px;
  background: #f4f7f4;
  color: var(--muted);
}

.detail-kpis strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 18px;
}

.deal-amount-editor {
  display: grid;
  align-items: stretch;
  gap: 8px;
}

.deal-amount-editor input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d6e0ec;
  border-radius: 10px;
  background: #fff;
  color: #172033;
  font-weight: 900;
}

.mini-primary-btn {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #1d5fb7;
  border-radius: 9px;
  background: linear-gradient(180deg, #276fc8, #1d5aa8);
  color: #fff;
  font-weight: 900;
}

.account-contact-list {
  display: grid;
  gap: 10px;
}

.account-deal-list {
  display: grid;
  gap: 10px;
}

.account-deal-item {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(360px, 1.15fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.account-deal-item strong,
.account-deal-item small {
  display: block;
}

.account-deal-item strong {
  margin-top: 8px;
}

.account-deal-item small {
  margin-top: 5px;
  color: var(--muted);
}

.account-deal-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.account-deal-metrics span {
  min-height: 58px;
  padding: 9px;
  border-radius: 8px;
  background: #f4f7f4;
  color: var(--muted);
  font-size: 12px;
}

.account-deal-metrics strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 15px;
}

.account-contact-item {
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(260px, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.account-contact-item strong,
.account-contact-item span {
  display: block;
}

.account-contact-item span {
  margin-top: 4px;
  color: var(--muted);
}

.stage-path {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stage-step {
  min-width: max-content;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f2f5f2;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.stage-step:hover,
.stage-step:focus {
  border-color: var(--green);
  color: var(--green-dark);
  outline: 0;
}

.stage-step.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.stage-step.done {
  border-color: var(--green);
  background: #e7f3ea;
  color: var(--green-dark);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 18px;
  align-items: start;
}

.deal-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.deal-tools label,
.deal-tools span {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.deal-tools input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.task-composer {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 100px 110px;
  gap: 10px;
  margin-bottom: 16px;
}

.task-composer input,
.task-composer select {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.activity-composer {
  display: grid;
  grid-template-columns: 150px 150px minmax(260px, 1fr) 110px;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.activity-composer input,
.activity-composer select,
.activity-composer textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.activity-composer textarea {
  resize: vertical;
}

.maintenance-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.weekly-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-section-title {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  font-size: 16px;
}

.maintenance-form input,
.maintenance-form select,
.maintenance-form textarea,
.weekly-form input,
.weekly-form select,
.weekly-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.task-item strong,
.task-item span {
  display: block;
}

.task-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.task-item.done {
  background: #eef4ef;
}

.task-item.done strong {
  text-decoration: line-through;
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timeline h3 {
  margin: 0;
  font-size: 16px;
}

.timeline-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background: #f4faf9;
}

.timeline-item span,
.timeline-item small {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item p {
  margin: 0;
  color: var(--ink);
}

.deal-side {
  position: sticky;
  top: 18px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece8;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.milestones {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.milestone {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #b8c1bb;
}

.dot.done {
  border-color: var(--green);
  background: var(--green);
}

.modal {
  width: min(980px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.28);
}

.small-modal {
  width: min(520px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(20, 28, 23, 0.38);
}

.modal form {
  padding: 22px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head p {
  margin-top: 5px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.password-grid {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
}

label input,
label select,
label textarea {
  min-height: 42px;
  padding: 9px 11px;
}

input[readonly] {
  background: #f4f7f4;
  color: var(--muted);
  cursor: not-allowed;
}

label textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.form-error {
  margin: 0 auto 0 0;
  color: var(--red);
  font-weight: 700;
}

.inline-field {
  gap: 8px;
}

.inline-field input[type="range"] {
  width: 160px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    overflow-x: auto;
  }

  .metrics-grid,
  .kpi-grid,
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .detail-hero-grid,
  .detail-layout,
  .account-deal-item {
    grid-template-columns: 1fr;
  }

  .account-deal-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .deal-side {
    position: static;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 16px;
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sidebar .brand {
    min-width: 0;
  }

  .brand small {
    line-height: 1.35;
  }

  .nav {
    display: none;
  }

  .mobile-nav-field {
    display: grid;
    gap: 6px;
  }

  .mobile-nav-field span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .mobile-nav-field select {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid #c8dccd;
    border-radius: 8px;
    background: var(--surface);
    color: var(--green-dark);
    font-size: 18px;
    font-weight: 700;
  }

  .topbar,
  .section-toolbar,
  .deal-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-menu {
    display: grid;
    gap: 10px;
  }

  .mobile-actions-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
  }

  .mobile-actions-toggle::after {
    content: "▾";
    margin-left: 8px;
    font-size: 14px;
  }

  .topbar-menu.open .mobile-actions-toggle::after {
    content: "▴";
  }

  .topbar-actions {
    display: none;
  }

  .topbar-menu.open .topbar-actions {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .topbar-menu.open .topbar-actions > * {
    width: 100%;
  }

  .user-chip {
    min-width: 0;
  }

  .funnel-row {
    grid-template-columns: 1fr;
  }

  .detail-kpis,
  .task-composer,
  .activity-composer,
  .maintenance-form,
  .weekly-form,
  .account-deal-metrics,
  .account-contact-item {
    grid-template-columns: 1fr;
  }

  .timeline-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .search {
    min-width: 0;
  }

  .metrics-grid,
  .kpi-grid,
  .owner-board,
  .cards-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .deal-card {
    display: grid;
    grid-template-columns: 1fr;
  }
}

/* Premium CRM final layer - must remain at file end */
body {
  background: linear-gradient(180deg, #f8fbff 0, #f4f7fb 320px), #f4f7fb;
  color: #172033;
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: linear-gradient(180deg, #10213d 0%, #142849 100%);
  color: #dbe8f8;
  box-shadow: 12px 0 32px rgba(15, 31, 58, 0.08);
}

.sidebar .brand {
  padding: 6px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .brand strong {
  color: #fff;
}

.sidebar .brand small {
  color: #9fb0c9;
}

.nav {
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 10px;
  color: #cbd8ea;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  background: #2f6ecf;
}

.nav-group-title {
  margin: 14px 10px 6px;
  color: #8fa3bf;
  font-size: 12px;
  font-weight: 800;
}

.main {
  padding: 26px 30px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -26px -30px 24px;
  padding: 20px 30px;
  border-bottom: 1px solid rgba(219, 227, 238, 0.86);
  background: rgba(248, 251, 255, 0.94);
  backdrop-filter: blur(16px);
}

.page-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: #1e5aa8;
  font-size: 11px;
  font-weight: 900;
}

.company-vision {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  color: #1e5aa8;
  font-size: 12px;
  font-weight: 900;
}

.user-chip,
.search,
.panel,
.account-card,
.deal-card,
.record-detail,
.table-wrap {
  border: 1px solid #dbe3ee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(15, 31, 58, 0.06);
}

.primary-btn {
  border-color: #1d5fb7;
  background: linear-gradient(180deg, #276fc8, #1d5aa8);
  color: #fff;
  box-shadow: 0 10px 22px rgba(30, 90, 168, 0.22);
}

.ghost-btn,
.segment,
.icon-btn,
.notification-btn {
  border: 1px solid #dbe3ee;
  background: #fff;
  color: #22304a;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid #d7e3f2;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(30, 90, 168, 0.12), rgba(31, 138, 91, 0.08)), #fff;
  box-shadow: 0 18px 45px rgba(15, 31, 58, 0.08);
}

.dashboard-hero h2 {
  margin-top: 12px;
  font-size: 24px;
}

.hero-actions {
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.metric-card,
.kpi-card {
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(15, 31, 58, 0.06);
}

.metric-card strong,
.kpi-card strong {
  color: #101828;
  font-size: 30px;
}

th {
  background: #f3f7fb;
  color: #42526b;
}

th,
td {
  padding: 14px 16px;
  border-bottom-color: #e8eef5;
}

.deal-card {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.7fr) minmax(250px, 0.7fr);
}

.progress span {
  background: linear-gradient(90deg, #276fc8, #1f8a5b);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    gap: 12px;
  }

  .nav {
    display: none;
  }

  .mobile-nav-field {
    display: grid;
  }

  .main {
    padding: 20px;
  }

  .topbar {
    position: static;
    margin: -20px -20px 20px;
    padding: 18px 20px;
  }

  .dashboard-hero,
  .dashboard-grid,
  .deal-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: none;
  }

  .topbar-menu.open .topbar-actions {
    display: grid;
  }

  .mobile-actions-toggle {
    display: flex;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
