/* ══════════════════════════════════════════════════════
   劳务报酬计算器 — 样式
   高级 · 简约 · 时尚
   ══════════════════════════════════════════════════════ */

/* ── CSS 变量 ─────────────────────────────────────── */
:root {
  /* 主色调 */
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-primary: #0f172a;
  --color-primary-light: #1e293b;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;

  /* 语义色 */
  --color-success: #059669;
  --color-success-light: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;

  /* 文本 */
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-text-on-accent: #ffffff;

  /* 边框 & 阴影 */
  --color-border: #e2e8f0;
  --color-border-focus: #93c5fd;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);

  /* 排版 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;

  /* 布局 */
  --max-width: 1160px;
  --sidebar-width: 380px;
}

/* ── Reset ────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── 应用容器 ─────────────────────────────────────── */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 60px;
}

/* ── 头部 ─────────────────────────────────────────── */
.app-header {
  margin-bottom: 40px;
  text-align: center;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.app-header h1 .icon {
  font-size: 1.5rem;
  line-height: 1;
}

.app-header .subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ── 主布局 ───────────────────────────────────────── */
.app-main {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 32px;
  align-items: start;
}

/* ── 面板卡片 ─────────────────────────────────────── */
.panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.panel-header {
  padding: 20px 24px 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.panel-body {
  padding: 16px 24px 24px;
}

/* ── 输入面板 ─────────────────────────────────────── */
.input-panel .panel-body {
  padding-top: 20px;
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-wrapper .prefix {
  padding: 0 0 0 14px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  user-select: none;
}

.input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 14px 14px 8px;
  font-size: 1.15rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
  min-width: 0;
}

.input-wrapper input::placeholder {
  color: var(--color-text-muted);
  font-weight: 400;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

.input-wrapper input::-webkit-outer-spin-button,
.input-wrapper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.input-wrapper input[type="number"] {
  -moz-appearance: textfield;
}

/* ── 按钮 ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
}

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

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--color-primary);
  color: var(--color-text-on-accent);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  margin-top: 10px;
}

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

.btn-secondary {
  padding: 8px 14px;
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-secondary:hover {
  background: #dbeafe;
}

.btn-ghost {
  padding: 8px 14px;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-bg);
}

.btn-danger {
  padding: 8px 14px;
  background: var(--color-danger-light);
  color: var(--color-danger);
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-success-outline {
  padding: 8px 14px;
  background: var(--color-success-light);
  color: var(--color-success);
  font-size: 0.8rem;
}

.btn-success-outline:hover {
  background: #d1fae5;
}

/* ── 快捷示例 ─────────────────────────────────────── */
.quick-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.quick-samples button {
  padding: 5px 12px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.quick-samples button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* ── 警告提示 ─────────────────────────────────────── */
.warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-warning-light);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #92400e;
  margin-top: 16px;
  line-height: 1.5;
}

.warning-banner .warn-icon {
  flex-shrink: 0;
  font-size: 1rem;
  margin-top: 1px;
}

/* ── 结果面板 ─────────────────────────────────────── */
.result-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--color-text-muted);
}

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

.result-empty p {
  font-size: 0.9rem;
}

/* ── 结果卡片 ─────────────────────────────────────── */
.result-card {
  display: none;
}

.result-card.visible {
  display: block;
}

/* 汇总 */
.summary-card {
  background: linear-gradient(135deg, var(--color-primary) 0%, #1e3a5f 100%);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  color: #fff;
  margin-bottom: 16px;
}

.summary-card .summary-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-bottom: 4px;
}

.summary-card .summary-value {
  font-size: 2.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.summary-card .summary-meta {
  margin-top: 8px;
  font-size: 0.82rem;
  opacity: 0.75;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.summary-card .summary-meta .tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 0.75rem;
  font-weight: 500;
}

/* 明细 */
.detail-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.detail-card .detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.detail-card .detail-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.detail-card .detail-body {
  padding: 4px 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.detail-row:hover {
  background: var(--color-bg);
}

.detail-row .label {
  color: var(--color-text-secondary);
}

.detail-row .value {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
}

.detail-row.highlight {
  background: var(--color-accent-light);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin-top: -1px;
}

.detail-row.highlight .label {
  font-weight: 700;
  color: var(--color-accent);
}

.detail-row.highlight .value {
  font-size: 1.1rem;
  color: var(--color-accent);
}

.detail-row.total-advance {
  background: var(--color-success-light);
}

.detail-row.total-advance .label {
  font-weight: 700;
  color: var(--color-success);
}

.detail-row.total-advance .value {
  font-size: 1.05rem;
  color: var(--color-success);
}

.detail-row .bracket-info {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 400;
  font-family: var(--font-sans);
}

/* 备注 */
.footnote {
  padding: 10px 24px 14px;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  line-height: 1.5;
}

.footnote strong {
  color: var(--color-text-secondary);
}

/* ── 批量计算 ─────────────────────────────────────── */
.batch-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.batch-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}

.batch-section textarea {
  width: 100%;
  min-height: 90px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--color-text);
  background: var(--color-surface);
  line-height: 1.6;
}

.batch-section textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.batch-section textarea::placeholder {
  color: var(--color-text-muted);
  font-family: var(--font-sans);
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* 批量结果 */
.batch-result {
  display: none;
  margin-top: 24px;
}

.batch-result.visible {
  display: block;
}

.batch-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.batch-result-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

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

table.batch-table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.batch-table th:first-child {
  text-align: left;
}

table.batch-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

table.batch-table td:first-child {
  text-align: left;
  font-weight: 600;
  font-family: var(--font-sans);
}

table.batch-table tr:last-child td {
  border-bottom: none;
}

table.batch-table tr:hover td {
  background: var(--color-bg);
}

table.batch-table .row-below {
  opacity: 0.6;
}

table.batch-table .row-below td:first-child::after {
  content: " ⚠️";
  font-size: 0.7rem;
}

table.batch-table .num-vat {
  color: var(--color-warning);
}

table.batch-table .num-city-tax {
  color: var(--color-warning);
}

table.batch-table .num-tax {
  color: var(--color-danger);
}

table.batch-table .num-netpay {
  color: var(--color-success);
  font-weight: 700;
}

/* ── 档位参考 ─────────────────────────────────────── */
.bracket-reference {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.bracket-reference .ref-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.bracket-reference .ref-header h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bracket-reference table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.bracket-reference table th {
  text-align: left;
  padding: 10px 12px 10px 24px;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.bracket-reference table th:last-child {
  text-align: right;
  padding-right: 24px;
}

.bracket-reference table td {
  padding: 8px 12px 8px 24px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.bracket-reference table td:last-child {
  text-align: right;
  padding-right: 24px;
  font-family: var(--font-mono);
  color: var(--color-text);
}

.bracket-reference table tr:last-child td {
  border-bottom: none;
}

.bracket-reference .ref-note {
  padding: 10px 24px 14px;
  font-size: 0.74rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

/* ── 页脚 ─────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 32px 0 8px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.app-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

/* ── Toast 消息 ───────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.error {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

.toast.success {
  background: var(--color-success-light);
  color: var(--color-success);
  border: 1px solid #a7f3d0;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── 响应式 ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .app {
    padding: 24px 16px 40px;
  }

  .app-header h1 {
    font-size: 1.4rem;
  }

  .summary-card .summary-value {
    font-size: 1.8rem;
  }

  .detail-row {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .app-header {
    margin-bottom: 24px;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }

  .input-wrapper input {
    font-size: 1rem;
    padding: 12px 12px 12px 6px;
  }

  .summary-card {
    padding: 20px;
  }

  .summary-card .summary-value {
    font-size: 1.5rem;
  }

  .detail-card .detail-header,
  .detail-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  .batch-actions {
    flex-direction: column;
  }

  .batch-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .batch-result-header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}
