:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fb;
  --text: #17202a;
  --muted: #68727d;
  --line: #dde2e7;
  --primary: #146ef5;
  --primary-dark: #0a56ca;
  --success: #14804a;
  --danger: #c9362b;
  --warning: #a65f00;
  --shadow: 0 14px 42px rgba(23, 32, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 10px max(20px, calc((100vw - 1180px) / 2));
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: white;
  background: var(--primary);
  border-radius: 11px;
  font-size: 19px;
}

.main-nav { display: flex; align-items: center; gap: 6px; }

.main-nav a, .ghost-button {
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

.main-nav a:hover, .main-nav a.active, .ghost-button:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 64px;
}

.narrow { width: min(760px, calc(100% - 32px)); }

.page-title { margin-bottom: 28px; }
.page-title h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.04em; }
.page-title p { margin: 0; color: var(--muted); font-size: 17px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-card { padding: clamp(20px, 4vw, 34px); }

.field { margin-bottom: 22px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label, .field-label { display: block; margin-bottom: 8px; font-weight: 750; }
.field-hint { margin-top: 7px; color: var(--muted); font-size: 13px; }

input[type="text"], input[type="password"] {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  color: var(--text);
  background: white;
  border: 1px solid #cbd2d9;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(20, 110, 245, .12); }

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 285px;
  padding: 24px;
  overflow: hidden;
  text-align: center;
  background: var(--surface-soft);
  border: 2px dashed #bdc7d1;
  border-radius: 16px;
  transition: border-color .15s, background .15s;
}

.drop-zone.dragging { border-color: var(--primary); background: #eff6ff; }
.drop-zone.has-image { padding: 10px; border-style: solid; }
.drop-zone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-icon { margin-bottom: 12px; font-size: 38px; }
.drop-title { margin: 0 0 7px; font-size: 18px; font-weight: 800; }
.drop-copy { margin: 0; color: var(--muted); }
.drop-zone img { display: none; max-width: 100%; max-height: 440px; object-fit: contain; border-radius: 10px; }
.drop-zone.has-image .drop-placeholder { display: none; }
.drop-zone.has-image img { display: block; }

.sku-combobox { position: relative; }
.suggestions {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 300px;
  padding: 6px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 38px rgba(20, 32, 48, .16);
}

.suggestions[hidden] { display: none; }
.suggestion { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.suggestion:hover { background: var(--surface-soft); }
.suggestion img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: #eef0f2; }
.suggestion strong { display: block; }
.suggestion span { color: var(--muted); font-size: 13px; }

.selected-sku {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  background: #f1f7ff;
  border: 1px solid #c9ddff;
  border-radius: 12px;
}
.selected-sku[hidden] { display: none; }
.selected-sku img { width: 68px; height: 68px; border-radius: 10px; object-fit: cover; }
.selected-sku strong, .selected-sku span { display: block; }
.selected-sku span { margin-top: 3px; color: var(--muted); }

.recent-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--text); font-size: 13px; font-weight: 700; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

.checkbox { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.primary-button, .secondary-button, .danger-button {
  min-height: 48px;
  padding: 11px 18px;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  transition: transform .1s, background .15s, opacity .15s;
}
.primary-button { color: white; background: var(--primary); }
.primary-button:hover { background: var(--primary-dark); }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { color: var(--primary); background: #edf4ff; }
.danger-button { color: var(--danger); background: #fff0ef; }
.full-button { width: 100%; }

.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 26px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(430px, calc(100vw - 40px));
  padding: 14px 18px;
  color: white;
  background: #202b36;
  border-radius: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .24);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-card { width: min(430px, 100%); padding: 34px; }
.login-card h1 { margin: 18px 0 8px; font-size: 30px; }
.login-card p { margin: 0 0 26px; color: var(--muted); }
.login-error { min-height: 22px; margin: 10px 0; color: var(--danger); font-size: 14px; }

.catalog-layout { display: grid; grid-template-columns: 390px 1fr; gap: 22px; align-items: start; }
.sticky-card { position: sticky; top: 90px; }
.section-card { padding: 24px; }
.section-card h2 { margin: 0 0 20px; }
.reference-preview { display: none; width: 100%; max-height: 260px; margin-top: 10px; object-fit: contain; border-radius: 12px; background: var(--surface-soft); }
.reference-preview.visible { display: block; }

.sku-list { display: grid; gap: 12px; }
.sku-row { display: grid; grid-template-columns: 82px 1fr; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.sku-row img { width: 82px; height: 82px; border-radius: 10px; object-fit: cover; background: var(--surface-soft); }
.sku-code { display: inline-flex; margin-bottom: 6px; padding: 4px 8px; border-radius: 7px; color: var(--primary-dark); background: #edf4ff; font-weight: 850; }
.sku-row h3 { margin: 0 0 5px; font-size: 16px; }
.sku-row p { margin: 0; color: var(--muted); font-size: 14px; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; }

.board-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.summary-pill { padding: 10px 14px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.summary-pill strong { margin-right: 6px; }
.board-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.batch-card { overflow: hidden; }
.batch-main { display: grid; grid-template-columns: 132px 1fr; gap: 18px; padding: 18px; }
.batch-reference { width: 132px; height: 132px; border-radius: 13px; object-fit: cover; background: var(--surface-soft); }
.batch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.batch-head h2 { margin: 5px 0; font-size: 19px; }
.count-badge { display: grid; flex: 0 0 auto; place-items: center; min-width: 46px; height: 46px; padding: 0 10px; border-radius: 14px; color: white; background: var(--primary); font-size: 20px; font-weight: 900; }
.status-label { color: var(--muted); font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.batch-details { padding: 0 18px 18px; }
.batch-details[hidden] { display: none; }
.shipment-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.shipment-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.shipment-card img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; }
.shipment-card span { display: block; padding: 7px; color: var(--muted); background: white; font-size: 12px; }

@media (max-width: 820px) {
  .app-header { align-items: flex-start; padding: 10px 16px; }
  .brand span:last-child { display: none; }
  .main-nav { overflow-x: auto; }
  .main-nav a, .ghost-button { white-space: nowrap; padding: 9px; font-size: 14px; }
  .page { width: min(100% - 24px, 760px); padding-top: 26px; }
  .catalog-layout, .board-grid { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}

@media (max-width: 520px) {
  .app-header { gap: 8px; }
  .main-nav { gap: 0; }
  .main-nav a { font-size: 0; }
  .main-nav a::first-letter { font-size: 18px; }
  .page-title { margin-bottom: 20px; }
  .form-card { padding: 16px; }
  .drop-zone { min-height: 230px; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .form-footer .primary-button { order: -1; width: 100%; }
  .batch-main { grid-template-columns: 92px 1fr; gap: 12px; padding: 12px; }
  .batch-reference { width: 92px; height: 92px; }
  .shipment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

