/* ---------------------------------------------------------------------------
 * app.css — the MediRest Web design system.
 *
 * Hand-rolled: Bootstrap is removed, not upgraded [B2]. Layout is CSS Grid and
 * Flexbox directly — no grid framework, no col-*-N classes
 * (weborder-revamp.md §2.3).
 *
 * Contents
 *   1  Reset and base
 *   2  Typography
 *   3  Layout primitives
 *   4  App header and navigation
 *   5  Cards, toolbars, notices
 *   6  Forms
 *   7  Buttons
 *   8  Data tables            (§2.4)
 *   9  Badges and indicators
 *  10  Async view states      (§2.5)
 *  11  Dialogs
 *  12  Order entry screen
 *  13  Login screen
 *  14  Desktop-only overlay   (§3)
 *  15  Utilities
 *  16  Small-viewport floor   [C5]
 *  17  Contact screen
 *
 * Every colour, font and space value comes from tokens.css. No hex literals
 * below this line (handoff.md §3.6).
 * ------------------------------------------------------------------------- */

/* == 1. Reset and base ==================================================== */

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

html {
  /* The mobile overlay is fixed-position; this stops the page behind it from
     rubber-banding on touch devices. */
  -webkit-text-size-adjust: 100%;
}

/* Flex column so .app-footer is pushed to the bottom of the viewport (via its
   own margin-top: auto below) on pages whose content is shorter than one
   screen, instead of sitting directly under a half-empty page. */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* One visible focus style for the whole application. Never `outline: none`
   (weborder-revamp.md §2.6) — keyboard users are the ones who need it, and
   this is a data-entry tool driven largely from the keyboard. */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

/* Skip link: first tab stop on every page, hidden until focused. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-12));
  z-index: calc(var(--z-header) + 1);
  padding: var(--space-2) var(--space-4);
  background: var(--color-brand);
  color: var(--color-text-invert);
  border-radius: var(--radius);
  font-family: var(--font-heading);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--space-4); }

/* == 2. Typography ======================================================== */

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-heading);
  color: var(--color-heading);
  line-height: var(--leading-tight);
  font-weight: 600;
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--color-brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--color-brand-hover); }

small, .text-sm { font-size: var(--text-sm); }
.text-muted { color: var(--color-text-muted); }

/* Tabular figures. Applied to every numeric context so columns of rupee
   amounts align vertically (weborder-revamp.md §2.2). */
.num,
.data-table td.num,
input[type="number"],
.stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* == 3. Layout primitives ================================================= */

.page {
  max-width: var(--page-max);
  margin-inline: auto;             /* centring is margin, not empty columns */
  padding: var(--space-6) var(--space-6) var(--space-12);
}
.page--wide { max-width: none; }
.page--narrow { max-width: 560px; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.page-header h1 { margin: 0; }
.page-header__meta { color: var(--color-text-muted); font-size: var(--text-sm); }

.stack   { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--tight { gap: var(--space-2); }
.row     { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.spacer  { flex: 1 1 auto; }

/* Two-column working layout: main grid + a sticky side panel. Collapses to one
   column below 1100px so the bypassed mobile view stays usable [C5]. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-5);
  align-items: start;
}
.split__aside { position: sticky; top: calc(var(--header-h) + var(--space-4)); }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split__aside { position: static; }
}

/* == 4. App header and navigation ========================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.app-header__inner {
  max-width: var(--page-max);
  margin-inline: auto;
  min-height: var(--header-h);
  padding: var(--space-2) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
}
.brand img { width: 36px; height: 36px; object-fit: contain; border-radius: var(--radius-sm); }

/* Cinzel appears here and nowhere else [C4]. */
.brand__mark {
  font-family: var(--font-brand);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--color-brand);
  line-height: 1;
}
.brand__company {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.app-nav { display: flex; gap: var(--space-1); flex-wrap: wrap; }

.app-nav a,
.app-nav span.nav-item {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text);
  border: 1px solid transparent;
  white-space: nowrap;
}
.app-nav a:hover { background: var(--color-brand-soft); color: var(--color-brand); }

/* The current page. aria-current="page" carries the same meaning for screen
   readers, so the styling hook and the semantics cannot drift apart. */
.app-nav a[aria-current="page"] {
  background: var(--color-brand);
  color: var(--color-text-invert);
  border-color: var(--color-brand);
}
.app-nav a[aria-current="page"]:hover { background: var(--color-brand-hover); color: var(--color-text-invert); }

.app-nav span.nav-item { color: var(--color-text-muted); cursor: not-allowed; }

.app-header__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  font-size: var(--text-sm);
}
.app-header__user .who { color: var(--color-text-muted); }
.app-header__user .who strong { color: var(--color-heading); font-family: var(--font-table); }

.app-header__credit {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.app-header__credit strong { color: var(--color-text); font-weight: 600; }
/* Only needed when there is no signed-in user block ahead of it to already
   carry the margin-left: auto that pushes this flush to the right edge. */
.app-header__credit--alone { margin-left: auto; }

.app-footer {
  /* Consumes the leftover space in the body flex column, so the footer sits
     at the viewport bottom on short pages instead of riding up under the
     content; on pages taller than the viewport this has no effect and the
     footer simply follows the content as normal. */
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  text-align: center;
}
.app-footer a { color: inherit; }

/* == 5. Cards, toolbars, notices ========================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}
.card--flush { padding: 0; overflow: hidden; }

.card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.card__header h2, .card__header h3 { margin: 0; }
.card__body { padding: var(--space-6); }
.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.toolbar {
  display: flex;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
}
.toolbar .field { margin: 0; }

/* Replaces the <marquee> announcements on the v0 login and home screens
   (weborder-revamp.md §2.3). Static, dismissible, readable. */
.notice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.notice--error   { border-left-color: var(--color-error);   background: var(--color-error-bg); }
.notice--success { border-left-color: var(--color-success); background: var(--color-success-bg); }
.notice--info    { border-left-color: var(--color-info);    background: var(--color-info-bg); }
.notice__close {
  margin-left: auto;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--text-md);
  line-height: 1;
  padding: 0 var(--space-1);
}

/* == 6. Forms ============================================================= */

.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field--grow { flex: 1 1 220px; min-width: 0; }

/* Real labels everywhere. v0 used placeholders as labels, which disappear on
   focus and are not announced by screen readers (weborder-revamp.md §2.6). */
label,
.field > label {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-heading);
}
.field__hint { font-size: var(--text-xs); color: var(--color-text-muted); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  font-family: var(--font-table);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  min-height: 40px;
  width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

input:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--color-muted); }

input:focus, select:focus, textarea:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-soft);
}

input:disabled, select:disabled, input[readonly] {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

input[aria-invalid="true"] { border-color: var(--color-error); }

/* Inline validation message beside the field, never alert()
   (weborder-revamp.md §2.6). */
.field__error {
  font-size: var(--text-xs);
  color: var(--color-error);
  min-height: 1em;
}

fieldset { border: 0; margin: 0; padding: 0; }
legend {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-heading);
  padding: 0 0 var(--space-2);
}

.radio-row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 400;
  font-family: var(--font-body);
  cursor: pointer;
}
.radio-row input { width: auto; min-height: 0; }

/* == 7. Buttons =========================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-2) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}

.btn:disabled,
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn--primary {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: var(--color-text-invert);
}
.btn--primary:not(:disabled):hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
  color: var(--color-text-invert);
}

.btn--secondary { border-color: var(--color-border-strong); color: var(--color-heading); }
.btn--secondary:not(:disabled):hover { background: var(--color-brand-soft); color: var(--color-brand); }

.btn--ghost { border-color: transparent; color: var(--color-brand); background: transparent; }
.btn--ghost:not(:disabled):hover { background: var(--color-brand-soft); }

.btn--danger { border-color: var(--color-error); color: var(--color-error); background: var(--color-surface); }
.btn--danger:not(:disabled):hover { background: var(--color-error-bg); }

.btn--lg { min-height: 48px; font-size: var(--text-base); padding-inline: var(--space-6); }
.btn--sm { min-height: 32px; font-size: var(--text-xs); padding-inline: var(--space-3); }
.btn--block { width: 100%; }

/* Busy state: the button reports work in progress rather than looking dead. */
.btn[data-busy="true"] { position: relative; color: transparent !important; }
.btn[data-busy="true"]::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--color-text-invert);
  animation: spin .7s linear infinite;
}
.btn--secondary[data-busy="true"]::after,
.btn--ghost[data-busy="true"]::after { color: var(--color-brand); }

@keyframes spin { to { transform: rotate(360deg); } }

/* == 8. Data tables ======================================================= *
 * v0 set `display: block` on thead/tbody — which removes them from the table
 * layout algorithm, which is why every cell then needed a hardcoded 300px to
 * line up, and why the header drifted the moment content differed. It also set
 * tbody height to 0 until JS set it to 400px, so tables were invisible before
 * data arrived. None of that is reproduced (weborder-revamp.md §2.4).        */

.table-scroll {
  max-height: 65vh;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}
.table-scroll--tall { max-height: 72vh; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-table);
  font-size: var(--text-sm);
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface);
  border-bottom: 2px solid var(--color-brand);
  padding: var(--space-3);
  text-align: left;
  font-weight: 600;
  color: var(--color-heading);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tbody tr:nth-child(even) { background: var(--color-bg); }
.data-table tbody tr:hover { background: var(--color-brand-soft); }

/* Numeric columns right-aligned with tabular figures; text left. Never centre
   numbers (weborder-revamp.md §2.4). */
.data-table th.num,
.data-table td.num { text-align: right; }

.data-table .col-name { min-width: 220px; }
.data-table .col-code { min-width: 90px; font-family: var(--font-mono); font-size: var(--text-xs); }
.data-table .nowrap { white-space: nowrap; }

.data-table tfoot td {
  border-top: 2px solid var(--color-border-strong);
  font-weight: 600;
  background: var(--color-surface-alt);
}

/* == 9. Badges and indicators ============================================= */

.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

/* Order lifecycle [A7]. The data attribute is the status letter as stored, so
   markup and database agree without a translation table in CSS. */
.badge[data-status="U"] { color: var(--color-status-u); background: var(--color-status-u-bg); }
.badge[data-status="P"] { color: var(--color-status-p); background: var(--color-status-p-bg); }
.badge[data-status="Y"] { color: var(--color-status-y); background: var(--color-status-y-bg); }
.badge[data-status="C"] { color: var(--color-status-c); background: var(--color-status-c-bg); }

/* Stock availability. v0 rendered these as disabled buttons with the text
   "aaaaa" coloured to match the background — a dot with a text label is both
   legible and announced. */
.avail { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }
.avail__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--color-avail-none);
  flex: 0 0 auto;
}
.avail[data-avail="G"] .avail__dot { background: var(--color-avail-g); }
.avail[data-avail="Y"] .avail__dot { background: var(--color-avail-y); }
.avail[data-avail="R"] .avail__dot { background: var(--color-avail-r); }
.avail__label { font-size: var(--text-xs); color: var(--color-text-muted); }

/* == 10. Async view states =============================================== *
 * Every async view implements four explicit states. v0 showed a hardcoded
 * "No Orders present..." before any search had run — asserting there were no
 * orders before it had looked (weborder-revamp.md §2.5).                    */

.view-state { display: none; padding: var(--space-8) var(--space-6); text-align: center; }
.view-state__title {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: var(--space-1);
}
.view-state__body { color: var(--color-text-muted); font-size: var(--text-sm); }
.view-state__actions { margin-top: var(--space-4); }

/* A [data-state] on the container decides which child is visible, so a view
   can never show two states at once. */
[data-state="idle"]    .view-state--idle,
[data-state="empty"]   .view-state--empty,
[data-state="error"]   .view-state--error,
[data-state="loading"] .view-state--loading { display: block; }

[data-state="idle"]    .view-results,
[data-state="empty"]   .view-results,
[data-state="error"]   .view-results { display: none; }

[data-state="loading"] .view-results { opacity: .4; pointer-events: none; }

/* Skeleton rows, shown in place of the table body while a request is in
   flight. Layout-stable: the same height as real rows, so nothing jumps. */
.skeleton-rows { padding: var(--space-3); }
.skeleton-row {
  height: 20px;
  margin-bottom: var(--space-3);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--color-surface-alt) 25%,
    var(--color-border) 37%,
    var(--color-surface-alt) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-row:last-child { margin-bottom: 0; }

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
  .btn[data-busy="true"]::after { animation: none; }
}

/* == 11. Dialogs ========================================================= *
 * Native <dialog>: focus trapping, Escape to close and the backdrop come from
 * the browser rather than from a JS modal library [B7].                     */

dialog.dialog {
  width: min(1200px, 94vw);
  max-height: 88vh;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--color-surface);
  color: var(--color-text);
  overflow: hidden;
}
dialog.dialog::backdrop { background: rgba(26, 26, 26, .45); }

.dialog__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}
.dialog__header h2 { margin: 0; }
.dialog__body { padding: var(--space-4) var(--space-6); overflow: auto; max-height: 60vh; }
.dialog__footer {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}
.dialog__close {
  margin-left: auto;
  background: none;
  border: 0;
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
}

/* Key/value strip used in the invoice dialog header. */
.kv { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.kv__item { display: flex; flex-direction: column; }
.kv__key { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kv__val { font-family: var(--font-table); font-weight: 600; font-variant-numeric: tabular-nums; }

/* == 12. Order entry screen ============================================== */

/* The line-entry strip: barcode / item / qty / read-only computed fields.
   Grid, not eleven Bootstrap columns of fixed-width inputs. */
.entry-grid {
  display: grid;
  grid-template-columns:
    minmax(130px, .9fr)   /* barcode */
    minmax(220px, 2fr)    /* item name */
    minmax(80px, .5fr)    /* qty */
    minmax(70px, .5fr)    /* pack */
    minmax(140px, 1fr)    /* manufacturer */
    minmax(90px, .6fr)    /* mrp */
    minmax(100px, .7fr)   /* amount */
    minmax(110px, .7fr)   /* availability */
    minmax(70px, .5fr)    /* gst */
    auto;                 /* add button */
  gap: var(--space-3);
  align-items: end;
}
.entry-grid .computed {
  font-family: var(--font-table);
  font-variant-numeric: tabular-nums;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-alt);
  color: var(--color-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-grid .computed.num { justify-content: flex-end; }

@media (max-width: 1560px) {
  .entry-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .entry-grid .entry-add { grid-column: 1 / -1; }
}

/* Typeahead results, built with createElement and textContent in order.js —
   never innerHTML (weborder-revamp.md §4.5). */
.typeahead { position: relative; }
.typeahead__list {
  position: absolute;
  z-index: 20;
  left: 0; right: 0; top: calc(100% + 2px);
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  max-height: 320px;
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.typeahead__list[hidden] { display: none; }
.typeahead__option {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-table);
  font-size: var(--text-sm);
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
}
.typeahead__option[aria-selected="true"],
.typeahead__option:hover { background: var(--color-brand-soft); }
.typeahead__name { flex: 1 1 auto; font-weight: 600; color: var(--color-heading); }
.typeahead__meta { color: var(--color-text-muted); font-size: var(--text-xs); white-space: nowrap; }
.typeahead__empty { padding: var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm); }

/* Cart summary panel. */
.summary { display: flex; flex-direction: column; gap: var(--space-2); }
.summary__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-2) 0;
  border-bottom: 1px dashed var(--color-border);
  font-size: var(--text-sm);
}
.summary__row:last-of-type { border-bottom: 0; }
.summary__row--total { font-size: var(--text-md); font-weight: 700; color: var(--color-heading); }
.stat-value { font-family: var(--font-table); font-weight: 600; }

.customer-card dt { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .04em; }
.customer-card dd { margin: 0 0 var(--space-2); font-family: var(--font-table); }

/* == 13. Login screen ==================================================== */

.auth-layout {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: var(--space-10);
  align-items: center;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-10) var(--space-6);
}
.auth-intro h1 { font-size: var(--text-2xl); }
.auth-intro__lede { font-size: var(--text-md); color: var(--color-text-muted); max-width: 52ch; }
.auth-links { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-6); }

@media (max-width: 900px) {
  .auth-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
}

/* == 14. Desktop-only overlay [A3], [C5] ================================= *
 * CSS-first: shown by a media query, so it appears even if JavaScript is slow
 * or blocked — no flash of an unusable desktop layout. The bypass button adds
 * .mobile-ack to <html>, which hides it (weborder-revamp.md §3).            */

.desktop-notice { display: none; }

@media (max-width: 900px) {
  html:not(.mobile-ack) .desktop-notice {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    padding: var(--space-8) var(--space-6);
    background: var(--color-bg);
    text-align: center;
    overflow: auto;
  }
  /* Stop the page behind the overlay scrolling under it. */
  html:not(.mobile-ack) body { overflow: hidden; }
}

.desktop-notice__brand {
  font-family: var(--font-brand);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--color-brand);
}
.desktop-notice h1 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  margin: 0;
}
.desktop-notice p {
  font-family: var(--font-body);
  color: var(--color-text);
  max-width: 46ch;
  margin: 0;
}

/* == 15. Utilities ======================================================= */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.mt-0 { margin-top: 0; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* == 16. Small-viewport floor [C5] ======================================= *
 * The bypassed mobile view is graceful degradation, not a responsive design:
 * no horizontal page scroll, 44px tap targets, tables scroll inside their own
 * container, forms operable. No card-collapse patterns, no redesign.        */

@media (max-width: 900px) {
  body { overflow-x: hidden; }

  .page { padding: var(--space-4) var(--space-4) var(--space-10); }

  .app-header__inner { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) var(--space-4); }
  .app-nav { width: 100%; overflow-x: auto; padding-bottom: var(--space-1); }
  .app-header__user { margin-left: 0; }
  .app-header__credit--alone { margin-left: 0; }

  .btn, .app-nav a, .app-nav span.nav-item { min-height: 44px; }
  input, select { min-height: 44px; }

  .card, .card__body, .card__header, .card__footer { padding: var(--space-4); }
  .table-scroll { max-height: 60vh; }
  .entry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { gap: var(--space-4); }
  dialog.dialog { width: 96vw; }
  .dialog__body { padding: var(--space-3); }
}

/* == 17. Contact screen =================================================== */

.contact-intro {
  display: flex;
  align-items: flex-start;
  gap: var(--space-6);
  flex-wrap: wrap;
}
.contact-intro__logo { width: 96px; height: 96px; object-fit: contain; border-radius: var(--radius); }
.contact-intro h2 { margin-bottom: var(--space-2); }
