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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e5ee;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --success: #16a34a;
  --muted: #6b7280;
  --text: #111827;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
}

body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; padding: 10px; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem; width: 360px; box-shadow: var(--shadow);
}
.login-box h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-box .subtitle { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Topbar ── */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; height: 52px; position: sticky; top: 0; z-index: 100;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 1rem; }
.logo { font-weight: 600; font-size: 1rem; }
.user-label { font-size: 13px; color: var(--muted); }
.user-label strong { color: var(--text); }

/* ── Container ── */
.container { width: 100%; padding: 1.5rem 2rem; }

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.page-header h2 { font-size: 1.25rem; font-weight: 600; }

/* ── Banners ── */
.banner {
  padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  font-size: 13px; border: 1px solid transparent;
}
.banner-warn { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.banner-info { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

/* ── Table ── */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden;
}
.table th {
  background: var(--bg); padding: 10px 12px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; border-bottom: 1px solid var(--border);
}
.table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #f9fafb; }
.table-wrap { overflow-x: auto; }

/* ── Status badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.badge-draft { background: #f3f4f6; color: var(--muted); }
.badge-confirmed { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-shipped { background: #e0e7ff; color: #3730a3; }
.badge-completed { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
.badge-pending { background: #fef3c7; color: #92400e; }

/* ── Status bar ── */
.status-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.status-info { display: flex; align-items: center; gap: 1rem; }
.status-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ── Exchange rate row ── */
.exchange-row {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; box-shadow: var(--shadow);
}
.exchange-row label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.exchange-row input { width: 120px; }

/* ── Section header ── */
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem;
}
.section-header h3 { font-size: 1rem; font-weight: 600; }

/* ── Items table specifics ── */
.items-table td { vertical-align: middle; }
.item-pending td { background: #fffbeb !important; }
.item-pending-badge { font-size: 11px; color: var(--warn); display: block; margin-top: 2px; }
.item-variation { font-size: 11px; color: var(--muted); display: block; }

.totals-row td {
  background: #f9fafb; font-size: 13px; border-top: 1px solid var(--border);
}
.grand-total td { font-size: 14px; font-weight: 700; background: #eff6ff; }

/* ── Shipping list ── */
.shipping-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.5rem; }
.shipping-option {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem;
}
.shipping-option.selected { border-color: var(--primary); background: #eff6ff; }
.shipping-info { display: flex; flex-direction: column; gap: 2px; }
.shipping-name { font-weight: 600; }
.shipping-cost { font-size: 12px; color: var(--muted); }
.shipping-actions { display: flex; gap: .5rem; }

/* ── Tracking ── */
.tracking-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.tracking-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }
.tracking-row { display: flex; gap: .5rem; align-items: center; }
.tracking-row input { max-width: 300px; }

/* ── Side panels (tracking + invoices) ── */
.side-panels {
  display: flex; gap: 1.5rem; margin-bottom: 1.25rem;
}
.side-panels > * { flex: 1; min-width: 0; }

/* ── Change requests section ── */
.change-requests-list { display: flex; flex-direction: column; gap: .5rem; padding: .5rem 0; }
.change-request-item {
  background: var(--surface); border: 1px solid #fcd34d; border-radius: var(--radius);
  padding: .75rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.change-request-info { font-size: 13px; }
.change-request-info .cr-product { font-weight: 600; }
.change-request-info .cr-detail { color: var(--muted); }
.change-request-actions { display: flex; gap: .5rem; }

/* ── Forms / Fields ── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: .75rem; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], textarea, select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; width: 100%; background: var(--surface); color: var(--text);
  transition: border .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.field-full { grid-column: 1 / -1; }

.error-msg { color: var(--danger); font-size: 12px; padding: .5rem 0; }

/* ── Image preview ── */
.image-preview { display: flex; align-items: center; gap: .75rem; margin-top: .5rem; }
.image-preview img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.item-image { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.modal-box {
  position: relative; background: var(--surface); border-radius: var(--radius);
  padding: 1.5rem; width: 540px; max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 3rem); overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-box h3 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* ── Confirmation checkmarks ── */
.confirm-checks { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.confirm-checks span { display: flex; align-items: center; gap: 4px; }
.check-yes { color: var(--success); }
.check-no { color: var(--muted); }

/* ── Autocomplete ── */
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.autocomplete-item {
  padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.active { background: var(--bg); }
.autocomplete-item .ac-variation { font-size: 11px; color: var(--muted); }

/* ── Drag handle ── */
.drag-handle {
  cursor: grab; color: var(--muted); font-size: 15px; padding: 0 4px;
  user-select: none; line-height: 1;
}
.drag-handle:active { cursor: grabbing; }
tr.drag-over td { border-top: 2px solid var(--primary); }
tr.dragging { opacity: .4; }

/* ── Invoice items ── */
.invoice-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.invoice-item:last-child { border-bottom: none; }
.invoice-item a { flex: 1; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .status-bar { flex-direction: column; align-items: flex-start; }
  .exchange-row { flex-wrap: wrap; }
}
