/* ============================================================
   CRG — Concord-Rovenka Gateway
   Design language: freight manifest / warehouse signage.
   Tracking numbers read like stenciled crate marks; statuses
   read like rubber ink stamps. Amber (#ffb100) is the working
   color of hazard tape and shipping labels — used deliberately,
   not decoratively.
   ============================================================ */

:root {
  --amber: #ffb100;
  --amber-dark: #cc8d00;
  --ink: #1a1d29;
  --ink-soft: #3d4152;
  --paper: #f7f6f2;
  --surface: #ffffff;
  --border: #e2ded4;
  --border-strong: #c9c3b3;
  --green: #2d6a4f;
  --green-bg: #e8f3ee;
  --red: #c1121f;
  --red-bg: #fbe9e9;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(26,29,41,0.06), 0 2px 8px rgba(26,29,41,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin: 0;
}

.brand-hero-title {
  text-transform: none;
  letter-spacing: 0;
}

.mono {
  font-family: var(--mono);
}

a { color: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--ink);
  color: #fff;
  padding: 0 20px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.brand .mark {
  width: 28px;
  height: 28px;
  background: var(--amber);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 2px;
}

.brand-module {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-module-full { display: none; }
.brand-module-short { display: inline; }

@media (min-width: 641px) {
  .brand-module-short { display: none; }
  .brand-module-full { display: inline; }
}

.user-chip {
  min-width: 0;
}
.user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.role-badge {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(255,177,0,0.15);
  color: var(--amber);
  border: 1px solid rgba(255,177,0,0.4);
}

.logout-link {
  color: #b8bccb;
  text-decoration: none;
  font-size: 13px;
}
.logout-link:hover { color: #fff; }

.back-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.back-btn:hover {
  background: rgba(255,177,0,0.15);
  border-color: var(--amber);
  color: var(--amber);
}

.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-head h1 {
  font-size: 30px;
}

.page-head .eyebrow {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--amber-dark);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  display: block;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: var(--body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--amber);
  color: var(--ink);
}
.btn-primary:hover { background: var(--amber-dark); }

/* Unsaved changes — draws attention to a Save button once a form's fields
   have actually been touched, so changes don't get accidentally lost. */
/* Collapsible variant rows — squeezed to just a summary line by default,
   click to expand and see/edit full details. */
/* Back link, styled as an actual bordered button — the plain text version
   wasn't recognizable as tappable on mobile. */
.back-link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  margin-bottom: 10px;
}
.back-link-button:hover { border-color: var(--amber); color: var(--amber); }
@media (max-width: 640px) {
  .back-link-button { padding: 9px 16px; font-size: 14px; }
}

.collapsible-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.collapsible-row-header .chevron {
  transition: transform 0.15s ease;
  font-size: 11px;
  color: #8a8f9e;
  flex: 0 0 auto;
  margin-left: 8px;
}
.collapsible-row-header.open .chevron { transform: rotate(90deg); }
.collapsible-row-body { display: none; margin-top: 14px; }
.collapsible-row-body.open { display: block; }

.btn-unsaved {
  animation: btn-unsaved-pulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(232,135,30,0.6);
}
@keyframes btn-unsaved-pulse {
  0% { box-shadow: 0 0 0 0 rgba(232,135,30,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(232,135,30,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,135,30,0); }
}

.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn-outline:hover { border-color: var(--ink); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card-pad { padding: 22px; }

/* ---------- Stamp-style status badges ---------- */
.stamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1.5px solid currentColor;
}

.stamp-processing { color: var(--amber-dark); background: rgba(255,177,0,0.1); }
.stamp-complete { color: var(--green); background: var(--green-bg); }
.stamp-dispatch { color: var(--ink-soft); background: #eceef2; border-color: var(--border-strong); }
.stamp-locked { color: var(--red); background: var(--red-bg); }

/* ---------- Crate-mark labels (waybill / CTN) ---------- */
.crate-label {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 4px;
  background: #fcfbf8;
  color: var(--ink-soft);
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.req::after {
  content: ' *';
  color: var(--red);
}

input[type=text], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--body);
  background: var(--surface);
  color: var(--ink);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255,177,0,0.2);
}

.field { margin-bottom: 18px; }

.scan-row {
  display: flex;
  gap: 8px;
}
.scan-row input { flex: 1; }

.scan-btn {
  flex-shrink: 0;
  background: var(--ink);
  color: var(--amber);
  border: none;
  border-radius: var(--radius);
  width: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

/* ---------- Lists / rows ---------- */
.row-list { display: flex; flex-direction: column; gap: 10px; }

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease;
}
.list-row:hover { border-color: var(--amber); }

.list-row .meta { display: flex; flex-direction: column; gap: 4px; }
.list-row .title { font-weight: 600; font-size: 15px; }
.list-row .sub { font-size: 12.5px; color: black; font-weight: 600px; font-family: var(--mono); }
.list-row .right { display: flex; align-items: center; gap: 12px; }

/* ---------- Dashboard stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-tile:hover {
  box-shadow: 0 4px 14px rgba(26,29,41,0.12);
  transform: translateY(-1px);
}
.stat-tile .num {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}
.stat-tile .lbl {
  font-size: 12px;
  color: #8a8f9e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
  text-decoration: none;
}

.dispute-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  background: #c1121f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  vertical-align: middle;
}

/* ---------- Login screen ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image:
    repeating-linear-gradient(135deg, rgba(255,177,0,0.05) 0 2px, transparent 2px 14px);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .mark {
  width: 52px;
  height: 52px;
  background: var(--amber);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 800;
  font-size: 22px;
  margin: 0 auto 14px;
}

.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  margin: 0 auto 14px;
}
.login-brand h1 { font-size: 22px; }
.login-brand .sub {
  font-family: var(--mono);
  font-size: 14px;
  color: black;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 4px;
}

.error-box {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(193,18,31,0.3);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.info-box {
  background: rgba(255,177,0,0.1);
  border: 1px solid rgba(255,177,0,0.35);
  color: var(--amber-dark);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,29,41,0.55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
}
.modal h3 { font-size: 20px; margin-bottom: 18px; }
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #8a8f9e;
}
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }

/* ---------- Search / filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 180px; }
.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
  font-size: 13px;
}
.filter-checkbox input[type="checkbox"] { width: auto; flex: 0 0 auto; }
@media (max-width: 640px) {
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { min-width: 0; width: 100%; }
  .filter-checkbox { width: auto; }
}

/* ---------- Photo thumbnails ---------- */
.thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: #eee;
}

.product-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: center;
}
.product-card .pname { font-weight: 600; font-size: 14.5px; }
.product-card .pdetail { font-size: 12.5px; color: #8a8f9e; margin-top: 3px; }

/* ---------- Weight banner (Ready for Dispatch calc) ---------- */
.calc-banner {
  background: var(--paper);
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
  text-align: center;
}
.calc-banner .val {
  font-family: var(--display);
  font-size: 30px;
  color: var(--amber-dark);
}
.calc-banner .lbl {
  font-size: 12px;
  color: #8a8f9e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .main { padding: 20px 14px 50px; }
  .page-head h1 { font-size: 24px; }
  .list-row { flex-direction: column; align-items: flex-start; }
  .list-row .right { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .back-btn { display: none; }

  .topbar { padding: 0 12px; }
  .role-badge { display: none; }
  .user-name { max-width: 90px; }
  .user-chip { gap: 8px; }

  .row-actions { flex-wrap: wrap; width: 100%; }
  .row-actions .btn { flex: 1 1 auto; }
}

/* ---------- Focus visibility ---------- */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* ---------- Module tiles (Hub, and any module's own sub-navigation) ---------- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}
.module-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
.module-tile:hover {
  border-color: var(--amber);
  box-shadow: 0 4px 14px rgba(26,29,41,0.12);
  transform: translateY(-2px);
}
.module-tile-disabled {
  opacity: 0.55;
  cursor: default;
}
.module-tile-disabled:hover {
  border-color: var(--border);
  box-shadow: none;
  transform: none;
}
.module-icon { font-size: 34px; margin-bottom: 10px; }
.module-label { font-family: var(--display); font-size: 22px; font-weight: 700; }
.module-sub { font-size: 12.5px; color: #8a8f9e; margin-top: 4px; }

/* ---------- Kanban board (used by SRS dashboard and CRG's SRS Tracker) ---------- */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}
.kanban-column {
  flex: 0 0 280px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 200px;
}
.kanban-column-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 10px 10px 0 0;
}
.kanban-column-title { font-family: var(--display); font-size: 14px; font-weight: 700; }
.kanban-column-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
}
.kanban-column-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow-y: auto; }
.kanban-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease;
}
.kanban-card:hover { border-color: var(--amber); }
.kanban-card-title { font-weight: 700; font-size: 13.5px; font-family: var(--display); }
.kanban-card-sub { font-size: 11.5px; color: #8a8f9e; margin-top: 3px; }
.kanban-card-dispute { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; color: #c1121f; }
.kanban-column-empty { padding: 20px 14px; text-align: center; font-size: 12.5px; color: #8a8f9e; }

.kanban-column[data-status="in_transit"] .kanban-column-head { background: #f3e9d8; }
.kanban-column[data-status="open_to_review"] .kanban-column-head,
.kanban-column[data-status="reviewing"] .kanban-column-head { background: #e4f0f9; }
.kanban-column[data-status="fully_received"] .kanban-column-head,
.kanban-column[data-status="verified"] .kanban-column-head { background: #e2f0e8; }
.kanban-column[data-status="partially_received"] .kanban-column-head { background: #fbe9e9; }
.kanban-column[data-status="disputed"] .kanban-column-head { background: #f8d7da; }

@media (max-width: 640px) {
  .kanban-column { flex: 0 0 240px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- WMS Dark Theme — scoped to .wms-dark, doesn't touch shared vars ---------- */
.wms-dark { background: #0f1115; min-height: 100vh; }
.wms-dark .page-head h1, .wms-dark h1, .wms-dark h2 { color: #f0f0f0; }
.wms-dark .eyebrow { color: #e8871e; }
.wms-dark .card, .wms-dark .list-row, .wms-dark .product-card, .wms-dark .stat-tile {
  background: #1a1d24;
  border-color: #2a2e38;
  color: #d0d3da;
}
.wms-dark .list-row:hover, .wms-dark .product-card:hover { border-color: #e8871e; }
.wms-dark .list-row .title, .wms-dark .product-card .pname, .wms-dark .meta .title { color: #f0f0f0; }
.wms-dark .list-row .sub, .wms-dark .product-card .pdetail, .wms-dark .meta .sub { color: #8a8f9e; }
.wms-dark input, .wms-dark select, .wms-dark textarea {
  background: #22262f;
  border-color: #3a3f4a;
  color: #f0f0f0;
}
.wms-dark input:focus, .wms-dark select:focus, .wms-dark textarea:focus {
  border-color: #e8871e;
  box-shadow: 0 0 0 3px rgba(232,135,30,0.2);
}
.wms-dark label { color: #b8bccb; }
.wms-dark .btn-outline { border-color: #3a3f4a; color: #d0d3da; background: transparent; }
.wms-dark .btn-outline:hover { border-color: #e8871e; color: #e8871e; }
.wms-dark .btn-primary { background: #e8871e; color: #14171f; }
.wms-dark .btn-primary:hover { background: #cf7615; }
.wms-dark .empty-state { color: #8a8f9e; }
.wms-dark .crate-label { background: #22262f; border-color: #3a3f4a; color: #b8bccb; }
.wms-dark .stamp-complete { background: rgba(45,106,79,0.25); }
.wms-dark .stamp-processing { background: rgba(232,135,30,0.15); color: #e8871e; }
.wms-dark .module-tile { background: #1a1d24; border-color: #2a2e38; color: #d0d3da; }
.wms-dark .module-tile:hover { border-color: #e8871e; }
.wms-dark .module-label { color: #f0f0f0; }
.wms-dark .module-sub { color: #8a8f9e; }

/* ---------- Rose bloom (box-added success) ---------- */
.rose-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 6px;
}

.rose-petal {
  transform-origin: 0px 2px;
  animation: petal-bloom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.rose-petal-1 { animation-delay: 0.05s; }
.rose-petal-2 { animation-delay: 0.12s; }
.rose-petal-3 { animation-delay: 0.19s; }
.rose-petal-4 { animation-delay: 0.26s; }

.rose-leaf {
  transform-origin: 0px 0px;
  animation: leaf-sway 0.5s ease-out both;
}
.rose-leaf-2 { animation-delay: 0.08s; }

@keyframes petal-bloom {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  70%  { transform: scale(1.1) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes leaf-sway {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
