body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: #1f2933;
  background: #f3f6f8;
  font-size: 14px;
}
.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #d8e0e8;
  box-shadow: 0 1px 2px rgba(16, 42, 67, 0.04);
}
.brand {
  color: #102a43;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}
.panel {
  background: #ffffff;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(16, 42, 67, 0.05);
}
.flash-messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.flash-message {
  padding: 10px 12px;
  border: 1px solid #f4c7a1;
  border-radius: 8px;
  color: #7c2d12;
  background: #fff7ed;
  font-weight: 600;
}
.panel h1 {
  margin: 0 0 14px;
  font-size: 20px;
  line-height: 1.3;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.35;
}
.auth-panel {
  max-width: 360px;
  margin: 80px auto;
}
label {
  display: block;
  margin-bottom: 0;
  color: #334e68;
  font-size: 13px;
  font-weight: 600;
}
input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid #c7d1dc;
  border-radius: 6px;
  background: #ffffff;
  color: #102a43;
  font: inherit;
}
textarea {
  min-height: 78px;
  resize: vertical;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #1d6fa5;
  box-shadow: 0 0 0 3px rgba(29, 111, 165, 0.12);
  outline: none;
}
.inline-check {
  width: auto;
  margin: 0 6px 0 0;
}
button,
.button {
  display: inline-block;
  padding: 8px 13px;
  border: 0;
  border-radius: 6px;
  background: #1d6fa5;
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
button:hover,
.button:hover {
  background: #155d8b;
}
.danger {
  background: #b42318;
}
.danger-zone {
  margin-top: 18px;
  border-color: #f2b8b5;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: #ffffff;
}
th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e4ebf1;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
th {
  color: #486581;
  background: #f7fafc;
  font-size: 13px;
  font-weight: 700;
}
td {
  color: #243b53;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}
.line-items {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #f8fafc;
}
.line-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.line-items-header h2 {
  margin: 0;
  font-size: 16px;
}
.line-item {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #ffffff;
}
.line-item label:nth-child(2),
.line-item label:nth-child(5) {
  grid-column: span 2;
}
.match-note {
  color: #486581;
  font-size: 12px;
  align-self: center;
  min-width: 120px;
  white-space: normal;
  grid-column: span 3;
}
.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.nav a {
  color: #486581;
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}
.nav a:hover {
  color: #102a43;
  background: #edf2f7;
}
.secondary {
  background: #486581;
}
.import-form {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #d9e2ec;
}
.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  background: #fbfcfd;
}
.history-panel {
  margin-top: 0;
}
.history-panel h2 {
  font-size: 15px;
  margin: 0 0 8px;
}
.muted {
  color: #627d98;
  font-weight: 400;
}
.history-search {
  display: grid;
  grid-template-columns: 1fr 86px auto;
  gap: 10px;
  align-items: end;
}
.history-block {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid #e4ebf1;
}
.history-block:first-of-type {
  padding-top: 4px;
  margin-top: 0;
  border-top: 0;
}
.quote-editor-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr);
  gap: 18px;
  align-items: start;
}
.quote-history {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 92px);
  overflow: auto;
}
.quote-main {
  min-width: 0;
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-title h1 {
  margin-bottom: 0;
}
.table-scroll {
  overflow-x: auto;
}
.compact-table table {
  min-width: 560px;
  font-size: 13px;
}
.compact-table th,
.compact-table td {
  padding: 7px 8px;
}
.editable-table {
  min-width: 1080px;
}
.supplier-table {
  min-width: 1280px;
}
.editable-table input {
  min-width: 92px;
  margin-top: 0;
  padding: 6px 8px;
}
.editable-table td {
  padding: 7px 6px;
}
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.row-actions form {
  margin: 0;
}
.row-actions button {
  padding: 7px 10px;
}
.status-checks {
  display: flex;
  gap: 10px;
  align-items: center;
}
.status-checks form {
  margin: 0;
}
.status-checks label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  color: #334e68;
}
.report-filter {
  display: grid;
  grid-template-columns: minmax(180px, 240px) auto;
  gap: 12px;
  align-items: end;
  max-width: 380px;
  margin-bottom: 18px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin: 14px 0 22px;
}
.metric-card {
  padding: 16px;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  background: #f8fafc;
}
.metric-card span {
  display: block;
  margin-bottom: 8px;
  color: #627d98;
  font-size: 13px;
  font-weight: 700;
}
.metric-card strong {
  display: block;
  color: #102a43;
  font-size: 22px;
  line-height: 1.2;
}
.secondary-metric {
  background: #ffffff;
}
.report-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.report-section-title h2 {
  margin: 0;
  font-size: 16px;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.customer-quote {
  background: #fbfcfd;
}
@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }
  .import-form,
  .history-search,
  .line-item,
  .grid-form,
  .metric-grid,
  .report-filter,
  .quote-editor-layout,
  .split {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 14px;
  }
  .quote-history {
    position: static;
    max-height: none;
  }
  .section-title {
    display: block;
  }
}
