:root {
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #66758a;
  --line: #d8e2ee;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e7f6f3;
  --accent: #c05a2b;
  --nav: #182235;
  --shadow: 0 18px 42px rgba(21, 34, 55, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: var(--nav);
  color: #fff;
}

.brand {
  display: grid;
  gap: 8px;
  padding: 8px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
}

.brand span {
  color: #7dd3c7;
  font-size: 12px;
  font-weight: 800;
}

.brand strong {
  font-size: 21px;
  line-height: 1.25;
}

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

.side-nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe6f3;
  text-align: left;
}

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

.main {
  min-width: 0;
  padding: 24px clamp(16px, 3vw, 36px) 44px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.18;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

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

.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 292px;
}

.hero-actions .primary {
  grid-column: 1 / -1;
}

button,
.hero-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

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

.metric-card {
  padding: 16px;
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 23px;
  line-height: 1.2;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.panel-head input,
.panel-head select {
  width: min(100%, 420px);
}

.customer-cards,
.reminders {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.customer-card {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 78px;
  padding: 12px;
  text-align: left;
}

.customer-card span {
  color: var(--muted);
}

.customer-card small {
  color: var(--accent);
  font-weight: 800;
}

.reminders p {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.reminders strong {
  color: var(--brand);
}

.quote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.form-body {
  display: grid;
  gap: 18px;
  padding: 16px;
}

.form-section {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  border-bottom: 0;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.quick-products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.quick-products button {
  display: grid;
  gap: 4px;
  min-height: 68px;
  background: var(--brand-soft);
  text-align: left;
}

.quick-products span {
  font-size: 13px;
  line-height: 1.3;
}

.quick-products strong {
  color: var(--brand);
  font-size: 13px;
}

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

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

.compact table {
  min-width: 0;
}

th {
  background: #24344c;
  color: #fff;
  font-weight: 800;
  text-align: left;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

td {
  color: #263246;
}

.line-total {
  white-space: nowrap;
  font-weight: 800;
}

.text-danger {
  border-color: #f0c9c3;
  color: #a7352a;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.submit-btn {
  width: 100%;
  min-height: 46px;
}

.preview-panel {
  position: sticky;
  top: 18px;
}

#quotePreview {
  padding: 18px;
}

.quote-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--brand);
}

.quote-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quote-title strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.preview-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.totals {
  width: min(100%, 360px);
  margin: 16px 0 0 auto;
}

.totals p {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.totals .grand {
  color: var(--brand);
  font-size: 18px;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(20px);
  opacity: 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .brand {
    border-bottom: 0;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .side-nav button {
    min-width: 104px;
    text-align: center;
  }

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

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

  .preview-panel {
    position: static;
  }
}

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

  .hero,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .metrics,
  .form-grid,
  .notes-grid,
  .quick-products,
  .preview-meta {
    grid-template-columns: 1fr;
  }

  .metric-card strong {
    font-size: 21px;
  }

  table {
    min-width: 680px;
  }

  .compact table {
    min-width: 560px;
  }
}

@media print {
  .sidebar,
  .hero,
  .form-body,
  .metrics,
  .dashboard-grid {
    display: none;
  }

  .app-shell,
  .quote-layout {
    display: block;
  }

  body {
    background: #fff;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }
}
