:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e0e4ec;
  --text: #1f2937;
  --muted: #6b7280;
  --warn-bg: #fff7e6;
  --warn-border: #f2c94c;
  --danger: #dc2626;
  --ok: #16a34a;
}

* { box-sizing: border-box; }

body {
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0 0 60px;
}

header.top {
  background: linear-gradient(120deg, var(--primary), #1e3a8a);
  color: #fff;
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.top h1 { font-size: 20px; margin: 0; }
header.top a { color: #dbeafe; text-decoration: none; font-size: 14px; }
header.top a:hover { text-decoration: underline; }

main {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card h2 {
  font-size: 16px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  flex: none;
}

.dropzone {
  border: 2px dashed #c7d2fe;
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s;
}
.dropzone.drag { background: #eef2ff; border-color: var(--primary); }
.dropzone input { display: none; }
.dropzone .hint { font-size: 12px; margin-top: 6px; }

.provider-row { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; gap: 16px; align-items: center; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  background: var(--primary);
  color: #fff;
  transition: background .15s;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #eef2ff; color: var(--primary-dark); }
button.secondary:hover { background: #e0e7ff; }
button:disabled { background: #cbd5e1; cursor: not-allowed; }

table.items {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
table.items th, table.items td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}
table.items th { background: #f8fafc; font-weight: 600; }
table.items input, table.items textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  padding: 3px 4px;
  border-radius: 4px;
  font-family: inherit;
}
table.items input:focus, table.items textarea:focus {
  border-color: var(--primary);
  background: #fff;
  outline: none;
}
table.items input.num { text-align: right; }
table.items tr.uncertain td { background: var(--warn-bg); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 16px;
  margin-bottom: 14px;
}
.field-grid label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.field-grid input, .field-grid textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}

.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.company-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.company-chip:hover { border-color: var(--primary); }
.company-chip input { width: 16px; height: 16px; }

.warn-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  color: #92610a;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 14px;
}
.result-row .amount { color: var(--primary-dark); font-weight: 600; }
.result-row .actions { display: flex; gap: 8px; }
.markup-note { color: #b45309; font-weight: 600; }

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

.markup-row {
  margin-top: 10px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}
.markup-row label { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.markup-row input[type="checkbox"] { margin-top: 2px; }

.small-muted { font-size: 12px; color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

.badge { display:inline-block; font-size:11px; padding:2px 8px; border-radius:10px; background:#e0f2fe; color:#0369a1; }
.badge.off { background:#fee2e2; color:#b91c1c; }

.hidden { display: none !important; }

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
