/* ========== 设计令牌（Linear/Notion 风格）========== */
:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f5f5f5;
  --border: #ececec;
  --border-strong: #e0e0e0;
  --text-primary: #111111;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --accent: #111111;
  --accent-hover: #2a2a2a;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ========== 顶部导航 ========== */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.nav-brand .logo-mark {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--bg);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn-ghost { color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(220, 38, 38, 0.08); color: var(--danger); }
.btn-sm { height: 28px; padding: 0 8px; font-size: 12px; }
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

/* ========== 内容区 ========== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* ========== 信息提示条 ========== */
.info-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  font-size: 12px;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.info-bar svg {
  flex-shrink: 0;
}

/* ========== 工具栏 ========== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* ========== 输入框 ========== */
.input,
.select {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}
.input::placeholder { color: var(--text-tertiary); }
.input:hover, .select:hover { border-color: #d0d0d0; }
.input:focus, .select:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06);
}
.input-search {
  width: 280px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  padding-left: 30px;
}
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  min-width: 130px;
}
.toolbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ========== 表格 ========== */
.table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  user-select: none;
  letter-spacing: 0;
}
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { color: var(--text-secondary); }
thead th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
}
thead th.sorted .sort-arrow { opacity: 1; }
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }
.td-name { font-weight: 500; }
.td-spec { color: var(--text-secondary); }
.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.profit-pos { color: var(--success); }
.profit-neg { color: var(--danger); }
.td-time { color: var(--text-tertiary); font-size: 12px; }
.row-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}
tbody tr:hover .row-actions { opacity: 1; }
.row-actions .btn { padding: 0 8px; height: 26px; font-size: 12px; }

/* ========== 空状态 ========== */
.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-tertiary);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}
.empty-state-text {
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}
.empty-state-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 16px 20px 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* ========== 表单 ========== */
.form-row { margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input::placeholder { color: var(--text-tertiary); }
.form-input:hover { border-color: #d0d0d0; }
.form-input:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.06);
}
.form-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--danger);
  display: none;
}
.form-error.show { display: block; }

/* ========== 订单数徽章 ========== */
.order-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  line-height: 1;
}
.order-count-badge:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.order-count-badge.has-orders {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.order-count-badge.has-orders:hover {
  background: var(--accent-hover);
}

/* ========== 订单列表 ========== */
.order-list-wrap {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 2px;
}
.order-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--text-tertiary);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}
.order-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
.order-summary strong {
  color: var(--text-primary);
  font-weight: 600;
  margin-left: 2px;
}
.order-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.order-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.order-item:hover {
  background: var(--bg-subtle);
}
.order-item-main {
  flex: 1;
  min-width: 0;
}
.order-item-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.order-customer {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}
.order-time {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.order-item-nums {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.order-item-nums strong {
  color: var(--text-primary);
  font-weight: 600;
}
.order-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
  word-break: break-all;
}
.order-recorder {
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.order-recorder::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  margin-right: 6px;
  vertical-align: middle;
}
.order-form-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ========== 记录人统计 ========== */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.stats-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.stats-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.stats-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.stats-card-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-card-name .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}
.stats-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 12px;
}
.stats-card-grid .k { color: var(--text-tertiary); }
.stats-card-grid .v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.stats-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-tertiary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.stats-detail-wrap { margin-top: 20px; }
.stats-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}
.stats-total-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
.stats-total-bar strong { color: var(--text-primary); font-weight: 600; }
.stats-quick { display: flex; gap: 4px; }
.stats-quick .btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.input-date {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}
.date-sep { color: var(--text-tertiary); font-size: 12px; }
tr.stats-day-row td {
  background: var(--bg-subtle);
  padding: 8px 14px !important;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-strong);
}
tr.stats-day-row td .day-sub {
  font-weight: 500;
  color: var(--text-tertiary);
  margin-left: 10px;
  font-variant-numeric: tabular-nums;
}
tr.stats-day-row td .weekday {
  color: var(--text-tertiary);
  font-weight: 500;
  margin-left: 8px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .nav { padding: 0 12px; height: 50px; }
  .nav-brand { font-size: 14px; gap: 6px; }
  .nav-brand .logo-mark { width: 20px; height: 20px; font-size: 11px; }
  .nav-actions .btn { padding: 0 8px; height: 30px; font-size: 12px; }
  .nav-actions .btn-icon { width: 30px; padding: 0; }
  .info-bar { padding: 6px 12px; font-size: 11px; }
  .info-bar span { white-space: normal; line-height: 1.3; }

  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  .input-search { width: 100%; flex: 1 1 100%; }
  .select { min-width: 0; flex: 1; }
  .toolbar-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    gap: 6px;
  }
  .toolbar-right .btn { padding: 0 10px; height: 30px; font-size: 12px; }

  /* 统计页日期筛选换行 */
  .stats-quick { flex: 1 1 100%; }
  .input-date { flex: 1; min-width: 0; }
  .date-sep { display: none; }
  #btn-stats-date-clear { flex: 0 0 auto; }

  /* 表格横向滚动 */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 600px; font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }
  .row-actions { opacity: 1; }

  .form-grid { grid-template-columns: 1fr; }

  /* 模态框全屏化 */
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100%;
    min-height: 100vh;
    border-radius: 0;
  }
  .modal-header { padding: 14px 16px 0; font-size: 14px; }
  .modal-body { padding: 14px 16px 18px; }
  .modal-footer { padding: 10px 16px; }
  .form-input { height: 38px; font-size: 14px; }

  /* 订单面板优化 */
  .order-list-wrap { max-height: 40vh; }
  .order-summary {
    gap: 8px 12px;
    font-size: 11px;
    padding: 8px 10px;
  }
  .order-item {
    padding: 8px 10px;
  }
  .order-item-nums { gap: 8px; font-size: 11px; }
}

@media (max-width: 380px) {
  .nav-brand span:not(.logo-mark) { font-size: 13px; }
  .nav-actions .btn { padding: 0 6px; font-size: 11px; }
  table { min-width: 540px; font-size: 11px; }
  thead th, tbody td { padding: 6px 8px; }
}
