@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@500;600;700;800&display=swap');

:root {
  --color-bg: #F6F7F9;
  --color-surface: #fff;
  --color-border: #E7E9EF;
  --color-border-strong: #DBDFE7;
  --color-text: #1A1D23;
  --color-text-2: #4A5266;
  --color-text-3: #7A8296;
  --color-text-4: #9AA1B2;
  --color-text-5: #B7BCC9;
  --color-primary: #2F5FDB;
  --color-primary-hover: #2854C4;
  --color-primary-soft: #EAF0FE;
  --color-success: #1E8E5A;
  --color-success-soft: #E7F7EE;
  --color-danger: #C0392B;
  --color-danger-soft: #FBEAEA;
  --color-warning: #B7791F;
  --color-warning-soft: #FFF4E0;
  --shadow-sm: 0 1px 2px rgba(20,30,60,.04), 0 1px 1px rgba(20,30,60,.03);
  --shadow-md: 0 2px 10px rgba(20,30,60,.06), 0 1px 2px rgba(20,30,60,.04);
  --shadow-lg: 0 10px 28px rgba(20,30,60,.09), 0 2px 6px rgba(20,30,60,.05);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.45;
}
::selection { background: rgba(47,95,219,.18); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); }
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }
button { cursor: pointer; transition: box-shadow .15s ease, background-color .15s ease, border-color .15s ease, transform .08s ease, opacity .15s ease; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(47,95,219,.25); }
input, select, textarea { transition: border-color .15s ease, box-shadow .15s ease; }
/* All typed text is shown in capitals (everything except passwords); the real
   value is uppercased by assets/js/uppercase-inputs.js. Opt out: data-no-upper. */
input:not([type]), input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="url"], textarea { text-transform: uppercase; }
input[data-no-upper], textarea[data-no-upper] { text-transform: none; }
input::placeholder, textarea::placeholder { text-transform: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(47,95,219,.12); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 32px 28px 60px; }
.narrow { max-width: 680px; margin: 0 auto; padding: 32px 28px 60px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255,255,255,.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand-name { font-size: 14px; font-weight: 800; letter-spacing: -.01em; }
.role-badge { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--color-primary); background: var(--color-primary-soft); padding: 3px 8px; border-radius: 5px; text-transform: uppercase; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--color-text-2); }

.card {
  background: var(--color-surface);
  border: 1.5px solid #C7CCDA;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(20,30,60,.10), 0 1px 3px rgba(20,30,60,.08);
  padding: 24px 26px;
}
.eyebrow { font-size: 11px; font-weight: 700; color: var(--color-text-3); text-transform: uppercase; letter-spacing: .07em; }
h1 { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -.015em; }
.sub { margin: 4px 0 0; font-size: 13.5px; color: var(--color-text-3); }

.btn { display: inline-flex; align-items: center; gap: 7px; border: none; border-radius: 9px; padding: 11px 18px; font-size: 14px; font-weight: 700; letter-spacing: -.005em; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 1px 3px rgba(47,95,219,.22); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); box-shadow: 0 4px 12px rgba(47,95,219,.3); }
.btn-dark { background: var(--color-text); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #000; }
.btn-outline { background: #fff; color: var(--color-text-2); border: 1px solid var(--color-border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--color-bg); border-color: var(--color-text-5); }
.btn-link { background: none; border: none; color: var(--color-primary); font-weight: 700; padding: 0; }

/* min-width:0 overrides the flex default (min-width:auto), which lets .field
   items in a `flex:1` row (e.g. two fields side by side) shrink below their
   input's intrinsic content width instead of overflowing past the card's edge
   -- flagged 2026-09-28 on the staff-join form ("the field off the box"), same
   root cause already fixed one-off for the address-autocomplete widget. */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 11px; font-weight: 700; color: var(--color-text-3); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea { border: 1px solid var(--color-border-strong); border-radius: 8px; padding: 10px 12px; }
.field select { -webkit-appearance: none; appearance: none; font: inherit; color: inherit; cursor: pointer; padding-right: 34px; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%237A8296' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 12px center; }
.field textarea { resize: vertical; min-height: 60px; }

/* Hide native number-input spinner arrows app-wide so number fields (parcel
   weight/pcs/fees, rate amounts, etc.) match the flat look of every other
   input instead of showing the browser's default up/down buttons (2026-09-09,
   per the user flagging the order-edit page "looking off"). Arrow-key
   increment/decrement and the mobile numeric keypad still work — only the
   visible spin buttons are removed. */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.pill { font-size: 12px; font-weight: 700; padding: 5px 11px 5px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; flex: 0 0 auto; }
.badge-high { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--color-warning); background: var(--color-warning-soft); padding: 4px 9px; border-radius: 20px; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--color-text-3); font-size: 12.5px; font-weight: 700; margin-bottom: 16px; transition: color .12s ease; }
.back-link:hover { color: var(--color-text-2); }

.error-box { background: var(--color-danger-soft); border: 1px solid #F3C9C9; color: #7A2020; border-radius: 10px; padding: 12px 14px; font-size: 13px; font-weight: 600; }
.hint-box { background: var(--color-warning-soft); border-radius: 9px; padding: 11px 14px; font-size: 12.5px; color: #8A5A15; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--color-surface);
  border: 1.5px solid #C7CCDA;
  border-radius: 12px;
  padding: 16px 18px 16px 20px;
  box-shadow: 0 3px 10px rgba(20,30,60,.08), 0 1px 2px rgba(20,30,60,.06);
  transition: box-shadow .18s ease, transform .18s ease;
}
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--color-primary); opacity: .85; }
.stat-card:hover { box-shadow: 0 6px 20px rgba(20,30,60,.12), 0 2px 4px rgba(20,30,60,.08); transform: translateY(-1px); }
.stat-card:nth-child(4)::before, .stat-card:nth-child(5)::before { background: var(--color-success); }
.stat-value { font-size: 22px; font-weight: 800; display: block; margin-top: 8px; letter-spacing: -.01em; }
.stat-label { font-size: 11.5px; color: var(--color-text-3); font-weight: 600; }

.type-cards { display: flex; gap: 16px; }
.type-card { flex: 1; background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: 14px; padding: 24px 22px; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.type-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.type-card button { all: unset; display: block; width: 100%; cursor: pointer; }

.row-card { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1.5px solid #EEF0F4; background: var(--color-surface); border-radius: 10px; transition: border-color .15s ease, background-color .15s ease; }
.row-card.clickable:hover { border-color: var(--color-primary); background: #FAFBFF; }

table.simple { width: 100%; border-collapse: collapse; }
table.simple th { text-align: left; font-size: 10.5px; font-weight: 700; color: var(--color-text-4); text-transform: uppercase; letter-spacing: .05em; padding: 9px 10px; border-bottom: 1px solid var(--color-border); background: #FAFBFC; }
table.simple thead th:first-child { border-top-left-radius: 8px; }
table.simple thead th:last-child { border-top-right-radius: 8px; }
table.simple td { padding: 11px 10px; font-size: 13.5px; border-bottom: 1px solid #F3F4F7; vertical-align: top; }
table.simple tbody tr { transition: background-color .12s ease; }
table.simple tbody tr:hover { background: #FAFBFF; }

details { border-radius: 10px; overflow: hidden; }
details > summary { transition: background-color .12s ease; }
details > summary:hover { background: #FAFBFF; }

.ship-progress-track { height: 6px; border-radius: 999px; background: #EEF0F4; overflow: hidden; }
.ship-progress-fill { height: 100%; border-radius: 999px; background: var(--color-primary); transition: width .6s ease; }

.orders-menu-item:hover { background: #F1F3F7; }
.orders-page-prev:not(:disabled):hover,
.orders-page-next:not(:disabled):hover { background: #F1F3F7; }
.orders-menu-toggle:hover { background: #F1F3F7; }

/* =====================================================================
   Mobile / small-screen support (2026-10-06)
   Phones and small tablets: every page of the Store, Warehouse and Admin
   apps has to be usable one-handed. Desktop layout above is untouched --
   everything below only applies at <= 720px wide. Many views lay
   themselves out with inline flex/width styles, so the rules here use
   attribute selectors (+ !important) to reflow those too.
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, canvas, video, svg { max-width: 100%; }
.nav-toggle { display: none; }
.topbar .user { margin-left: auto; }
.topnav { display: contents; }
.table-scroll { width: 100%; }

@media (max-width: 720px) {
  .wrap, .narrow { padding: 16px 14px 44px; }
  /* Flex/grid children must be allowed to shrink below their content, or a wide table forces the whole page wider. */
  .wrap > *, .narrow > *, .card { min-width: 0; max-width: 100%; }
  .table-scroll { max-width: 100%; }
  .card { padding: 18px 16px; border-radius: 12px; }
  h1 { font-size: 21px; }

  /* ---- Top bar: brand + hamburger; links and user collapse under it ---- */
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 0; position: sticky; }
  .topbar .brand { flex: 1 1 100%; flex-wrap: wrap; padding-right: 52px; min-height: 36px; }
  .topbar .brand-name { font-size: 13.5px; }
  .nav-toggle {
    display: flex !important; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    position: absolute; top: 8px; right: 10px; width: 42px; height: 42px;
    background: #fff; border: 1px solid var(--color-border-strong); border-radius: 10px; padding: 0;
  }
  .nav-toggle span { display: block; width: 18px; height: 2px; background: var(--color-text-2); border-radius: 2px; transition: transform .15s ease, opacity .15s ease; }
  .topbar.open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .topbar.open .nav-toggle span:nth-child(2) { opacity: 0; }
  .topbar.open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .topnav { display: none; flex: 1 1 100%; flex-direction: column; margin-top: 8px; border-top: 1px solid var(--color-border); }
  .topbar.open .topnav { display: flex; }
  .topnav a { margin-left: 0 !important; padding: 13px 4px; font-size: 14.5px !important; border-bottom: 1px solid #F1F3F7; }
  .topbar .user { display: none; flex: 1 1 100%; justify-content: space-between; padding: 12px 4px 4px; font-size: 14px; }
  .topbar.open .user { display: flex; }

  /* ---- Rows of fields / cards stack and wrap ---- */
  div[style*="display:flex"], div[style*="display: flex"], form[style*="display:flex"], label[style*="display:flex"] { flex-wrap: wrap; }
  .field[style*="flex"], .field[style*="width"] { flex: 1 1 100% !important; width: 100% !important; }
  [style*="width:"], [style*="width: "] { max-width: 100%; }
  [style*="grid-template-columns:repeat"], [style*="grid-template-columns: repeat"] { grid-template-columns: repeat(2, 1fr) !important; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .type-cards { flex-direction: column; }
  .row-card { flex-wrap: wrap; }

  /* ---- Tables scroll sideways inside their card instead of squashing ---- */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll > table { min-width: 560px; }
  table.simple th, .invoice-table th { white-space: nowrap; }

  /* ---- Touch-friendly controls (16px stops iOS zooming into inputs) ---- */
  input, select, textarea, button { font-size: 16px !important; }
  .field input, .field select, .field textarea, input[type="text"], input[type="search"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"], input[type="password"], select, textarea { min-height: 44px; }
  .btn { min-height: 44px; justify-content: center; }
  .back-link { padding: 6px 0; font-size: 13.5px; }
  details > summary { padding-top: 14px; padding-bottom: 14px; }
  canvas { height: auto; }
  input[type="checkbox"], input[type="radio"] { min-width: 20px; min-height: 20px; }
}
