:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f6f9fc;
  --line: #d8e0e8;
  --text: #15202b;
  --muted: #637381;
  --primary: #0f6cbd;
  --primary-dark: #0a4f8a;
  --success: #12724f;
  --warning: #9a6700;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(21, 32, 43, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 108, 189, 0.08), transparent 30%),
    linear-gradient(180deg, #f7fafc 0%, #edf3f8 100%);
}

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

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 32px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(216, 224, 232, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(460px, 100%);
  margin: 72px auto;
  padding: 32px;
}

.brand h1,
.topbar h2,
.section-head h3,
.group-title h4 {
  margin: 0;
}

.brand p,
.eyebrow,
.demo-note,
.stat-card span {
  color: var(--muted);
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-grid span {
  font-size: 14px;
  color: var(--muted);
}

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

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid rgba(15, 108, 189, 0.18);
  border-color: var(--primary);
}

.primary-btn,
.ghost-btn,
.text-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.primary-btn {
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

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

.ghost-btn {
  padding: 11px 15px;
  background: #eef5fb;
  color: var(--primary-dark);
}

.text-btn {
  padding: 0;
  color: var(--primary);
  background: transparent;
}

.small {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.demo-note {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  background: var(--panel-soft);
  font-size: 14px;
}

.auth-panel .brand {
  text-align: center;
}

.auth-panel .brand h1 {
  font-size: 30px;
  letter-spacing: 0.04em;
}

.auth-panel .form-grid {
  grid-template-columns: 1fr;
  margin-top: 28px;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.dashboard {
  display: grid;
  gap: 20px;
}

.section-head,
.inline-actions,
.group-title,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

.stats-grid {
  display: grid;
  gap: 16px;
}

.stats-stack {
  display: grid;
  gap: 16px;
}

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.stat-card-feature strong {
  font-size: 36px;
}

.stat-card-action {
  width: 100%;
  text-align: left;
}

.stat-card-action em {
  display: block;
  margin-top: 8px;
  color: var(--primary);
  font-style: normal;
  font-size: 13px;
}

.detail-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

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

.detail-panel-head h4 {
  margin: 0;
}

.dashboard > .panel,
#admin-view .panel,
#sales-view .panel {
  padding: 20px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fbfd;
}

.compact-table {
  font-size: 12px;
}

.compact-table th,
.compact-table td {
  padding: 9px 8px;
}

.compact-text td:nth-child(3),
.compact-text th:nth-child(3) {
  min-width: 180px;
}

.compact-text td,
.compact-text th {
  white-space: normal;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  background: #dcfae6;
  color: var(--success);
}

.badge.muted {
  background: #edf1f5;
  color: #52606d;
}

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

.wide {
  min-width: 1120px;
}

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

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

.group-block {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.sales-order-groups {
  display: grid;
  gap: 16px;
}

.group-title {
  margin-bottom: 14px;
}

.month-total {
  margin-top: 16px;
  text-align: right;
  color: var(--primary-dark);
}

.table-input {
  width: 100%;
  min-width: 96px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}

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

.mini-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mini-form-grid span {
  font-size: 13px;
  color: var(--muted);
}

.mini-form-grid input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mini-form-grid select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

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

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

.entry-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f9fe 100%);
  text-align: left;
  cursor: pointer;
}

.entry-card strong {
  font-size: 18px;
}

.entry-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.entry-card.is-active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(15, 108, 189, 0.16);
}

.admin-section-panel {
  padding: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 32, 43, 0.42);
}

.modal-card {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 20px;
}

.align-table {
  table-layout: fixed;
}

.align-table th,
.align-table td {
  word-break: break-word;
}

.admin-order-table {
  table-layout: fixed;
}

.admin-order-table th:nth-child(3),
.admin-order-table td:nth-child(3) {
  width: 170px;
}

.admin-order-table th:nth-child(4),
.admin-order-table td:nth-child(4) {
  width: 100px;
}

.admin-order-table th:nth-child(11),
.admin-order-table td:nth-child(11),
.admin-order-table th:nth-child(12),
.admin-order-table td:nth-child(12) {
  width: 132px;
}

.admin-order-table th:nth-child(10),
.admin-order-table td:nth-child(10) {
  width: 74px;
}

.admin-order-table .inline-actions {
  flex-wrap: nowrap;
}

#orders-panel .section-head {
  flex-wrap: nowrap;
}

#orders-panel .section-head .inline-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.admin-order-table .express-company-input {
  min-width: 58px;
  width: 58px;
}

.admin-order-table .express-no-input {
  min-width: 138px;
  width: 138px;
  white-space: nowrap;
}

.admin-order-table .express-status-input {
  min-width: 72px;
  width: 72px;
}

.admin-order-table th:nth-child(10),
.admin-order-table td:nth-child(10) {
  width: 68px;
}

.admin-order-table th:nth-child(11),
.admin-order-table td:nth-child(11) {
  width: 144px;
}

.admin-order-table th:nth-child(12),
.admin-order-table td:nth-child(12) {
  width: 78px;
}

.table-cell-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.button-disabled {
  background: #e5ebf1;
  color: #8a96a3;
  cursor: not-allowed;
}

.sales-record-table {
  table-layout: fixed;
  font-size: 12px;
}

.sales-record-table th,
.sales-record-table td {
  padding: 8px 4px;
  white-space: nowrap;
}

.sales-record-table th:nth-child(1),
.sales-record-table td:nth-child(1) {
  width: 240px;
}

.sales-record-table th:nth-child(9),
.sales-record-table td:nth-child(9) {
  width: 50px;
}

.sales-record-table th:nth-child(10),
.sales-record-table td:nth-child(10) {
  width: 126px;
}

.sales-record-table th:nth-child(11),
.sales-record-table td:nth-child(11) {
  width: 82px;
}

.sales-record-table th:nth-child(12),
.sales-record-table td:nth-child(12) {
  width: 88px;
}

.sales-record-table th:nth-child(13),
.sales-record-table td:nth-child(13) {
  width: 70px;
}

.sales-record-table .sales-express-status-input {
  min-width: 76px;
  width: 76px;
  padding: 4px 18px 4px 8px;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  text-align-last: center;
}

.sales-record-table td:nth-child(10) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.remark-preview {
  position: relative;
  display: inline-block;
  cursor: default;
}

.remark-preview[data-full-text]:hover::before {
  content: attr(data-full-text);
  position: absolute;
  right: calc(100% + 8px);
  left: auto;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  max-width: none;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(21, 32, 43, 0.92);
  color: #fff;
  white-space: nowrap;
  line-height: 1.5;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

@media (max-width: 960px) {
  .stats-grid-three,
  .order-form,
  .form-grid,
  .mini-form-grid,
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .inline-actions,
  .group-title,
  .form-actions,
  .detail-panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  #orders-panel .section-head,
  #orders-panel .section-head .inline-actions {
    flex-direction: row;
    align-items: center;
  }

  .app-shell {
    width: min(100% - 20px, 1280px);
    margin: 20px auto;
  }

  .dashboard > .panel,
  .admin-section-panel,
  .modal-card {
    padding: 16px;
  }

  .auth-panel {
    margin: 32px auto;
    padding: 20px;
  }

  .data-table {
    min-width: 760px;
  }

  .table-scroll {
    margin: 0 -4px;
    padding-bottom: 4px;
  }
}
