* { 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;
}

.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);
  }
}
