:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --border: #e2dcd3;
  --text: #2c2825;
  --text-muted: #7a7268;
  --accent: #c45c26;
  --accent-dark: #9a4518;
  --accent-soft: #f3e4d8;
  --header-bg: #8b5a2b;
  --header-text: #fff8f0;
  --success: #2d6a4f;
  --danger: #b23a48;
  --warning: #d4a017;
  --shadow: 0 8px 32px rgba(44, 40, 37, 0.08);
  --radius: 10px;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse at 10% 0%, rgba(196, 92, 38, 0.08), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(139, 90, 43, 0.06), transparent 45%),
    var(--bg);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
}

button,
input,
select {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

/* ── Login ── */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  animation: rise 0.5s ease;
}

.login-card h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 92, 38, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  padding: 12px;
}

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

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.login-footer {
  margin-top: 18px;
  text-align: center;
}

.error-msg {
  background: #fde8ea;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

/* ── App Shell ── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.app-header .brand {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.88rem;
}

.role-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
}

.app-body {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab-btn {
  position: relative;
  padding: 12px 20px;
  background: none;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn .dot,
.sub-tab-btn .dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(178, 58, 72, 0.3);
  pointer-events: none;
  z-index: 1;
}

.sub-tab-btn.active .dot {
  border-color: var(--accent);
}

.sub-tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.sub-tab-btn {
  position: relative;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.sub-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Cards & Panels ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  animation: rise 0.35s ease;
}

.panel-title {
  font-size: 1.05rem;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  align-items: end;
}

.form-row .form-group-compact {
  max-width: 132px;
}

.form-row .form-group-narrow {
  max-width: 120px;
}

.form-row .form-group-compact select,
.form-row .form-group-narrow input {
  width: 100%;
}

.form-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: -8px 0 16px;
}

.input-readonly {
  background: #f5f2ed;
  color: var(--text);
  cursor: default;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Records ── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="date"],
.filter-bar input[type="month"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.88rem;
}

.record-group {
  margin-bottom: 24px;
}

.record-group-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 10px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border-radius: 6px;
  display: inline-block;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
}

.record-item .meta {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 4px;
}

.record-item .actions {
  display: flex;
  gap: 6px;
}

/* ── Messages ── */
.msg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.unread-badge {
  background: var(--danger);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.message-item:hover {
  background: var(--surface-2);
}

.message-item.unread {
  border-left: 3px solid var(--accent);
  background: #fff9f5;
}

.message-item .msg-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.message-item .msg-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 6px;
}

.msg-status.approved {
  background: #d8f3dc;
  color: var(--success);
}

.msg-status.rejected {
  background: #fde8ea;
  color: var(--danger);
}

/* ── Preview Table (参考图风格) ── */
.preview-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
}

.preview-table thead th {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 8px 10px;
  text-align: center;
  font-weight: 600;
  border: 1px solid #6d4522;
  position: sticky;
  top: 0;
}

.preview-table tbody td {
  padding: 6px 10px;
  text-align: right;
  border: 1px solid #ddd5c8;
}

.preview-table tbody td.text-left {
  text-align: left;
}

.preview-table tbody tr:nth-child(even):not(.total-row) {
  background: #faf3e8;
}

.preview-table tbody tr:nth-child(odd):not(.total-row) {
  background: #fff;
}

.preview-table .col-sales {
  background: #e8f5e9 !important;
}

.preview-table .col-subtotal {
  background: #e3f2fd !important;
}

.preview-table .col-total {
  background: #e3f2fd !important;
  font-weight: 600;
}

.preview-table .total-row td {
  background: #f0e6d6 !important;
  font-weight: 700;
  border-top: 2px solid var(--header-bg);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 0.88rem;
}

.pagination button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  color: var(--text-muted);
  padding: 0 8px;
}

/* ── Approval List ── */
.approval-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface-2);
}

.approval-card .approval-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.approval-card .approval-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.approval-card .approval-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.approval-card .field label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.approval-card .field .old-val {
  text-decoration: line-through;
  color: var(--text-muted);
}

.approval-card .field .new-val {
  color: var(--accent);
  font-weight: 600;
}

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

/* ── Employee Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.data-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.data-table tr:hover td {
  background: var(--surface-2);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  white-space: nowrap;
}

.inline-form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form-row input {
  flex: 1;
  min-width: 160px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.inline-form-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 149, 106, 0.15);
}

.product-picker-panel {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.product-picker-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.product-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.product-check-item:hover {
  border-color: var(--accent);
}

.product-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.product-check-name {
  flex: 1;
  font-size: 0.9rem;
}

.product-sale-price {
  width: 100px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.88rem;
  text-align: right;
  background: var(--surface);
}

.product-sale-price:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

.product-sale-price:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(196, 149, 106, 0.15);
}

.product-check-price {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.product-sum-hint {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.product-sum-hint span,
.product-sum-value {
  color: var(--accent);
  font-weight: 700;
}

.product-empty-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 40, 37, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: rise 0.3s ease;
}

.modal h3 {
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-wide {
  width: min(720px, 100%);
}

.salary-modal-meta {
  margin: -8px 0 18px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.salary-calc-section {
  margin-bottom: 22px;
}

.salary-section-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.salary-section-hint {
  margin: -6px 0 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.salary-section-head .salary-section-title {
  margin: 0;
}

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

.salary-calc-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.salary-readonly-value {
  padding: 11px 14px;
  border-radius: 8px;
  background: #f5f2ed;
  font-weight: 600;
}

.salary-other-income-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
}

.salary-other-income-row input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.salary-empty-hint {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.salary-calc-summary {
  margin-top: 8px;
  padding: 16px;
  border-radius: 10px;
  background: #faf7f3;
  border: 1px solid var(--border);
}

.salary-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 0.9rem;
}

.salary-summary-total {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 1rem;
}

.table-action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.salary-product-table .product-commission-input {
  width: 100%;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.salary-doc-modal {
  width: min(860px, 100%);
}

.salary-doc-editor {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.salary-doc-editor label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.salary-doc-editor input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.salary-doc {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 28px;
}

.salary-doc-title {
  margin: 0 0 16px;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.08em;
}

.salary-doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.salary-doc-meta {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.salary-doc-meta div {
  display: flex;
  gap: 10px;
}

.salary-doc-meta strong {
  color: var(--text);
}

.salary-doc-summary,
.salary-doc-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.salary-doc-summary th,
.salary-doc-summary td,
.salary-doc-table th,
.salary-doc-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
}

.salary-doc-summary th,
.salary-doc-table th {
  background: #f7f3ed;
}

.salary-doc-summary td,
.salary-doc-table td {
  text-align: right;
}

.salary-doc-summary th:first-child,
.salary-doc-summary td:first-child,
.salary-doc-table th:first-child,
.salary-doc-table td:first-child {
  text-align: left;
}

.salary-doc-amount {
  font-size: 1.8rem;
  font-weight: 800;
}

.salary-doc-tax {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 2000;
  animation: rise 0.3s ease;
  box-shadow: var(--shadow);
}

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

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.loading-overlay.hidden {
  display: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary, #333);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ── Sales Stats ── */
.sales-toolbar select,
.sales-toolbar input[type="date"],
.sales-toolbar input[type="month"],
.sales-toolbar input[type="week"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--surface);
}

.sales-period-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: auto;
}

.sales-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.sales-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.sales-card-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sales-card-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.sales-stats-table td:nth-child(n+3):not(:last-child):not(:nth-last-child(2)) {
  text-align: right;
}

.sales-stats-table .total-row td {
  background: #f0e6d6;
  font-weight: 600;
}

.sales-zero-row td {
  color: var(--text-muted);
}

.role-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e3f2fd;
  color: #1565c0;
  font-weight: 600;
  vertical-align: middle;
}

.sales-bar-wrap {
  width: 80px;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.sales-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  min-width: 0;
}

.sales-detail-row td {
  padding: 0 !important;
  background: var(--surface-2);
}

.sales-detail-panel {
  padding: 12px 16px 16px;
}

.sales-detail-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.sales-detail-table {
  font-size: 0.82rem;
}

.income-type-table td:nth-child(2),
.income-type-table td:nth-child(5) {
  text-align: right;
}

.income-type-bar {
  width: 100px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.income-pct {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.income-section-head td {
  background: #efe8df;
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-top: 2px solid var(--border);
}

.income-section-head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.income-section-head-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.income-section-title {
  font-weight: 700;
}

.income-section-meta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

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

.panel-section-header .panel-section-title {
  margin: 0;
}

.panel-section-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.income-section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
}

.income-section-divider td {
  padding: 0;
  height: 10px;
  background: linear-gradient(to bottom, transparent 4px, var(--border) 4px, var(--border) 5px, transparent 5px);
  border: none;
}

.income-section-total td {
  background: #faf7f3;
  border-top: 1px solid var(--border);
}

.income-product-row td {
  background: #f5f0ea;
}

.income-product-row td:first-child {
  padding-left: 24px;
}

.income-product-detail-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.panel-section-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
}

.panel-section-header .panel-section-title {
  margin: 0;
}

.profit-formula-bar {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #f5f2ed;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.profit-summary-cards .profit-card-detail {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.sales-card.profit-positive {
  border-color: #b8dfc4;
  background: linear-gradient(180deg, #f4fbf6 0%, var(--surface) 100%);
}

.sales-card.profit-positive .sales-card-value {
  color: #1f7a3b;
}

.sales-card.profit-negative {
  border-color: #efc4c4;
  background: linear-gradient(180deg, #fff5f5 0%, var(--surface) 100%);
}

.sales-card.profit-negative .sales-card-value {
  color: #b42318;
}

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

.profit-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

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

.profit-expense-table input {
  width: 100%;
  max-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

@media (max-width: 640px) {
  .app-body {
    padding: 16px;
  }

  .profit-layout {
    grid-template-columns: 1fr;
  }

  .record-item {
    grid-template-columns: 1fr;
  }

  .preview-table {
    font-size: 0.7rem;
  }
}
