:root {
  --bg: #0e1014;
  --panel: #15181e;
  --panel-2: #1b1f27;
  --hover: #20252f;
  --border: #252a34;
  --border-strong: #323946;
  --text: #e4e7ec;
  --text-2: #b4bac5;
  --muted: #7d8594;
  --star-muted: #7d859460;
  --accent: #5b8cff;
  --accent-2: #3f6fe0;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --ok: #3fb950;
  --warn: #d4a72c;
  --danger: #f05d5e;
  --r-common: #c6c9cf;
  --r-uncommon: #9fc0d4;
  --r-rare: #d9b45a;
  --r-mythic: #ec6b2d;
  --r-special: #b07ad6;
  --radius: 8px;
  --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --mono: 'Cascadia Mono', 'JetBrains Mono', Consolas, ui-monospace, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: #2c323d;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #3a4250;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand > i {
  color: var(--accent);
  font-size: 16px;
}
.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.2px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
}
.chip-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip:hover {
  border-color: #414a5a;
  color: var(--text);
}
.chip > i {
  font-size: 9px;
  color: var(--muted);
}
.chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}
.chip[data-state='cardmarket'] .dot {
  background: var(--ok);
}
.chip[data-state='loading'] .dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.price-src {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.pop-title {
  font-weight: 600;
  margin-bottom: 6px;
}
.pop-desc {
  margin: 0 0 12px;
  color: var(--text-2);
}
.pop-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pop-actions .btn {
  justify-content: flex-start;
}
.pop-hint {
  margin: 10px 0 0;
  font-size: 12px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.seg button + button {
  border-left: 1px solid var(--border-strong);
}
.seg button:hover {
  color: var(--text);
}
.seg button.on {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) {
  background: var(--hover);
  border-color: #414a5a;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn.sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.btn.ghost {
  background: transparent;
}
.btn.primary {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.btn kbd {
  font: 11px var(--font);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  opacity: 0.8;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.28;
  cursor: default;
  color: var(--muted);
}
.icon-btn.danger:hover:not(:disabled) {
  color: var(--danger);
  background: rgba(240, 93, 94, 0.1);
}

/* ---------- layout ---------- */

.layout {
  --input-w: 340px;
  --input-h: 420px;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--input-w) 12px minmax(5em, 1fr);
  gap: 0;
  padding: 12px;
}

.splitter {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  outline: none;
  transition: background 0.15s;
}
.splitter::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--border);
  transition: background 0.15s, box-shadow 0.15s, width 0.15s;
}
.splitter i {
  position: relative;
  z-index: 1;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.splitter:hover,
.splitter:focus-visible,
body.resizing .splitter {
  background: var(--accent-soft);
}
.splitter:hover::before,
.splitter:focus-visible::before,
body.resizing .splitter::before {
  width: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(91, 140, 255, 0.25);
}
.splitter:hover i,
.splitter:focus-visible i,
body.resizing .splitter i {
  opacity: 1;
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}
body.resizing-row {
  cursor: row-resize;
}
body.resizing iframe,
body.resizing * {
  cursor: inherit !important;
}

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-weight: 600;
}

/* ---------- input panel ---------- */

.input-panel {
  min-width: 0;
  overflow: hidden;
}
.input-panel textarea {
  flex: 1;
  min-height: 0;
  margin: 12px 12px 0;
  padding: 10px 12px;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  font: 13px/1.65 var(--mono);
  outline: none;
  tab-size: 4;
  white-space: pre;
  overflow: auto;
}
.input-panel textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-panel textarea::placeholder {
  color: #545c69;
}

.search-status {
  margin: 10px 12px 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text-2);
  max-height: 160px;
  overflow: auto;
}
.search-status > i {
  margin-right: 4px;
}
.search-status.ok > i {
  color: var(--ok);
}
.search-status.error {
  color: var(--danger);
}
.search-status .missing {
  margin-top: 6px;
  color: var(--warn);
}
.search-status ul {
  margin: 4px 0 0;
  padding-left: 22px;
  color: var(--text-2);
}

.input-actions {
  display: flex;
  gap: 8px;
  padding: 12px 12px 0;
}
.input-actions .primary {
  flex: 1;
}

.hint {
  margin: 8px 12px 12px;
  font-size: 12px;
}

/* ---------- table panel ---------- */

.toolbar {
  gap: 8px;
}
.toolbar .spacer {
  flex: 1;
}

.filter {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  width: min(320px, 100%);
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
}
.filter:focus-within {
  border-color: var(--accent);
}
.filter input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
}

.table-scroll {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.table-panel {
  min-width: 0;
}

.table-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 14px;
  border-top: 1px solid var(--border);
}
.total {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.total strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.total strong.fallback::after {
  content: '*';
  color: var(--warn);
  margin-left: 2px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 16px;
  color: var(--muted);
  text-align: center;
}
.empty i {
  font-size: 28px;
  opacity: 0.5;
}

/* DataTables overrides */

.dt-container {
  color: var(--text);
}

table.dataTable.cards {
  width: max-content !important;
  min-width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.dataTable.cards > thead > tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 10px !important;
  border-bottom: 1px solid var(--border-strong) !important;
  white-space: nowrap;
  text-align: left;
}
table.dataTable.cards > thead > tr > th.dt-orderable-asc:hover,
table.dataTable.cards > thead > tr > th.dt-orderable-desc:hover {
  color: var(--text);
  outline: none;
}
table.dataTable.cards > thead > tr > th.dt-ordering-asc,
table.dataTable.cards > thead > tr > th.dt-ordering-desc {
  color: var(--accent);
}
table.dataTable.cards thead th .dt-column-order {
  opacity: 0.6;
}

table.dataTable.cards > tbody > tr {
  background: transparent;
}
table.dataTable.cards > tbody > tr > td {
  padding: 1px 10px !important;
  height: 30px;
  border-top: 0 !important;
  border-bottom: 1px solid #3a4252;
  vertical-align: middle;
  white-space: nowrap;
}
table.dataTable.cards > tbody > tr:hover > td {
  background: #2a3140;
}
table.dataTable.cards > tbody > tr.row-checked > td {
  background: rgba(63, 185, 80, 0.07);
}
table.dataTable.cards > tbody > tr.row-checked:hover > td {
  background: rgba(63, 185, 80, 0.12);
}
table.dataTable.cards > tbody > tr.flash > td {
  animation: flash 1.4s ease-out;
}

@keyframes flash {
  0% {
    background: rgba(91, 140, 255, 0.22);
  }
  100% {
    background: transparent;
  }
}

table.dataTable.cards th.c-check,
table.dataTable.cards td.c-check {
  width: 1%;
  text-align: center !important;
  padding-left: 10px !important;
  padding-right: 4px !important;
}
table.dataTable.cards th.c-check .dt-column-header {
  justify-content: center;
}

.row-check {
  display: inline-grid;
  place-items: center;
  margin: 0;
  cursor: pointer;
}
.row-check-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.row-check-box {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  color: transparent;
  transition: border-color 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
}
.row-check-box i {
  font-size: 11px;
  line-height: 1;
}
.row-check:hover .row-check-box {
  border-color: var(--ok);
  color: rgba(63, 185, 80, 0.35);
}
.row-check.on .row-check-box {
  border-color: var(--ok);
  background: rgba(63, 185, 80, 0.15);
  color: var(--ok);
  box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.2);
}

table.dataTable.cards th.c-qty,
table.dataTable.cards td.c-qty {
  width: 1%;
  text-align: center !important;
  padding-left: 8px !important;
}
table.dataTable.cards th.c-qty .dt-column-header {
  justify-content: center;
}
table.dataTable.cards th.c-lang,
table.dataTable.cards td.c-lang {
  width: 1%;
  padding-left: 4px !important;
  padding-right: 4px !important;
}
table.dataTable.cards th.c-foil,
table.dataTable.cards td.c-foil {
  width: 1%;
  text-align: center !important;
  padding-left: 4px !important;
  padding-right: 4px !important;
}
table.dataTable.cards th.c-foil .dt-column-header {
  justify-content: center;
}

.foil {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--star-muted);
  transition: color 0.12s, background 0.12s;
}
.foil:hover {
  background: var(--hover);
  color: #d4a72c;
}
.foil.on {
  color: #f0c14a;
}
.foil.on:hover {
  color: #ffd666;
}
.foil-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.foil i {
  font-size: 14px;
  line-height: 1;
  transition: font-size 0.12s;
}
.foil:not(.on) i {
  font-size: 11px;
}
table.dataTable.cards .c-type {
  width: 1%;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.dataTable.cards .c-mana {
  width: 1%;
}
table.dataTable.cards .c-set {
  width: 1%;
}
table.dataTable.cards .c-cm {
  width: 1%;
}
table.dataTable.cards td.c-price,
table.dataTable.cards th.c-price {
  width: 1%;
  text-align: right !important;
}
table.dataTable.cards .c-actions {
  width: 1%;
  padding-right: 8px !important;
}

.lang-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.lang-cell:hover,
.lang-cell:focus-visible {
  border-color: var(--border-strong);
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.lang-flag {
  display: block;
  width: auto;
  height: 15px;
  max-width: 22px;
  border-radius: 2px;
  object-fit: contain;
  flex: none;
}
.lang-code {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.lang-menu {
  position: fixed;
  z-index: 250;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transform: translateY(-50%);
}
.lang-menu.open {
  display: flex;
}
.lang-opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.lang-opt:hover {
  background: var(--hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.lang-opt.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

input.qty {
  width: 44px;
  height: 26px;
  padding: 0 4px;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
input.qty::-webkit-inner-spin-button,
input.qty::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
tr:hover input.qty {
  border-color: var(--border-strong);
}
input.qty:focus {
  border-color: var(--accent);
  background: var(--bg);
}

table.dataTable.cards td.c-name {
  padding: 0 !important;
}
.name {
  display: flex;
  align-items: center;
  height: 100%;
  min-height: 30px;
  padding: 0 10px;
  box-sizing: border-box;
  font-weight: 500;
  cursor: pointer;
}
.name:hover {
  color: #fff;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}

.type {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.type-icons {
  display: inline-flex;
  gap: 4px;
  min-width: 16px;
  color: var(--text-2);
  font-size: 15px;
}
.type-main {
  color: var(--text-2);
}

/* mana symbols, offset shadow like on printed cards */
.c-mana {
  line-height: 0;
}
.mana-sym {
  width: 17px;
  height: 17px;
  margin-right: 2px;
  vertical-align: middle;
  border-radius: 50%;
  box-shadow: -1px 1px 0 rgba(0, 0, 0, 0.85);
}
.ms-sep {
  margin: 0 6px 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  vertical-align: middle;
}

.set {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.set-ico {
  flex: none;
  display: inline-block;
  width: 18px;
  height: 16px;
  background: var(--r-common);
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}
.set-ico.r-uncommon {
  background: linear-gradient(135deg, #6f8796, #d4e6f1 50%, #6f8796);
}
.set-ico.r-rare {
  background: linear-gradient(135deg, #8c6d2c, #f2d68a 50%, #8c6d2c);
}
.set-ico.r-mythic {
  background: linear-gradient(135deg, #b23c12, #f7a14c 50%, #b23c12);
}
.set-ico.r-special,
.set-ico.r-bonus {
  background: linear-gradient(135deg, #6a3d8f, #d4a5f2 50%, #6a3d8f);
}
.set-code {
  font-weight: 600;
  letter-spacing: 0.3px;
}
.set-cn {
  color: var(--muted);
}

.cm-link {
  color: var(--accent);
  text-decoration: none;
}
.cm-link:hover {
  text-decoration: underline;
}

.price {
  font-variant-numeric: tabular-nums;
}
.price.fallback {
  color: var(--text-2);
  font-style: italic;
}
.price.fallback::after {
  content: '*';
  color: var(--warn);
  font-style: normal;
  margin-left: 1px;
}

.actions {
  display: flex;
  gap: 2px;
  opacity: 0.55;
  transition: opacity 0.12s;
}
tr:hover .actions,
.actions:focus-within {
  opacity: 1;
}

/* ---------- preview ---------- */

.preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  display: flex;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
.preview.on {
  opacity: 1;
}
.preview img {
  width: 244px;
  aspect-ratio: 488 / 680;
  border-radius: 12px;
  background: var(--panel-2);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  max-height: 100svh;
  box-sizing: border-box;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(5, 6, 9, 0.65);
  animation: fade 0.12s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(720px, 100%);
  max-height: min(720px, calc(100vh - 48px), calc(100dvh - 48px), calc(100svh - 48px));
  margin: auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.modal-title strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-count {
  font-size: 12px;
}
.modal-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: 42px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.modal-filter input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
}
.prints {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  padding: 4px 0;
  outline: none;
}
.prints-state {
  padding: 32px;
  text-align: center;
}
.prints-state.error {
  color: var(--danger);
}
.print {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 110px 42px 22px 76px 18px;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 16px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.print.active {
  background: var(--hover);
}
.print.current {
  color: var(--accent);
}
.print.current .p-set {
  font-weight: 600;
}
.p-set {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-code {
  font-weight: 600;
}
.p-rar {
  font-weight: 700;
  font-size: 11px;
  text-align: center;
}
.p-rar.r-common {
  color: var(--r-common);
}
.p-rar.r-uncommon {
  color: var(--r-uncommon);
}
.p-rar.r-rare {
  color: var(--r-rare);
}
.p-rar.r-mythic {
  color: var(--r-mythic);
}
.p-rar.r-special,
.p-rar.r-bonus {
  color: var(--r-special);
}
.p-price {
  text-align: right;
  color: var(--text);
}
.p-cur {
  color: var(--accent);
}
.modal-foot {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

/* ---------- export modal ---------- */

.export-modal {
  width: min(440px, 100%);
  max-height: none;
}
.export-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.export-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.export-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.export-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}
.export-section.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.png-capture-host {
  position: fixed;
  left: -10000px;
  top: 0;
  z-index: -1;
  pointer-events: none;
  overflow: visible;
  background: var(--panel);
  padding: 0;
  margin: 0;
}
.export-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.export-check:hover {
  background: var(--hover);
}
.export-check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
}
.export-select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  outline: none;
  cursor: pointer;
}
.export-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.export-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}
.export-hint.error {
  color: var(--danger);
}
.export-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.export-foot .spacer {
  flex: 1;
}
.export-check.locked {
  opacity: 0.55;
  cursor: default;
}
.export-check.locked:hover {
  background: transparent;
}
.export-check input:disabled {
  cursor: default;
}

.led-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.led-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.led-choice:hover {
  background: var(--hover);
  color: var(--text);
}
.led-choice.on {
  border-color: rgba(63, 185, 80, 0.45);
  background: rgba(63, 185, 80, 0.08);
  color: var(--text);
}
.led {
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: #2a303a;
  box-shadow: inset 0 0 0 1px #1a1e26;
}
.led-choice.on .led {
  background: #3fb950;
  box-shadow:
    0 0 0 2px rgba(63, 185, 80, 0.2),
    0 0 10px rgba(63, 185, 80, 0.65),
    inset 0 0 4px rgba(255, 255, 255, 0.35);
}

.selection-modal {
  width: min(520px, 100%);
}
.sel-count {
  font-size: 12px;
  font-weight: 400;
}
.sel-body {
  gap: 12px;
}
.sel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sel-row .btn {
  justify-content: flex-start;
}
.sel-foil-ico {
  color: #f0c14a;
}
.sel-langs .sel-lang {
  gap: 6px;
}
.sel-langs .lang-flag {
  width: auto;
  height: 14px;
}
.danger-outline {
  border-color: rgba(240, 93, 94, 0.45);
  color: var(--danger);
}
.danger-outline:hover:not(:disabled) {
  background: rgba(240, 93, 94, 0.1);
  border-color: var(--danger);
}
.danger-btn {
  background: #b43a3b !important;
  border-color: #b43a3b !important;
}
.danger-btn:hover:not(:disabled) {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
}
.sel-confirm {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

/* ---------- toasts ---------- */

.tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 320;
  max-width: 240px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #1e2430;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4);
  animation: tip-in 0.12s ease-out;
}
.tip[hidden] {
  display: none !important;
}
@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toasts {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 8px 8px 8px 14px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  animation: rise 0.16s ease-out;
}
.toast.ok {
  border-left-color: var(--ok);
}
.toast.warn {
  border-left-color: var(--warn);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast:not(:has(button)) {
  padding-right: 14px;
}
.toast.out {
  opacity: 0;
  transform: translateY(6px);
  transition: 0.18s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- drop zone ---------- */

.drop-zone {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background: rgba(14, 16, 20, 0.82);
  pointer-events: none;
}
.drop-zone > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 56px;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
}
.drop-zone i {
  font-size: 32px;
  color: var(--accent);
}

/* ---------- edit banner / save ---------- */

.edit-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(91, 140, 255, 0.12);
  border-bottom: 1px solid rgba(91, 140, 255, 0.35);
  color: var(--text);
  font-size: 13px;
}
.edit-banner > i {
  color: var(--accent);
}
.edit-banner span {
  flex: 1;
}
.table-foot-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

/* ---------- history page ---------- */

.history-page {
  overflow-x: hidden;
  overflow-y: auto;
  height: auto;
  min-height: 100%;
  max-width: 100%;
  width: 100%;
}
.history-page.is-editing {
  height: 100%;
  overflow: hidden;
}
.history-page .topbar {
  position: sticky;
  top: 0;
  z-index: 20;
}
.history-page.is-editing .topbar {
  position: relative;
  flex: none;
}
.hist-main {
  max-width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px 16px 48px;
  min-width: 0;
  overflow-x: clip;
}
.history-page.is-editing .hist-main {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hist-toolbar {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 12px;
}
.hist-toolbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}
.hist-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.hist-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
}
.hist-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.hist-card-filter {
  position: relative;
  width: 100%;
}
.hist-card-field {
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  overflow: hidden;
}
.hist-card-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.hist-card-field > i {
  flex: none;
  margin-left: 10px;
}
.hist-card-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}
.hist-card-clear {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.hist-card-clear:hover {
  background: var(--hover);
  color: var(--text);
}
.hist-card-side {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 46%;
  height: 100%;
  padding: 0 28px 0 12px;
  border: 0;
  border-left: 1px solid var(--border-strong);
  border-radius: 0;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237d8594' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
}
.hist-card-side:focus {
  background-color: var(--hover);
}
.hist-card-suggest {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  max-height: min(320px, 50vh);
  overflow: auto;
}
.hist-card-suggest[hidden] {
  display: none !important;
}
.hist-card-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
}
.hist-card-opt:hover,
.hist-card-opt.on {
  background: var(--hover);
}
.hist-card-opt-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-card-opt-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--text-2);
  font-size: 12px;
}
.hist-card-opt-meta .type {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-card-opt-empty {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}
.hist-card-field.has-filter {
  border-color: rgba(91, 140, 255, 0.45);
}
.hist-filter-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.hist-filter-seg {
  flex: none;
  white-space: nowrap;
  max-width: 100%;
}
.hist-filter-seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 8px;
}
.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hist-filter-seg button.on .filter-badge {
  background: rgba(79, 140, 255, 0.22);
  color: var(--accent);
}
.hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 16px;
  text-align: center;
}
.hist-empty i {
  font-size: 32px;
  opacity: 0.5;
}
.hist-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.hist-card {
  --hist-card-accent: var(--border-strong);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-left: 7px solid var(--hist-card-accent);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.hist-card:hover {
  background: var(--hover);
  border-color: var(--hist-card-accent);
}
.hist-card:focus-visible {
  outline: 2px solid var(--hist-card-accent);
  outline-offset: 2px;
}
.hist-card.status-draft {
  --hist-card-accent: #8b93a7;
}
.hist-card.status-confirmed {
  --hist-card-accent: #3b82f6;
}
.hist-card.status-done {
  --hist-card-accent: #22c55e;
}
.hist-card.status-abandoned {
  --hist-card-accent: #9ca3af;
}
.hist-card.status-dispute {
  --hist-card-accent: #ef4444;
}
.hist-badges-wrap {
  position: absolute;
  top: -1px;
  right: 12px;
  z-index: 3;
  display: flex;
  gap: 6px;
}
.hist-badge-wrap {
  position: relative;
}
.hist-status,
.hist-kind {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 0 0 8px 8px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.hist-status:hover,
.hist-kind:hover {
  filter: brightness(1.08);
}
.hist-kind.kind-sale,
.hist-status-opt.kind-sale {
  background: #0d9488;
  border-color: #0f766e;
}
.hist-kind.kind-exchange,
.hist-status-opt.kind-exchange {
  background: #7c3aed;
  border-color: #6d28d9;
}
.hist-status.status-draft,
.hist-status-opt.status-draft {
  background: #6b7280;
  border-color: #4b5563;
}
.hist-status.status-confirmed,
.hist-status-opt.status-confirmed {
  background: #2563eb;
  border-color: #1d4ed8;
}
.hist-status.status-done,
.hist-status-opt.status-done {
  background: #16a34a;
  border-color: #15803d;
}
.hist-status.status-abandoned,
.hist-status-opt.status-abandoned {
  background: #9ca3af;
  border-color: #6b7280;
  color: #111827;
}
.hist-status-inline {
  border-radius: 6px;
  height: 20px;
  padding: 0 8px;
  font-size: 10px;
  vertical-align: middle;
  cursor: default;
  pointer-events: none;
  box-shadow: none;
}
.hist-status-inline:hover {
  filter: none;
}
.hist-delete-warn {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hist-delete-warn p {
  margin: 0;
}
.hist-status.status-dispute,
.hist-status-opt.status-dispute {
  background: #dc2626;
  border-color: #b91c1c;
}
.hist-badge-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.hist-badge-menu[hidden] {
  display: none;
}
.hist-status-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.hist-status-opt.on {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: -2px;
}
.hist-status-opt:hover {
  filter: brightness(1.1);
}
.hist-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding-right: 200px;
}
.hist-card-title {
  font-size: 15px;
}
.hist-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
}
.hist-sides {
  display: grid;
  gap: 6px;
  font-size: 13px;
}
.hist-dash {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.hist-dash-col {
  flex: 1 1 140px;
  min-width: 0;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}
.hist-dash-main,
.hist-dash-value {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.hist-dash-col:first-child {
  text-align: right;
}
.hist-dash-col:first-child .hist-dash-label,
.hist-dash-col:first-child .hist-dash-main,
.hist-dash-col:first-child .hist-dash-value {
  text-align: right;
}
.hist-dash-label {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.hist-dash-main {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.hist-dash-value {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-2);
}
.hist-card-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
.hist-card-meetup {
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-card-timer {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.25;
  white-space: nowrap;
}
.hist-card-timer.is-past {
  color: var(--muted);
  border-color: transparent;
  background: transparent;
  font-weight: 500;
}
.hist-card-timer.is-urgent {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.08);
  animation: hist-timer-pulse 1.6s ease-in-out infinite;
}
@keyframes hist-timer-pulse {
  0%,
  100% {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
  50% {
    border-color: rgba(239, 68, 68, 0.9);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
  }
}
.hist-detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}
.hist-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hist-editor-full {
  flex: 1;
  min-height: 0;
  gap: 0;
}
.hist-editor-bar {
  position: relative;
  z-index: 30;
  flex: none;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.hist-editor-bar-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.hist-editor-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.hist-editor-badges .hist-status,
.hist-editor-badges .hist-kind {
  border-radius: 6px;
  height: 26px;
  box-shadow: none;
}
.contacts-summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(280px, 36vw);
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
}
.contacts-summary > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contacts-summary > i {
  flex: none;
  opacity: 0.75;
  font-size: 11px;
}
.contacts-summary.is-empty {
  color: var(--muted);
  font-style: italic;
}
.contacts-summary:hover {
  border-color: rgba(79, 140, 255, 0.45);
  background: var(--accent-soft);
  color: var(--text);
}
.contacts-modal {
  width: min(720px, 100%);
}
.contacts-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(60vh, 480px);
  overflow: auto;
}
.contacts-modal .contact-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.contacts-modal .contact-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.contacts-modal .contact-row label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
}
.contacts-modal .contact-row input:not([type='checkbox']) {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
.hist-side-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}
.hist-side-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.hist-editor-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px 16px;
  overflow: hidden;
}
.hist-editor-meta {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 12px;
  min-height: 0;
  max-height: min(42vh, 360px);
  overflow: auto;
}
.hist-notes-section {
  display: flex;
  padding: 6px !important;
  overflow: hidden;
}
.hist-notes-section .notes-area {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}
.hist-notes-section .notes-area:focus {
  outline: none;
  border-color: var(--accent);
}
.hist-section-meetup {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.meetup-sticky {
  flex: none;
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 8px;
  background: var(--panel);
}
.meetup-fields {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
  z-index: 1;
}
.meetup-seg {
  width: 100%;
  display: flex;
  position: relative;
  z-index: 6;
  background: var(--panel);
}
.meetup-seg button {
  flex: 1;
  padding: 6px 8px;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
.datetime-wrap,
.maps-url-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1;
  min-width: 0;
}
.datetime-wrap input[type='datetime-local'],
.maps-url-wrap input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.maps-url-wrap.is-empty input {
  border-radius: 6px;
}
.datetime-wrap .icon-btn,
.maps-url-wrap .icon-btn {
  height: 34px;
  width: 34px;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: var(--panel-2);
  text-decoration: none;
  color: inherit;
}
.datetime-wrap .icon-btn:hover,
.maps-url-wrap .icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.maps-url-wrap .icon-btn[hidden] {
  display: none;
}
.money-input {
  display: flex;
  align-items: stretch;
}
.money-input input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.currency-affix {
  flex: none;
  width: 42px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.currency-affix:hover {
  background: var(--hover);
  color: var(--accent);
}
.currency-choice-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.currency-choice-sym {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  min-width: 1.1em;
  text-align: center;
}
.hist-card-row {
  cursor: default;
}
.hist-foil {
  color: #eab308;
  font-size: 11px;
}
.hist-table-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 0;
  min-width: 0;
}
.hist-table-bar .hist-side-summary {
  margin: 0;
}
.hist-view-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.hist-view-seg button {
  width: 32px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hist-grid-size {
  display: inline-flex;
  align-items: center;
}
.hist-grid-size input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 176px;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.hist-grid-size input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
.hist-grid-size input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
.hist-grid-size input[type='range']:hover::-webkit-slider-thumb {
  background: var(--accent);
}
.hist-grid-size input[type='range']:focus {
  outline: none;
}
.hist-grid-size input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.hist-grid-size input[type='range']::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
}
.hist-grid-size input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.hist-grid-size input[type='range']:hover::-moz-range-thumb {
  background: var(--accent);
}
.hist-card-grid {
  --hist-card-w: 140px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--hist-card-w));
  justify-content: start;
  gap: 12px 10px;
  margin-top: 10px;
  min-width: 0;
}
.hist-grid-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: var(--hist-card-w);
  max-width: 100%;
  min-width: 0;
  text-align: center;
}
.hist-grid-art {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.hist-grid-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}
.hist-grid-missing {
  width: 100%;
  height: 100%;
  background: linear-gradient(160deg, var(--panel-2), var(--bg));
}
.hist-grid-qty {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 1.6em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.hist-grid-foil {
  position: absolute;
  top: 6px;
  right: 6px;
  color: #eab308;
  font-size: 12px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}
.hist-grid-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-align: center;
}
.hist-grid-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.hist-grid-meta .lang-flag {
  flex: none;
}
.hist-grid-meta .set-ico {
  width: 16px;
  height: 14px;
}
.hist-grid-meta .set-code {
  font-weight: 600;
}
.hist-grid-meta .set-cn {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-list-empty,
.hist-side-summary {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-2);
}
.hist-table-wrap {
  margin-top: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.hist-data-table {
  width: max-content;
  min-width: 100%;
  max-width: none;
  border-collapse: collapse;
  font-size: 12px;
}
.hist-data-table th,
.hist-data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.hist-data-table th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  z-index: 1;
}
.hist-data-table tbody tr:last-child td {
  border-bottom: 0;
}
.hist-data-table .hist-td-name {
  white-space: normal;
  min-width: 120px;
}
.copy-name {
  cursor: pointer;
}
.copy-name:hover {
  color: #fff;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}
.hist-grid-name.copy-name:hover {
  color: var(--text);
}
.hist-data-table th[data-col='lang'],
.hist-data-table th[data-col='foil'],
.hist-data-table .hist-td-lang,
.hist-data-table .hist-td-foil {
  width: 1%;
  padding-left: 6px;
  padding-right: 6px;
}
.hist-data-table .hist-td-lang {
  line-height: 0;
}
.hist-data-table .hist-td-lang .lang-cell-inner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
  vertical-align: middle;
}
.hist-data-table .hist-td-foil {
  text-align: center;
}
.hist-data-table .hist-td-type {
  line-height: 1.2;
}
.hist-data-table .hist-td-type .type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  line-height: 1.2;
}
.hist-data-table .hist-td-type .type-icons {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  line-height: 1;
  font-size: 14px;
}
.hist-data-table .hist-td-type .type-icons .ms {
  display: inline-block;
  line-height: 1;
  vertical-align: middle;
}
.hist-data-table .hist-td-type .type-main {
  line-height: 1.2;
}
.hist-side-panel .money-grid > label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}
.money-summary {
  min-width: 0;
}
.money-summary-labels {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.money-summary-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  line-height: 1.35;
}
.money-summary-line.muted {
  color: var(--muted);
}
.money-summary-line.muted .money-summary-badge {
  opacity: 0.7;
}
.money-summary-badge {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 1px 8px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  cursor: pointer;
}
.money-summary-badge:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}
.money-summary-diff {
  font-weight: 500;
  color: var(--text-2);
}
.money-summary-only .money-summary-line {
  font-size: 26px;
  gap: 10px;
}
.money-summary-only .money-summary-badge {
  font-size: 24px;
  padding: 4px 14px;
  border-radius: 8px;
}
.money-values-modal .money-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.money-values-modal .money-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.money-values-modal .money-input input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.money-values-modal .money-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.money-values-modal .money-input input[readonly] {
  opacity: 0.75;
  cursor: default;
}
.hist-side-panel .sel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hist-sides-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
}
.hist-side-panel {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: auto;
}
.hist-side-panel > #side-give,
.hist-side-panel > #side-receive,
.hist-side-panel .money-grid {
  min-width: 0;
  max-width: 100%;
}
.hist-section-compact {
  min-height: 0;
  overflow: auto;
}
.hist-section-compact.hist-section-meetup {
  overflow: hidden;
}
.hist-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.hist-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.hist-section {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hist-section h2 {
  margin: 0;
  font-size: 14px;
}
.hist-side-panel > .hist-section-head > h2 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.hist-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.hist-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.hist-section label.full {
  grid-column: 1 / -1;
}
.hist-section input,
.hist-section select,
.hist-section textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.hist-section textarea {
  height: auto;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
}
.hist-section .check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
}
.hist-section > label,
.money-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.meetup-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hist-section label.field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: inherit;
  font-size: inherit;
}
.hist-section label.field-inline.field-inline-top {
  align-items: flex-start;
}
.field-inline-label {
  flex: none;
  width: 7.5rem;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}
.hist-section label.field-inline > input,
.hist-section label.field-inline > textarea,
.hist-section label.field-inline > .datetime-wrap,
.hist-section label.field-inline > .maps-url-wrap {
  flex: 1;
  min-width: 0;
}
.hist-section label.field-inline > textarea {
  min-height: 64px;
}
.contact-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.hist-editor-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding: 12px 0;
  background: linear-gradient(transparent, var(--bg) 30%);
}

.save-modal {
  width: min(480px, 100%);
}
.save-modal label.field-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.save-modal label.field-inline > input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  outline: none;
}
.save-modal label.field-inline > input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Touch / no-hover: keep controls visible, skip card hover preview */
@media (hover: none) {
  .actions {
    opacity: 1;
  }
  .preview {
    display: none !important;
  }
  input.qty {
    border-color: var(--border-strong);
  }
}

/* ---------- tablet & below ---------- */

@media (max-width: 1100px) {
  .hist-editor-meta {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .hist-sides-split {
    grid-template-columns: minmax(0, 1fr);
    overflow: auto;
  }
  .hist-editor-bar-main {
    flex-wrap: wrap;
  }
  .hist-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
  .layout {
    --input-h: min(280px, 38dvh);
    grid-template-columns: 1fr;
    grid-template-rows: var(--input-h) 12px minmax(12em, 1fr);
    padding: 8px;
  }
  .splitter {
    cursor: row-resize;
  }
  .splitter::before {
    top: 50%;
    bottom: auto;
    left: 12px;
    right: 12px;
    width: auto;
    height: 2px;
    transform: translateY(-50%);
  }
  .splitter:hover::before,
  .splitter:focus-visible::before,
  body.resizing .splitter::before {
    width: auto;
    height: 3px;
  }
  .splitter i {
    transform: rotate(90deg);
  }
  .topbar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 8px 12px;
  }
  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-left: auto;
  }
  .toolbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 46px;
  }
  .toolbar .filter {
    flex: 1 1 100%;
    width: 100%;
    order: -1;
  }
  .toolbar .spacer {
    display: none;
  }
  .table-foot {
    height: auto;
    min-height: 40px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .table-foot-right {
    flex-wrap: wrap;
    margin-left: auto;
  }
  .modal-backdrop {
    align-items: center;
    justify-content: center;
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .modal {
    max-height: min(calc(100dvh - 24px), calc(100svh - 24px));
    width: min(720px, 100%);
    max-width: 100%;
    box-sizing: border-box;
  }
  .modal.export-modal,
  .modal.save-modal,
  .modal.selection-modal,
  .modal.contacts-modal {
    width: min(100%, 480px);
    max-width: 100%;
  }
  .modal-head {
    flex-wrap: wrap;
  }
  .modal-title {
    white-space: normal;
  }
  .export-body,
  .export-foot,
  .led-choices,
  .led-choice {
    min-width: 0;
    max-width: 100%;
  }
  .led-choice {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .export-foot {
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .export-foot .btn {
    flex: 1 1 auto;
  }
  .popover {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(340px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
  }
  .print {
    grid-template-columns: 20px minmax(0, 1fr) 22px 72px 18px;
    gap: 8px;
    height: auto;
    min-height: 36px;
    padding: 6px 12px;
  }
  .print .p-code,
  .print .p-year {
    display: none;
  }
  .lang-menu {
    flex-wrap: wrap;
    max-width: calc(100vw - 16px);
    transform: none;
  }
  .preview img {
    width: min(200px, 42vw);
  }
  .hist-card-top {
    padding-right: 0;
    padding-top: 18px;
  }
  .hist-badges-wrap {
    right: 8px;
  }
  .hist-editor-bar {
    padding: 10px;
  }
  .contacts-summary {
    max-width: min(220px, 50vw);
  }
  .hist-dash-col:first-child,
  .hist-dash-col:first-child .hist-dash-label,
  .hist-dash-col:first-child .hist-dash-main,
  .hist-dash-col:first-child .hist-dash-value {
    text-align: left;
  }
  .hist-card-foot {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .hist-card-meetup {
    flex: 1 1 100%;
    text-align: left;
    white-space: normal;
  }

  /* Transaction detail: page scrolls; panels do not nest-scroll */
  .history-page.is-editing {
    height: auto;
    min-height: 100%;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .history-page.is-editing .topbar {
    position: relative;
  }
  .history-page.is-editing .hist-main {
    flex: none;
    min-height: 0;
    overflow: visible;
    display: block;
  }
  .hist-editor-full {
    flex: none;
    min-height: 0;
  }
  .hist-editor-bar {
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .hist-editor-body {
    flex: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 10px 14px;
    overflow: visible;
  }
  .hist-editor-meta,
  .hist-sides-split,
  .hist-side-panel,
  .hist-section-compact,
  .meetup-fields {
    max-height: none;
    min-width: 0;
    max-width: 100%;
    overflow: visible;
  }
  .hist-section-compact.hist-section-meetup {
    overflow: visible;
  }
  .hist-editor-full,
  .hist-editor-body {
    min-width: 0;
    max-width: 100%;
  }
  .hist-table-wrap {
    width: 100%;
    max-width: 100%;
  }
  .hist-notes-section {
    overflow: visible;
  }
  .hist-notes-section .notes-area {
    height: auto;
    min-height: 120px;
  }
  .meetup-seg button {
    white-space: normal;
    line-height: 1.25;
    padding: 6px 4px;
  }
}

/* ---------- phone ---------- */

@media (max-width: 640px) {
  .brand-name {
    font-size: 13px;
  }
  .topbar-right .btn.sm > i + span,
  .toolbar .btn.sm > i + span,
  .hist-detail-actions .btn.sm > i + span,
  .hist-editor-bar .btn.sm > i + span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .topbar-right .btn.sm:has(> i),
  .toolbar .btn.sm:has(> i),
  .hist-detail-actions .btn.sm:has(> i),
  .hist-editor-bar .btn.sm:has(> i) {
    width: 32px;
    padding: 0;
    gap: 0;
  }
  .btn.primary kbd {
    display: none;
  }
  .chip {
    max-width: min(140px, 36vw);
  }
  .input-actions {
    flex-wrap: wrap;
  }
  .input-actions .btn {
    flex: 1 1 auto;
  }
  .edit-banner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
  }
  .export-cols {
    grid-template-columns: 1fr;
  }
  .export-foot {
    flex-wrap: wrap;
  }
  .sel-row .btn {
    flex: 1 1 calc(50% - 4px);
  }
  .drop-zone > div {
    margin: 16px;
    padding: 28px 24px;
    text-align: center;
  }
  .hist-main {
    padding: 14px 10px 40px;
  }
  .hist-toolbar {
    flex-wrap: wrap;
    gap: 6px 10px;
  }
  .hist-toolbar h1 {
    font-size: 18px;
  }
  .hist-meta-grid {
    grid-template-columns: 1fr;
  }
  .hist-section > label {
    grid-template-columns: 1fr;
  }
  .hist-side-panel > .hist-section-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .hist-side-actions {
    width: auto;
    max-width: 100%;
    justify-content: flex-end;
  }
  .hist-side-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .money-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }
  .money-grid .money-field-surcharge {
    grid-column: 1 / -1;
  }
  .money-grid .money-field {
    min-width: 0;
  }
  .hist-editor-body {
    padding-left: 0;
    padding-right: 0;
  }
  .hist-detail-actions,
  .hist-editor-meta {
    padding-left: 10px;
    padding-right: 10px;
  }
  .hist-sides-split {
    gap: 10px;
  }
  .hist-side-panel.hist-section {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .hist-table-bar {
    flex-wrap: wrap;
  }
  .hist-view-controls {
    margin-left: auto;
  }
  .hist-section label.field-inline,
  .save-modal label.field-inline {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  .field-inline-label {
    width: auto;
  }
  .hist-filter-row {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    overflow-x: visible;
  }
  .hist-filter-seg {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    white-space: normal;
  }
  .hist-filter-seg button {
    flex: 1 1 auto;
  }
  .hist-card-field {
    position: relative;
    flex-wrap: wrap;
    height: auto;
    min-height: 36px;
  }
  .hist-card-field > i {
    margin-top: 10px;
  }
  .hist-card-field input {
    min-height: 36px;
  }
  .hist-card-side {
    flex: 1 1 100%;
    max-width: none;
    height: 34px;
    border-left: 0;
    border-top: 1px solid var(--border-strong);
  }
  .hist-card-clear {
    position: absolute;
    right: 8px;
    top: 4px;
  }
  .hist-card-field.has-filter input {
    padding-right: 36px;
  }
  .hist-card-title,
  .hist-meta {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .hist-card-opt {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .hist-card-opt-meta {
    flex-wrap: wrap;
  }
  .hist-card-opt-meta .type {
    max-width: 100%;
  }
  .hist-editor-badges {
    flex-wrap: wrap;
  }
  /* Keep every column; scroll the table horizontally inside the card */
  .hist-table-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .hist-data-table {
    width: max-content;
    min-width: 100%;
    max-width: none;
  }
  .hist-data-table th,
  .hist-data-table td,
  .hist-data-table .hist-td-name {
    white-space: nowrap;
  }
  .modal-foot {
    display: none;
  }
  .tip {
    max-width: min(240px, calc(100vw - 16px));
    white-space: normal;
  }
}

@media (max-width: 420px) {
  .layout {
    --input-h: min(220px, 34dvh);
    padding: 6px;
  }
  .chip {
    max-width: 96px;
  }
  .chip > i.fa-chevron-down {
    display: none;
  }
  .print {
    grid-template-columns: 18px minmax(0, 1fr) 64px;
    gap: 6px;
  }
  .print .p-rar,
  .print .p-cur {
    display: none;
  }
  .hist-dash-col {
    flex: 1 1 100%;
  }
  .hist-cards {
    min-width: 0;
  }
}

.hist-login {
  width: min(360px, calc(100vw - 2rem));
  margin: 0;
  padding: 1.5rem;
  border: 1px solid var(--border, #2a3542);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel, #1a222c) 92%, transparent);
}
.hist-login h1 {
  margin: 0;
  font-size: 1.25rem;
  text-align: center;
}
.hist-login-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.hist-login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted, #8b9aab);
}
.hist-login-form input {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border, #2a3542);
  background: var(--bg, #0f1419);
  color: inherit;
}
.hist-login-error {
  margin: 0;
  color: #e07070;
}
.history-page.hist-locked .topbar-right #hist-import,
.history-page.hist-locked .topbar-right #hist-export-all {
  display: none;
}

body.app-locked .topbar,
body.app-locked .app-shell,
body.app-locked .edit-banner,
body.app-locked .drop-zone,
body.app-locked #history-link,
body.app-locked .price-src,
body.app-locked #app-logout {
  display: none !important;
}
body.app-locked #auth-gate,
body.app-locked #hist-root {
  display: flex !important;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 1rem;
  box-sizing: border-box;
  overflow: auto;
}

.share-page .share-main {
  padding-bottom: 2rem;
}
.share-page .share-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.share-page .share-meta .hist-status {
  border-radius: 6px;
  cursor: default;
}
.share-page .share-meta .hist-status:hover {
  filter: none;
}
.share-page .share-updated {
  font-size: 0.9rem;
}
.share-page .share-tx-title {
  flex: 1 1 100%;
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.share-page .share-side-head {
  align-items: flex-start;
}
.share-page .share-side-headings {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.share-page .share-side-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.share-page .share-side-extra {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text, #e8eef4);
  letter-spacing: 0.01em;
}
.share-page .hist-side-actions .hist-view-controls {
  margin-left: 2px;
}

