/* KTools3 — Concept B: Clean Card */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f4f8;
  --white:     #ffffff;
  --grad-a:    #0d47a1;
  --grad-b:    #00838f;
  --accent:    #0d47a1;
  --accent2:   #00838f;
  --text:      #1a2636;
  --muted:     #607d8b;
  --border:    #dde5ee;
  --danger:    #c62828;
  --success:   #2e7d32;
  --warning:   #c75000;
  --info:      #1565c0;
  --shadow:    0 2px 12px rgba(13,71,161,.10);
  --radius:    14px;
  --radius-sm: 10px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ── */
.app-header {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  padding: 18px 18px 16px;
}
.header-row { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 24px; }
.header-title { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.header-sub { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 1px; }

/* ── Chip nav ── */
.chip-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 12px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.chip-nav a {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  padding: 6px 4px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .15s;
}
.chip-nav a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Cards ── */
.cb-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 12px 14px;
  overflow: hidden;
}
.cb-card-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.cb-card-icon { font-size: 16px; }
.cb-card-title { font-size: 13px; font-weight: 700; color: var(--accent); }
.cb-card-header-actions {
  flex-basis: 100%;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}
.game-header-pill {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 9px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.15;
}
.game-header-pill.profile {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #6ee7b7;
  box-shadow: 0 1px 4px rgba(4,120,87,.16);
}
.game-header-pill.profile:hover { color: #065f46; background: #d1fae5; }
.game-header-pill.rules {
  background: #fff8e1;
  color: #8a4b00;
  border: 1px solid #ffe082;
}
.game-header-pill.rules:hover { color: #6d3900; background: #ffefb3; }
.game-header-pill.stat {
  background: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #bbdefb;
}
.cb-card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* ── Inline guess form (index page) ── */
.index-guess-section { border-top: 1.5px solid var(--border,#dde5ee); padding: 12px 0 2px; }
.index-guess-label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.index-guess-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: #ede9fe; color: #5b21b6; font-size: 12px; font-weight: 800; border: 1px solid #c4b5fd; }
.index-guess-badge.early { background: #fff8e1; color: #8a4b00; border-color: #ffe082; }
.index-guess-wrongs { font-size: 11px; color: #dc2626; font-weight: 700; }
.index-guess-btn { background: linear-gradient(135deg, #7c3aed, #5b21b6) !important; font-size: 14px !important; font-weight: 900 !important; padding: 0 18px !important; }
.index-guess-btn:disabled { opacity: .6; }
.index-guess-result { margin-top: 8px; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; line-height: 1.4; }
.index-guess-result.correct { background: #e8f5e9; color: #1b5e20; border: 1.5px solid #81c784; }
.index-guess-result.wrong { background: #fff8e1; color: #8a4b00; border: 1.5px solid #ffd54f; }
.index-guess-result.err { background: #fef2f2; color: #991b1b; border: 1.5px solid #f87171; }

/* ── Floating label fields ── */
.float-field { position: relative; }
.float-field input,
.float-field select,
.float-field textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-size: 15px;
  padding: 18px 13px 6px;
  min-height: 52px;
  outline: none;
  appearance: none; -webkit-appearance: none;
  transition: border-color .15s;
}
.float-field input:focus,
.float-field select:focus,
.float-field textarea:focus { border-color: var(--accent); }
.float-field label {
  position: absolute;
  top: 7px; left: 14px;
  font-size: 10px; font-weight: 600;
  color: var(--muted);
  letter-spacing: .5px; text-transform: uppercase;
  pointer-events: none;
}
.float-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23607d8b' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  padding-right: 36px;
}
.float-field.static-field input,
.float-field.static-field select { color: var(--muted); background: var(--bg); }

/* ── Input group with scan button ── */
.cb-input-group { display: flex; gap: 8px; }
.cb-input-group .float-field { flex: 1; }
.btn-scan {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  border: none; border-radius: var(--radius-sm);
  color: #fff; font-size: 20px;
  padding: 0 15px; min-height: 52px;
  cursor: pointer; flex-shrink: 0;
}

/* ── Row grid ── */
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Checkbox card ── */
.check-card {
  display: flex; align-items: center; gap: 12px;
  background: #e3f2fd;
  border: 1.5px solid #90caf9;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.check-card input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.check-card label { font-size: 14px; font-weight: 600; color: var(--accent); cursor: pointer; }

/* ── Alerts ── */
.cb-alert { margin: 10px 14px; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }
.cb-alert-danger  { background: rgba(198,40,40,.12);  border: 1px solid rgba(198,40,40,.4);  color: var(--danger); }
.cb-alert-warning { background: rgba(199,80,0,.10);   border: 1px solid rgba(199,80,0,.4);   color: var(--warning); }
.cb-alert-success { background: rgba(46,125,50,.10);  border: 1px solid rgba(46,125,50,.4);  color: var(--success); }
.cb-alert-info    { background: rgba(21,101,192,.10); border: 1px solid rgba(21,101,192,.35); color: var(--info); }

.sku-loading {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-top: -6px;
}
.sku-loading.active { display: flex; }
.sku-loading[hidden] { display: none !important; }
.sku-loading-dot {
  width: 16px;
  height: 16px;
  border: 2px solid #d7e3ef;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sku-spin .75s linear infinite;
  flex: 0 0 auto;
}
@keyframes sku-spin {
  to { transform: rotate(360deg); }
}

.template-apply-wrap {
  background: #fef9c3;
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
}
.template-apply-wrap .float-field select {
  border-color: #f59e0b;
  font-weight: 600;
}

.sku-image-preview {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(200px, calc(100vw - 32px));
  height: min(200px, calc(100vw - 32px));
  z-index: 8500;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, .22);
  padding: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.sku-image-preview.active {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}
.sku-image-preview[hidden] { display: none !important; }
.sku-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 8px;
}

.sku-image-preview.is-warning {
  border-color: #dc2626;
  background: #fff7ed;
  box-shadow: 0 14px 38px rgba(185, 28, 28, .32);
}

.sku-warning-panel {
  width: 100%;
  height: 100%;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
  padding: 12px;
}

.sku-warning-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
}

.sku-warning-text {
  font-size: 15px;
}

.confirm-product-thumb-wrap {
  float: right;
  width: 74px;
  height: 74px;
  margin: 0 0 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}
.confirm-product-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 6px;
}

/* ── Save pill button ── */
.confirm-product-thumb-wrap.has-warning {
  width: 96px;
  height: 88px;
  border-color: #dc2626;
  background: #fef2f2;
  padding: 6px;
}

.confirm-product-thumb-wrap.has-warning img {
  display: none;
}

.confirm-sku-warning {
  width: 100%;
  height: 100%;
  color: #991b1b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.confirm-sku-warning[hidden] {
  display: none !important;
}

.confirm-sku-warning .sku-warning-icon {
  width: 32px;
  height: 32px;
  font-size: 22px;
}

.save-wrap { padding: 8px 14px 20px; }
.btn-save {
  display: block; width: 100%;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  font-size: 16px; font-weight: 700;
  border: none; border-radius: 50px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(13,71,161,.3);
  transition: opacity .15s;
}
.btn-save:active { opacity: .85; }

/* ── Link inside label ── */
.lbl-link { color: var(--accent2); font-size: 11px; margin-left: 4px; text-decoration: none; font-weight: 600; }

/* ── Hazmat badge ── */
.hazmat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: #ffebee; border: 1.5px solid #ef9a9a;
  color: var(--danger); font-size: 13px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--radius-sm);
}

/* ── Table card (view.php) ── */
.cb-table-wrap {
  margin: 12px 14px 20px;
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--white);
}
.cb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cb-table thead th {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
  font-size: 12px;
}
.cb-table tbody tr:nth-child(even) { background: #f7fafd; }
.cb-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.cb-table tbody tr:hover { background: #e8f0fe; }

.cb-table tbody tr.record-row {
  cursor: pointer;
}
.cb-table tbody tr.record-row:focus {
  outline: 2px solid var(--accent2);
  outline-offset: -2px;
}

.record-modal[hidden] { display: none !important; }
body.record-modal-open { overflow: hidden; }
.record-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 86px 14px 22px;
}
.record-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .48);
}
.record-modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 108px);
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 55px rgba(15, 23, 42, .32);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.record-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
}
.record-modal-kicker {
  font-size: 11px;
  font-weight: 700;
  opacity: .78;
  text-transform: uppercase;
}
.record-modal-header h2 {
  font-size: 18px;
  line-height: 1.2;
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.record-modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.record-modal-body {
  overflow-y: auto;
  padding: 14px 16px 18px;
}
.record-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.record-detail-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--bg);
  min-width: 0;
}
.record-detail-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.record-detail-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.record-detail-section {
  margin-top: 15px;
}
.record-detail-section h3 {
  color: var(--accent);
  font-size: 13px;
  margin-bottom: 7px;
}
.record-list {
  display: grid;
  gap: 7px;
}
.record-list-item,
.record-empty {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--white);
}
.record-list-item strong,
.record-list-item span {
  display: block;
  overflow-wrap: anywhere;
}
.record-list-item strong {
  font-size: 13px;
  color: var(--text);
}
.record-list-item span,
.record-empty {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 560px) {
  .record-modal {
    padding: 74px 10px 14px;
  }
  .record-modal-panel {
    max-height: calc(100vh - 88px);
  }
  .record-detail-grid {
    grid-template-columns: 1fr;
  }
  .record-modal-header h2 {
    font-size: 16px;
  }
}

/* ── Result grid cards (search results) ── */
.result-grid { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 0 14px 14px; }
.result-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.result-card h6 { font-weight: 700; color: var(--accent); font-size: 14px; margin-bottom: 4px; }
.result-card p { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.result-card .qty-badge { color: #1b5e20; font-weight: 700; font-size: 14px; }
.result-img { width: 100%; max-height: 200px; object-fit: contain; border-radius: 8px; background: var(--bg); }

/* ── Progress bars (record_added.php) ── */
.cb-progress-wrap { margin: 0 14px 16px; position: relative; }
.cb-progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.cb-progress-track { height: 22px; background: #dde5ee; border-radius: 12px; overflow: visible; position: relative; }
.cb-progress-bar {
  height: 100%; border-radius: 12px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  font-size: 12px; color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1; transition: width .6s ease;
}
.cb-progress-bar.bar-danger { background: #c62828; }
.cb-progress-bar.bar-gold { background: #d4af37; color: #212529; }
.cb-progress-bar.bar-warning { background: #f9a825; color: #212529; }
.cb-marker {
  position: absolute; top: 0; bottom: 0; width: 0; z-index: 3;
}
.cb-marker::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 2px; background: #c62828;
}

/* ══════════════════════════════════════════════════════════
   FRONT-END THEMES  — override :root variables per theme class
   Applied to <html class="fe-theme-X">
   ══════════════════════════════════════════════════════════ */

html.fe-theme-dark {
  --bg:      #121218; --white:   #1e1e2e;
  --grad-a:  #1e1e2e; --grad-b:  #2d2d3e;
  --accent:  #6d9eeb; --accent2: #93c6e0;
  --text:    #e0e0e0; --muted:   #9e9e9e;
  --border:  rgba(255,255,255,.1);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-forest {
  --bg:      #0d1a10; --white:   #142418;
  --grad-a:  #1b4332; --grad-b:  #40916c;
  --accent:  #52b788; --accent2: #74c69d;
  --text:    #d4e8d4; --muted:   #95b99a;
  --border:  rgba(100,200,100,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-ocean {
  --bg:      #0a1628; --white:   #0d1e35;
  --grad-a:  #0a1628; --grad-b:  #0891b2;
  --accent:  #38bdf8; --accent2: #22d3ee;
  --text:    #d0e8f8; --muted:   #7eb5d0;
  --border:  rgba(8,145,178,.25);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-sunset {
  --bg:      #1a0e1a; --white:   #261226;
  --grad-a:  #7c3aed; --grad-b:  #f97316;
  --accent:  #fb923c; --accent2: #a78bfa;
  --text:    #f3e8ff; --muted:   #c4a9d0;
  --border:  rgba(251,146,60,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-slate {
  --bg:      #1e2a3a; --white:   #263347;
  --grad-a:  #1e3a5f; --grad-b:  #2563eb;
  --accent:  #60a5fa; --accent2: #93c5fd;
  --text:    #e2e8f0; --muted:   #94a3b8;
  --border:  rgba(96,165,250,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-rose {
  --bg:      #1a0a12; --white:   #261426;
  --grad-a:  #9f1239; --grad-b:  #db2777;
  --accent:  #f472b6; --accent2: #fb7185;
  --text:    #fce7f3; --muted:   #d096b5;
  --border:  rgba(244,114,182,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-midnight {
  --bg:      #0a0e1a; --white:   #111827;
  --grad-a:  #0a0e1a; --grad-b:  #1e3a5f;
  --accent:  #818cf8; --accent2: #a5b4fc;
  --text:    #e0e7ff; --muted:   #8896b0;
  --border:  rgba(129,140,248,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.5);
}
html.fe-theme-mocha {
  --bg:      #1a1008; --white:   #261a10;
  --grad-a:  #3d1a00; --grad-b:  #78350f;
  --accent:  #d97706; --accent2: #f59e0b;
  --text:    #fef3c7; --muted:   #c4a35a;
  --border:  rgba(217,119,6,.25);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-crimson {
  --bg:      #1a0808; --white:   #261212;
  --grad-a:  #7f1d1d; --grad-b:  #dc2626;
  --accent:  #f87171; --accent2: #fca5a5;
  --text:    #fee2e2; --muted:   #c08080;
  --border:  rgba(248,113,113,.2);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-cyber {
  --bg:      #050a05; --white:   #0a140a;
  --grad-a:  #050a05; --grad-b:  #14532d;
  --accent:  #22c55e; --accent2: #4ade80;
  --text:    #d1fae5; --muted:   #6b8f7a;
  --border:  rgba(34,197,94,.25);
  --shadow:  0 2px 12px rgba(0,0,0,.5);
}
html.fe-theme-nord {
  --bg:      #2e3440; --white:   #3b4252;
  --grad-a:  #2e3440; --grad-b:  #4c566a;
  --accent:  #88c0d0; --accent2: #81a1c1;
  --text:    #eceff4; --muted:   #9eaabf;
  --border:  rgba(136,192,208,.25);
  --shadow:  0 2px 12px rgba(0,0,0,.35);
}
html.fe-theme-mint {
  --bg:      #f0faf5; --white:   #ffffff;
  --grad-a:  #059669; --grad-b:  #10b981;
  --accent:  #059669; --accent2: #10b981;
  --text:    #064e3b; --muted:   #4b7a6a;
  --border:  #a7f3d0;
  --shadow:  0 2px 12px rgba(5,150,105,.1);
}
html.fe-theme-lavender {
  --bg:      #f5f0ff; --white:   #ffffff;
  --grad-a:  #7c3aed; --grad-b:  #a855f7;
  --accent:  #7c3aed; --accent2: #a855f7;
  --text:    #2d1b69; --muted:   #7c6d8f;
  --border:  #ddd6fe;
  --shadow:  0 2px 12px rgba(124,58,237,.1);
}
html.fe-theme-copper {
  --bg:      #1a100a; --white:   #261810;
  --grad-a:  #7c2d12; --grad-b:  #c2410c;
  --accent:  #ea580c; --accent2: #f97316;
  --text:    #fef0e6; --muted:   #c4846a;
  --border:  rgba(234,88,12,.25);
  --shadow:  0 2px 12px rgba(0,0,0,.45);
}
html.fe-theme-classic {
  --bg:      #ddeeff; --white:   #ffffff;
  --grad-a:  #0d47a1; --grad-b:  #0288d1;
  --accent:  #0d47a1; --accent2: #0288d1;
  --text:    #07192e; --muted:   #3a5878;
  --border:  #90c8f8;
  --shadow:  0 2px 12px rgba(13,71,161,.18);
}
html.fe-theme-mockup {
  --bg:      #f0f4f8; --white:   #ffffff;
  --grad-a:  #0d47a1; --grad-b:  #00838f;
  --accent:  #0d47a1; --accent2: #00838f;
  --text:    #1a2636; --muted:   #607d8b;
  --border:  #dde5ee;
  --shadow:  0 2px 12px rgba(13,71,161,.10);
}

/* ── Semantic color overrides for dark-background themes ── */
html.fe-theme-dark, html.fe-theme-forest, html.fe-theme-ocean, html.fe-theme-sunset,
html.fe-theme-slate, html.fe-theme-rose, html.fe-theme-midnight, html.fe-theme-mocha,
html.fe-theme-crimson, html.fe-theme-cyber, html.fe-theme-nord, html.fe-theme-copper {
  --danger:  #ff6b6b;
  --success: #4ade80;
  --warning: #fb923c;
  --info:    #60a5fa;
}

/* ── Theme selector page ── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px;
}
.theme-tile {
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, transform .1s;
  user-select: none;
}
.theme-tile:active { transform: scale(.97); }
.theme-tile.active { border-color: var(--accent); }
.theme-tile-preview {
  height: 52px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px;
}
.theme-tile-bar {
  height: 10px;
  border-radius: 4px;
}
.theme-tile-row {
  display: flex; gap: 4px; flex: 1;
}
.theme-tile-card {
  flex: 1; border-radius: 3px;
}
.theme-tile-label {
  font-size: 11px; font-weight: 700;
  color: var(--text);
  padding: 5px 8px 7px;
  text-align: center;
}
.theme-check {
  display: none;
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 2px 0;
  font-weight: 700;
}
.theme-tile.active .theme-check { display: block; }

/* Mobile app install tile */
.mobile-app-tile {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(13,71,161,.08), rgba(0,131,143,.08));
  padding: 12px;
}
.mobile-app-mark {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.mobile-app-copy {
  min-width: 0;
}
.mobile-app-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.mobile-app-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}
.mobile-app-install {
  border: 1px solid rgba(255,255,255,.22);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
  box-shadow: var(--shadow);
  text-shadow: 0 1px 1px rgba(0,0,0,.18);
  transition: transform .1s, filter .15s, box-shadow .15s;
  white-space: nowrap;
}
.mobile-app-install:hover,
.mobile-app-install:focus-visible {
  filter: brightness(1.06);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent), var(--shadow);
}
.mobile-app-install:active {
  transform: scale(.97);
}
.mobile-app-install.is-installed,
.mobile-app-install:disabled {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: none;
  color: var(--muted);
  cursor: default;
  filter: none;
  opacity: 1;
  text-shadow: none;
}
.pwa-install-help {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 3000;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .16s, transform .16s;
}
.pwa-install-help.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 520px) {
  .mobile-app-tile {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  .mobile-app-mark {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    font-size: 16px;
  }
  .mobile-app-install {
    grid-column: 1 / -1;
    width: 100%;
  }
}
.cb-marker.marker-best::after { background: #0d47a1; border-left: 2px dotted #0d47a1; width: 0; }
.cb-marker .cb-marker-label {
  position: absolute; transform: translate(-50%, -220%);
  font-size: 11px; white-space: nowrap; font-weight: 600; color: #c62828;
}
.cb-marker.marker-best .cb-marker-label { color: #0d47a1; }

/* ── Confirm Submit Modal ── */
.cb-confirm-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cb-confirm-panel {
  background: var(--white);
  border-radius: 14px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 12px 44px rgba(0,0,0,.38);
  overflow: hidden;
  border: 1px solid var(--border);
}
.cb-confirm-header {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cb-confirm-header-icon { font-size: 20px; }
.cb-confirm-header-text { color: #fff; font-weight: 700; font-size: 15px; }
.cb-confirm-body { padding: 18px 18px 8px; background: var(--white); }
.cb-confirm-summary { font-size: 14px; color: var(--text); line-height: 1.7; }
.cb-confirm-footer {
  padding: 12px 18px 18px;
  display: flex;
  gap: 10px;
  background: var(--white);
}
.cb-confirm-cancel {
  flex: 1; padding: 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: border-color .15s;
}
.cb-confirm-cancel:hover { border-color: var(--accent); }
.cb-confirm-submit {
  flex: 2; padding: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.cb-confirm-submit:hover { opacity: .9; }
.cb-confirm-submit:disabled,
.cb-confirm-cancel:disabled {
  cursor: wait;
  opacity: .72;
}

/* Submit lock overlay */
.cb-submit-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,.68);
}
.cb-submit-loading-overlay.is-active { display: flex; }
.cb-submit-loading-overlay[hidden] { display: none !important; }
.cb-submit-loading-panel {
  width: min(320px, 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--white);
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0,0,0,.42);
  padding: 22px 18px;
  text-align: center;
}
.cb-submit-loading-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  border: 5px solid rgba(21,101,192,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cb-submit-spin .8s linear infinite;
}
.cb-submit-loading-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 5px;
}
.cb-submit-loading-copy {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}
@keyframes cb-submit-spin {
  to { transform: rotate(360deg); }
}

/* ── Scanner modal ── */
.scanner-modal {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.85); z-index: 2000;
  flex-direction: column; align-items: center; justify-content: center;
}
.scanner-modal.active { display: flex; }
.scanner-inner {
  background: var(--white); border-radius: var(--radius);
  padding: 16px; width: 92%; max-width: 480px;
  box-sizing: border-box; overflow: hidden;
}
.scanner-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.scanner-title { font-weight: 700; font-size: 15px; }
.btn-close-scanner {
  background: var(--danger); color: #fff; border: none;
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
#scanner-area,
#scanner-area-alt,
#do-scanner-area,
#pl-scanner-area {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #07150d;
  max-width: 100% !important;
  box-sizing: border-box;
}
#scanner-area video,
#scanner-area canvas,
#scanner-area-alt video,
#scanner-area-alt canvas,
#do-scanner-area video,
#do-scanner-area canvas,
#pl-scanner-area video,
#pl-scanner-area canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  object-fit: cover;
}

/* ── Spacer at bottom ── */
.page-end { height: 30px; }

/* ── hide scanner-open nav ── */
body.scanner-open .app-header,
body.scanner-open .chip-nav { display: none !important; }
