/* Terminal app shell — minimal, no admin sidebar (F4) */

body.terminal-app {
  /* follows the app theme (light by default, dark when the app is dark) */
  --term-bg: var(--bg);
  --term-surface: var(--surface);
  --term-text: var(--text);
  --term-muted: var(--muted);
  --term-accent: var(--primary-text, var(--primary));
  --term-danger: var(--danger);
  --term-warn: #B7791F;
  background: var(--bg);
  color: var(--text);
}
[data-theme="dark"] body.terminal-app { --term-warn: var(--accent, #EACC08); }
body.terminal-app .term-switch { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

body.terminal-app .term-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 1rem 1rem 2rem;
}

.term-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.term-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.term-header .term-muted { color: var(--term-muted); font-size: 0.85rem; }

.term-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.term-tab {
  flex: 1;
  appearance: none;
  border: 1px solid transparent;
  background: var(--term-surface);
  color: var(--term-muted);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem;
  border-radius: 8px;
  cursor: pointer;
}
.term-tab[aria-selected="true"] {
  color: var(--term-text);
  border-color: var(--term-accent);
}

.term-row {
  background: var(--term-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.65rem;
}
.term-row-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.term-code { font-weight: 700; letter-spacing: 0.02em; }
.term-amount { font-weight: 700; color: var(--term-accent); }
.term-meta { color: var(--term-muted); font-size: 0.8rem; }
.term-claimed {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--ok-bg, rgba(23, 93, 49, 0.12));
  color: var(--term-accent);
  margin-left: 0.35rem;
}
.term-countdown {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  color: var(--term-warn);
}
.term-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}
.term-actions .btn { font-size: 0.85rem; }

.term-empty {
  text-align: center;
  color: var(--term-muted);
  padding: 2rem 1rem;
}

.term-access-ended {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--term-danger);
}

/* Owner on the Terminal: switcher + way back to the app */
.term-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.term-owner-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.term-switch { min-height: 2rem; border-radius: 8px; padding: 0 0.5rem; max-width: 12rem; }

/* Queue sections, alerts, badge (build 174) */
.term-head-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.term-section { margin-bottom: 1rem; }
.term-section-title { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.02em; color: var(--term-muted); }
.term-count { font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--term-surface); color: var(--term-text); }
.term-section-guest_claimed .term-section-title { color: var(--term-accent); }
.term-stage-guest_claimed { border-left: 4px solid var(--term-accent); }
.term-stage-awaiting_payment { border-left: 4px solid var(--term-warn); }
.term-stage-pending { border-left: 4px solid var(--term-muted); opacity: 0.92; }
.term-badge { display: inline-block; min-width: 1.25rem; padding: 0 0.4rem; margin-left: 0.25rem; border-radius: 999px; font-size: 0.75rem; line-height: 1.25rem; background: var(--term-muted); color: var(--term-bg); }
.term-badge.urgent { background: var(--term-accent); }
.term-badge.hidden, .term-alert.hidden { display: none; }
.term-alert { margin-bottom: 0.75rem; padding: 0.65rem 0.85rem; border-radius: 8px; background: var(--term-surface); border: 1px solid var(--term-warn); font-weight: 600; }
.term-alert.urgent { border-color: var(--term-accent); }

/* Build 213: breakdown line and the Expired group (kept apart from live items) */
.term-breakdown { opacity: .85; font-size: .85em; }
.term-section-expired .term-section-title { color: var(--term-muted, #8a93a6); }
.term-stage-expired { border-left: 4px solid var(--term-muted, #6b7385); opacity: .8; }

/* Build 222: the check box that drops down under "Match this order" */
.term-match { margin-top: 0.6rem; padding: 0.6rem 0.75rem; border: 1px dashed var(--term-warn); border-radius: 8px; display: flex; flex-direction: column; gap: 0.6rem; }
.term-match-check { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; line-height: 1.3; cursor: pointer; }
.term-match-check input { width: 1.15rem; height: 1.15rem; margin-top: 0.1rem; flex: none; }
.term-match .btn { align-self: flex-start; }
.term-match .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Build 226: the terminal's own bottom nav (Home, Orders, Bookings), Home tiles, Sign out */
body.terminal-app [hidden] { display: none !important; }
body.terminal-app .term-shell { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
.term-tiles.term-tiles-3 { grid-template-columns: repeat(3, 1fr); }
.term-home-who { margin-bottom: 0.75rem; }
.term-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin-bottom: 1rem; }
.term-tile { background: var(--term-surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.85rem 1rem; }
.term-tile.urgent { border-left: 4px solid var(--term-accent); }
.term-tile-n { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.term-tile-l { color: var(--term-muted); font-size: 0.8rem; }
.term-tiles .term-empty { grid-column: 1 / -1; padding: 0.5rem; }

/* build 275: owner's Me = the JekkaPay panel */
.term-me { padding: 0.75rem 0 1rem; }

/* build 294: Supported payments (icon grid) + Payment methods list, inside the JekkaPay panel */
.pay-h { margin: 1.25rem 0 0.25rem; font-size: 1rem; }
.pay-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin: 0.6rem 0 0; }
.pay-tile { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.9rem 0.5rem; text-align: center; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-height: 44px; }
.pay-tile:hover, .pay-tile:focus-visible { border-color: var(--primary); outline: none; }
.pay-tile svg.i { width: 30px; height: 30px; color: var(--primary-text, var(--primary)); }
.pay-tile-name { font-weight: 700; font-size: 0.95rem; }
.pay-method { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.pay-method:last-child { border-bottom: none; }
.pay-method svg.i { width: 24px; height: 24px; flex: none; color: var(--primary-text, var(--primary)); }
.pay-method-main { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pay-cfg-head { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.5rem; }
.pay-cfg-head svg.i { width: 28px; height: 28px; color: var(--primary-text, var(--primary)); }

/* Build 319: Me is a profile icon (top left); Exit is the only bottom-nav item; Transactions opens from the Dashboard */
.term-head-left { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.term-icon-btn { position: relative; flex: none; width: 2.5rem; height: 2.5rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 50%; background: var(--term-surface); color: var(--term-text); text-decoration: none; cursor: pointer; }
.term-icon-btn .i { width: 20px; height: 20px; }
.term-icon-btn:focus-visible { outline: 2px solid var(--term-accent); outline-offset: 2px; }
.term-icon-back .i { transform: rotate(180deg); }
.term-icon-btn .term-badge { position: absolute; top: -0.25rem; right: -0.25rem; margin: 0; min-width: 1rem; line-height: 1rem; font-size: 0.65rem; text-align: center; }
.term-quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; margin: 0 0 1rem; }
.term-quick { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; margin: 0 0 1rem; }
.term-quick-grid .term-quick { margin: 0; }
/* Build 346: Statement (Money In) */
.term-stmt { margin: 0 0 1.25rem; }
.term-stmt-total { font-size: 1.8rem; font-weight: 800; margin: 0.15rem 0 0.6rem; }
.term-stmt-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--border); margin: 0 0 0.75rem; }
.term-stmt-bar i.bank, .dot.bank { background: var(--term-accent, #175D31); }
.term-stmt-bar i.cash, .dot.cash { background: #EACC08; }
.term-stmt-split { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
.term-stmt-split > div { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: 12px; background: var(--term-surface); }
.term-stmt-l { font-size: 0.78rem; display: flex; align-items: center; gap: 0.35rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.term-quick .i { width: 18px; height: 18px; }
.term-quick .term-badge { margin: 0; }
.term-txn-bar { margin: 0 0 0.75rem; }
.term-txn-bar[hidden] { display: none; }

/* Build 321: Me (profile icon) at the far right; JekkaPay icon top left (owner) opens POS Terminals */
.term-head-actions { margin-left: auto; }   /* the group, and so the profile icon last in it, stays at the far right even when it wraps */
.term-icon-mm img.mm-mark { display: block; width: 24px; height: 24px; margin: 0; vertical-align: baseline; }
.term-icon-btn[aria-current="page"] { border-color: var(--term-accent); color: var(--term-accent); }

/* POS Terminals: one plain list on its own page (no card around it) */
.pos-title { margin: 0 0 0.75rem; font-size: 1.15rem; }
.pos-rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--term-surface); }
.pos-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; flex-wrap: wrap; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
.pos-row:last-child { border-bottom: 0; }
.pos-row.is-retired { opacity: 0.6; }
.pos-main { flex: 1 1 11rem; min-width: 0; }
.pos-name { overflow-wrap: anywhere; }
.pos-code { color: var(--term-muted); font-size: 0.85rem; margin-left: 0.25rem; }
.pos-sub { font-size: 0.8rem; margin-top: 0.15rem; }
.pos-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-left: auto; }
.pos-retire { position: relative; display: inline-flex; align-items: center; gap: 0.45rem; min-height: 44px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.pos-retire.is-locked { opacity: 0.45; cursor: not-allowed; }
.pos-switch { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }   /* the real checkbox stays focusable; .pos-switch-ui is what you see */
.pos-switch-ui { position: relative; flex: none; width: 2.5rem; height: 1.5rem; border-radius: 999px; background: var(--term-muted); transition: background 0.15s; }
.pos-switch-ui::after { content: ""; position: absolute; top: 0.2rem; left: 0.2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--term-bg, #fff); transition: transform 0.15s; }
.pos-switch:checked + .pos-switch-ui { background: var(--term-danger); }
.pos-switch:checked + .pos-switch-ui::after { transform: translateX(1rem); }
.pos-switch:focus-visible + .pos-switch-ui { outline: 2px solid var(--term-accent); outline-offset: 2px; }
.pos-add { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin-top: 1rem; }
@media (prefers-reduced-motion: reduce) { .pos-switch-ui, .pos-switch-ui::after { transition: none; } }

/* Terminal settings: Operators are a read-only list (name + Staff ID) */
.op-list { list-style: none; margin: 0; padding: 0; }
.op-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.op-row:last-child { border-bottom: 0; }
.op-name { font-weight: 600; overflow-wrap: anywhere; }
.op-id { color: var(--term-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-default { margin-top: 0.75rem; }

/* Build 322: tapping the title opens a switcher between this app's terminals (.hd-*, shared by JekkaPay terminal and JekkaGO) */
.hd-title-wrap { position: relative; min-width: 0; }
.hd-title { display: block; min-width: 0; margin: -0.2rem -0.35rem; padding: 0.2rem 0.35rem; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.hd-title:hover, .hd-title:focus-visible { background: var(--chip-bg, rgba(127, 127, 127, 0.12)); }
.hd-title:focus-visible { outline: 2px solid var(--primary, #175D31); outline-offset: 1px; }
.hd-title.is-static { cursor: default; }
.hd-name { display: flex; align-items: center; gap: 0.4rem; font-size: 1.15rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.hd-caret { flex: none; width: 0.4rem; height: 0.4rem; margin-top: -0.2rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); opacity: 0.7; }
.hd-sub { display: block; color: var(--term-muted, var(--muted, #6b7280)); font-size: 0.85rem; font-weight: 400; }
.hd-menu { position: absolute; top: calc(100% + 0.4rem); left: 0; z-index: 30; min-width: 15rem; max-width: min(21rem, 86vw); padding: 0.35rem; border: 1px solid var(--border, #e5e2d9); border-radius: 12px; background: var(--surface, #fff); color: var(--text, #111); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2); }
.hd-menu[hidden] { display: none; }
.hd-menu-label { padding: 0.35rem 0.6rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted, #6b7280); }
.hd-item { display: flex; align-items: stretch; gap: 0.2rem; }
.hd-pick { flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; padding: 0.4rem 0.6rem; border-radius: 8px; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.hd-item.is-current .hd-pick { font-weight: 700; color: var(--primary-text, var(--primary, #175D31)); }
.hd-gear { flex: none; width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted, #6b7280); text-decoration: none; }
.hd-gear .i { width: 18px; height: 18px; }
.hd-pick:hover, .hd-gear:hover, .hd-manage:hover, .hd-pick:focus-visible, .hd-gear:focus-visible, .hd-manage:focus-visible { background: var(--chip-bg, rgba(127, 127, 127, 0.14)); outline: none; }
.hd-manage { display: flex; align-items: center; min-height: 44px; margin-top: 0.25rem; padding: 0.4rem 0.6rem; border-top: 1px solid var(--border, #e5e2d9); border-radius: 0 0 8px 8px; color: var(--primary-text, var(--primary, #175D31)); font-weight: 600; text-decoration: none; }

/* Build 326: Terminal PIN area (shared by POS Terminal settings and JekkaGO): status, length, a tidy 2-column button grid, Retire apart at the bottom */
.pin-status { margin: 0 0 0.75rem; font-weight: 600; }
.pin-note { margin: 0.75rem 0 0; font-size: 0.85rem; }
.pin-len { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--border, #e5e2d9); }
.pin-len label { font-size: 0.9rem; }
.pin-len select { min-height: 40px; min-width: 7.5rem; }
.pin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }
.pin-actions .btn { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; margin: 0; }
.pin-actions .pin-wide { grid-column: 1 / -1; }
.pin-own { display: grid; gap: 0.5rem; margin-top: 0.75rem; padding: 0.75rem; border: 1px solid var(--border, #e5e2d9); border-radius: 12px; }
.pin-own input { width: 100%; min-height: 44px; }
.pin-own .pin-actions { margin-top: 0; }
.pin-danger { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border, #e5e2d9); font-size: 0.9rem; }
.pin-retire { min-height: 40px; color: var(--term-danger, #b42318); border-color: currentColor; }
@media (max-width: 360px) { .pin-actions { grid-template-columns: 1fr; } }

/* Build 327: Operators live inside the Terminal card, under "Terminal is on" */
.ts-operators { margin: 0.75rem 0 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border, #e5e2d9); }
.ts-sub { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 700; }

/* Build 328: Sound and Reload belong to each terminal card */
.pos-card-tools { flex: 1 1 100%; display: flex; align-items: center; gap: 0.5rem; padding-top: 0.6rem; border-top: 1px solid var(--border, #e5e2d9); }

/* Build 329: login approval per operator */
.op-row { flex-wrap: wrap; gap: 0.4rem 0.75rem; }
.op-appr { margin-left: auto; min-height: 36px; }

/* Build 330: Online pill (replaces the constant busy blip); a slow, soft fade, steady when offline */
.term-online { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border-radius: 999px; border: 1px solid var(--border, #e5e2d9); font-size: 0.75rem; color: var(--term-muted, var(--muted, #6b7280)); white-space: nowrap; }
.term-online i { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #1f9d55; animation: term-online-fade 4s ease-in-out infinite; }
.term-online[data-state="off"] i { background: #9ca3af; animation: none; }
@keyframes term-online-fade { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .term-online i { animation: none; } }


/* Build 333: Show retired row in the title switcher, retired terminals dimmed */
.hd-item.is-retired { opacity: 0.55; }
.hd-retired { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.4rem 0.6rem; font-size: 0.9rem; cursor: pointer; }

/* Build 337: header Back is hidden until Transactions is open */
.term-icon-btn[hidden] { display: none; }

/* Build 349: Account + Exit live in the title menu (no bottom nav) */
.hd-account { margin-top: 0.25rem; padding-top: 0.25rem; border-top: 1px solid var(--border, #e5e2d9); }
.hd-menu .hd-account:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.hd-row { appearance: none; width: 100%; min-height: 44px; display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border: 0; border-radius: 8px; background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.hd-row .i { width: 18px; height: 18px; color: var(--muted, #6b7280); }
.hd-row:hover, .hd-row:focus-visible { background: var(--chip-bg, rgba(127, 127, 127, 0.14)); outline: none; }
.hd-badge { flex: none; min-width: 1rem; padding: 0 0.3rem; border-radius: 999px; background: var(--danger, #b91c1c); color: #fff; font-size: 0.65rem; font-weight: 700; line-height: 1rem; text-align: center; }
.hd-badge.hidden { display: none; }
