:root {
  --bg: #f6f1e8;
  --panel: #fffdfa;
  --panel-soft: #f3ece1;
  --line: #d8ccb8;
  --text: #2f2419;
  --muted: #74624f;
  --brand: #9f5b2d;
  --brand-deep: #6a3513;
  --accent: #d87b39;
  --danger: #a53725;
  --danger-soft: #fde7e2;
  --edited: #fff0df;
  --success: #3f7b4f;
  --shadow: 0 18px 40px rgba(77, 48, 21, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 123, 57, 0.18), transparent 28%),
    linear-gradient(180deg, #fcf8f2 0%, var(--bg) 100%);
}

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

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.panel-card,
.section-card,
.dialog-card {
  background: var(--panel);
  border: 1px solid rgba(159, 91, 45, 0.12);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 700;
}

.login-card h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.15;
}

.muted {
  color: var(--muted);
}

.error-text {
  min-height: 24px;
  color: var(--danger);
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.login-form input,
.full-input,
.field input,
.field select,
.field textarea,
.table-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.table-input {
  min-width: 74px;
  padding: 8px 10px;
  border-radius: 10px;
}

.table-input[readonly] {
  background: #f7f3ee;
}

.edited-field {
  background: #fff0df !important;
  border-color: #d79252 !important;
  color: #7d471a;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.secondary-btn {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.18s ease;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  padding: 11px 16px;
  font-weight: 700;
}

.ghost-btn {
  padding: 10px 14px;
  background: var(--panel-soft);
  color: var(--text);
}

.ghost-btn:hover,
.secondary-btn:hover {
  filter: brightness(0.98);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--brand));
  color: #fff;
}

.secondary-btn {
  background: #efe3d3;
  color: var(--brand-deep);
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 24px clamp(18px, 3vw, 36px) 16px;
}

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

.nav-btn.active {
  background: var(--brand-deep);
  color: #fff;
}

.page-shell {
  padding: 0 clamp(18px, 3vw, 36px) 32px;
}

.status-bar {
  min-height: 24px;
  margin-bottom: 18px;
  color: var(--brand-deep);
  font-weight: 600;
}

.view-panel {
  display: grid;
  gap: 20px;
}

.panel-card {
  padding: 22px;
}

.panel-title-row,
.section-header,
.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.quote-print-header {
  margin: 18px 0 20px;
  padding: 16px 18px;
  border: 1px solid #eadfce;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff8ef 0%, #f8efe2 100%);
  text-align: center;
}

.quote-print-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--brand-deep);
}

.quote-print-phone {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.04em;
}

.panel-title-row h2,
.dialog-header h3,
.section-header h3 {
  margin: 0;
}

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

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

.field label {
  font-weight: 700;
}

.panel-body {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-card {
  padding: 18px;
}

.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #eadfce;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8f2ea;
  font-size: 14px;
}

.quote-row-edited td {
  background: var(--edited);
}

.section-summary,
.quote-total {
  display: flex;
  justify-content: flex-end;
  padding-top: 12px;
  font-weight: 700;
}

.quote-total {
  font-size: 22px;
  color: var(--brand-deep);
}

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

.inline-lock {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(0, 1.45fr);
  gap: 20px;
}

.database-shell {
  display: grid;
  gap: 20px;
}

.database-nav-card {
  position: sticky;
  top: 12px;
  z-index: 2;
}

.database-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.database-section-tip {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.panel-stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

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

.admin-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.subpanel {
  padding: 16px;
  border: 1px solid #eadfce;
  border-radius: 16px;
  background: #fcfaf7;
}

.subpanel h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--brand-deep);
}

.toolbar-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pricing-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 10px;
}

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

.list-item-stack {
  align-items: stretch;
}

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

.product-item-row {
  display: flex;
  align-items: end;
  gap: 14px;
  width: 100%;
}

.product-name {
  flex: 0 0 220px;
  min-width: 160px;
  word-break: break-all;
}

.product-inline-fields {
  display: grid;
  grid-template-columns: 110px 130px minmax(220px, 1fr);
  gap: 10px;
  margin-top: 0;
  flex: 1;
}

.product-inline-field {
  display: grid;
  gap: 6px;
}

.product-inline-field span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.compact-table {
  max-height: 240px;
  overflow: auto;
}

.button-row-split {
  justify-content: flex-start;
}

.section-form-card {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #eadfce;
  border-radius: 16px;
  background: #fcfaf7;
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #eadfce;
  border-radius: 14px;
  background: #fff;
}

.product-select-box {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.product-select-box input {
  width: 18px;
  height: 18px;
}

.picker-list {
  display: grid;
  gap: 10px;
  max-height: 56vh;
  overflow: auto;
  margin-top: 16px;
}

.picker-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border: 1px solid #eadfce;
  border-radius: 14px;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dialog-card {
  width: min(760px, calc(100vw - 32px));
  padding: 22px;
  border: none;
}

.dialog-card::backdrop {
  background: rgba(49, 34, 17, 0.35);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.panel-tools {
  margin-top: 4px;
}

.panel-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3ece1;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.nav-chip {
  border: 1px solid #e2d4bf;
  background: #fff;
  color: var(--brand-deep);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.nav-chip.active {
  background: linear-gradient(135deg, #b9824e, #93643a);
  color: #fff;
  border-color: transparent;
}

.panel-collapsed-note {
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.pagination-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: #efe5d8;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 700;
}

.history-table td,
.history-table th,
.pricing-table td,
.pricing-table th {
  white-space: nowrap;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 1080px) {
  .admin-layout,
  .split-grid,
  .three-grid {
    grid-template-columns: 1fr;
  }

  .admin-two-column {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .product-item-row {
    flex-direction: column;
    align-items: stretch;
  }

  .product-name {
    flex: 0 0 auto;
  }

  .product-inline-fields {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  #status-bar,
  #import-view,
  #history-view,
  #database-view,
  .button-row,
  .section-toolbar,
  .table-actions,
  .meta-note {
    display: none !important;
  }

  #quote-view {
    display: block !important;
  }

  .panel-card,
  .section-card {
    box-shadow: none;
    border: none;
    padding: 0;
    background: #fff;
  }

  .quote-total {
    font-size: 18px;
  }

  th,
  td {
    border: 1px solid #ccc;
  }

  .quote-print-header {
    margin: 0 0 14px;
    padding: 0 0 10px;
    border: none;
    border-bottom: 2px solid #b88a5a;
    border-radius: 0;
    background: #fff;
  }

  .quote-row-edited td {
    background: #f3f3f3 !important;
  }
}
