/* ============================================================
   B109 CASE MOD AUDIT — Global Styles
   Maersk brand-compliant — see BRANDING.md. Never hardcode a hex
   value outside this :root block.

   Mobile-first: auditors work on handhelds in poor warehouse
   lighting, so type is large and contrast is high.
   ============================================================ */

:root {
  /* Maersk Brand */
  --maersk-blue:    #42B0D5;   /* PRIMARY — accent, buttons, highlights */
  --maersk-black:   #141414;   /* Body text */
  --maersk-white:   #FFFFFF;

  /* Blues */
  --dark-blue:      #003E62;   /* Topbar, deep contrast — never a flood fill */
  --mid-blue:       #1686BD;   /* Secondary accent, hover */
  --light-blue:     #A1D1E8;   /* Subtext on dark backgrounds */
  --bright-blue:    #E2F3FB;   /* Card backgrounds, info panels */

  /* Neutrals */
  --dark-grey:      #363636;
  --mid-grey:       #6A6A6A;
  --light-grey:     #D4D4D4;   /* Hairline borders only */
  --bright-grey:    #F0F0F0;   /* Page bg, table row highlight */

  /* Status — Red (errors, 1:1 violations) */
  --mid-red:        #EA5D4B;
  --light-red:      #FDA99E;
  --bright-red:     #FFE9E7;

  /* Status — Green (match, verified) */
  --mid-green:      #6CA926;
  --light-green:    #B9E371;
  --bright-green:   #E8F6D0;

  /* Status — Orange (warnings, count discrepancies) */
  --mid-orange:     #F3870C;
  --light-orange:   #FED195;
  --bright-orange:  #FFF5DD;

  /* Status — Purple (wrong SKU) */
  --mid-purple:     #7B2D8B;
  --bright-purple:  #F3E6F5;

  /* Derived hover shades — darkened/lightened from the palette above.
     Not brand colours in their own right; they exist so no rule below
     needs a hardcoded hex. */
  --dark-blue-hover:   #1A4F78;
  --mid-red-hover:     #D44A39;
  --mid-green-hover:   #5C9020;
  --mid-orange-hover:  #D4760A;

  /* Misc */
  --radius:         6px;
  --radius-lg:      8px;
  --shadow:         0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

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

html { font-size: 16px; }

body {
  font-family: 'Maersk Text', Arial, sans-serif;
  background: var(--bright-grey);
  color: var(--maersk-black);
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--dark-blue);
  border-bottom: 3px solid var(--maersk-blue);
  padding: 0 1.25rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar__logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--maersk-white);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.topbar__user {
  font-size: .85rem;
  color: var(--light-blue);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.main-content {
  flex: 1;
  padding: 1.5rem 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--dark-blue);
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark-grey);
  margin-bottom: .75rem;
}

/* Offline banner — full-width block between header and main. Must NOT go
   inside the topbar; that breaks the topbar layout on mobile. */
.offline-indicator {
  background: var(--mid-orange);
  color: var(--maersk-white);
  text-align: center;
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 600;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--maersk-white);
  border: 1px solid var(--light-grey);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 1rem; }

.card--info {
  background: var(--bright-blue);
  border-left: 4px solid var(--maersk-blue);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark-blue);
}

.report-chevron {
  font-size: .8rem;
  color: var(--mid-grey);
  transition: transform .2s ease;
  display: inline-block;
  margin-left: .5rem;
  user-select: none;
}

/* ============================================================
   TABS
   ============================================================ */

.tab-nav {
  display: flex;
  gap: .25rem;
  border-bottom: 1px solid var(--light-grey);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.tab-btn {
  padding: .6rem 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  color: var(--mid-grey);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--dark-blue); }
.tab-btn.active { color: var(--maersk-blue); border-bottom-color: var(--maersk-blue); }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--maersk-blue); color: var(--maersk-white); border-color: var(--maersk-blue); }
.btn--primary:hover:not(:disabled) { background: var(--mid-blue); border-color: var(--mid-blue); }

.btn--secondary { background: var(--maersk-white); color: var(--dark-grey); border-color: var(--light-grey); }
.btn--secondary:hover:not(:disabled) { background: var(--bright-grey); }

.btn--danger { background: var(--mid-red); color: var(--maersk-white); border-color: var(--mid-red); }
.btn--danger:hover:not(:disabled) { background: var(--mid-red-hover); }

.btn--warning { background: var(--mid-orange); color: var(--maersk-white); border-color: var(--mid-orange); }
.btn--warning:hover:not(:disabled) { background: var(--mid-orange-hover); }

.btn--success { background: var(--mid-green); color: var(--maersk-white); border-color: var(--mid-green); }
.btn--success:hover:not(:disabled) { background: var(--mid-green-hover); }

.btn--lg {
  padding: .875rem 1.5rem;
  font-size: 1.125rem;
  border-radius: var(--radius-lg);
  width: 100%;
  justify-content: center;
}

.btn--sm { padding: .3rem .75rem; font-size: .8rem; }

.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--dark-grey);
  margin-bottom: .35rem;
}

input[type=text],
input[type=number],
input[type=email],
input[type=password],
input[type=date],
select,
textarea {
  width: 100%;
  padding: .6rem .875rem;
  border: 1px solid var(--light-grey);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  color: var(--maersk-black);
  background: var(--maersk-white);
  transition: border-color .15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--maersk-blue);
  box-shadow: 0 0 0 3px rgba(66, 176, 213, .15);
}

.form-hint { font-size: .8rem; color: var(--mid-grey); margin-top: .25rem; }

/* Scan input — wand output lands here, so it must be unmissable */
.scan-input {
  font-size: 1.375rem !important;
  font-weight: 700;
  text-align: center;
  letter-spacing: .05em;
  padding: .875rem !important;
  text-transform: uppercase;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th {
  text-align: left;
  padding: .6rem .875rem;
  background: var(--dark-blue);
  color: var(--maersk-white);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--light-grey);
}

td {
  padding: .75rem .875rem;
  border-bottom: 1px solid var(--light-grey);
  color: var(--dark-grey);
}

tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--bright-grey); }
tr:hover td { background: var(--bright-blue); }

/* Denser rows for data-heavy tables. Prefer this over per-table ID rules
   so a new table gets compact treatment by adding one class. */
.table--compact th,
.table--compact td { padding: .45rem .6rem; font-size: .8rem; }
.table--compact td:last-child { white-space: nowrap; width: 1%; }
.table--compact .btn-group { flex-wrap: nowrap; gap: .35rem; }
.table--compact .btn--sm { padding: .25rem .55rem; font-size: .75rem; }
.table--compact .num { text-align: right; }

/* Filter strip above sortable tables */
.audits-filter-bar {
  display: flex;
  gap: .5rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--light-grey);
  background: var(--bright-grey);
  flex-wrap: wrap;
  align-items: center;
}
.audits-filter-bar input,
.audits-filter-bar select {
  padding: .375rem .6rem;
  border: 1px solid var(--light-grey);
  border-radius: 4px;
  font-size: .875rem;
  background: var(--maersk-white);
  min-width: 0;
  width: auto;
}
.audits-filter-bar input:focus,
.audits-filter-bar select:focus {
  outline: 2px solid var(--maersk-blue);
  outline-offset: -1px;
  box-shadow: none;
}

.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { background: var(--dark-blue-hover); }

.sort-icon { font-size: .7rem; opacity: .3; margin-left: .3rem; display: inline-block; }

/* ============================================================
   BADGES / STATUS PILLS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
}

/* Audit + session lifecycle */
.badge--draft        { background: var(--bright-grey);   color: var(--mid-grey); }
.badge--active       { background: var(--bright-blue);   color: var(--mid-blue); }
.badge--completed    { background: var(--bright-green);  color: var(--mid-green); }
.badge--archived     { background: var(--bright-grey);   color: var(--light-grey); }
.badge--not-started  { background: var(--light-grey);    color: var(--dark-grey); }
.badge--warning      { background: var(--bright-orange); color: var(--mid-orange); }
.badge--danger       { background: var(--bright-red);    color: var(--mid-red); }

/* Case Mod audit results.
   Colour carries meaning consistently:
     green  = verified correct
     orange = count or placement warning
     purple = wrong SKU
     red    = hard error / 1:1 rule violation
     grey   = cannot be judged (source data untrustworthy) */
.badge--match                 { background: var(--bright-green);  color: var(--mid-green); }
.badge--empty_confirmed       { background: var(--bright-green);  color: var(--mid-green); }
.badge--qty_mismatch          { background: var(--bright-orange); color: var(--mid-orange); }
.badge--unexpected_product    { background: var(--bright-orange); color: var(--mid-orange); }
.badge--sku_mismatch          { background: var(--bright-purple); color: var(--mid-purple); }
.badge--mixed_sku             { background: var(--bright-red);    color: var(--mid-red); }
.badge--location_ucc_conflict { background: var(--bright-red);    color: var(--mid-red); }
.badge--missing_product       { background: var(--bright-red);    color: var(--mid-red); }
.badge--data_anomaly          { background: var(--bright-grey);   color: var(--mid-grey); }

/* Clickable badge — aisle assignment grid */
.badge--selectable {
  background: var(--bright-grey);
  color: var(--mid-grey);
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.badge--selectable:hover { background: var(--bright-blue); color: var(--mid-blue); }
.badge--selectable.selected { background: var(--maersk-blue); color: var(--maersk-white); }

/* Inline status dropdown, styled as a pill.
   The chevron is a background-image on the <select> itself — never a
   ::after on the wrapper, because browsers paint <select> above
   pseudo-elements. */
.status-select-wrap {
  display: inline-block;
  border-radius: 99px;
  border: 1px solid transparent;
}
.status-select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 99px;
  padding: .2rem 1.5rem .2rem .6rem;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  width: auto;
  font-family: inherit;
  color: inherit;
  background-repeat: no-repeat;
  background-position: right .45rem center;
  background-size: 8px 5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23666'/%3E%3C/svg%3E");
}
.status-select-wrap.status-select--draft     { background: var(--bright-grey);  color: var(--mid-grey);   border-color: var(--light-grey); }
.status-select-wrap.status-select--active    { background: var(--bright-blue);  color: var(--mid-blue);   border-color: var(--light-blue); }
.status-select-wrap.status-select--completed { background: var(--bright-green); color: var(--mid-green);  border-color: var(--light-green); }
.status-select-wrap.status-select--archived  { background: var(--bright-grey);  color: var(--light-grey); border-color: var(--light-grey); }

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.stat-grid--3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid--4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid--5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--maersk-white);
  border: 1px solid var(--light-grey);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stat-card__label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--mid-grey);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .35rem;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark-blue);
  line-height: 1;
}

.stat-card__sub { font-size: .8rem; color: var(--mid-grey); margin-top: .25rem; }

/* ============================================================
   AUDITOR SCAN UI — large format, handheld optimised
   ============================================================ */

/* The location under audit. Must be readable at arm's length under bad
   warehouse lighting. */
.scan-prompt {
  background: var(--dark-blue);
  border-left: 6px solid var(--maersk-blue);
  color: var(--maersk-white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.scan-prompt__label { font-size: .9rem; opacity: .85; margin-bottom: .25rem; }

.scan-prompt__location {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.1;
}

.scan-prompt__expected {
  font-size: .85rem;
  color: var(--light-blue);
  margin-top: .5rem;
}

/* Open transaction indicator — the location is locked to this auditor */
.lock-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: var(--bright-blue);
  border: 1px solid var(--maersk-blue);
  border-left: 4px solid var(--maersk-blue);
  border-radius: var(--radius);
  padding: .6rem .875rem;
  font-size: .85rem;
  color: var(--dark-blue);
  margin-bottom: 1rem;
}

/* Someone else holds the lock — blocks the scan flow */
.lock-banner--held {
  background: var(--bright-red);
  border-color: var(--mid-red);
  border-left-color: var(--mid-red);
  color: var(--mid-red);
  font-weight: 600;
}

/* Wanded UPC lines within one case */
.scan-list { list-style: none; margin-bottom: 1rem; }

.scan-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .875rem;
  background: var(--maersk-white);
  border: 1px solid var(--light-grey);
  border-radius: var(--radius);
  margin-bottom: .4rem;
  font-size: .95rem;
}

/* A second distinct UPC in one case is always an error — mark it on sight */
.scan-list__item--mixed {
  border-color: var(--mid-red);
  background: var(--bright-red);
}

.scan-list__upc { font-weight: 700; letter-spacing: .02em; }
.scan-list__qty { font-weight: 700; color: var(--dark-blue); }

/* Result legend under the scan list */
.result-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  font-size: .78rem;
  color: var(--mid-grey);
  margin-bottom: .75rem;
}

.progress-bar-wrap {
  background: var(--light-grey);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-bottom: .35rem;
}

.progress-bar {
  height: 100%;
  background: var(--maersk-blue);
  border-radius: 99px;
  transition: width .3s;
}

/* ============================================================
   COMPLETE SCREENS
   ============================================================ */

.complete-screen { text-align: center; padding: 3rem 1.5rem; }
.complete-screen__icon { font-size: 4rem; margin-bottom: 1rem; }
.complete-screen__title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .5rem;
  color: var(--mid-green);
}
.complete-screen__sub { color: var(--mid-grey); margin-bottom: 1.5rem; }

/* ============================================================
   TOASTS
   ============================================================ */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark-blue);
  color: var(--maersk-white);
  padding: .75rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: .9rem;
  z-index: 1000;
  animation: slideUp .2s ease;
  max-width: 90vw;
  text-align: center;
}

.toast--success { background: var(--mid-green); }
.toast--error   { background: var(--mid-red); }
.toast--warning { background: var(--mid-orange); }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.modal {
  background: var(--maersk-white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.modal--wide { max-width: 680px; }

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark-blue);
  margin-bottom: .75rem;
}

.modal__body { color: var(--dark-grey); margin-bottom: 1.25rem; font-size: .95rem; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bright-grey);
}

.login-card {
  background: var(--maersk-white);
  border: 1px solid var(--light-grey);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--dark-blue);
  margin-bottom: 1.5rem;
}

/* ============================================================
   HELP MENU (topbar disclosure)
   ============================================================ */

.help-menu { position: relative; }

.help-menu__trigger {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.4);
  color: var(--maersk-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
  outline: none;
}

.help-menu__trigger:hover,
.help-menu__trigger:focus-visible {
  background: rgba(255,255,255,.12);
  border-color: var(--maersk-white);
}
.help-menu__trigger:focus-visible { outline: 2px solid var(--maersk-blue); outline-offset: 2px; }

.help-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--maersk-white);
  border: 1px solid var(--light-grey);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 200;
  padding: .4rem 0;
}

.help-menu__link {
  display: block;
  padding: .55rem 1rem;
  color: var(--dark-grey);
  text-decoration: none;
  font-size: .875rem;
  transition: background .12s, color .12s;
}

.help-menu__link:hover,
.help-menu__link:focus-visible {
  background: var(--bright-grey);
  color: var(--maersk-blue);
  outline: none;
}

.help-menu__caption {
  padding: .4rem 1rem .3rem;
  font-size: .75rem;
  color: var(--mid-grey);
  border-top: 1px solid var(--light-grey);
  margin-top: .25rem;
}

/* ============================================================
   UTILITY
   ============================================================ */

.text-muted   { color: var(--mid-grey); }
.text-sm      { font-size: .875rem; }
.text-xs      { font-size: .8rem; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-danger  { color: var(--mid-red); }
.text-success { color: var(--mid-green); }
.text-warning { color: var(--mid-orange); }
.mono         { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 480px) {
  .btn--lg { font-size: 1rem; padding: .875rem 1rem; }
  .stat-card__value { font-size: 1.5rem; }
  .scan-prompt__location { font-size: 2rem; }
  .stat-grid--3,
  .stat-grid--4,
  .stat-grid--5 { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 1rem .875rem; }
}
