*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

/* Header */
.site-header {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-title { font-size: 1.1rem; font-weight: 600; }
.site-nav { display: flex; gap: 4px; }
.nav-link { color: #aaa; font-size: 0.9rem; text-decoration: none; padding: 4px 14px; border-radius: 6px; transition: background 0.15s; }
.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link-active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }
.logout-link { color: #aaa; font-size: 0.85rem; text-decoration: none; }
.logout-link:hover { color: #fff; }

.site-main { padding: 16px; }

/* Page container */
.page-container {
  max-width: 1300px;
  margin: 0 auto;
}
.page-title {
  font-size: 1.4rem;
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.15s;
  line-height: 1.4;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: #1a56db; color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-secondary { background: #555; color: #fff; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-xs { padding: 4px 10px; font-size: 0.78rem; border-radius: 4px; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}
.alert-warn  { background: #fefce8; border: 1px solid #fde047; color: #854d0e; }
.alert-info  { background: #f0f4ff; border: 1px solid #c6d4f5; color: #1e3a8a; }
.alert-error { background: #fff0f0; border: 1px solid #f5c6c6; color: #991b1b; }

/* Steps grid (home page) */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.step-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  display: flex;
  gap: 14px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.step-card-review { border-color: #bbf7d0; background: #f0fdf4; }

.step-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1a56db;
  min-width: 36px;
  line-height: 1;
}
.step-card-review .step-num { color: #16a34a; }

.step-body { flex: 1; }
.step-body h3 { font-size: 0.95rem; margin-bottom: 6px; }
.step-desc { font-size: 0.82rem; color: #666; margin-bottom: 10px; }

.step-params { margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.step-params label { font-size: 0.82rem; color: #555; display: flex; align-items: center; gap: 6px; }
.step-params input[type="date"],
.step-params input[type="text"] {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Log box (progress page) */
.log-box {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 14px;
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
}
.log-box pre {
  color: #d4d4d4;
  font-family: 'Cascadia Code', 'Fira Mono', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Review toolbar */
.review-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.dry-run-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: #555;
  cursor: pointer;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 16px;
  background: #e5e7eb;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.88rem;
  color: #444;
  transition: background 0.15s;
}
.tab:hover { background: #d1d5db; }
.tab-active { background: #1a56db; color: #fff; }
.tab-count {
  display: inline-block;
  background: rgba(255,255,255,.3);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 0.75rem;
  margin-left: 4px;
}
.tab:not(.tab-active) .tab-count { background: rgba(0,0,0,.1); }

/* Warehouse panels */
.warehouse-hidden { display: none; }

/* Orders table */
.orders-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  font-size: 0.875rem;
}
.orders-table th {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: #555;
  white-space: nowrap;
}
.orders-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}
.order-row:last-child td { border-bottom: none; }

.cell-posting { min-width: 160px; }
.posting-id { font-family: monospace; font-size: 0.8rem; color: #444; word-break: break-all; }
.posting-link { color: #1a56db; text-decoration: none; }
.posting-link:hover { text-decoration: underline; }
.cell-offer { min-width: 120px; color: #555; }
.cell-chat { max-width: 280px; }
.cell-engrave { min-width: 160px; }
.cell-label { min-width: 100px; }

.chat-pre {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #333;
  max-height: 120px;
  overflow-y: auto;
  background: #f9fafb;
  padding: 6px 8px;
  border-radius: 4px;
}

.no-data { color: #bbb; font-size: 0.82rem; }
.empty-msg { color: #888; padding: 20px 0; text-align: center; }

/* Engraving images */
.engrave-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 10px;
}
.engrave-img {
  width: 100px;
  height: auto;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: zoom-in;
  transition: transform 0.2s;
}
.engrave-img.img-zoom {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1000;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  cursor: zoom-out;
}
.engrave-name {
  font-size: 0.72rem;
  color: #888;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.replace-btn { margin-top: 2px; }

.replace-status { font-size: 0.78rem; min-height: 1em; }
.replace-status.ok  { color: #16a34a; }
.replace-status.err { color: #dc2626; }

/* Label image */
.label-img {
  width: 80px;
  height: auto;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  cursor: zoom-in;
}
.label-img.img-zoom {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 1000;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  cursor: zoom-out;
}

/* Warehouse table blocks (index page) */
.wh-table-block {
  margin-bottom: 24px;
}
.wh-table-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.wh-table-title {
  font-size: 1rem;
  font-weight: 600;
}
.wh-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Engrave generation panel */
.order-row-active { background: #eff6ff; }
.order-data-row:hover { background: #f9fafb; }
.order-data-row:hover td { background: transparent; }

.engrave-panel-row td { padding: 0 !important; border-bottom: 2px solid #bfdbfe; }
.engrave-panel-cell { padding: 0 !important; }
.engrave-panel {
  background: #eff6ff;
  border-left: 3px solid #1a56db;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.engrave-panel-title { font-size: 0.88rem; color: #1e3a8a; font-weight: 600; }
.engrave-panel-variants { display: flex; flex-direction: column; gap: 8px; }
.engrave-variant { display: flex; flex-direction: column; gap: 4px; }
.engrave-text-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  resize: vertical;
  background: #fff;
}
.engrave-text-input:focus { outline: none; border-color: #1a56db; box-shadow: 0 0 0 2px rgba(26,86,219,.15); }
.engrave-panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.engrave-panel-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #1e3a8a;
  padding: 4px 0;
}
.engrave-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #bfdbfe;
  border-top-color: #1a56db;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.engrave-panel-status { font-size: 0.82rem; min-height: 1em; }
.engrave-panel-status.ok  { color: #16a34a; }
.engrave-panel-status.err { color: #dc2626; }
.design-hints { font-size: 0.8rem; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.design-hints-label { color: #374151; font-weight: 600; margin-bottom: 2px; }
.design-hints-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.design-hints-group-name { color: #6b7280; white-space: nowrap; }
.design-chip {
  display: inline-block; padding: 1px 7px; font-size: 0.78rem;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 4px;
  color: #1d4ed8; cursor: pointer; line-height: 1.5;
}
.design-chip:hover { background: #dbeafe; border-color: #93c5fd; }
.engrave-chat-hint {
  font-size: 0.8rem;
  color: #1e3a8a;
  background: #dbeafe;
  border-radius: 4px;
  padding: 6px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 100px;
  overflow-y: auto;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 400px;
  width: 90%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box p { font-size: 1rem; }
