:root {
  color-scheme: light;
  --navy: #0f2f4f;
  --navy-2: #1a4a75;
  --sea: #0a7c76;
  --sea-ink: #07504c;
  --sea-soft: #e0f4f2;
  --sea-tint: rgba(10, 124, 118, .15);
  --bg: #e6f0f3;
  --card: rgba(255, 255, 255, .66);
  --line: #d9e1e9;
  --ink: #13283c;
  --muted: #3f5163;
  --amber-bg: #fff3d1;
  --amber-ink: #6f4c00;
  --green-bg: #dcf4e8;
  --green-ink: #0f5c44;
  --red: #b3261e;
  --radius: 20px;
  --tap: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --dock: 78px;
  --glass: rgba(255, 255, 255, .56);
  --glass-edge: rgba(255, 255, 255, .78);
  --glass-shadow: 0 14px 34px -12px rgba(15, 47, 79, .26), inset 0 1px 0 rgba(255, 255, 255, .9);
  --soft-shadow: 0 8px 20px -14px rgba(15, 47, 79, .3), inset 0 1px 0 rgba(255, 255, 255, .8);
  --field-line: rgba(15, 47, 79, .2);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
/* the sea behind the glass; fixed so it stays still while the pills and content move over it */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(70vmax 52vmax at -6% -4%, rgba(10, 124, 118, .36), transparent 62%),
    radial-gradient(64vmax 50vmax at 104% 6%, rgba(38, 112, 178, .32), transparent 60%),
    radial-gradient(70vmax 56vmax at 90% 104%, rgba(10, 124, 118, .28), transparent 62%),
    radial-gradient(56vmax 44vmax at 2% 98%, rgba(38, 112, 178, .2), transparent 60%),
    var(--bg);
}
h1, h2, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
input, select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--field-line);
  border-radius: 14px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--sea);
  outline-offset: 1px;
}
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 20px;
  background: rgba(255, 255, 255, .74);
  border: 1px solid var(--field-line);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, box-shadow .2s, transform .12s;
}
.btn:hover { background: #fff; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--sea); border-color: var(--sea); color: #fff; box-shadow: 0 10px 20px -10px rgba(10, 124, 118, .7); }
.btn.primary:hover { background: #086a65; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger-text { color: var(--red); }
.btn.wide { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: none;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  transition: background .2s;
}
.iconbtn:hover { background: rgba(255, 255, 255, .7); }
.iconbtn:disabled { opacity: .3; cursor: default; }
.iconbtn.danger { color: var(--red); }
.iconbtn.tiny { width: 28px; height: 28px; color: var(--navy); }

/* the frame: floating glass pills */
.layout { min-height: 100dvh; display: flex; flex-direction: column; }
.layout::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  z-index: 9;
  height: calc(14px + var(--safe-top));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  -webkit-mask-image: linear-gradient(#000 45%, transparent);
  mask-image: linear-gradient(#000 45%, transparent);
  pointer-events: none;
}
.glass, .itembar, .login form {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: saturate(170%) blur(18px);
  backdrop-filter: saturate(170%) blur(18px);
}
.topbar {
  position: sticky;
  top: calc(10px + var(--safe-top));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  margin: calc(10px + var(--safe-top)) 12px 0;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
}
.topbar:has(> a.iconbtn) { padding-left: 6px; }
.topbar h1 { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandmark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-style: italic;
  font-weight: 700;
}
.brandmark img { flex: none; width: 36px; height: 36px; border-radius: 12px; }
.who {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-left: auto;
  padding: 3px 8px 3px 3px;
  background: none;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.who:hover { background: rgba(255, 255, 255, .7); }
.who svg { color: var(--muted); }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--navy);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.main { flex: 1; width: 100%; padding: 14px 16px calc(var(--dock) + 20px + var(--safe-bottom)); }
.main.with-footer { padding-bottom: calc(var(--dock) + 90px + var(--safe-bottom)); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 10;
  display: flex;
  gap: 4px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border-radius: 999px;
  transform: translateX(-50%);
}
.dock a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 68px;
  height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 650;
  transition: background .2s, color .2s;
}
.dock a span { display: none; }
.dock a .dot { position: absolute; top: 3px; left: calc(50% + 3px); }
.dock a.on { flex: none; background: var(--sea-tint); color: var(--sea-ink); }
.dock a.on span { display: block; overflow: hidden; }
.dock a.on .dot { position: static; }
.dock a.arrive span { animation: navlabel .26s ease-out; }
@keyframes navlabel {
  from { max-width: 0; opacity: 0; }
  to { max-width: 90px; opacity: 1; }
}
.dot {
  min-width: 20px;
  padding: 1px 6px;
  background: #d9480f;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* delivery date and form tabs */
.datebar { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
.datebar .label { font-size: 14px; color: var(--muted); font-weight: 600; }
.chip {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--field-line);
  border-radius: 21px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.datepick { background: rgba(224, 244, 242, .8); border-color: #9bd6d1; color: var(--sea-ink); }
.chip.datepick input {
  position: absolute;
  inset: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}
.chip.datepick input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.segments {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, .44);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
}
.segments button {
  flex: 1;
  min-height: 44px;
  padding: 6px 10px;
  background: none;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.segments button.on { background: #fff; color: var(--sea-ink); box-shadow: 0 4px 10px -6px rgba(15, 47, 79, .4); }
/* many customers wrap onto a second line rather than widening the page */
.segments.customers { flex-wrap: wrap; border-radius: 27px; }

/* location list */
.group { margin-bottom: 16px; }
.group > h2, .section {
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.section { margin-top: 20px; }
.section.flush { margin-top: 0; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}
a.card { transition: background .2s, transform .12s; }
a.card:hover { background: rgba(255, 255, 255, .86); }
a.card:active { transform: scale(.99); }
.card.row { display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 10px 12px 10px 16px; }
.card.row strong { display: block; font-size: 16.5px; font-weight: 650; }
.card.row .muted { font-size: 14px; }
.card.row > svg { color: #8a9bab; flex: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px;
  background: #e8edf2;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.sent { background: var(--green-bg); color: var(--green-ink); }
.pill.draft { background: var(--amber-bg); color: var(--amber-ink); }
.pill.office { background: #dfe7f5; color: #27436f; }

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, .62);
  border-radius: 16px;
  font-size: 14.5px;
}
.banner > span { flex: 1; }
.banner svg { flex: none; }
.banner.warn { background: var(--amber-bg); color: var(--amber-ink); }
.banner.good { background: var(--green-bg); color: var(--green-ink); }
.banner.linklike { width: 100%; border: 0; font-weight: 600; text-align: left; cursor: pointer; }

/* one location */
.context { margin-bottom: 10px; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--field-line);
  border-radius: 999px;
  color: var(--muted);
}
.search input { border: 0; padding-left: 0; background: none; color: var(--ink); }
.search input:focus-visible { outline: none; }
.search:focus-within { outline: 3px solid var(--sea); outline-offset: 1px; }
.items { display: flex; flex-direction: column; gap: 6px; }
.item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 7px 8px 7px 10px;
  background: var(--card);
  border: 1px solid var(--glass-edge);
  border-radius: 18px;
  box-shadow: var(--soft-shadow);
}
.item.filled { border-color: #6cc4bd; background: rgba(224, 244, 242, .86); }
.item .no { color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; }
.item .name { font-weight: 600; font-size: 15.5px; line-height: 1.25; overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  background: rgba(15, 47, 79, .08);
  border: 0;
  border-radius: 14px;
  color: var(--navy);
  cursor: pointer;
  touch-action: manipulation;
}
.stepper button:last-child { background: var(--navy); color: #fff; }
.stepper button:disabled { opacity: .4; }
.stepper input.qty {
  width: 46px;
  min-height: var(--tap);
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper input.qty::placeholder { color: #7f8f9e; font-weight: 500; }

.itembar, .sendbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
}
.itembar { padding: 8px; border-radius: 34px; }
.sendbar { bottom: calc(var(--dock) + 8px + var(--safe-bottom)); pointer-events: none; }
.sendbar .btn { pointer-events: auto; }
.tally { flex: 1; min-width: 0; padding-left: 12px; font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.itembar .btn { flex: none; max-width: 62%; }
.itembar .btn:only-child { flex: 1; max-width: none; }

/* sheets and toasts */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px 10px calc(10px + var(--safe-bottom));
  background: rgba(15, 35, 55, .36);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 20px 16px 16px;
  background: rgba(255, 255, 255, .93);
  border: 1px solid var(--glass-edge);
  border-radius: 28px;
  box-shadow: var(--glass-shadow);
}
.sheet h2 { font-size: 20px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }
.review { list-style: none; margin: 0; padding: 0; }
.review li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.review .leftout { flex-basis: 100%; color: var(--amber-ink); }
.plain { margin: 0; padding-left: 18px; }
.creds { margin: 0; padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.creds dt { font-size: 13px; color: var(--muted); }
.creds dd { margin: 0 0 8px; font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--dock) + 72px + var(--safe-bottom));
  z-index: 40;
  max-width: 460px;
  margin: 0 auto;
  padding: 12px 16px;
  background: var(--navy);
  border-radius: 18px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 35, 55, .3);
}
.toast.good { background: var(--green-ink); }
.toast.bad { background: var(--red); }

/* login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login form { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 380px; padding: 26px 22px; border-radius: 28px; }
.login .brandmark { margin-bottom: 4px; font-size: 26px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .field > label > span { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.field > label { display: block; }
.error { color: var(--red); font-weight: 600; font-size: 15px; }

/* grid */
.toolbar { display: flex; flex-direction: column; }
.hint { margin-bottom: 10px; font-size: 14px; }
.gridwrap { overflow: auto; max-height: calc(100dvh - 240px); background: #fff; border: 1px solid var(--glass-edge); border-radius: var(--radius); box-shadow: var(--glass-shadow); }
.grid { border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; width: 100%; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grid thead th { position: sticky; z-index: 3; padding: 6px 8px; background: var(--navy); color: #fff; font-weight: 650; text-align: center; }
.grid thead tr:nth-child(1) th { top: 0; height: 32px; background: var(--navy-2); font-size: 13px; letter-spacing: .03em; }
.grid thead tr:nth-child(2) th { top: 32px; min-width: 96px; max-width: 120px; height: 66px; line-height: 1.2; }
.grid thead tr:nth-child(3) th { top: 98px; background: #eef3f7; color: var(--ink); padding: 4px; }
.grid thead th.stick { left: 0; z-index: 5; text-align: left; vertical-align: bottom; background: var(--navy); min-width: 200px; }
.grid thead th.total { z-index: 4; right: 0; background: var(--navy); vertical-align: bottom; }
.grid td.no { position: sticky; left: 0; z-index: 2; width: 34px; min-width: 34px; background: #fff; color: var(--muted); text-align: center; font-size: 12.5px; }
.grid td.name { position: sticky; left: 34px; z-index: 2; min-width: 166px; max-width: 240px; padding: 6px 10px; background: #fff; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; box-shadow: 1px 0 0 var(--line); }
.grid td.cell { min-width: 96px; height: 38px; padding: 0; text-align: center; font-weight: 600; }
.grid td.cell.filled { background: var(--sea-soft); }
.grid td.cell.closed { background: #eef1f4; color: #55677a; }
.grid td.cell input {
  display: block;
  width: 100%;
  height: 38px;
  min-height: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  text-align: center;
  font-weight: 650;
}
.grid td.cell input:focus { outline: 2px solid var(--sea); outline-offset: -2px; background: #fff; }
.grid td.total { position: sticky; right: 0; min-width: 62px; padding: 0 8px; background: #e8eef4; font-weight: 700; text-align: center; }
.grid tfoot td { position: sticky; bottom: 0; z-index: 3; height: 40px; background: #e8eef4; font-weight: 700; text-align: center; border-top: 1px solid #b9c7d4; }
.grid tfoot td.stick { left: 0; z-index: 4; text-align: left; padding-left: 12px; }
.grid tfoot td.grand { right: 0; z-index: 4; background: var(--navy); color: #fff; }
.colactions { display: flex; align-items: center; justify-content: center; gap: 2px; flex-wrap: wrap; }
.grid .pill { font-size: 11.5px; padding: 1px 6px; }

.stats { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.stat { display: flex; align-items: baseline; gap: 6px; padding: 8px 16px; background: var(--card); border: 1px solid var(--glass-edge); border-radius: 999px; box-shadow: var(--soft-shadow); }
.stat strong { font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.stat-action { margin-left: auto; }
.empty { padding: 44px 16px; color: var(--muted); text-align: center; background: var(--card); border: 1px dashed var(--field-line); border-radius: var(--radius); }

/* setup */
.editor { display: flex; flex-direction: column; gap: 10px; }
.fields { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.editrow { display: grid; gap: 10px; padding: 14px; background: var(--card); border: 1px solid var(--glass-edge); border-radius: var(--radius); box-shadow: var(--soft-shadow); }
.rowbtns { display: flex; justify-content: flex-end; gap: 2px; }
.codehint { margin-top: 4px; font-size: 13px; color: var(--muted); }
.codehint.missing { display: inline-block; align-self: flex-start; padding: 0 7px; background: var(--amber-bg); border-radius: 6px; color: var(--amber-ink); font-weight: 600; }
.user { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.user strong { display: block; }
.user .muted { font-size: 14px; }
.user select { width: auto; min-height: 40px; padding: 4px 8px; }
.user.off { opacity: .6; }
.rolename { padding: 0 8px; font-size: 14.5px; font-weight: 600; }
.setup-home .banner { margin-bottom: 0; }

/* roles: one row per action, one column per role */
.tick { flex: none; width: 22px; height: 22px; min-height: 0; margin: 0; padding: 0; accent-color: var(--sea); cursor: pointer; }
.tick:disabled { cursor: default; }
.tickrow { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.placelist { max-height: 46dvh; overflow: auto; }
.placelist[hidden] { display: none; }
.placelist h3 { margin: 10px 0 2px; font-size: 14px; font-weight: 700; color: var(--muted); }
.fields.bare { padding: 0; }
.permgrid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14.5px; }
.permgrid th, .permgrid td { padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.permgrid thead th { position: sticky; top: 0; z-index: 3; min-width: 92px; background: var(--navy); color: #fff; font-weight: 650; }
.permgrid thead small { display: block; color: rgba(255, 255, 255, .78); font-size: 12px; font-weight: 400; }
.permgrid .stick { position: sticky; left: 0; z-index: 2; min-width: 250px; text-align: left; font-weight: 600; box-shadow: 1px 0 0 var(--line); }
.permgrid thead .stick { z-index: 4; }
.permgrid tbody small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; line-height: 1.25; }
.permgrid .module th, .permgrid .module td { background: #dcecee; color: var(--sea-ink); font-weight: 750; }
.rolehead { color: inherit; font: inherit; }
button.rolehead { padding: 0; background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* the totals grid on a phone: narrow columns, and only the item name stays pinned */
@media (max-width: 899px) {
  .grid { font-size: 13px; }
  .grid thead th.stick { min-width: 136px; max-width: 136px; }
  .grid thead tr:nth-child(2) th { min-width: 72px; max-width: 84px; font-size: 12px; }
  .grid td.no { width: 26px; min-width: 26px; }
  .grid td.name { left: 26px; min-width: 110px; max-width: 110px; padding: 4px 6px; font-size: 12.5px; }
  .grid td.cell { min-width: 72px; }
  .grid td.total, .grid thead th.total, .grid tfoot td.grand { position: static; }
  .main:has(.permgrid) .gridwrap { max-height: max(280px, calc(100dvh - 302px)); }
  .permgrid { font-size: 13.5px; }
  .permgrid th, .permgrid td { padding: 7px 6px; }
  .permgrid thead th { min-width: 72px; }
  .permgrid .stick { min-width: 150px; max-width: 150px; }
  .stat-action { width: 100%; margin-left: 0; }
  .toolbar > .btn, .toolbar > select { margin-bottom: 8px; }
  .itembar:not(:has(.tally)) .btn { flex: 1; max-width: none; padding-inline: 12px; }
}

@media (max-width: 359px) {
  .dock a { min-width: 56px; padding: 0 14px; }
}

/* wide screens */
@media (min-width: 900px) {
  .layout.wide { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 14px; padding: 14px; }
  .side {
    position: sticky;
    top: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100dvh - 28px);
  }
  .brandcard { flex: none; display: flex; align-items: center; min-height: 66px; padding: 0 16px; border-radius: 24px; }
  .sidenav { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; border-radius: 24px; }
  .navlabel { padding: 2px 14px 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .sidenav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 600;
    transition: background .2s, color .2s;
  }
  .sidenav a:hover { background: rgba(255, 255, 255, .6); }
  .sidenav a.on { background: var(--sea-tint); color: var(--sea-ink); }
  .sidenav a .dot { margin-left: auto; }
  .signout {
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 0 24px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
  }
  .signout:hover { background: rgba(255, 255, 255, .8); }
  .page { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
  .topbar { top: 14px; min-height: 66px; margin: 0; padding: 8px 12px 8px 26px; }
  .topbar:has(> a.iconbtn) { padding-left: 10px; }
  .topbar h1 { font-size: 22px; font-weight: 750; }
  .who { padding-right: 12px; }
  .main { min-width: 0; padding: 2px 8px 14px; }
  .main.with-footer { padding-bottom: 14px; }
  .toolbar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
  .toolbar .datebar, .toolbar .segments { margin-bottom: 0; }
  .toolbar .segments button { padding: 6px 18px; white-space: nowrap; }
  .overlay { align-items: center; }
  .sheet { padding: 22px; }
  .toast { left: auto; right: 24px; bottom: 24px; margin: 0; }
  .itembar { position: sticky; left: auto; right: auto; bottom: 14px; margin-top: 16px; justify-content: flex-end; }
  .itembar .btn:only-child { flex: none; }
  .setup-home, .fields, .search, .main > .cards { max-width: 720px; }
  .main > .cards ~ .search { max-width: 720px; }
  .editor { max-width: 1040px; }
  .editrow.item-edit { grid-template-columns: minmax(180px, 1.4fr) minmax(220px, 1.6fr) 140px auto; align-items: start; }
  .editrow.loc-edit { grid-template-columns: 1fr 1.4fr auto; align-items: end; }
  .rowbtns { align-self: center; margin-top: 22px; }
  .loc-edit .rowbtns { margin-top: 0; }
  .editor .btn.wide { width: auto; align-self: flex-start; }
  .fields .btn.wide { width: auto; align-self: flex-start; }
  .gridwrap { max-height: calc(100dvh - 232px); }
  .main:has(.stats) .gridwrap { max-height: calc(100dvh - 282px); }
  .main:has(.permgrid) .gridwrap { max-height: max(280px, calc(100dvh - 306px)); }
  .fields.bare .btn.wide { width: 100%; align-self: stretch; }
}

/* old phones with no blur, and people who ask for less see-through */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass: rgba(255, 255, 255, .95); }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: rgba(255, 255, 255, .96); --card: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
}

/* the SOR on screen, laid out like the sheet */
.stat-action + .stat-action { margin-left: 0; }
.sorsheet { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; background: #fff; }
.sorsheet th { position: sticky; top: 0; padding: 9px 7px; background: var(--navy); color: #fff; font-weight: 650; text-align: left; white-space: nowrap; }
.sorsheet td { padding: 8px 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.sorsheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sorsheet tr.unmapped td { background: #ffff00; }
@media (min-width: 900px) {
  .toolbar select { flex: 0 1 340px; width: auto; min-width: 0; }
  .toolbar .btn { white-space: nowrap; }
}
.sorsheet td:nth-child(3) { min-width: 170px; white-space: normal; }

/* the billers' order list and Pending */
.orderlist { width: 100%; min-width: 680px; border-collapse: separate; border-spacing: 0; font-size: 14px; background: #fff; }
.orderlist th { position: sticky; top: 0; z-index: 1; padding: 9px 10px; background: var(--navy); color: #fff; font-weight: 650; text-align: left; white-space: nowrap; }
.orderlist td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.orderlist td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.orderlist tr.day th { position: static; background: #e8eef4; color: var(--sea-ink); font-size: 13px; }
.orderlist tr.done td { color: var(--muted); }
.orderlist .state { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.orderlist .state .btn { margin-left: auto; }
.orderlist .by { font-size: 12.5px; color: var(--muted); }
@media (min-width: 900px) {
  .segments.views { width: fit-content; max-width: 100%; margin-bottom: 12px; }
  .segments.views button { flex: none; padding: 6px 18px; white-space: nowrap; }
  .main:has(.views) .gridwrap { max-height: calc(100dvh - 290px); }
  .main:has(.views):has(.stats) .gridwrap { max-height: calc(100dvh - 340px); }
  .main:has(.filters) .gridwrap { max-height: calc(100dvh - 350px); }
}
.copybox { position: fixed; top: 0; left: -9999px; }
.copyhand { width: 100%; height: 150px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; font-family: Consolas, monospace; font-size: 12px; white-space: pre; overflow: auto; }

/* the SOR page: column switches, row ticks and edits, as in the LPO app */
.sorsheet th .colswitch { all: unset; cursor: pointer; user-select: none; }
.sorsheet th .colswitch::after { content: ' \21C5'; font-size: 9px; opacity: .45; }
.sorsheet th .colswitch:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 3px; }
.sorsheet th.col-inactive { opacity: .45; text-decoration: line-through; }
.sorsheet td.col-inactive { opacity: .2; }
.sorsheet th.tick, .sorsheet td.tick { width: 34px; padding: 0 6px; text-align: center; }
.sorsheet input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--sea); cursor: pointer; }
.sorsheet tbody tr { cursor: pointer; }
.sorsheet tr.selected td { background: var(--sea-soft); }
.sorsheet tr.unmapped td, .sorsheet tr.unmapped.selected td { background: #ffff00; }
.sorsheet tr.edited td:first-child { box-shadow: inset 4px 0 0 var(--sea); }
.sorsheet td.edit { padding: 2px 3px; }
.sorsheet input.sorcell { display: block; width: 100%; min-width: 64px; min-height: 0; height: 32px; padding: 0 5px; font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 6px; cursor: text; }
.sorsheet td.num input.sorcell { text-align: right; font-variant-numeric: tabular-nums; }
.sorsheet input.sorcell:hover { border-color: var(--line); }
.sorsheet input.sorcell:focus { outline: none; border-color: var(--sea); background: #fff; }
.sorsheet td.bad, .sorsheet tr.unmapped td.bad { background: #fde2df; }
.sorsheet td.bad input.sorcell { border-color: var(--red); }
.sortools { gap: 8px; }
.stat.warn { background: var(--amber-bg); }
.stat.warn strong, .stat.warn span { color: var(--amber-ink); }

/* Setup, Prices */
.pricegrid thead th.allhead { min-width: 96px; background: var(--navy); vertical-align: bottom; }
.pricegrid td.cell.all { background: #f1f5f8; }
.pricegrid td.cell.changed { background: var(--amber-bg); }
.pricegrid td.cell.bad { background: #fde2df; }
.pricegrid td.cell.bad input { color: var(--red); }
.pricegrid td.cell input:disabled { color: inherit; opacity: 1; -webkit-text-fill-color: currentColor; cursor: default; }
.grid td.name .codeline { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.gridwrap.pricelog { max-height: 420px; }
@media (min-width: 900px) {
  .main:has(.sorsheet) .gridwrap { max-height: max(320px, calc(100dvh - 400px)); } /* the SOR page has more above its table */
}

/* reports: one row of period chips, one of filters, then KPI tiles, tabs and tables */
.reportbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.reportbar select { width: auto; min-width: 0; flex: 0 1 260px; }
.reportbar .btn { white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; background: var(--card); border: 1px solid var(--glass-edge); border-radius: 16px; box-shadow: var(--soft-shadow); }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 650; }
.kpi strong { font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .sub { color: var(--muted); font-size: 13px; }
.kpi.warn { background: var(--amber-bg); }
.kpi.warn .label, .kpi.warn strong, .kpi.warn .sub { color: var(--amber-ink); }
.up { color: var(--green-ink); font-weight: 650; }
.down { color: var(--red); font-weight: 650; }
.segments.reporttabs { width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segments.reporttabs button { flex: none; padding: 6px 16px; white-space: nowrap; }
.gridwrap.report { max-height: 460px; margin-bottom: 16px; }
.reporttable th.num { text-align: right; }
.reporttable td small { display: block; color: var(--muted); font-size: 12px; }
.reporttable td small.warnnote { color: var(--amber-ink); }
.reporttable tr.quiet td { color: var(--muted); }
.sharecell { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.sharebar { display: block; width: 52px; height: 6px; overflow: hidden; background: #e8eef4; border-radius: 3px; }
.sharebar i { display: block; height: 100%; background: #008f86; border-radius: 3px; }
.stale { opacity: .55; transition: opacity .2s; }
.trend { position: relative; margin-bottom: 16px; padding: 14px 16px 8px; background: #fff; border: 1px solid var(--glass-edge); border-radius: var(--radius); box-shadow: var(--glass-shadow); }
.trend:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }
.trend h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.trend svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.trend text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend .gridline { stroke: #e6ecf1; stroke-width: 1; }
.trend .area { fill: rgba(0, 143, 134, .1); }
.trend .line { fill: none; stroke: #008f86; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend .dot { fill: #008f86; stroke: #fff; stroke-width: 2; }
.trend .cross { stroke: #9aa9b7; stroke-width: 1; }
.trend .endlabel { fill: var(--ink); font-weight: 650; }
.charttip { position: absolute; z-index: 2; display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--soft-shadow); font-size: 13px; color: var(--muted); white-space: nowrap; }
.charttip strong { color: var(--ink); font-size: 15px; }
.charttip[hidden] { display: none; }
.reporttable th.namecell, .reporttable td.namecell { min-width: 220px; white-space: normal; }
.reporttable th, .reporttable td { padding-inline: 8px; }
.reporttable th.namecell, .reporttable td.namecell { min-width: 190px; }
.reporttable th { white-space: normal; vertical-align: bottom; line-height: 1.2; }
.reporttable td { white-space: nowrap; }
.reporttable td.namecell { white-space: normal; }
@media (max-width: 599px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; }
  .kpi strong { font-size: 17px; }
}
