:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e3e8ef;
  --line-strong: #cbd5e1;
  --text: #172033;
  --muted: #667085;
  --muted-2: #98a2b3;
  --primary: #176b87;
  --primary-hover: #0f5268;
  --primary-soft: #e8f3f6;
  --accent: #a35d00;
  --success: #0f7a4f;
  --success-soft: #eaf7f1;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --warning-soft: #fff7e8;
  --sidebar: #111827;
  --sidebar-2: #1f2937;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #e5edf5;
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 18px 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: #e7f5f7;
  color: #0f5268;
  font-weight: 800;
  font-size: 19px;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-subtitle {
  color: #98a8ba;
  font-size: 12px;
  margin-top: 2px;
}

.side-nav {
  padding: 10px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  color: #8da0b5;
  font-size: 12px;
  padding: 16px 10px 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 10px;
  margin-bottom: 4px;
  border-radius: var(--radius);
  color: #d8e3ed;
  transition: background .15s ease, color .15s ease;
}

.side-nav a:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.side-nav a.active {
  background: #f8fafc;
  color: #111827;
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(255,255,255,.08);
  font-size: 13px;
  font-weight: 700;
}

.active .nav-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.sidebar-foot {
  margin: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #b9c7d5;
  font-size: 12px;
}

.sidebar-foot strong {
  color: #fff;
  font-size: 12px;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-kicker {
  color: var(--muted);
  font-size: 12px;
}

.topbar-title {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

h1, h2 {
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  padding: 18px;
  margin-bottom: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
  margin: -2px 0 14px;
  font-size: 15px;
  color: #243244;
}

.panel-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
  display: inline-block;
  margin-right: 6px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--primary-soft);
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
  color: #111827;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 320px;
  gap: 16px;
}

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

.quick-list a {
  display: block;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, #fbfdff);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.quick-list a:hover {
  border-color: #b8c6d6;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .07);
  transform: translateY(-1px);
}

.quick-list strong {
  display: block;
  color: #1f2a37;
  margin-bottom: 4px;
}

.quick-list span {
  color: var(--muted);
  font-size: 12px;
}

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

.form-grid.two { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(170px, 1fr)); }

.field label {
  display: block;
  color: #475467;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:hover, select:hover, textarea:hover {
  border-color: #98a2b3;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23,107,135,.14);
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.field.span-2 { grid-column: span 2; }
.field.span-4 { grid-column: 1 / -1; }

.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: #243244;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn:hover, button:hover {
  border-color: #98a2b3;
  background: #f8fafc;
}

.btn.primary, button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(23,107,135,.18);
}

.btn.primary:hover, button.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.ghost {
  background: var(--surface-soft);
}

.btn.danger, button.danger {
  border-color: #f3b5ae;
  color: var(--danger);
  background: #fff;
}

.btn.danger:hover, button.danger:hover {
  background: var(--danger-soft);
}

.link-btn {
  color: var(--primary);
  font-weight: 700;
  margin-right: 6px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 860px;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475467;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
}

td {
  color: #263445;
  background: #fff;
}

tbody tr:hover td {
  background: #fbfdff;
}

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

td.numeric, th.numeric { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.flash-stack {
  margin-bottom: 14px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(15,23,42,.04);
}

.flash.success {
  border-color: #a6d8c0;
  color: var(--success);
  background: var(--success-soft);
}

.flash.error {
  border-color: #f1a9a2;
  color: var(--danger);
  background: var(--danger-soft);
}

.inline-form { display: inline; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
}

.result-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-item {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.result-item span {
  color: var(--muted);
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
}

.result-item strong {
  font-size: 18px;
  line-height: 1.2;
  color: var(--accent);
}

.quote-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 16px;
  align-items: start;
}

.quote-summary-panel {
  position: sticky;
  top: 82px;
}

.quote-save-actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.quote-save-actions .primary {
  width: 100%;
}

.selected-row td { background: var(--warning-soft) !important; }
.recommended-row td { background: var(--success-soft) !important; }

.split {
  display: grid;
  grid-template-columns: minmax(320px, .95fr) minmax(560px, 1.45fr);
  gap: 16px;
}

.small-text {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 12px;
  font-weight: 700;
}

.subtle-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, .46);
  backdrop-filter: blur(5px);
}

.modal-backdrop.open {
  display: flex;
}

.modal-panel {
  width: min(1120px, 100%);
  max-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .28);
  overflow: hidden;
}

.modal-panel.wide {
  width: min(1280px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 800;
  color: #172033;
}

.modal-desc {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: #243244;
}

.modal-body {
  padding: 20px 22px;
  overflow: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

.form-section {
  margin-bottom: 18px;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #172033;
  font-weight: 800;
}

.form-section-title::before {
  content: "";
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: var(--primary);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar-meta {
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.print-only { display: none; }

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

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

  .brand-block {
    padding: 14px;
  }

  .side-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 0 12px 12px;
  }

  .nav-section, .sidebar-foot {
    display: none;
  }

  .side-nav a {
    white-space: nowrap;
    min-width: max-content;
  }
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .page { padding: 14px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .metric-grid, .dashboard-grid, .form-grid, .form-grid.two, .form-grid.three, .result-grid, .result-grid.compact, .split, .quote-workbench {
    grid-template-columns: 1fr;
  }
  .field.span-2, .field.span-4 { grid-column: auto; }
  .quote-summary-panel { position: static; }
  .modal-backdrop { padding: 10px; align-items: stretch; }
  .modal-panel { max-height: none; height: 100%; }
}

@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .actions, .flash-stack, .no-print { display: none !important; }
  .app-shell { display: block; }
  .page { max-width: none; padding: 0; }
  .panel { border: none; box-shadow: none; padding: 0; margin: 0 0 12px; }
  .table-wrap { border: none; }
  table { min-width: 0; font-size: 12px; }
  th, td { padding: 6px; }
  .print-only { display: block; }
}
