/* ==========================================================================
   Turbo Solutions — Order Portal
   One stylesheet for every page: sign-in, customer portal, admin, password reset.

   Palette comes off the Turbo Solutions logo — navy housing, turbine green.
   Type is Archivo (headings), Public Sans (body), IBM Plex Mono (part/PO/order
   numbers, where digits need to line up and read unambiguously).

   Deliberately single-theme: the navy only carries weight as contrast against
   paper, so the whole portal stays on a paper ground.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --ink:          #0b1a2b;
  --ink-2:        #102438;
  --steel:        #14335a;
  --blue:         #1c6bc4;
  --blue-deep:    #17569e;
  --blue-wash:    #eaf2fb;
  --turbine:      #1f9d52;
  --turbine-deep: #197f43;
  --turbine-wash: #e8f6ed;

  /* Neutrals — biased toward the navy rather than pure grey */
  --paper:        #f5f7fa;
  --paper-sunk:   #eef2f7;
  --surface:      #ffffff;
  --slate:        #5a6e85;
  --slate-soft:   #8598ac;
  --rule:         #dfe6ee;
  --rule-soft:    #ebf0f5;

  /* Semantics — kept separate from the brand accent */
  --amber:        #a8710f;
  --amber-wash:   #fdf4e3;
  --clay:         #ad3826;
  --clay-wash:    #fcece9;

  /* Type */
  --display: 'Archivo', system-ui, sans-serif;
  --body:    'Public Sans', system-ui, sans-serif;
  --data:    'IBM Plex Mono', ui-monospace, monospace;

  /* Scale */
  --t-display: 2.5rem;
  --t-h1:      1.75rem;
  --t-h2:      1.25rem;
  --t-h3:      1rem;
  --t-body:    0.9375rem;
  --t-small:   0.8125rem;
  --t-micro:   0.6875rem;

  /* Space */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;
  --s9: 56px; --s10: 72px;

  /* Form */
  --r-control: 7px;
  --r-inner:   10px;
  --r-card:    14px;

  /* Elevation — tight contact shadow plus a wide soft one */
  --e1: 0 1px 2px rgba(11, 26, 43, .06);
  --e2: 0 1px 2px rgba(11, 26, 43, .06), 0 6px 16px rgba(11, 26, 43, .05);
  --e3: 0 2px 4px rgba(11, 26, 43, .06), 0 16px 36px rgba(11, 26, 43, .09);
  --e4: 0 4px 8px rgba(11, 26, 43, .08), 0 32px 68px rgba(11, 26, 43, .16);

  --swift:  150ms cubic-bezier(.4, 0, .2, 1);
  --smooth: 380ms cubic-bezier(.22, 1, .36, 1);

  /* Aliases — page scripts write inline styles against these names */
  --text: var(--ink);
  --text-secondary: var(--slate);
  --border: var(--rule);
  --bg: var(--paper);
  --accent: var(--blue);
  --error: var(--clay);
  --error-dim: var(--clay-wash);
  --success: var(--turbine-deep);
  --success-dim: var(--turbine-wash);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--slate);
  font-family: var(--body);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  color: var(--ink);
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.018em;
  text-wrap: balance;
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }

a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--swift), border-color var(--swift);
}
a:hover { color: var(--blue-deep); border-bottom-color: currentColor; }

img, svg { display: block; max-width: 100%; }
::selection { background: rgba(31, 157, 82, .2); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--turbine);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

/* A stamped, tracked-out label. Used for eyebrows and column headers. */
.label,
.eyebrow,
.queue-label,
.rail-group {
  font-family: var(--data);
  font-size: var(--t-micro);
  font-weight: 500;
  line-height: 1;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--slate-soft);
}

.mono, .fname { font-family: var(--data); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   3. Controls
   -------------------------------------------------------------------------- */
label {
  display: block;
  margin-bottom: var(--s2);
  color: var(--ink);
  font-size: var(--t-small);
  font-weight: 600;
}

.field { margin-bottom: var(--s5); }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-body);
  box-shadow: var(--e1);
  transition: border-color var(--swift), box-shadow var(--swift);
}
input::placeholder, textarea::placeholder { color: var(--slate-soft); }
textarea { min-height: 84px; padding-top: 10px; resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

input:hover, select:hover, textarea:hover { border-color: #c4d1de; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--turbine);
  box-shadow: 0 0 0 3px rgba(31, 157, 82, .13);
}
input[type="file"] { padding: 8px 10px; font-size: var(--t-small); cursor: pointer; }

/* Primary: solid steel-to-blue. The only filled control on any screen. */
button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 46px;
  padding: 0 var(--s6);
  border: none;
  border-radius: var(--r-control);
  background: linear-gradient(180deg, var(--blue) 0%, var(--blue-deep) 100%);
  color: #fff;
  font-family: var(--body);
  font-size: var(--t-body);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--e2), inset 0 1px 0 rgba(255, 255, 255, .16);
  transition: background var(--swift), box-shadow var(--swift), transform var(--swift);
}
button.primary:hover {
  background: linear-gradient(180deg, #2277d3 0%, var(--blue) 100%);
  box-shadow: var(--e3), inset 0 1px 0 rgba(255, 255, 255, .2);
  transform: translateY(-1px);
}
button.primary:active { transform: translateY(0); box-shadow: var(--e1); }
button.primary:disabled {
  background: #b6c4d2;
  box-shadow: none;
  transform: none;
  cursor: default;
}

/* Secondary: outlined on paper. */
button.ghost, .refresh-btn, .row-btn, .compare-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--s3);
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-small);
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--e1);
  transition: border-color var(--swift), background var(--swift), color var(--swift);
}
button.ghost:hover, .refresh-btn:hover:not(:disabled), .row-btn:hover, .compare-btn:hover {
  border-color: #c4d1de;
  background: var(--paper-sunk);
}
.refresh-btn:disabled { color: var(--slate-soft); cursor: default; }
.row-btn { min-height: 32px; margin-right: 6px; font-size: var(--t-micro); }
.row-btn.danger { color: var(--clay); border-color: #e6c4bd; }
.row-btn.danger:hover { background: var(--clay-wash); border-color: var(--clay); }
.row-file-input { display: none; }

/* --------------------------------------------------------------------------
   4. Sign-in — dark spec plate against the form on paper
   -------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}

.plate {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s8);
  padding: var(--s9) clamp(var(--s7), 5vw, var(--s10));
  overflow: hidden;
  background:
    radial-gradient(ellipse 32rem 24rem at 88% 6%, rgba(28, 107, 196, .28), transparent 70%),
    radial-gradient(ellipse 26rem 22rem at 4% 96%, rgba(31, 157, 82, .2), transparent 72%),
    linear-gradient(162deg, #081726 0%, #10314f 52%, #0a1e33 100%);
  color: #cddceb;
}

/* Machined datum grid — the plate's only texture */
.plate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(140, 190, 235, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 190, 235, .07) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at 55% 40%, #000 5%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse at 55% 40%, #000 5%, transparent 78%);
}
.plate > * { position: relative; z-index: 1; }

.plate-lockup { display: flex; flex-direction: column; gap: var(--s4); }
.plate-lockup img { width: min(320px, 74%); filter: drop-shadow(0 14px 26px rgba(0, 0, 0, .38)); }
.plate-lockup .label { color: #7fa4c4; }

.plate-headline {
  max-width: 17ch;
  color: #fff;
  font-family: var(--display);
  font-size: clamp(2rem, 3.4vw, var(--t-display));
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -.03em;
}

/* The three steps are a real sequence, so they are numbered. */
.steps {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  margin-top: var(--s7);
  max-width: 42ch;
  list-style: none;
  counter-reset: step;
}
.steps li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: var(--s4);
  align-items: start;
  font-size: var(--t-small);
  line-height: 1.65;
  color: #a8c2d8;
}
.steps li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  padding-top: 1px;
  border-top: 2px solid var(--turbine);
  font-family: var(--data);
  font-size: var(--t-micro);
  letter-spacing: .06em;
  color: var(--turbine);
}
.steps b { display: block; color: #eaf3fa; font-weight: 600; }

.plate-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s6);
  margin-top: auto;
  padding-top: var(--s5);
  border-top: 1px solid rgba(140, 190, 235, .14);
  color: #6f93b2;
}

/* Compressor wheel, drawn to canvas by portal.js — ambient, never animated fast */
.plate canvas {
  position: absolute;
  right: -13%;
  bottom: -16%;
  width: 34rem;
  height: 34rem;
  opacity: .42;
  z-index: 0;
  pointer-events: none;
}

.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s8) var(--s6);
}
.gate-inner { width: 100%; max-width: 25rem; }

.card {
  padding: var(--s8);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--e3);
}
.card > h1 { margin: var(--s2) 0 var(--s7); }

.form-note {
  margin-top: var(--s5);
  padding-top: var(--s5);
  border-top: 1px solid var(--rule-soft);
  font-size: var(--t-small);
  color: var(--slate);
}
.form-note + .form-note { margin-top: var(--s3); padding-top: 0; border-top: none; }

.notice {
  display: none;
  gap: var(--s2);
  margin-top: var(--s4);
  padding: 10px var(--s3);
  border-radius: var(--r-control);
  font-size: var(--t-small);
}
.notice.is-shown { display: flex; }
.notice.error { background: var(--clay-wash); color: var(--clay); }
.notice.info { background: var(--blue-wash); color: var(--blue-deep); }
.notice.ok { background: var(--turbine-wash); color: var(--turbine-deep); }

/* --------------------------------------------------------------------------
   5. Application frame — top bar, left rail, content
   -------------------------------------------------------------------------- */
#app-screen { display: none; }

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  height: 64px;
  padding: 0 var(--s6);
  background: linear-gradient(100deg, var(--ink) 0%, #10304e 68%, #0b2138 100%);
  border-bottom: 1px solid rgba(140, 190, 235, .12);
}
.appbar-brand { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.appbar-brand img { width: 40px; height: 30px; object-fit: contain; }
.appbar-brand .label { color: #8fb2cf; }

.appbar-account { display: flex; align-items: center; gap: var(--s4); min-width: 0; }

/* Who you are ordering for. Quiet, but never ambiguous. */
.tenant {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding-left: var(--s4);
  border-left: 1px solid rgba(140, 190, 235, .2);
  min-width: 0;
}
.tenant.is-shown { display: flex; }
.tenant .label { color: #6f93b2; letter-spacing: .12em; }
.tenant span:last-child {
  color: #fff;
  font-size: var(--t-small);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar button {
  min-height: 34px;
  padding: 0 var(--s3);
  border: 1px solid rgba(200, 222, 240, .26);
  border-radius: var(--r-control);
  background: rgba(200, 222, 240, .07);
  color: #dbe8f3;
  font-family: var(--body);
  font-size: var(--t-small);
  font-weight: 550;
  cursor: pointer;
  transition: background var(--swift), border-color var(--swift);
}
.appbar button:hover { background: rgba(200, 222, 240, .15); border-color: rgba(200, 222, 240, .45); }

.workspace {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s6) var(--s3);
  border-right: 1px solid var(--rule);
  background: var(--surface);
}
.rail-group { padding: 0 var(--s3) var(--s2); }
.rail-group + .tab { margin-top: 0; }
.rail hr { margin: var(--s4) var(--s3); border: none; border-top: 1px solid var(--rule-soft); }

/* Nav items keep the .tab class and data-tab hooks the page scripts rely on. */
.tab {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 9px var(--s3);
  border-radius: var(--r-control);
  color: var(--slate);
  font-size: var(--t-small);
  font-weight: 550;
  cursor: pointer;
  user-select: none;
  transition: background var(--swift), color var(--swift);
}
.tab svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 1.6; opacity: .75; }
.tab:hover { background: var(--paper-sunk); color: var(--ink); }
.tab.active { background: var(--blue-wash); color: var(--blue-deep); font-weight: 650; }
.tab.active svg { opacity: 1; }

/* Live count of what is in each queue. */
.tab-count {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--paper-sunk);
  color: var(--slate);
  font-family: var(--data);
  font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.tab.active .tab-count { background: rgba(28, 107, 196, .14); color: var(--blue-deep); }
.tab-count:empty { display: none; }

.content {
  min-width: 0;
  padding: var(--s7) clamp(var(--s5), 3vw, var(--s8));
  background: var(--paper);
}
.content-inner { max-width: 68rem; margin: 0 auto; }

.app-panel, .panel { display: none; }
.app-panel.active, .panel.active { display: block; animation: rise var(--smooth) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s6);
}
.panel-head p { margin-top: 6px; font-size: var(--t-small); color: var(--slate); }

/* --------------------------------------------------------------------------
   6. Summary strip — order state before the detail
   -------------------------------------------------------------------------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s7);
}
.stat {
  position: relative;
  padding: var(--s4) var(--s5);
  border: 1px solid var(--rule);
  border-radius: var(--r-inner);
  background: var(--surface);
  box-shadow: var(--e1);
  overflow: hidden;
}
/* Severity stripe: state reads before the number does. */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--rule);
}
.stat[data-tone="open"]::before   { background: var(--blue); }
.stat[data-tone="ready"]::before  { background: var(--turbine); }
.stat[data-tone="hold"]::before   { background: var(--amber); }
.stat-value {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.625rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
}

/* --------------------------------------------------------------------------
   7. Dropzone
   -------------------------------------------------------------------------- */
.dropzone {
  position: relative;
  display: block;
  padding: var(--s8) var(--s6);
  border: 1.5px dashed #ccd8e4;
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--e1);
  transition: border-color var(--swift), background var(--swift), box-shadow var(--swift);
}
.dropzone:hover { border-color: var(--turbine); box-shadow: var(--e2); }
.dropzone.drag-over {
  border-style: solid;
  border-color: var(--turbine);
  background: var(--turbine-wash);
  box-shadow: var(--e2);
}
.dropzone input[type="file"] { display: none; }
.dropzone .ticket-no { margin-bottom: var(--s5); }
.dropzone .icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--s4);
  color: var(--blue);
  stroke-width: 1.5;
}
.dropzone h3 { margin-bottom: var(--s1); }
.dropzone p { font-size: var(--t-small); color: var(--slate); }

/* Reading pass indicator — a light sweep down the panel while the PO is parsed */
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--turbine), transparent);
  opacity: 0;
}
.scanning { border-color: var(--turbine); border-style: solid; }
.scanning .scan-line { opacity: 1; animation: sweep 1.4s ease-in-out infinite; }
@keyframes sweep {
  0%, 100% { top: 4%; }
  50%      { top: 96%; }
}

.hint {
  margin-top: var(--s4);
  font-size: var(--t-small);
  color: var(--slate-soft);
  text-align: center;
}

/* --------------------------------------------------------------------------
   8. Session queue
   -------------------------------------------------------------------------- */
.queue { margin-top: var(--s7); }
.queue-label { display: block; margin-bottom: var(--s3); }
.queue-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s2);
  border: 1px solid var(--rule);
  border-radius: var(--r-inner);
  background: var(--surface);
  box-shadow: var(--e1);
  animation: rise 320ms cubic-bezier(.22, 1, .36, 1) both;
}
.queue-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.queue-item .fname { color: var(--ink); font-size: var(--t-small); }
.queue-item-details {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  font-size: var(--t-small);
  color: var(--slate);
}
.compare-btn { margin-left: auto; min-height: 30px; color: var(--clay); border-color: #e6c4bd; }
.compare-btn:hover { background: var(--clay-wash); }

/* --------------------------------------------------------------------------
   9. Status chips
   -------------------------------------------------------------------------- */
.status-pill, .status-tag, .role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--paper-sunk);
  color: var(--slate);
  font-family: var(--data);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: .04em;
  white-space: nowrap;
}
.status-pill.processing, .status-tag.complete {
  background: var(--blue-wash);
  border-color: #c3daf2;
  color: var(--blue-deep);
}
.status-pill.done, .status-tag.confirmed, .role-pill.admin {
  background: var(--turbine-wash);
  border-color: #bfe4cd;
  color: var(--turbine-deep);
}
.status-pill.error {
  background: var(--clay-wash);
  border-color: #eccbc4;
  color: var(--clay);
}
.status-tag.blank { background: transparent; color: var(--slate-soft); }

/* A dot that pulses only while work is actually in flight. */
.status-pill.processing::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.5s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.backorder-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  background: var(--clay-wash);
  border: 1px solid var(--clay);
  color: var(--clay);
  font-family: var(--data);
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 0 0 1px rgba(173,56,38,.06), 0 2px 8px rgba(173,56,38,.18);
}
.backorder-check::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clay);
  box-shadow: 0 0 6px 1px rgba(173,56,38,.9);
  animation: backorder-pulse 1.6s ease-in-out infinite;
}
@keyframes backorder-pulse {
  0%   { box-shadow: 0 0 4px 1px rgba(173,56,38,.7), 0 0 0 0 rgba(173,56,38,.55); }
  70%  { box-shadow: 0 0 8px 2px rgba(173,56,38,.9), 0 0 0 7px rgba(173,56,38,0); }
  100% { box-shadow: 0 0 4px 1px rgba(173,56,38,.7), 0 0 0 0 rgba(173,56,38,0); }
}
@media (prefers-reduced-motion: reduce) {
  .backorder-check::before { animation: none; }
}

/* --------------------------------------------------------------------------
   10. Tables
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   Clearable search fields + sortable table headers (shared: portal + admin)
   -------------------------------------------------------------------------- */
.search-clearable { position: relative; }
.search-clearable input { width: 100%; padding-right: 34px; }
.search-clear-btn {
  position: absolute; top: 50%; right: 9px; transform: translateY(-50%);
  display: none; width: 22px; height: 22px; border: none; background: transparent;
  color: var(--slate-soft); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 50%;
}
.search-clear-btn:hover { background: rgba(31,157,82,.08); color: var(--ink); }
.search-clearable.has-value .search-clear-btn { display: block; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable.sort-asc::after { content: " ▲"; font-size: 8px; }
th.sortable.sort-desc::after { content: " ▼"; font-size: 8px; }

.table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--r-inner);
  background: var(--surface);
  box-shadow: var(--e1);
  overflow-x: auto;
}
table, table.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}
th, td {
  padding: var(--s3) var(--s4);
  text-align: left;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
th {
  position: sticky;
  top: 0;
  background: var(--paper-sunk);
  border-bottom: 1px solid var(--rule);
  font-family: var(--data);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
  white-space: nowrap;
}
td { color: var(--slate); font-variant-numeric: tabular-nums; }
td.key { color: var(--ink); font-family: var(--data); font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--swift); }
tbody tr:hover { background: var(--paper); }
.table-empty { color: var(--slate-soft); }

/* --------------------------------------------------------------------------
   11. Admin forms
   -------------------------------------------------------------------------- */
.add-form {
  padding: var(--s6);
  margin-bottom: var(--s6);
  border: 1px solid var(--rule);
  border-radius: var(--r-inner);
  background: var(--surface);
  box-shadow: var(--e1);
}
.add-form h3 { margin-bottom: var(--s5); }
.add-form .field:last-of-type { margin-bottom: var(--s5); }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s5);
}
.form-row .field { margin-bottom: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.toolbar input { max-width: 22rem; }

.result-box {
  display: none;
  margin-top: var(--s4);
  padding: var(--s4);
  border-radius: var(--r-inner);
  font-family: var(--data);
  font-size: var(--t-small);
  white-space: pre-wrap;
}
.result-box.success { display: block; background: var(--turbine-wash); color: var(--turbine-deep); }
.result-box.error { display: block; background: var(--clay-wash); color: var(--clay); }

/* --------------------------------------------------------------------------
   12. Comparison modal
   -------------------------------------------------------------------------- */
.comparison-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: var(--s6);
  background: rgba(11, 26, 43, .58);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.comparison-modal.is-open { display: flex; animation: fade var(--smooth) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.comparison-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 96vw;
  max-height: 96vh;
  height: 96vh;
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: var(--e4);
  overflow: hidden;
  animation: rise var(--smooth) both;
}
.comparison-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--rule);
}
.comparison-header button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--rule);
  border-radius: var(--r-control);
  background: var(--surface);
  color: var(--slate);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--swift), color var(--swift);
}
.comparison-header button:hover { background: var(--paper-sunk); color: var(--ink); }
.comparison-error-banner {
  padding: var(--s3) var(--s5);
  background: var(--clay-wash);
  color: var(--clay);
  font-size: var(--t-small);
}
.comparison-error-banner:empty { display: none; }
.comparison-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  flex: 1;
  min-height: 0;
  background: var(--rule);
}
.comparison-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
.comparison-pane h3 {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--rule-soft);
  font-family: var(--data);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--slate);
}
.comparison-pane iframe { flex: 1; width: 100%; border: none; }
.comparison-pane-empty {
  display: none;
  padding: var(--s6);
  font-size: var(--t-small);
  color: var(--slate-soft);
}

/* --------------------------------------------------------------------------
   13. Standalone card page (password reset)
   -------------------------------------------------------------------------- */
.solo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--s6);
  background:
    radial-gradient(ellipse 40rem 28rem at 50% -10%, rgba(28, 107, 196, .09), transparent 70%),
    var(--paper);
}
.solo .card { width: 100%; max-width: 24rem; }
.solo-brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s5);
}
.solo-brand img { width: 26px; height: 20px; object-fit: contain; }

/* --------------------------------------------------------------------------
   14. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .scanning .scan-line { opacity: .7; top: 50%; }
}

/* --------------------------------------------------------------------------
   15. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 200px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .plate { gap: var(--s7); padding: var(--s7) var(--s6); }
  .plate canvas { width: 20rem; height: 20rem; right: -14%; }
  .gate { padding: var(--s7) var(--s5); }
  .card { padding: var(--s6); }

  /* The rail folds into a scrolling strip above the content. */
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .rail {
    flex-direction: row;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s5);
    border-right: none;
    border-bottom: 1px solid var(--rule);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-group, .rail hr { display: none; }
  .tab { flex-shrink: 0; }
  .content { padding: var(--s6) var(--s5); }
  .comparison-panes { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .appbar { height: auto; padding: var(--s3) var(--s4); flex-wrap: wrap; }
  .appbar-brand .label { display: none; }
  .tenant { padding-left: 0; border-left: none; }
  .plate-headline { font-size: 1.875rem; }
  .steps { margin-top: var(--s5); }
  .summary { grid-template-columns: 1fr 1fr; }
  .dropzone { padding: var(--s7) var(--s4); }
  th, td { padding: 10px var(--s3); }
}
