/* ============================================================
   components.css — All Reusable UI Components
   Premium AI Intelligence Platform
   ============================================================ */

/* ────────── SECTION HEADINGS ────────── */
h2 {
  font-family: var(--font-display);
  font-size: var(--fs-caption);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: var(--s8) 0 var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s3);
}

h2::before {
  content: "";
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--gold), var(--gold-dark));
  border-radius: var(--r-full);
  box-shadow: 0 0 8px var(--gold-glow);
}

/* ────────── PREMIUM GLASS CARDS ────────── */
.card {
  background: var(--glass-medium);
  
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  
  padding: var(--s6);
  margin-bottom: var(--s4);
  
  box-shadow: var(--shadow-md),
              inset 0 1px 0 rgba(255, 255, 255, 0.05);
  
  transition: all var(--t-base) var(--ease-out);
}

.card:hover {
  border-color: var(--glass-border-hover);
  box-shadow: var(--shadow-lg),
              inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

/* ────────── COLLAPSIBLE FOLDS ────────── */
.fold {
  background: var(--glass-medium);
  
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  
  margin-bottom: var(--s4);
  overflow: hidden;
  
  box-shadow: var(--shadow-sm);
  transition: all var(--t-base) var(--ease-out);
}

.fold[open] {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-md),
              0 0 0 1px var(--border-gold);
}

.fold > summary {
  position: sticky;
  top: 0;
  z-index: 20;
  list-style: none;
  cursor: pointer;
  padding: var(--s4) var(--s5);
  
  background: var(--glass-strong);
  
  user-select: none;
  transition: all var(--t-fast) var(--ease-out);
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary:hover {
  background: var(--bg-surface);
}

.fold > summary h2 {
  margin: 0;
  pointer-events: none;
  font-size: var(--fs-small);
}

.fold[open] > summary {
  border-bottom: 1px solid var(--border-subtle);
}

.fold[open] > summary h2 {
  color: var(--gold);
}

/* Chevron indicator */
.fold > summary::after {
  content: "";
  position: absolute;
  right: var(--s5);
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-right: 2px solid var(--text-tertiary);
  border-bottom: 2px solid var(--text-tertiary);
  transform: rotate(45deg);
  transition: all var(--t-base) var(--ease-out);
}

.fold[open] > summary::after {
  transform: rotate(-135deg);
  border-color: var(--gold);
}

.fold .card {
  margin: 0;
  padding: var(--s5);
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: slideDown var(--t-base) var(--ease-out) both;
}

.fold .card + .card {
  border-top: 1px solid var(--border-subtle);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Close bar at bottom of folds */
.closebar {
  display: flex;
  gap: var(--s3);
  margin: var(--s5) var(--s5) 0;
  padding: var(--s4) 0 var(--s5);
  border-top: 1px solid var(--border-subtle);
}

.closebar button {
  font-size: var(--fs-small);
  padding: var(--s3) var(--s4);
}

/* ────────── PREMIUM BUTTONS ────────── */
button {
  width: 100%;
  min-height: max(40px, calc(52px * var(--zoom-k)));
  padding: var(--s4) var(--s6);
  
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-base);
  
  border: 0;
  border-radius: var(--r-md);
  
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  
  cursor: pointer;
  
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  
  box-shadow: var(--shadow-md),
              0 0 24px var(--gold-glow);
  
  transition: all var(--t-fast) var(--ease-out);
  
  position: relative;
  overflow: hidden;
}

/* Shimmer effect on primary buttons */
button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 70%
  );
  transform: translateX(-100%);
  transition: transform var(--t-slow) var(--ease-out);
}

button:hover::before {
  transform: translateX(100%);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg),
              0 0 32px var(--gold-glow);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:disabled {
  opacity: 0.4;
  pointer-events: none;
  box-shadow: none;
}

/* Ghost button variant */
button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  box-shadow: none;
}

button.ghost::before {
  display: none;
}

button.ghost:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* Sub button variant (toggle group) */
button.sub {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  font-weight: var(--fw-semibold);
  box-shadow: none;
  min-height: max(40px, calc(48px * var(--zoom-k)));
}

button.sub::before {
  display: none;
}

button.sub[aria-selected="true"] {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-base);
  border-color: transparent;
  box-shadow: var(--shadow-md), 0 0 20px var(--gold-glow);
}

button.sub:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

button.sub[aria-selected="true"]:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
}

/* Mini button */
button.mini {
  width: auto;
  min-height: max(36px, calc(40px * var(--zoom-k)));
  padding: var(--s2) var(--s4);
  font-size: var(--fs-small);
}

/* Danger button */
button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  box-shadow: none;
}

button.danger::before {
  display: none;
}

button.danger:hover {
  background: var(--danger-wash);
  box-shadow: 0 0 20px var(--danger-glow);
}

/* Button row layout */
.subrow {
  display: flex;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}

.subrow button {
  flex: 1 1 120px;
}

/* ────────── FORM CONTROLS ────────── */
label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-tiny);
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: var(--s5) 0 var(--s2);
}

select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="search"],
textarea {
  width: 100%;
  min-height: max(40px, calc(52px * var(--zoom-k)));
  
  background: var(--bg-surface);
  color: var(--text-primary);
  
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  
  padding: var(--s3) var(--s4);
  
  font-size: var(--fs-body);
  font-family: var(--font-body);
  font-weight: var(--fw-regular);
  font-variant-numeric: tabular-nums;
  
  transition: all var(--t-fast) var(--ease-out);
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--gold-wash),
              var(--shadow-md);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

input[type="password"] {
  letter-spacing: 0.2em;
}

textarea {
  min-height: 120px;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  line-height: var(--lh-relaxed);
  resize: vertical;
}

/* Select dropdown */
select {
  appearance: none;
  cursor: pointer;
  padding-right: 44px;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23A1A1AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 16px center;
  background-repeat: no-repeat;
  background-size: 12px;
}

/* Form row layout */
.row {
  display: flex;
  gap: var(--s3);
}

.row > * {
  flex: 1;
  min-width: 0;
}

/* ────────── STAT ROWS ────────── */
.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-body);
  color: var(--text-secondary);
}

.stat:last-child {
  border-bottom: 0;
}

.stat b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-bold);
  text-align: right;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ────────── LIST ITEMS ────────── */
.list {
  margin-top: var(--s3);
}

.item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s4);
  padding: var(--s4) 0;
  border-top: 1px solid var(--border-subtle);
}

.item:first-child {
  border-top: 0;
}

.item .n {
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  font-size: var(--fs-large);
  color: var(--text-primary);
  border-left: 3px solid var(--border-default);
  padding-left: var(--s3);
}

.item .n.k5 {
  border-left-color: var(--gold);
  color: var(--gold);
}

.item .meta {
  font-size: var(--fs-small);
  color: var(--text-tertiary);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ────────── NUMBER CHIPS (Premium 3D Tiles) ────────── */
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: var(--s3);
  margin-top: var(--s4);
}

.chips.wide {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.chip {
  display: block;
  text-align: center;
  
  font-family: var(--font-mono);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lead);
  line-height: 1.3;
  color: var(--text-primary);
  
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  
  padding: var(--s4) var(--s2);
  
  box-shadow: var(--shadow-sm),
              inset 0 1px 0 rgba(255, 255, 255, 0.03);
  
  transition: all var(--t-fast) var(--ease-out);
  cursor: pointer;
}

.chip:hover {
  background: var(--bg-overlay);
  border-color: var(--border-strong);
  transform: translateY(-3px) scale(1.02);
  box-shadow: var(--shadow-md);
}

.chip i {
  display: block;
  font-style: normal;
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  font-size: var(--fs-tiny);
  color: var(--text-tertiary);
  margin-top: var(--s1);
}

/* Premium 5K chip */
.chip.k5 {
  background: linear-gradient(135deg, var(--gold-wash), var(--gold-wash));
  border-color: var(--border-gold);
  color: var(--gold);
  box-shadow: var(--shadow-md),
              0 0 20px var(--gold-glow);
}

.chip.k5:hover {
  background: linear-gradient(135deg, var(--gold-wash), var(--gold));
  color: var(--bg-base);
  box-shadow: var(--shadow-lg),
              0 0 32px var(--gold-glow);
}

.chip.k5 i {
  color: var(--gold-dark);
}

/* 5K badge */
.tag5 {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-base);
  font-family: var(--font-display);
  font-weight: var(--fw-heavy);
  font-size: var(--fs-micro);
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  margin-left: var(--s1);
  vertical-align: middle;
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Chip entrance animation */
.chips > .chip {
  animation: chipPop var(--t-base) var(--ease-spring) both;
}

.chips > .chip:nth-child(1) { animation-delay: 0ms; }
.chips > .chip:nth-child(2) { animation-delay: 30ms; }
.chips > .chip:nth-child(3) { animation-delay: 60ms; }
.chips > .chip:nth-child(4) { animation-delay: 90ms; }
.chips > .chip:nth-child(5) { animation-delay: 120ms; }
.chips > .chip:nth-child(6) { animation-delay: 150ms; }
.chips > .chip:nth-child(7) { animation-delay: 180ms; }
.chips > .chip:nth-child(8) { animation-delay: 210ms; }
.chips > .chip:nth-child(n+9) { animation-delay: 240ms; }

@keyframes chipPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ────────── BAR CHARTS ────────── */
.bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--fs-small);
  margin: var(--s2) 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.bar span {
  min-width: 100px;
  flex-shrink: 0;
}

.bar i {
  display: block;
  height: 10px;
  min-width: 4px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transform-origin: left center;
  animation: barGrow var(--t-slow) var(--ease-out) both;
  box-shadow: 0 0 12px var(--gold-glow);
}

@keyframes barGrow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Interactive bar */
.bar[onclick],
.bar.clickable {
  cursor: pointer;
  border-radius: var(--r-sm);
  padding: var(--s1) var(--s2);
  margin-inline: calc(-1 * var(--s2));
  transition: background var(--t-fast) var(--ease-out);
}

.bar[onclick]:hover,
.bar.clickable:hover {
  background: var(--bg-surface);
}

.bar.active i {
  background: linear-gradient(90deg, var(--emerald), var(--emerald-light));
  box-shadow: 0 0 12px var(--emerald-glow);
}

.bar.active span {
  color: var(--emerald);
  font-weight: var(--fw-semibold);
}

/* ────────── NOTES & MESSAGES ────────── */
.note {
  font-size: var(--fs-small);
  color: var(--text-secondary);
  border-left: 3px solid var(--border-default);
  padding: var(--s2) 0 var(--s2) var(--s4);
  margin-top: var(--s4);
  line-height: var(--lh-relaxed);
}

/* Honesty strip */
.honesty {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  margin-top: var(--s5);
  padding: var(--s4);
  
  background: var(--gold-wash);
  border: 1px solid var(--border-gold);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  
  font-size: var(--fs-small);
  color: var(--text-secondary);
  line-height: var(--lh-relaxed);
}

.honesty .ico {
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 2px;
}

.honesty b {
  color: var(--text-primary);
}

/* Verdict boxes */
.verd {
  padding: var(--s4);
  border-radius: var(--r-md);
  font-size: var(--fs-body);
  margin-top: var(--s3);
  border: 1px solid transparent;
}

.verd.ch {
  background: var(--emerald-wash);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--text-primary);
}

.verd.up {
  background: var(--gold-wash);
  border-color: var(--border-gold);
  color: var(--text-primary);
}

/* Win announcement */
.win {
  background: linear-gradient(135deg, var(--emerald-wash), transparent);
  border: 2px solid var(--emerald);
  border-radius: var(--r-lg);
  padding: var(--s6);
  margin-top: var(--s4);
  text-align: center;
  box-shadow: 0 0 0 4px var(--emerald-wash),
              var(--shadow-lg);
  animation: winPop var(--t-slow) var(--ease-spring) both;
}

.win .amt {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: var(--fw-heavy);
  color: var(--emerald);
  line-height: 1;
  text-shadow: 0 0 24px var(--emerald-glow);
}

@keyframes winPop {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Lose result */
.lose {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: var(--s5);
  margin-top: var(--s3);
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--fs-body);
}

/* Error box */
.errb {
  background: var(--danger-wash);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--text-primary);
  border-radius: var(--r-md);
  padding: var(--s4);
  margin-top: var(--s3);
  font-size: var(--fs-body);
}

/* Ad placeholder */
.ad {
  border: 2px dashed var(--border-default);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  border-radius: var(--r-md);
  padding: var(--s4);
  text-align: center;
  font-size: var(--fs-tiny);
  letter-spacing: 0.14em;
  margin-bottom: var(--s4);
}

/* ────────── TABLES ────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  margin-top: var(--s4);
  font-variant-numeric: tabular-nums;
}

td, th {
  padding: var(--s3) var(--s2);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

th {
  color: var(--text-tertiary);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-tiny);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover {
  background: var(--bg-surface);
}

/* ────────── DETAILS / ACCORDION ────────── */
details:not(.fold) {
  margin-top: var(--s3);
}

details:not(.fold) > summary {
  cursor: pointer;
  font-size: var(--fs-body);
  color: var(--gold);
  padding: var(--s3) 0;
  font-weight: var(--fw-semibold);
  transition: color var(--t-fast) var(--ease-out);
}

details:not(.fold) > summary:hover {
  color: var(--gold-light);
}

/* ────────── DRAW PANEL ────────── */
.drawpanel {
  margin-top: var(--s5);
  padding: var(--s5);
  
  background: var(--glass-medium);
  
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  
  box-shadow: var(--shadow-md);
}

.dphead {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding-bottom: var(--s4);
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--border-subtle);
}

.dphead b {
  font-family: var(--font-mono);
  font-size: var(--fs-large);
  color: var(--text-primary);
}

.dphead span {
  flex: 1;
  font-size: var(--fs-small);
  color: var(--text-tertiary);
}

.dphead button {
  width: auto;
  min-height: max(36px, calc(40px * var(--zoom-k)));
  padding: var(--s2) var(--s4);
  font-size: var(--fs-small);
}

.drawpanel .stat {
  padding: var(--s3) 0;
}

.drawpanel .chips {
  margin-bottom: var(--s5);
}

/* ────────── OCR CAMERA ────────── */
#ocrwrap {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: var(--r-lg);
  border: 2px solid var(--border-default);
  aspect-ratio: 4/3;
  max-height: 48vh;
  margin: var(--s4) 0;
  box-shadow: var(--shadow-lg);
}

#ocrwrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ────────── EMPTY STATES ────────── */
.empty {
  text-align: center;
  padding: var(--s8) var(--s5);
  color: var(--text-tertiary);
  font-size: var(--fs-body);
}

.empty .ico {
  display: block;
  margin: 0 auto var(--s4);
  width: 40px;
  height: 40px;
  opacity: 0.4;
}

/* Loading placeholder */
.loading-rows::before {
  content: "";
  display: block;
  height: 24px;
  width: 55%;
  margin-bottom: var(--s4);
  border-radius: var(--r-sm);
  background: linear-gradient(
    90deg,
    var(--skeleton-from) 25%,
    var(--skeleton-to) 50%,
    var(--skeleton-from) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

.loading-rows::after {
  content: "";
  display: block;
  height: 120px;
  border-radius: var(--r-md);
  background: linear-gradient(
    90deg,
    var(--skeleton-from) 25%,
    var(--skeleton-to) 50%,
    var(--skeleton-from) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* ────────── ZONE PILL ────────── */
.zonepill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  background: var(--gold-wash);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  border-radius: var(--r-full);
  padding: var(--s2) var(--s4);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  margin: var(--s3) 0;
  box-shadow: 0 0 16px var(--gold-glow);
}

/* ============================================================
   FINALIZATION FIXES — styles for classes that previously had
   none and were inheriting the wrong look.
   ============================================================ */

/* 1. Inline "Guide" link-button. Without this it inherited the
   global full-width gold button and swallowed the login's
   LANGUAGE field. Now it is a small text link. */
button.linkbtn {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 0;
  margin-left: var(--s2);
  padding: 2px 6px;
  background: none;
  border: 0;
  border-radius: var(--r-xs);
  box-shadow: none;
  color: var(--gold);
  font-size: var(--fs-caption);
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.linkbtn::before { display: none; }
button.linkbtn:hover { color: var(--gold-light); background: var(--gold-wash); }

/* 2. Ticket-anatomy row: label and number were running together. */
.tm-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  padding: 4px 0;
}
.tm-row .tm-label { color: var(--text-tertiary); font-size: var(--fs-small); }
.tm-row .tm-num {
  font-family: var(--font-mono, monospace);
  font-size: var(--fs-lead);
  letter-spacing: .12em;
  color: var(--text-primary);
}

/* 3. Upload-a-photo label: the italic hint was glued to the bold
   title. Stack them with breathing room. */
.pickfile > span { display: inline-flex; flex-direction: column; gap: 2px; min-width: 0; }
.pickfile b { font-size: var(--fs-body); }
.pickfile i {
  font-style: normal;
  font-size: var(--fs-caption);
  color: var(--text-tertiary);
}

/* 4. DATA footer: sentence was wrapping around the Guide button
   and language dropdown mid-sentence. Sentence gets its own line;
   controls sit centred underneath. */
.footerline { display: block; margin-bottom: var(--s3); line-height: 1.55; }
.langrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  flex-wrap: wrap;
}
.langrow button.ghost.mini { width: auto; }
.langrow select { min-height: max(36px, calc(40px * var(--zoom-k))); }

/* Offline banner — sits under the header, only visible with no connection. */
#offlineBar{
  position: sticky; top: var(--header-h); z-index: 60;
  padding: 10px var(--s4);
  background: #4A2410; color: #FFD9A0;
  border-bottom: 1px solid var(--border-gold);
  font-size: var(--fs-caption); text-align: center; letter-spacing: .02em;
}

/* ============================================================
   CHECK / BATCH RESULTS — compact, clear rows with a win/no-win
   state, a highlight for the just-added row, and a firecracker
   burst on a win.
   ============================================================ */
#batchOut{ display:flex; flex-direction:column; gap:8px; margin-top:10px; }

.checkrow{
  position:relative; overflow:hidden;
  padding:10px 12px;
  border:1px solid var(--border-default);
  border-radius:var(--r-md);
  background:var(--bg-surface);
}
.checkrow .cr-top{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.checkrow .cr-num{ font-family:var(--font-mono,monospace); font-size:var(--fs-lead); letter-spacing:.1em; color:var(--text-primary); }
.checkrow .cr-num.k5{ color:var(--gold-light); }
.checkrow .cr-key{ font-size:var(--fs-caption); color:var(--text-tertiary); }
.checkrow .cr-head{ margin-top:6px; font-size:var(--fs-small); font-weight:700; letter-spacing:.04em; }
.checkrow .cr-detail{ margin-top:3px; font-size:var(--fs-small); color:var(--text-secondary); }
.checkrow .cr-dim{ color:var(--text-tertiary); }

/* WIN state — warm gold, celebratory header */
.checkrow.win{ border-color:var(--border-gold); background:linear-gradient(180deg,var(--gold-wash),transparent); }
.checkrow .cr-win{ color:var(--gold-light); display:flex; align-items:center; gap:8px; font-size:var(--fs-body); }
.checkrow .cr-win .cr-fx{ font-size:var(--fs-lead); }

/* NO-WIN state — quiet, never harsh */
.checkrow.nowin{ opacity:.92; }
.checkrow .cr-none{ color:var(--text-tertiary); }

/* the row just added flashes gently so the eye follows it */
.checkrow.justadded{ animation:crFlash 1.1s ease-out 1; }
@keyframes crFlash{
  0%{ box-shadow:0 0 0 3px var(--gold-glow); transform:translateY(-4px); }
  100%{ box-shadow:0 0 0 0 transparent; transform:translateY(0); }
}

/* firecracker burst */
.fx-burst{ position:absolute; top:22px; left:50%; width:0; height:0; pointer-events:none; }
.fx-burst i{
  position:absolute; left:0; top:0; width:7px; height:7px; border-radius:50%;
  background:var(--gold-light);
  transform:translate(0,0) scale(1); opacity:1;
  animation:fxfly .9s ease-out forwards; animation-delay:var(--d,0s);
}
.fx-burst i:nth-child(3n){ background:#FF7A59; }
.fx-burst i:nth-child(3n+1){ background:#FFD34D; }
.fx-burst i:nth-child(3n+2){ background:#7ED0FF; }
@keyframes fxfly{
  0%{ transform:translate(0,0) scale(1); opacity:1; }
  100%{ transform:translate(var(--dx,0),var(--dy,0)) scale(.2); opacity:0; }
}
@media (prefers-reduced-motion: reduce){
  .checkrow.justadded{ animation:none; }
  .fx-burst{ display:none; }
}

/* Scan guide: example ticket diagram showing which barcode to scan */
.scan-guide{
  margin:10px 0; padding:12px;
  border:1px solid var(--border-default); border-radius:var(--r-md);
  background:var(--bg-elevated); text-align:center;
}
.scan-guide-title{ font-size:var(--fs-small); font-weight:700; color:var(--gold); margin-bottom:8px; letter-spacing:.03em; }
.scan-guide-img{ width:100%; max-width:320px; height:auto; }
.scan-guide-note{ margin-top:8px; font-size:var(--fs-caption); color:var(--text-tertiary); line-height:1.5; }

/* ============================================================
   DISPLAY PREFERENCES — user-controlled zoom + screen fit,
   shown in the DATA footer. Choices persist across sessions.
   ============================================================ */
#displayPrefs{
  max-width:340px; margin:14px auto 0; padding:10px 12px;
  border:1px solid var(--border-gold); border-radius:var(--r-md);
  background:var(--gold-wash); text-align:left;
}
#displayPrefs .dp-title{
  display:flex; align-items:center; gap:6px; justify-content:center;
  color:var(--gold-light); font-weight:700; font-size:var(--fs-caption);
  letter-spacing:.06em; text-transform:uppercase; margin-bottom:9px;
}
#displayPrefs .dp-title .ico{ width:14px; height:14px; }
#displayPrefs .dp-row{ display:flex; align-items:center; gap:9px; margin:7px 0; }
#displayPrefs label,#displayPrefs .dp-lbl{
  font-size:var(--fs-micro); color:var(--text-secondary); min-width:30px;
  text-transform:uppercase; letter-spacing:.05em;
}
#displayPrefs output{
  font-family:var(--font-mono,monospace); font-size:var(--fs-micro);
  color:var(--gold-light); min-width:38px; text-align:right;
}
#displayPrefs input[type="range"]{
  flex:1; min-height:0; -webkit-appearance:none; appearance:none;
  height:5px; border-radius:3px; background:var(--bg-surface);
  border:1px solid var(--border-default); padding:0;
}
#displayPrefs input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:18px; height:18px;
  border-radius:50%; background:linear-gradient(135deg,var(--gold),var(--gold-dark));
  border:2px solid var(--bg-base); cursor:pointer;
}
#displayPrefs input[type="range"]::-moz-range-thumb{
  width:18px; height:18px; border-radius:50%; border:2px solid var(--bg-base);
  background:var(--gold); cursor:pointer;
}
#displayPrefs .dp-seg{ display:flex; gap:0; flex:1; border-radius:var(--r-sm); overflow:hidden; border:1px solid var(--border-default); }
#displayPrefs .dp-seg button{
  flex:1; width:auto; min-height:30px; padding:4px 3px; margin:0;
  background:var(--bg-surface); color:var(--text-secondary);
  border:0; border-radius:0; font-size:var(--fs-micro); font-weight:600;
  box-shadow:none;
}
#displayPrefs .dp-seg button::before{ display:none; }
#displayPrefs .dp-seg button.on{ background:linear-gradient(135deg,var(--gold),var(--gold-dark)); color:var(--bg-base); }
#displayPrefs .dp-note{ margin-top:7px; font-size:9px; color:var(--text-tertiary); text-align:center; opacity:.8; }

/* the zoom/fit wrapper applied to <main> */
main{ transform-origin: top center; }
body[data-fit="tall"] main{ max-width:520px; margin-inline:auto; }
body[data-fit="wide"] main{ max-width:100%; }

/* Playful exit dialog */
.exit-emoji{ font-size:34px; text-align:center; margin-bottom:6px; }
.exit-card.exit-pop{ animation:exitPop .32s cubic-bezier(.34,1.56,.64,1) 1; }
@keyframes exitPop{
  0%{ transform:scale(.7) translateY(20px); opacity:0; }
  100%{ transform:scale(1) translateY(0); opacity:1; }
}
@media (prefers-reduced-motion: reduce){ .exit-card.exit-pop{ animation:none; } }

/* ============================================================
   SCAN REDESIGN (v51) — trimmed, polished, glassmorphic.
   Camera viewfinder overlay, clean barcode example, per-day
   scan toggle on recent draws, and the per-day scan popup.
   ============================================================ */

.scan-lead{ font-size:var(--fs-small); color:var(--text-secondary); line-height:1.55; margin:0 0 4px; }
.scan-cap{ font-size:11px; color:var(--text-tertiary); text-align:center; margin:8px 0 0; }
.scan-cap.ok{ color:var(--gold-light); }
.scan-stat{ margin-top:10px; }

/* One clean barcode example */
.barcode-eg{
  position:relative; display:flex; flex-direction:column; align-items:center; gap:10px;
  margin:14px 0; padding:18px 16px; border-radius:16px;
  background:linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border:1px solid var(--glass-border);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.05);
}
.be-tag{ position:absolute; top:10px; right:12px; font-size:9px; letter-spacing:.16em;
  text-transform:uppercase; color:var(--text-tertiary); }
.be-strip{
  width:min(260px,82%); height:58px; border-radius:8px; background:#f5f5f4;
  background-image:repeating-linear-gradient(90deg,
    #0b0b0d 0, #0b0b0d 2px, transparent 2px, transparent 5px,
    #0b0b0d 5px, #0b0b0d 8px, transparent 8px, transparent 10px,
    #0b0b0d 10px, #0b0b0d 13px, transparent 13px, transparent 16px);
  border:2px solid var(--gold);
  box-shadow:0 0 0 4px var(--gold-wash), 0 10px 26px rgba(0,0,0,.4);
}
.be-num{ font-family:var(--font-mono); letter-spacing:.2em; color:var(--text-secondary); font-size:14px; }

/* Camera viewfinder — shared by main scanner (#ocrwrap) and day popup (.dayscan-cam) */
#ocrwrap{
  border:1px solid var(--border-gold);
  box-shadow:0 12px 44px rgba(0,0,0,.5), inset 0 0 0 1px rgba(245,158,11,.14);
}
#ocrwrap.hit, .dayscan-cam.hit{ box-shadow:0 0 0 3px #2fbf71, 0 12px 44px rgba(0,0,0,.5); }

.reticle{ position:absolute; inset:0; pointer-events:none; }
.reticle .rc{
  position:absolute; width:34px; height:34px; border:3px solid var(--gold);
  filter:drop-shadow(0 0 5px var(--gold-glow));
}
.reticle .rc.tl{ top:14px; left:14px; border-right:0; border-bottom:0; border-radius:9px 0 0 0; }
.reticle .rc.tr{ top:14px; right:14px; border-left:0; border-bottom:0; border-radius:0 9px 0 0; }
.reticle .rc.bl{ bottom:14px; left:14px; border-right:0; border-top:0; border-radius:0 0 0 9px; }
.reticle .rc.br{ bottom:14px; right:14px; border-left:0; border-top:0; border-radius:0 0 9px 0; }
.reticle .sweep{
  position:absolute; left:16px; right:16px; top:16px; height:2px;
  background:linear-gradient(90deg, transparent, var(--gold), transparent);
  box-shadow:0 0 12px 2px var(--gold-glow); border-radius:2px;
  animation:scanSweep 2.4s var(--ease-in-out) infinite;
}
@keyframes scanSweep{
  0%{ top:16px; opacity:0; } 12%{ opacity:1; } 88%{ opacity:1; }
  100%{ top:calc(100% - 18px); opacity:0; }
}
.reticle-hint{
  position:absolute; left:50%; bottom:12px; transform:translateX(-50%);
  background:rgba(0,0,0,.6); color:#fff; font-size:11px; font-weight:600;
  padding:5px 12px; border-radius:999px; white-space:nowrap;
  box-shadow:0 2px 10px rgba(0,0,0,.4);
}

/* Action rows + manual entry */
.scan-actions{ display:flex; gap:10px; margin-top:12px; flex-wrap:wrap; }
.scan-actions > button{ flex:1 1 auto; }
.scan-manual{ margin-top:14px; }
.scan-manual > label{
  display:block; font-size:11px; text-transform:uppercase; letter-spacing:.08em;
  color:var(--text-tertiary); margin:12px 0 5px;
}
.scan-manual input, .scan-manual select{
  width:100%; height:46px; background:var(--bg-surface); color:var(--text-primary);
  border:1px solid var(--border-default); border-radius:12px; padding:0 14px; font-size:15px;
  appearance:none; -webkit-appearance:none;
}
.scan-manual input:focus, .scan-manual select:focus{
  outline:none; border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-wash); background:var(--bg-elevated);
}

/* Recent draws (last 6 days) — QR scan toggle on the left of each row */
.recent-list{ display:flex; flex-direction:column; gap:8px; margin-top:10px; }
.recent-row{ display:flex; align-items:stretch; gap:8px; }
.recent-row .chip{ flex:1 1 auto; display:flex; flex-direction:column; justify-content:center; text-align:left; margin:0; }
.dayscan-toggle{
  flex:0 0 auto; width:48px; display:flex; align-items:center; justify-content:center;
  border:1px solid var(--border-gold); border-radius:12px; cursor:pointer;
  background:linear-gradient(160deg, var(--gold-wash), rgba(245,158,11,.04));
  transition:transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.dayscan-toggle:hover{ background:var(--gold-wash); transform:translateY(-1px); box-shadow:0 6px 16px rgba(245,158,11,.22); }
.dayscan-toggle:active{ transform:translateY(0) scale(.97); }
.qr-ic{ width:22px; height:22px; fill:none; stroke:var(--gold); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }

/* Per-day scan popup — matches the app modal pattern (solid scrim, above modal layer) */
.dayscan{
  position:fixed; inset:0; z-index:var(--z-toast);
  display:flex; align-items:center; justify-content:center; padding:16px;
  background:rgba(6,6,8,0.92);
  opacity:0; animation:fadeIn var(--t-base) var(--ease-out) forwards;
}
.dayscan[hidden]{ display:none; animation:none; opacity:0; }
.dayscan-card{
  position:relative; width:100%; max-width:400px; max-height:92vh; overflow-y:auto;
  background:rgba(20,20,24,0.99); border:1px solid var(--glass-border);
  border-radius:20px; padding:18px 16px 16px;
  box-shadow:var(--shadow-2xl), inset 0 1px 0 rgba(255,255,255,.06);
  animation:scaleIn var(--t-base) var(--ease-spring) forwards;
}
.dayscan-card::before{
  content:""; position:absolute; top:0; left:0; right:0; height:2px;
  background:linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity:.7; border-radius:20px 20px 0 0;
}
.dayscan-close{
  position:absolute; top:8px; right:8px; width:34px; height:34px; padding:0;
  display:flex; align-items:center; justify-content:center;
  border:0; border-radius:50%; background:transparent; color:var(--text-tertiary);
  font-size:26px; line-height:1; cursor:pointer;
}
.dayscan-close:hover{ color:var(--text-primary); background:var(--bg-surface); }
.dayscan-head{ display:flex; gap:11px; align-items:flex-start; margin-bottom:12px; padding-right:30px; }
.dayscan-head .ico{ color:var(--gold); width:24px; height:24px; flex:0 0 auto; margin-top:2px; }
.dayscan-title{ font-family:var(--font-display); font-weight:var(--fw-heavy); font-size:16px; color:var(--text-primary); line-height:1.2; }
.dayscan-sub{ font-size:12px; color:var(--text-secondary); margin-top:3px; line-height:1.4; }
.dayscan-cam{
  position:relative; overflow:hidden; background:#000;
  border-radius:14px; border:1px solid var(--border-gold);
  aspect-ratio:4/3; max-height:40vh; margin:6px 0 10px;
  box-shadow:inset 0 0 0 1px rgba(245,158,11,.14);
}
.dayscan-cam[hidden]{ display:none; }
.dayscan-cam video{ width:100%; height:100%; object-fit:cover; }
.dayscan-manual{ margin-top:12px; display:flex; flex-wrap:wrap; gap:8px; align-items:flex-end; }
.dayscan-manual label{ flex:1 0 100%; font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--text-tertiary); }
.dayscan-manual input{
  flex:1 1 auto; min-width:0; height:44px; background:var(--bg-surface); color:var(--text-primary);
  border:1px solid var(--border-default); border-radius:12px; padding:0 14px; font-size:15px;
}
.dayscan-manual input:focus{ outline:none; border-color:var(--gold); box-shadow:0 0 0 3px var(--gold-wash); }
.dayscan-manual #dayCheck{ flex:0 0 auto; width:auto; padding:0 20px; height:44px; }
#dayResult{ margin-top:10px; }

/* Kerala-only guard note (v52) */
.scan-guard-note{
  display:flex; align-items:flex-start; gap:8px;
  margin:8px 0 0; padding:8px 11px;
  border:1px solid rgba(224,108,108,.32); border-left:3px solid #e06c6c; border-radius:0 10px 10px 0;
  background:rgba(224,108,108,.06);
  font-size:11px; color:var(--text-secondary); line-height:1.45;
}
.scan-guard-note[hidden]{ display:none; }
.scan-guard-note .ico{ color:#e06c6c; width:14px; height:14px; flex:0 0 auto; margin-top:1px; }

/* ============================================================
   CELEBRATION OVERLAY (v53) — win crackers / lose gentle note
   ============================================================ */
.celebrate{
  position:fixed; inset:0; z-index:1600; overflow:hidden;
  opacity:0; transition:opacity .3s var(--ease-out); pointer-events:none;
}
.celebrate.show{ opacity:1; pointer-events:auto; }
.celebrate.win{ background:radial-gradient(circle at 50% 42%, rgba(26,19,4,.34), rgba(6,6,8,.58)); }
.celebrate.lose{ background:rgba(7,9,13,.64); -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px); }

.celebrate .cel-glow{
  position:absolute; inset:0;
  background:radial-gradient(circle at 50% 40%, rgba(245,158,11,.42), transparent 62%);
  animation:celGlow 1.4s var(--ease-out);
}
@keyframes celGlow{ 0%{opacity:0} 35%{opacity:1} 100%{opacity:.15} }

.cel-confetti{
  position:absolute; top:-12vh; width:9px; height:15px; opacity:.96;
  animation-name:celFall; animation-timing-function:cubic-bezier(.28,.6,.42,1); animation-fill-mode:both;
}
@keyframes celFall{
  0%{ transform:translateY(-12vh) translateX(0) rotate(0deg); opacity:0; }
  8%{ opacity:1; }
  100%{ transform:translateY(114vh) translateX(calc(var(--dx,0) * 24vw)) rotate(var(--rot,360deg)); opacity:.85; }
}

.cel-card{
  position:absolute; left:50%; top:44%; transform:translate(-50%,-50%) scale(.55);
  width:min(320px,84vw); text-align:center; padding:24px 26px; border-radius:22px;
  background:rgba(20,20,24,.9); border:1px solid var(--border-gold);
  box-shadow:0 22px 70px rgba(0,0,0,.62), 0 0 64px rgba(245,158,11,.42);
  animation:celPop .6s var(--ease-spring) forwards;
}
.celebrate.lose .cel-card{ border-color:var(--border-subtle); box-shadow:0 22px 60px rgba(0,0,0,.5); }
@keyframes celPop{ to{ transform:translate(-50%,-50%) scale(1); } }

.cel-emoji{ font-size:42px; line-height:1; margin-bottom:8px; animation:celFloat 1.7s var(--ease-in-out) infinite; }
.cel-emoji.soft{ opacity:.92; }
@keyframes celFloat{ 0%,100%{ transform:translateY(0); } 50%{ transform:translateY(-6px); } }

.cel-title{
  font-family:var(--font-display); font-weight:900; letter-spacing:.05em; font-size:30px; line-height:1.1;
  background:linear-gradient(135deg, var(--gold-light), var(--gold) 45%, var(--gold-dark));
  -webkit-background-clip:text; background-clip:text; color:transparent;
}
.cel-title.soft{ background:none; color:var(--text-primary); -webkit-text-fill-color:currentColor; font-size:22px; font-weight:800; letter-spacing:.02em; }
.cel-amt{ margin-top:6px; font-family:var(--font-display); font-weight:800; font-size:23px; color:var(--gold-light); }
.cel-sub{ margin-top:9px; font-size:13px; color:var(--text-secondary); line-height:1.5; }
.cel-tap{ margin-top:12px; font-size:10px; letter-spacing:.14em; text-transform:uppercase; color:var(--text-tertiary); }

@media (prefers-reduced-motion: reduce){
  .cel-confetti{ display:none; }
  .cel-card{ animation:none; transform:translate(-50%,-50%) scale(1); }
  .cel-emoji{ animation:none; }
}
