:root {
  --bg-start: #f4f7f9;
  --bg-end: #eef6ed;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text-main: #1f2933;
  --text-sub: #52606d;
  --line: #d8e1e8;
  --brand: #15707e;
  --brand-deep: #0f4d57;
  --danger: #bf3a2b;
  --warning-bg: #fff3d6;
  --warning-text: #8b5301;
  --shadow: 0 6px 20px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--text-main);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(145deg, var(--bg-start), var(--bg-end));
}

.background-accent {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 16%, rgba(21, 112, 126, 0.11) 0%, rgba(21, 112, 126, 0) 38%),
    radial-gradient(circle at 88% 10%, rgba(239, 176, 48, 0.13) 0%, rgba(239, 176, 48, 0) 42%);
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  background: rgba(244, 247, 249, 0.92);
  backdrop-filter: blur(5px);
  padding: 10px 4px 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.02em;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--text-sub);
  font-size: 0.94rem;
}

.tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tab-btn {
  border: 1px solid #c7d6dc;
  background: #ffffff;
  color: var(--text-main);
  min-height: 48px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: linear-gradient(160deg, #1a8393, #0f5d68);
  color: #ffffff;
  border-color: #0f5d68;
  box-shadow: 0 6px 16px rgba(15, 93, 104, 0.25);
}

.main-content {
  display: block;
  margin-top: 8px;
}

.page {
  display: none;
  animation: fadeInUp 0.24s ease both;
}

.page.active {
  display: block;
}

.card {
  background: var(--panel);
  border: 1px solid #e2e9ef;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  animation: cardIn 0.35s ease both;
}

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

.card-title-row h2 {
  margin: 0;
  font-size: 1.1rem;
}

.hint-text {
  color: var(--text-sub);
  font-size: 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-field {
  position: relative;
}

.field > span {
  font-size: 0.92rem;
  color: var(--text-main);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  min-height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 12px;
  font-size: 1rem;
  color: var(--text-main);
  outline: none;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #4ca6b4;
  box-shadow: 0 0 0 3px rgba(76, 166, 180, 0.2);
}

.field input[readonly] {
  background: var(--panel-soft);
}

.field.full {
  grid-column: 1 / -1;
}

.field.compact {
  margin: 0;
}

.field.highlight input {
  background: #f2fbf5;
  border-color: #9cd4ac;
  font-weight: 700;
}

.suggest-box {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.12);
  z-index: 30;
}

.suggest-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid #edf2f6;
  font-size: 0.94rem;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background: #f0f8ff;
}

.suggest-main {
  color: var(--text-main);
  font-weight: 600;
}

.suggest-sub {
  color: var(--text-sub);
  font-size: 0.86rem;
}

.collapse {
  margin-top: 10px;
  border: 1px dashed #c6d5dc;
  border-radius: 12px;
  background: #fbfdff;
  padding: 8px 10px;
}

.collapse summary {
  cursor: pointer;
  font-weight: 700;
  color: #254d59;
  font-size: 1rem;
}

.mt-10 {
  margin-top: 10px;
}

.warning {
  margin: 12px 0 0;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #f3d293;
  font-size: 0.93rem;
}

.hidden {
  display: none !important;
}

.action-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

button {
  border: none;
  border-radius: 10px;
  min-height: 46px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.action-row button[type="submit"] {
  background: linear-gradient(160deg, var(--brand), var(--brand-deep));
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(21, 112, 126, 0.24);
}

button.secondary {
  background: #edf4f8;
  color: #184150;
  border: 1px solid #c6d7e0;
}

button.ghost {
  background: #fff8eb;
  color: #87530b;
  border: 1px solid #e5c48a;
}

.inline-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #d8e4ea;
  border-radius: 10px;
  background: #ffffff;
}

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

.sales-record-table {
  min-width: 2100px;
}

thead th {
  background: #eef7fc;
  color: #214a59;
  border-bottom: 1px solid #cfe0ea;
  font-size: 0.92rem;
  text-align: left;
  padding: 10px;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid #eef2f5;
  padding: 10px;
  font-size: 0.92rem;
  vertical-align: top;
}

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

.actions-cell {
  min-width: 126px;
}

.mini {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.88rem;
  margin-right: 6px;
  background: #e9f4fb;
  color: #1e4f61;
  border: 1px solid #bdd8e6;
}

.mini.danger {
  background: #ffecec;
  color: #8d251c;
  border-color: #efbfba;
}

.stock-danger {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  text-align: center;
  color: var(--text-sub);
  padding: 18px 12px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.996);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding: 20px 18px 28px;
  }

  .app-header {
    padding: 12px 6px 14px;
  }

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

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

  .inline-tools {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

@media (min-width: 1080px) {
  .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
