:root {
  color-scheme: light;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: #19212b;
  background: #f3f6f8;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea {
  font: inherit;
}
.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 40px 32px 56px;
}
.page-header,
.section-heading,
.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-header {
  margin-bottom: 18px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  margin-bottom: 7px;
  color: #102235;
  font-size: clamp(2rem, 4vw, 2.55rem);
  letter-spacing: -0.04em;
  line-height: 1;
}
h2 {
  margin-bottom: 0;
  color: #102235;
  font-size: 1.05rem;
}
h3 {
  margin-bottom: 0;
  font-size: 1rem;
}
.eyebrow {
  margin-bottom: 7px;
  color: #057a89;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.intro,
#preview-caption,
.hint {
  margin-bottom: 0;
  color: #627080;
  font-size: 0.9rem;
}
.app-message {
  min-height: 0;
  margin: 0 0 18px;
  padding: 0;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 650;
}
.app-message:not(:empty) {
  padding: 11px 13px;
  background: #e5f6ef;
  color: #0b6548;
}
.app-message.error:not(:empty) {
  background: #fff0ef;
  color: #ad2f27;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(380px, 0.8fr) minmax(540px, 1.2fr);
  gap: 28px;
  align-items: start;
}
.orders-panel,
.preview-panel {
  min-width: 0;
}
.section-heading {
  margin-bottom: 14px;
}
.orders {
  display: grid;
  gap: 18px;
}
.order-card {
  padding: 22px;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px #1022350b;
}
.order-card-header {
  padding-bottom: 15px;
  margin-bottom: 2px;
  border-bottom: 1px solid #edf0f2;
}
.order-summary {
  display: none;
  flex: 1;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: #102235;
  background: transparent;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.order-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.order-card.is-collapsed {
  padding: 15px 18px;
}
.order-card.is-collapsed .order-card-header {
  padding: 0;
  margin: 0;
  border: 0;
}
.order-card.is-collapsed h3,
.order-card.is-collapsed > label,
.order-card.is-collapsed .parse-status {
  display: none;
}
.order-card.is-collapsed .order-summary {
  display: block;
}
.order-card.is-collapsed .collapse-order {
  display: none;
}
label {
  display: grid;
  gap: 7px;
  margin-top: 17px;
  color: #354454;
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.015em;
}
input,
textarea {
  width: 100%;
  border: 1px solid #cbd6de;
  border-radius: 9px;
  padding: 11px 12px;
  color: #172331;
  background: #fff;
  font-size: 0.92rem;
  font-weight: 450;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.invoice-input {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}
textarea {
  min-height: 290px;
  resize: vertical;
  line-height: 1.55;
}
input:focus,
textarea:focus {
  outline: 0;
  border-color: #0c8291;
  box-shadow: 0 0 0 3px #08a5b51f;
}
.button {
  border: 0;
  border-radius: 9px;
  padding: 10px 15px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.button:hover {
  transform: translateY(-1px);
}
.button-primary {
  padding: 12px 19px;
  color: #fff;
  background: #087b88;
  box-shadow: 0 5px 12px #087b8830;
}
.button-primary:hover {
  background: #056d78;
}
.button-secondary {
  color: #16404a;
  background: #e3f1f3;
}
.button-link {
  padding: 4px 7px;
  color: #b12e28;
  background: #fff2f1;
  font-size: 0.8rem;
}
.button-link:disabled {
  color: #a5a8ac;
  cursor: not-allowed;
}
.icon-button {
  display: inline-grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 1px solid #bcd8de;
  border-radius: 50%;
  color: #0d6674;
  background: #eaf7f8;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px #0c596412;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}
.icon-button:hover {
  border-color: #087b88;
  color: #075c67;
  background: #d5f0f2;
  box-shadow: 0 2px 6px #087b8824;
}
.icon-button:focus-visible {
  outline: 0;
  border-color: #087b88;
  box-shadow: 0 0 0 3px #08a5b52b;
}
.icon-button-danger {
  border-color: #efc5c1;
  color: #b42318;
  background: #fff0ef;
  box-shadow: 0 1px 2px #b4231810;
}
.icon-button-danger:hover {
  border-color: #d92d20;
  color: #8f1c14;
  background: #ffe2df;
  box-shadow: 0 2px 6px #b4231820;
}
.icon-button:disabled {
  color: #a5b0b5;
  border-color: #e7edef;
  background: #f7f9fa;
  cursor: not-allowed;
}
.parse-status {
  min-height: 1.1em;
  margin: 12px 0 0;
  color: #62666b;
  font-size: 0.78rem;
}
.parse-status.error {
  color: #b42318;
}
.preview-panel {
  position: sticky;
  top: 20px;
  padding: 21px;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px #1022350b;
}
.preview-frame {
  padding: 14px;
  overflow: auto;
  border: 1px solid #d6e0e6;
  border-radius: 10px;
  background: #eef3f5;
}
#label-preview {
  display: block;
  width: 100%;
  min-width: 500px;
  height: auto;
  background: white;
  box-shadow: 0 5px 16px #10223524;
}
.calibration-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #dfe2e5;
  border-radius: 10px;
  background: #fff;
}
.calibration-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.calibration-heading p {
  margin: 4px 0 0;
  color: #62666b;
  font-size: 0.8rem;
}
.toggle-control {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 600;
}
.toggle-control input {
  width: auto;
  padding: 0;
}
.calibration-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 14px;
}
.calibration-field {
  padding: 10px;
  border: 1px solid #e2e4e6;
  border-radius: 7px;
  background: #fafafa;
}
.calibration-field h4 {
  margin: 0 0 8px;
  font-size: 0.82rem;
}
.calibration-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.calibration-inputs label {
  gap: 3px;
  margin: 0;
  color: #62666b;
  font-size: 0.7rem;
  font-weight: 600;
}
.calibration-inputs input {
  min-width: 0;
  padding: 6px;
  font-size: 0.78rem;
}
.hint {
  margin-top: 10px;
}
code {
  padding: 1px 4px;
  border-radius: 3px;
  background: #e7e9eb;
  color: #36393d;
}
/* ═══════════════════════════════════════════════════════════════ */
/* NEW: SPA APPLICATION STYLES */
/* ═══════════════════════════════════════════════════════════════ */

/* App container and navigation */
.app-container {
  display: flex;
  min-height: 100vh;
  background: #f3f6f8;
}

.app-nav {
  width: 240px;
  padding: 24px 16px;
  background: #fff;
  border-right: 1px solid #dbe3e9;
  box-shadow: 0 4px 12px #1022350c;
}

.nav-brand {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e7edef;
}

.nav-title {
  display: block;
  color: #057a89;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #354454;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.nav-link:hover {
  background: #e3f1f3;
  color: #057a89;
}

.nav-link.active {
  background: #087b88;
  color: #fff;
}

.app-content {
  flex: 1;
  max-width: 1480px;
  margin: 0 auto;
  width: 100%;
  padding: 40px 32px 56px;
}

/* Page layouts */
.page-dashboard,
.page-orders-list,
.page-create-order,
.page-order-details {
  min-height: 100%;
}

/* Dashboard styles */
.dashboard-grid {
  display: grid;
  gap: 28px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 20px;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 8px #1022350a;
  text-align: center;
}

.stat-value {
  display: block;
  margin-bottom: 8px;
  color: #087b88;
  font-size: 2.2rem;
  font-weight: 700;
}

.stat-label {
  display: block;
  color: #627080;
  font-size: 0.85rem;
  font-weight: 600;
}

.recent-orders-section {
  background: #fff;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  padding: 21px;
  box-shadow: 0 8px 24px #1022350b;
}

.recent-orders-container {
  display: grid;
  gap: 12px;
}

.recent-order-item {
  padding: 15px;
  border: 1px solid #edf0f2;
  border-radius: 10px;
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.order-info {
  flex: 1;
  min-width: 0;
}

.order-invoice {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.order-details {
  display: grid;
  gap: 4px;
}

.detail-row {
  display: flex;
  gap: 8px;
  font-size: 0.85rem;
}

.detail-label {
  color: #627080;
  font-weight: 600;
  min-width: 70px;
}

.detail-value {
  color: #19212b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-statuses {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.status-pending {
  background: #fff3e0;
  color: #e65100;
}

.status-processing {
  background: #e3f2fd;
  color: #1565c0;
}

.status-completed {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-cancelled {
  background: #ffebee;
  color: #c62828;
}

.status-paid {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-refunded {
  background: #f3e5f5;
  color: #6a1b9a;
}

.status-not-shipped {
  background: #fff3e0;
  color: #e65100;
}

.status-ready {
  background: #e1f5fe;
  color: #01579b;
}

.status-shipped {
  background: #e0f2f1;
  color: #00695c;
}

.status-delivered {
  background: #e8f5e9;
  color: #2e7d32;
}

/* Orders list styles */
.filters-section {
  background: #fff;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px #1022350a;
}

.search-box {
  margin-bottom: 12px;
}

.search-box input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #cbd6de;
  border-radius: 9px;
  font-size: 0.95rem;
}

.filter-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.filter-controls select,
.bulk-select {
  padding: 9px 11px;
  border: 1px solid #cbd6de;
  border-radius: 9px;
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
}

.filter-controls select:focus,
.bulk-select:focus {
  outline: 0;
  border-color: #0c8291;
  box-shadow: 0 0 0 3px #08a5b51f;
}

/* Bulk actions */
.bulk-actions-section {
  background: #e3f1f3;
  border: 1px solid #0c8291;
  border-radius: 9px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.bulk-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bulk-info label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
  color: #102235;
}

.bulk-info input {
  width: auto;
  padding: 0;
  margin: 0;
}

#selected-count {
  font-weight: 700;
  color: #057a89;
}

.bulk-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-buttons .button {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.button-danger {
  color: #b12e28;
  background: #fff2f1;
}

.button-danger:hover {
  background: #ffe2df;
}

.button.full-width {
  width: 100%;
}

/* Orders table */
.orders-table-section {
  background: #fff;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 24px #1022350b;
  overflow-x: auto;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
}

.order-row {
  display: grid;
  grid-template-columns: 40px 120px 200px 120px 100px 180px 80px;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #edf0f2;
  align-items: center;
  white-space: nowrap;
}

.order-row:last-child {
  border-bottom: none;
}

.order-row:hover {
  background: #fafbfc;
}

.row-checkbox {
  text-align: center;
}

.row-checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.row-invoice {
  font-weight: 700;
  font-size: 0.95rem;
}

.row-customer {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-customer small {
  display: block;
  color: #627080;
  font-size: 0.8rem;
  white-space: normal;
}

.row-city,
.row-date {
  color: #627080;
  font-size: 0.9rem;
}

.row-statuses {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-statuses .status-badge {
  padding: 4px 8px;
  font-size: 0.7rem;
}

.row-actions {
  text-align: right;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #627080;
}

.error-message {
  color: #ad2f27;
  text-align: center;
  padding: 20px;
}

/* Order details */
.order-details-container {
  background: #fff;
  border: 1px solid #dbe3e9;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 24px #1022350b;
}

.order-details-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0;
}

.order-main {
  padding: 24px;
  border-right: 1px solid #edf0f2;
}

.order-sidebar {
  padding: 24px;
  background: #fafbfc;
}

.order-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf0f2;
}

.order-header h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.order-meta {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  color: #627080;
}

.order-form {
  display: grid;
  gap: 24px;
}

.form-section {
  padding: 16px;
  border: 1px solid #edf0f2;
  border-radius: 10px;
  background: #fafbfc;
}

.form-section legend {
  margin-bottom: 12px;
  padding: 0 8px;
  color: #102235;
  font-weight: 700;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label:nth-child(n + 3) {
  grid-column: span 2;
}

.order-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd6de;
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}

.order-input:focus {
  outline: 0;
  border-color: #0c8291;
  box-shadow: 0 0 0 3px #08a5b51f;
}

.order-input:disabled {
  background: #f0f2f4;
  color: #a0a6aa;
  cursor: not-allowed;
}

select.order-input {
  cursor: pointer;
}

textarea.order-input {
  resize: vertical;
  min-height: 100px;
  line-height: 1.4;
}

.items-list {
  display: grid;
  gap: 8px;
}

.item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.item-input {
  width: 100%;
}

.original-message {
  padding: 12px;
  border-radius: 8px;
  background: #f5f5f5;
  font-size: 0.85rem;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: monospace;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #edf0f2;
}

.form-actions .button {
  flex: 1;
}

/* Order sidebar */
.preview-section,
.actions-section {
  margin-bottom: 20px;
}

.preview-section:last-child,
.actions-section:last-child {
  margin-bottom: 0;
}

.preview-section h3,
.actions-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #102235;
}

.preview-section .preview-frame {
  padding: 10px;
  border: 1px solid #dbe3e9;
  border-radius: 10px;
  background: #eef3f5;
}

.preview-section canvas {
  width: 100%;
  height: auto;
  display: block;
  background: white;
  box-shadow: 0 2px 8px #1022350c;
}

.actions-section .button {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px;
  font-size: 0.9rem;
}

.actions-section .button:last-child {
  margin-bottom: 0;
}

/* Create order */
.page-create-order .create-order-container {
  display: grid;
  grid-template-columns: minmax(380px, 0.8fr) minmax(540px, 1.2fr);
  gap: 28px;
  align-items: start;
}

.parse-status-section {
  min-height: 24px;
  margin-top: 8px;
}

.parse-status {
  margin: 0;
  font-size: 0.8rem;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 40px 20px;
  color: #627080;
}

.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Notifications */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  padding: 12px 20px;
  border-radius: 9px;
  font-weight: 600;
  animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* Responsive */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .preview-panel {
    position: static;
    order: initial;
  }
  .order-details-grid {
    grid-template-columns: 1fr;
  }
  .order-main {
    border-right: none;
    border-bottom: 1px solid #edf0f2;
  }
  .page-create-order .create-order-container {
    grid-template-columns: 1fr;
  }
  .order-row {
    grid-template-columns: 40px 1fr auto;
  }
  .row-customer,
  .row-city,
  .row-date,
  .row-statuses {
    display: none;
  }
  .stat-card {
    padding: 16px;
  }
  .stat-value {
    font-size: 1.8rem;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .app-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #dbe3e9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
  }
  .nav-brand {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
  }
  .nav-title {
    display: none;
  }
  .nav-links {
    flex-direction: row;
    gap: 4px;
  }
  .nav-link {
    padding: 8px 12px;
    font-size: 0.85rem;
  }
  .app-content {
    padding: 24px 16px 40px;
  }
  .filter-controls {
    grid-template-columns: 1fr;
  }
  .bulk-actions-section {
    flex-direction: column;
    align-items: flex-start;
  }
  .bulk-buttons {
    width: 100%;
    flex-direction: column;
  }
  .bulk-buttons .button,
  .bulk-buttons .bulk-select {
    width: 100%;
  }
  .order-row {
    grid-template-columns: 40px 1fr;
    gap: 8px;
  }
  .row-invoice {
    grid-column: 2;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .form-row label:nth-child(n + 3) {
    grid-column: 1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 24px 16px 40px;
  }
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .order-card,
  .preview-panel {
    padding: 16px;
  }
  .calibration-controls {
    grid-template-columns: 1fr;
  }
  #label-preview {
    min-width: 440px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-header {
    margin-bottom: 16px;
  }
  .page-header > div {
    width: 100%;
  }
  .page-header .button {
    width: 100%;
  }
}
