* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

header {
  margin-bottom: 16px;
}

header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
}

.subtitle {
  margin: 4px 0 0;
  color: #86868b;
  font-size: 14px;
}

#modeBanner {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
}

#modeBanner.test {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffe69c;
}

#modeBanner.live {
  background: #d1f5d3;
  color: #1e7e34;
  border: 1px solid #a3e6a8;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.pdf-drop {
  border: 2px dashed #c7c7cc;
  background: #fafafa;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
  display: block;
}

.pdf-drop:hover { border-color: #0071e3; background: #f0f8ff; }

.pdf-drop.drag-over {
  border-color: #0071e3;
  background: #e6f2ff;
  border-style: solid;
}

.pdf-drop-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pdf-drop-icon {
  font-size: 32px;
  line-height: 1;
}

.pdf-drop-text {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pdf-drop-text strong { font-size: 15px; }
.pdf-drop-text small { font-size: 12px; color: #86868b; margin-top: 2px; }

.pdf-drop-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.pdf-drop-status.working {
  background: #fff8e1;
  color: #6d4c00;
  border: 1px solid #ffe082;
}

.pdf-drop-status.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.pdf-drop-status.error {
  background: #fff5f5;
  color: #d70015;
  border: 1px solid #fcc;
}

#textPasteCard textarea {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
}

.hint {
  font-size: 13px;
  color: #515154;
  background: #f5f5f7;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 16px;
}

.muted {
  font-size: 13px;
  font-weight: 400;
  color: #86868b;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.row:last-child {
  margin-bottom: 0;
}

.field {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.field.narrow {
  flex: 0 0 110px;
}

.field.flex2 {
  flex: 2 1 200px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: #515154;
  margin-bottom: 4px;
}

.req {
  color: #d70015;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #0071e3;
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

input.has-error,
select.has-error,
textarea.has-error {
  border-color: #d70015;
  background: #fff5f5;
}

input.flash,
select.flash,
textarea.flash {
  animation: errorFlash 0.6s ease-in-out 2;
}

@keyframes errorFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 0, 21, 0); }
  50%      { box-shadow: 0 0 0 6px rgba(215, 0, 21, 0.35); }
}

input:disabled,
select:disabled {
  background: #f5f5f7;
  color: #86868b;
  cursor: not-allowed;
}

.error {
  font-size: 12px;
  color: #d70015;
  margin-top: 4px;
  min-height: 0;
  display: none;
}

.error.visible {
  display: block;
}

.global-error,
.global-success {
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
}

.global-error {
  background: #fff5f5;
  border: 1px solid #fcc;
  color: #d70015;
}

.global-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.global-error h3,
.global-success h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.global-error ul {
  margin: 0;
  padding-left: 20px;
}

.global-success a {
  color: #166534;
  font-weight: 600;
}

.hidden { display: none; }

.line-item {
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  background: #fafafa;
}

.line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.line-num {
  font-weight: 600;
  font-size: 13px;
  color: #515154;
}

.remove-line {
  background: transparent;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #515154;
}

.remove-line:hover {
  background: #ffe5e5;
  border-color: #ff8888;
  color: #d70015;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}

button {
  font-family: inherit;
}

.btn-primary {
  background: #0071e3;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: #0077ed;
}

.btn-primary:disabled {
  background: #86868b;
  cursor: wait;
}

.btn-secondary {
  background: #fff;
  color: #0071e3;
  border: 1px solid #0071e3;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

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

.btn-tertiary {
  background: transparent;
  color: #515154;
  border: none;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

.btn-tertiary:hover {
  color: #d70015;
}

.autosave {
  font-size: 12px;
  color: #86868b;
  font-style: italic;
}

@media (max-width: 640px) {
  .field.narrow {
    flex: 1 1 calc(50% - 6px);
  }
}


.tax-override-card {
  border: 2px solid #d70015 !important;
  background: #fff5f5 !important;
}

.tax-override-row {
  display: flex;
  align-items: center;
}

.tax-override-toggle {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700 !important;
  font-size: 15px !important;
  color: #d70015 !important;
}

.tax-override-toggle input {
  width: 20px !important;
  height: 20px !important;
  accent-color: #d70015;
  cursor: pointer;
  margin: 0;
}

.tax-override-hint {
  font-size: 13px;
  color: #6d0011;
  margin: 8px 0 0;
}

.tax-override-card.active {
  animation: taxOverridePulse 1.5s ease-in-out 2;
}

@keyframes taxOverridePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 0, 21, 0); }
  50%      { box-shadow: 0 0 0 8px rgba(215, 0, 21, 0.35); }
}

.tax-preview {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.tax-preview.idle    { background: #f5f5f7; color: #515154; border-color: #e5e5ea; }
.tax-preview.loading { background: #fff8e1; color: #6d4c00; border-color: #ffe082; }
.tax-preview.ok      { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.tax-preview.taxable { background: #eef4ff; color: #1a4b8a; border-color: #b4d5f0; }
.tax-preview.taxable.review { background: #fff8e1; color: #6d4c00; border-color: #ffe082; }
.tax-preview.override{ background: #fff5f5; color: #d70015; border-color: #fcc; }
.tax-preview.error   { background: #fff5f5; color: #d70015; border-color: #fcc; }
.tax-preview .tax-amount { font-weight: 700; }
.tax-preview .tax-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,0.08); margin: 0 2px; }
.tax-preview .tax-badge.override { background: #d70015; color: #fff; }
.tax-preview .tax-badge.review   { background: #f5a623; color: #fff; }
.tax-preview .tax-reason { font-size: 12px; opacity: 0.8; }


/* Order Summary (replaces the old inline tax preview) */
.order-summary { }
.order-summary .summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 0;
  font-size: 14px;
}
.order-summary .summary-label { color: #515154; }
.order-summary .summary-value { font-weight: 600; color: #1d1d1f; font-variant-numeric: tabular-nums; }
.order-summary .summary-tax { padding-top: 10px; border-top: 1px solid #e5e5ea; margin-top: 4px; }
.order-summary .summary-total {
  padding-top: 10px; border-top: 2px solid #1d1d1f; margin-top: 4px;
  font-size: 17px;
}
.order-summary .summary-total .summary-label,
.order-summary .summary-total .summary-value { font-weight: 700; color: #1d1d1f; }
.order-summary .summary-note {
  font-size: 12px; color: #515154; margin: 4px 0 6px; font-style: italic; min-height: 0;
}
.tax-badge-inline {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; margin-left: 4px;
  background: rgba(0,0,0,0.08); color: #515154;
  vertical-align: middle;
}
.tax-badge-inline.exempt   { background: #d1f5d3; color: #1e7e34; }
.tax-badge-inline.nexus    { background: #d1f5d3; color: #1e7e34; }
.tax-badge-inline.taxable  { background: #b4d5f0; color: #1a4b8a; }
.tax-badge-inline.review   { background: #ffe082; color: #6d4c00; }
.tax-badge-inline.override { background: #d70015; color: #fff; }
.tax-badge-inline.loading  { background: #fff8e1; color: #6d4c00; }
.tax-badge-inline.error    { background: #fcc;    color: #d70015; }


.line-warning {
  margin-top: 8px;
  padding: 6px 10px;
  background: #fff8e1;
  color: #6d4c00;
  border: 1px solid #ffe082;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
