/* Design tokens and the base look of the shared components. Same origin only: the page may not reach the internet,
   so there is no font loading; the stack below falls through to the system font. */

:root {
  /* Colour: light grey ground, white cards, black text. Red is the accent only. */
  --accent: #BA0C2F;        /* fills with white text */
  --accent-text: #A30A29;   /* red text on white or the grey ground */
  --accent-hover: #9C0A27;
  --bg: #F5F5F6;
  --surface: #FFFFFF;
  --text: #16161A;
  --muted: #5F6068;
  --line: #D9D9DD;
  --focus: #1A5FD0;         /* keyboard focus ring */
  --ok: #1E7B45;
  --warn: #B26A00;

  /* Shape */
  --radius-field: 4px;
  --radius-button: 6px;
  --radius-card: 6px;

  /* Type */
  --font: "Source Sans 3", system-ui, sans-serif;
  --fs-small: 0.8125rem;    /* 13px, the smallest size used */
  --fs-base: 0.9375rem;     /* 15px */
  --fs-large: 1.25rem;

  /* Space and size */
  --gap: 12px;
  --tap: 36px;              /* minimum control height with a mouse; 44px on touch, see the end of the file */
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.4;
}

/* Keyboard focus is always visible. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
}

.muted { color: var(--muted); }
.error-text { color: var(--accent-text); }

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-button);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:not(:disabled):hover { background: var(--bg); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-quiet { border-color: transparent; background: transparent; }

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--gap); }
.field-label { font-weight: 600; }
.field-input {
  min-height: var(--tap);
  padding: 6px 10px;
  border: 1px solid var(--muted);
  border-radius: var(--radius-field);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.field-hint { color: var(--muted); font-size: var(--fs-small); }
.field-error { color: var(--accent-text); font-size: var(--fs-small); font-weight: 600; }
.field-input[aria-invalid="true"] { border-color: var(--accent-text); }

/* ---------- StatusDot ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.status-ok .status-dot { background: var(--ok); }
.status-warn .status-dot { background: var(--warn); }
.status-bad .status-dot { background: var(--accent); }

/* ---------- PinPad ---------- */
.pinpad { display: inline-flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; }
.pinpad-dots { display: flex; justify-content: center; gap: 10px; min-height: 24px; }
.pinpad-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pinpad-dot-on { background: var(--text); border-color: var(--text); }
.pinpad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad-key { min-height: 64px; font-size: var(--fs-large); }
.pinpad-enter { min-height: 56px; font-size: var(--fs-large); }

/* The sign-in variant (board V): 92 x 76 keys in a 3 x 4 grid, 12px apart; the bottom row is Clear, 0, Sign in. */
.pinpad-signin { width: auto; max-width: 100%; align-items: center; gap: 28px; }
.pinpad-signin .pinpad-dots { gap: 14px; min-height: 14px; }
.pinpad-signin .pinpad-dot { width: 14px; height: 14px; border: 1.5px solid #7E7F87; /* 3.66:1 on the ground */ }
.pinpad-signin .pinpad-dot-on { background: var(--text); border-color: var(--text); }
/* Columns are 92px but may shrink (a 320px phone has 288px for the pad), so nothing overflows. */
.pinpad-signin .pinpad-keys { grid-template-columns: repeat(3, minmax(0, 92px)); gap: 12px; max-width: 100%; }
.pinpad-signin .pinpad-key {
  width: 100%;
  height: 76px;
  min-height: 0;
  padding: 0;
  border-radius: 12px;
  font-size: 1.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pinpad-signin .pinpad-clear { font-size: var(--fs-base); color: var(--muted); }
.pinpad-signin .pinpad-enter { min-height: 0; font-size: 1.0625rem; font-weight: 700; }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(22, 22, 26, 0.55);
}
.dialog {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
}
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); }
.dialog-title { margin: 0; font-size: var(--fs-large); }

/* Text for screen readers only. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Touch screens: 16px typed text (no zoom into a field on iOS) and 44px tap targets. Keep this block last. */
@media (any-pointer: coarse) {
  input, select, textarea, .field-input { font-size: 16px; }
  .btn, .field-input, input, select, textarea { min-height: 44px; }
  .pinpad-key { min-height: 72px; }
}
