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

:root {
  --color-primary: #1a56db;
  --color-primary-hover: #1746ba;
  --color-danger: #e02424;
  --color-danger-hover: #c81a1a;
  --color-success: #057a55;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-border: #d1d5db;
  --color-text: #111827;
  --color-muted: #6b7280;
  --color-label: #374151;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
}

/* ── App wrapper ─────────────────────────────────────────────────────────── */
.app-wrapper {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #d1fae5;
  color: var(--color-success);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

/* ── Hamburger menu ──────────────────────────────────────────────────────── */
.hamburger-wrapper {
  position: relative;
  margin-left: auto;
}

.hamburger-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--color-text);
  transition: background 0.15s;
}

.hamburger-btn:hover {
  background: #f3f4f6;
}

.hamburger-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.35rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 140px;
  z-index: 100;
  overflow: hidden;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
}

.menu-item:hover {
  background: #eff6ff;
}

/* ── Form sections ───────────────────────────────────────────────────────── */
.form-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.form-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-label);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.form-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-muted);
  margin: 1rem 0 0.6rem;
}

/* ── Grid layout ─────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem 1rem;
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.col-span-2 {
  grid-column: span 2;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-label);
}

.field.required label::after {
  content: " *";
  color: var(--color-danger);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

textarea {
  resize: vertical;
}

/* ── Checkbox label ──────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.hidden {
  display: none !important;
}

/* ── Line items (card layout) ────────────────────────────────────────────── */
#line-items-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.line-item-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--color-bg);
}

.line-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.line-item-number {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.line-item-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.75rem;
  align-items: end;
}

@media (max-width: 700px) {
  .line-item-fields {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .line-item-fields {
    grid-template-columns: 1fr;
  }
}

.line-item-fields select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.line-item-fields select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.li-subtotal-field .subtotal-cell {
  display: block;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.line-item-desc {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-muted);
  font-style: italic;
}

/* ── Namedrops ───────────────────────────────────────────────────────────── */
.namedrop-section {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--color-border);
}

.namedrop-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-label);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
  display: block;
}

.namedrop-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 0.75rem;
}

.namedrop-field label {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.li-price-field input[readonly] {
  background: #f3f4f6;
  color: var(--color-muted);
}

/* ── Totals ──────────────────────────────────────────────────────────────── */
.totals-section {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.totals-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2rem;
  font-size: 1.1rem;
}

.totals-label {
  font-weight: 600;
  color: var(--color-label);
}

.totals-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Actions ─────────────────────────────────────────────────────────────── */
.actions-section {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    opacity 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: #e5e7eb;
  color: var(--color-text);
}
.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover:not(:disabled) {
  background: #f3f4f6;
}

.btn-danger {
  background: #fee2e2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

/* ── Sticker preview ─────────────────────────────────────────────────────── */
.sticker-preview {
  margin-top: 0.5rem;
  text-align: center;
}

.sticker-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}

/* ── Error toast ─────────────────────────────────────────────────────────── */
.error-toast {
  display: none;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  color: var(--color-danger);
  padding: 0.65rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
