/* Modals, drawers and toasts for the dashboard mock-up. */

.ui-scrim {
  position: fixed; inset: 0; background: rgba(18,35,58,.48); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); z-index: 110;
}
.ui-scrim.is-open { opacity: 1; pointer-events: auto; }
/* Locking the page hides the scrollbar, which widens the viewport by the bar's
   width and makes everything, the sliding drawer included, jump sideways
   mid-animation. The script that locks measures the bar into --sbw; the page
   keeps that much padding and the drawer dock stops short of it. */
body.ui-locked { overflow: hidden; padding-right: var(--sbw, 0px); }
body.ui-locked .drawer-dock { right: var(--sbw, 0px); }

/* ---------- Modal ---------- */
.ui-modal {
  position: fixed; left: 50%; top: 50%; z-index: 120;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  background: var(--paper); border-radius: 18px; box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translate(-50%, -46%) scale(.97); opacity: 0; pointer-events: none;
  transition: transform .24s var(--ease), opacity .2s var(--ease);
}
.ui-modal.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.ui-modal--wide { width: min(880px, calc(100vw - 32px)); }

.ui-modal__head {
  display: flex; align-items: center; gap: 11px; padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.ui-modal__head h3 { flex: 1; font-size: 17px; }
.ui-modal__ico {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--orange-50); color: var(--orange-dk); font-size: 17px;
}
.ui-modal__body { padding: 18px; overflow-y: auto; }
.ui-modal__body > :last-child { margin-bottom: 0; }
.ui-modal__foot {
  display: flex; justify-content: flex-end; gap: 9px; padding: 14px 18px;
  border-top: 1px solid var(--line-soft); background: #fcfcfd;
}

/* ---------- Drawer ---------- */
.ui-drawer { z-index: 120; }

/* ---------- Toast ---------- */
.ui-toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 130;
  transform: translate(-50%, 140%); opacity: 0;
  background: var(--navy); color: #fff; border-radius: 13px; padding: 12px 18px;
  font-size: 14.5px; box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px);
  transition: transform .3s cubic-bezier(.32,.72,0,1), opacity .22s var(--ease);
}
.ui-toast.is-on { transform: translate(-50%, 0); opacity: 1; }
.ui-toast i { font-size: 17px; color: var(--orange-hi); }
.ui-toast--bad { background: var(--red); }
.ui-toast--bad i { color: #ffd9d6; }

/* ---------- Bits the forms use ---------- */
.note--warn { background: var(--amber-50); border-color: #F2D58A; border-left-color: var(--amber); }
.note--bad  { background: var(--red-50);   border-color: #F3CFCB; border-left-color: var(--red); }

/* An empty state inside a filtered table */
[data-empty] { padding: 40px 20px; }

/* Row-action buttons line up and stay reachable */
table.tbl td.row-actions { white-space: nowrap; }

/* A filter bar that wraps rather than pushing the table wide */
.filterbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.filterbar .search { max-width: 260px; flex: 1 1 200px; }
.filterbar .select { width: auto; max-width: 100%; }
.filterbar > .field { min-width: 0; max-width: 100%; }

@media (max-width: 560px) {
  .ui-modal { width: calc(100vw - 20px); max-height: calc(100vh - 32px); }
  .ui-modal__foot { flex-direction: column-reverse; }
  .ui-modal__foot .btn { width: 100%; justify-content: center; }
}

/* The shared drawer sits in its own dock, above the chat one. */
.drawer-dock:has(> .ui-drawer) { z-index: 120; }

/* ---------- Pieces the rebuilt dashboard adds ---------- */

/* Visible only to a screen reader: a label a sighted person gets from the
   placeholder, but which a screen reader would otherwise never announce. */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.filterbar {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center;
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft); background: var(--paper);
}
.filterbar .select { height: 36px; }

.tbl__sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.tbl__sort:hover { color: var(--orange-dk); }
.tbl__sort.is-on { color: var(--orange-dk); }

/* A balance still owed should catch the eye in a column of dashes. */
.is-owed { color: var(--red); font-weight: 600; }

.btn.is-disabled { opacity: .45; pointer-events: none; }

/* Two columns that collapse to one on a narrow screen. */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
/* minmax(0, 1fr), not 1fr: a bare fr track is min-width:auto, so a wide
   table inside it stretches the column and the whole page scrolls
   sideways instead of the table scrolling inside its own wrapper. */
@media (max-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr); } }

.kv { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--muted); flex: 0 0 42%; }
.kv__v { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* A single figure with its label, used in rows across the top of a screen. */
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: 13px;
  padding: 15px 17px; box-shadow: var(--shadow-1);
}
.stat__n { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat__l { color: var(--muted); font-size: 13px; margin-top: 3px; }
.stat--bad  .stat__n { color: var(--red); }
.stat--ok   .stat__n { color: var(--green); }
.stat--warn .stat__n { color: var(--orange-dk); }

.grid--4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .grid--4, .grid--3 { grid-template-columns: 1fr; } }

/* The badge on a sidebar item. */
.nav-item__pill {
  margin-left: auto; background: rgba(255,255,255,.14); color: #fff;
  border-radius: 99px; padding: 1px 8px; font-size: 11.5px; font-weight: 700;
}
.nav-item__pill.is-loud { background: var(--red); }
.nav-item.is-on .nav-item__pill { background: rgba(0,0,0,.2); }

/* The week view. */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
@media (max-width: 900px) { .cal { grid-template-columns: 1fr; } }
.cal__day { background: var(--paper); min-height: 150px; padding: 10px; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal__day:nth-child(7n) { border-right: 0; }
.cal--month .cal__day { min-height: 120px; }
.cal__day.is-other { opacity: .5; }
.cal__day.is-closed { background: var(--fog); }
.cal__day.is-today { box-shadow: inset 0 3px 0 var(--orange); }
.cal__head { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.cal__head b { display: block; font-size: 17px; color: var(--ink); font-family: var(--display); }
.cal__ev {
  display: block; border-radius: 7px; padding: 5px 7px; margin-bottom: 4px;
  font-size: 12.5px; color: #fff; text-decoration: none;
}
.cal__ev b { display: block; }
.cal__ev--out  { background: #1F4FA0; }
.cal__ev--back { background: #1B7447; }
.cal__ev--late { background: var(--red); }

/* ---------- A field that has something wrong with it ---------- */

.field__err {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--red, #c0392b);
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.field__err::before {
  content: '!';
  flex: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--red, #c0392b);
  color: #fff;
  font-size: 11px; font-weight: 700; line-height: 14px;
  text-align: center;
}
.field__err[hidden] { display: none; }

/* The field itself, so the eye finds it without reading. Both the border and
   the message: colour alone is not something everyone can see. */
.field.is-bad > .input,
.field.is-bad > .select,
.field.is-bad > .textarea,
.field.is-bad > .input-group > .input,
.input.is-bad, .select.is-bad, .textarea.is-bad {
  border-color: var(--red, #c0392b);
  background: #fffafa;
}
.field.is-bad > .input:focus,
.field.is-bad > .select:focus,
.field.is-bad > .textarea:focus {
  outline-color: var(--red, #c0392b);
}

/* ---------- The sidebar item that is open, and the one with children ---------- */
/* app.css styles .is-active, which is the design's class; the sidebar renders
   .is-on. Without this the rail never showed you which page you were on. */
.nav-item.is-on { background: var(--orange); color: #241200; font-weight: 600; }
.nav-item.is-on .nav-item__icon { color: #241200; }

/* "Pages" and its four screens: one item that opens, so the Storefront group
   is one decision rather than four siblings that were really one job. */
.nav-parent { display: block; }
.nav-item--parent {
  width: 100%; background: none; border: 0; font: inherit; cursor: pointer;
  text-align: left; font-size: 14.5px; color: #cdd8e6;
}
.nav-item__chev {
  margin-left: auto; font-size: 13px; color: #8fa3bb;
  transition: transform .14s var(--ease, ease);
}
.nav-parent.is-open .nav-item__chev { transform: rotate(180deg); }
.nav-sub { display: none; margin: 2px 0 4px 15px; padding-left: 9px;
           border-left: 1px solid rgba(255,255,255,.12); }
.nav-parent.is-open .nav-sub { display: block; }
.nav-item--child { font-size: 13.5px; padding: 7px 10px; }

body.rail-collapsed .nav-item__chev { display: none; }
body.rail-collapsed .nav-sub { margin-left: 0; padding-left: 0; border-left: 0; }

@media (prefers-reduced-motion: reduce) {
  .nav-item__chev { transition: none; }
}
