/* ============================================================
   Components — buttons, inputs, nav, cards, tables, modal,
   toast, badges, segmented, chips, login
   ============================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 0 var(--s4); height: 42px; min-width: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-base); font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .ic { width: 18px; height: 18px; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn.warn { background: var(--warn-weak); border-color: transparent; color: var(--warn); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { height: 34px; padding: 0 var(--s3); font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn.big { height: 52px; font-size: var(--fs-lg); border-radius: var(--r); }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Inputs ---------- */
input[type=text], input[type=search], input[type=number], input[type=password],
input[type=date], input[inputmode], select, textarea {
  width: 100%; height: 42px; padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea { height: auto; padding: var(--s3); resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
input::placeholder { color: var(--text-3); }
select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--s3) center; padding-right: var(--s7); }

label.fld, label.field { display: flex; flex-direction: column; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
label.fld > input, label.fld > select, label.field > input, label.field > select { font-weight: 400; color: var(--text); }
label.check { display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.req { color: var(--danger); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding: var(--s3) var(--s4); }
.toolbar input[type=search], .toolbar input[type=text] { width: auto; min-width: 180px; flex: 0 1 240px; }
.toolbar input[type=date] { width: auto; }
.toolbar select { width: auto; min-width: 180px; flex: 0 1 260px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow-1);
}
.kpi { display: flex; flex-direction: column; gap: var(--s1); }
.kpi .card-label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; }
.kpi .card-value { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3);
  padding: 0 var(--s4) var(--s4); }

.panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow-1); }
.panel-title { font-size: var(--fs-md); margin-bottom: var(--s3); }
.panel h3 { margin-bottom: var(--s3); }

/* ---------- Tables ---------- */
.table-wrap { padding: 0 var(--s4) var(--s4); }
table thead th {
  text-align: left; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2);
  padding: var(--s3); border-bottom: 2px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table tbody td { padding: var(--s3); border-bottom: 1px solid var(--border); font-size: var(--fs-base); }
.data-table, #productTable, #salesTable { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-1); }
tr.clickable { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
tr.clickable:hover { background: var(--accent-weak); }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px;
  background: var(--accent-weak); }
.row-btns { display: flex; gap: var(--s2); justify-content: flex-end; }
.stock-low { color: var(--danger); font-weight: 700; }

/* Loading / empty states */
.state-empty, .state-loading { padding: var(--s7); text-align: center; color: var(--text-2); }
.state-loading { display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.spinner { width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-xs); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Badges / tags / pills ---------- */
.badge { display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-xs); font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; }
.tag.completed { background: var(--success-weak); color: var(--success); }
.tag.refunded  { background: var(--danger-weak);  color: var(--danger); }
.tag.inactive  { background: var(--surface-3); color: var(--text-3); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
  border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 700; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.open { background: var(--success-weak); color: var(--success); }
.pill.closed { background: var(--warn-weak); color: var(--warn); }
.pos { color: var(--success); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-3);
  border-radius: var(--r-sm); }
.seg-btn { border: none; background: transparent; color: var(--text-2);
  padding: 7px 16px; border-radius: var(--r-xs); font-weight: 600; font-size: var(--fs-sm);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* ---------- Chips ---------- */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: var(--r-full); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  transition: all var(--dur-fast) var(--ease); }
.chip:hover { border-color: var(--accent-border); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Modal (stack-aware) ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center; padding: var(--s4);
  background: rgba(16, 24, 40, .55);
  backdrop-filter: blur(3px);
  animation: fade var(--dur) var(--ease);
}
:root[data-theme="dark"] .modal-back { background: rgba(0, 0, 0, .66); }
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(520px, 100%); max-height: 90dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: var(--s6); display: flex; flex-direction: column; gap: var(--s4);
  animation: pop var(--dur) var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal.wide { width: min(720px, 100%); }
.modal h2 { font-size: var(--fs-xl); }
.modal > label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm);
  font-weight: 600; color: var(--text-2); }
.modal > label > input, .modal > label > select { font-weight: 400; color: var(--text); }
.modal-actions { display: flex; gap: var(--s3); justify-content: flex-end; margin-top: var(--s2); }
.modal-actions .spacer { flex: 1; }
.confirm-message { color: var(--text-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: var(--s6); transform: translateX(-50%);
  z-index: var(--z-toast); max-width: 90vw;
  background: var(--text); color: var(--bg);
  padding: var(--s3) var(--s5); border-radius: var(--r-full);
  font-weight: 600; box-shadow: var(--shadow-3);
  animation: toast-in var(--dur) var(--ease-out);
}
.toast.error { background: var(--danger); color: var(--on-danger); }
.toast.success { background: var(--success); color: var(--on-success); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- Status bar items ----------
   Navigation, brand and account now live in the rail (shell.css);
   only state indicators remain here. */
#clock { font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums;
  white-space: nowrap; }
.store-switch { width: auto; height: 40px; max-width: 180px; }
.lang-switch { width: auto; height: 40px; max-width: 190px; }

/* Shift status pill in the header */
.shift-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 700; cursor: pointer;
  border: 1px solid transparent; transition: filter var(--dur-fast) var(--ease); }
.shift-chip:hover { filter: brightness(.97); }
.shift-chip.open { background: var(--success-weak); color: var(--success); }
.shift-chip.closed { background: var(--warn-weak); color: var(--warn); }
.shift-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Scanner status */
.scan-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm);
  color: var(--text-2); white-space: nowrap; }
.scan-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.scan-status.offline .dot { background: var(--text-3); }
.scan-status.flash { color: var(--success); }
.scan-status.flash .dot { background: var(--success); box-shadow: 0 0 0 4px var(--success-weak); }
.scan-status .ic { width: 16px; height: 16px; }

.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] .only-light { display: none; }

/* Theme toggle icon color */
#themeToggle .ic { width: 20px; height: 20px; }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: block; }
main.view { padding-top: var(--s3); }

/* keyboard hint row */
.kbd-hints { font-size: var(--fs-xs); color: var(--text-3); display: flex; flex-wrap: wrap;
  gap: 6px 10px; align-items: center; }
.kbd-hints .kbd-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
/* Each shortcut stays glued to its label, so a narrow cart never strands a key
   cap on one line and the word it explains on the next. */
.kbd-hints .kbd-pair { white-space: nowrap; }
.kbd-hints .kbd-pair + .kbd-pair::before { content: "·"; margin-inline-end: 8px; color: var(--text-3); }
kbd { display: inline-block; padding: 1px 6px; border-radius: var(--r-xs);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  font-family: var(--mono); font-size: 11px; color: var(--text-2); }
/* Shortcut printed on the control it triggers, so paying announces its own key. */
kbd.on-btn { margin-inline-start: var(--s2); border-color: currentColor; background: none;
  color: inherit; opacity: 0.75; font-size: 11px; }
.btn:disabled kbd.on-btn { opacity: 0.5; }

/* ---------- Login ---------- */
.login-screen { position: fixed; inset: 0; z-index: 150; display: flex;
  align-items: center; justify-content: center; padding: var(--s4);
  background: radial-gradient(120% 120% at 50% 0%, var(--accent-weak), var(--bg) 60%); }
.login-card { width: min(380px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: var(--s7); display: flex; flex-direction: column; gap: var(--s4); }
.login-brand { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-2xl);
  font-weight: 800; letter-spacing: -.02em; }
.login-sub { color: var(--text-2); margin-top: calc(var(--s3) * -1); }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm);
  font-weight: 600; color: var(--text-2); }
.login-field input { height: 48px; font-size: var(--fs-md); }
.login-error { background: var(--danger-weak); color: var(--danger); padding: var(--s3);
  border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600; }

/* ---------- Charts ---------- */
.chart { width: 100%; max-width: 760px; height: auto; display: block; }
.chart .bar { transition: opacity var(--dur-fast) var(--ease); }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--fs-sm);
  color: var(--text-2); margin-top: var(--s2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- sync indicator ----------
   Sits beside the scanner chip: both report whether something the shop depends
   on is currently working. Colour carries the same meaning as everywhere else in
   the app, and offline is deliberately neutral rather than red — for this
   product, offline is a normal state, not a fault. */
.sync-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm);
  color: var(--text-2); white-space: nowrap; }
.sync-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.sync-status.ok .dot { background: var(--success); }
.sync-status.pending .dot { background: var(--warn); }
.sync-status.offline .dot { background: var(--text-3); }
.sync-status.err .dot { background: var(--danger); }
.sync-status.unknown .dot { background: var(--text-3); }
.sync-status.err { color: var(--danger); }

/* A queue that is draining should read as activity, not alarm. */
@media (prefers-reduced-motion: no-preference) {
  .sync-status.pending .dot { animation: sync-pulse 1.8s var(--ease) infinite; }
}
@keyframes sync-pulse { 50% { opacity: .35; } }

/* ---------- hub view ----------
   Status pills reuse the existing .tag component rather than redefining .badge,
   which is the cart's item counter and would have been restyled app-wide. */
.tag.ok   { background: var(--success-weak); color: var(--success); }
.tag.warn { background: var(--warn-weak);    color: var(--warn); }
.tag.err  { background: var(--danger-weak);  color: var(--danger); }

tr.revoked { opacity: .55; }

/* The token is shown exactly once, so it needs to be unmissable and easy to
   select — not a toast that disappears while the operator reaches for a pen. */
.token-result { margin: var(--s3) 0; padding: var(--s3) var(--s4);
  background: var(--warn-weak); border: 1px solid var(--warn); border-radius: var(--r); }
.token-value { display: block; margin-top: var(--s2); padding: var(--s2);
  background: var(--surface); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: var(--fs-sm);
  word-break: break-all; user-select: all; }
