/* Module Tattoo — admin panel. Tablet at the counter first: big touch targets, few steps. */

:root {
  color-scheme: dark;
  --bg: #121010;
  --surface: #1c1918;
  --surface-2: #26221f;
  --line: #3a332d;
  --text: #f2ebe1;
  --muted: #a39a8f;
  --accent: #d7263d;
  --accent-ink: #fff;
  --ok: #5cc98f;
  --warn: #f2b134;
  --danger: #ff6b6b;
  --info: #3fa7d6;
  --gold: #e8b04a;
  --r-common: #c9c0b4;
  --r-rare: #3fa7d6;
  --r-epic: #b06ef0;
  --r-legendary: #f2b134;
  --radius: 10px;
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
}

a {
  color: var(--text);
  text-decoration-color: var(--muted);
  text-underline-offset: 3px;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.2;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

p {
  margin: 0 0 10px;
}

code,
.mono {
  font-family: var(--mono);
}

/* --- layout ------------------------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
}

.me {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.me form {
  display: inline;
}

.topbar .menu-toggle {
  display: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.page--narrow {
  max-width: 720px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.stack > * + * {
  margin-top: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}

.kpi {
  display: grid;
  gap: 4px;
}

.kpi b {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}

/* --- buttons and forms ------------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn--secondary {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.btn--danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

.btn--small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.btn--block {
  width: 100%;
}

.btn--huge {
  min-height: 96px;
  font-size: 1.35rem;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

label {
  display: block;
}

.field {
  display: grid;
  gap: 6px;
}

.field > span:first-child,
.label {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  width: 22px;
  min-height: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.is-invalid,
[aria-invalid="true"] {
  border-color: var(--danger);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.choices {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--surface-2);
}

.input-big {
  min-height: 64px;
  font-size: 1.4rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}

fieldset {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 6px;
  color: var(--muted);
}

details > summary {
  min-height: 40px;
  padding: 8px 0;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

/* --- messages, badges --------------------------------------------------------------------------- */

.flash,
.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--ok);
  border-radius: 8px;
  background: var(--surface-2);
}

.flash--error,
.alert--error {
  border-color: var(--danger);
}

.flash--warning,
.alert--warning {
  border-color: var(--warn);
}

.flash--info,
.alert--info {
  border-color: var(--info);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.badge--ok {
  border-color: var(--ok);
  color: var(--ok);
}

.badge--warn {
  border-color: var(--warn);
  color: var(--warn);
}

.badge--danger {
  border-color: var(--danger);
  color: var(--danger);
}

.r-common {
  --r: var(--r-common);
}

.r-rare {
  --r: var(--r-rare);
}

.r-epic {
  --r: var(--r-epic);
}

.r-legendary {
  --r: var(--r-legendary);
}

.badge.rarity {
  border-color: var(--r);
  color: var(--r);
}

.plus {
  color: var(--ok);
}

.minus {
  color: var(--danger);
}

.amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- tables, lists, tabs ---------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

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

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.is-off td {
  opacity: 0.55;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.list > li:last-child {
  border-bottom: 0;
}

.results a.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
}

.results a.result + a.result {
  margin-top: 8px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  border-color: var(--accent);
  color: var(--text);
}

.pager {
  margin-top: 16px;
}

.icon {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 10px;
  background: var(--surface-2);
  object-fit: contain;
}

.icon--big {
  width: 128px;
  height: 128px;
}

/* --- counter, scanner, visit form ------------------------------------------------------------- */

.counter-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}

.client-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.balance {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quote {
  display: grid;
  gap: 6px;
}

.quote dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  margin: 0;
}

.quote dt {
  color: var(--muted);
}

.quote dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.quote .total {
  font-size: 1.3rem;
  font-weight: 700;
}

.scanner {
  display: grid;
  gap: 16px;
  max-width: 640px;
}

.scanner video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: #000;
  object-fit: cover;
}

.scanner canvas {
  display: none;
}

/* --- charts ----------------------------------------------------------------------------------- */

/* One chart per row until there is room for two readable ones. */
.grid-charts {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr));
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

/* Line widths in screen pixels, whatever the chart's drawn size. */
.chart__grid,
.chart__line,
.chart__dot {
  vector-effect: non-scaling-stroke;
}

.chart__grid {
  stroke: var(--line);
  stroke-width: 1px;
}

/* SVG user units: the 720-wide chart is drawn at 520–700 px, so text is set larger. */
.chart__axis,
.chart__legend {
  fill: var(--muted);
  font: 17px var(--font);
}

.chart__legend {
  fill: var(--text);
}

.chart__empty {
  fill: var(--muted);
  font: 20px var(--font);
}

.chart__bar {
  fill: var(--accent);
}

.chart__line {
  fill: none;
  stroke-width: 3px;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart__dot {
  stroke: var(--surface);
  stroke-width: 2px;
}

.chart__line.s0,
.chart__key.s0,
.chart__dot.s0 {
  stroke: var(--info);
  fill: var(--info);
}

.chart__line.s1,
.chart__key.s1,
.chart__dot.s1 {
  stroke: var(--ok);
  fill: var(--ok);
}

.chart__line.s2,
.chart__key.s2,
.chart__dot.s2 {
  stroke: var(--warn);
  fill: var(--warn);
}

.chart__dot.s0,
.chart__dot.s1,
.chart__dot.s2 {
  stroke: var(--surface);
}

.chart__line.s0,
.chart__line.s1,
.chart__line.s2 {
  fill: none;
}

/* --- sign-in ---------------------------------------------------------------------------------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login .card {
  width: min(100%, 400px);
}

@media (max-width: 760px) {
  .topbar .menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
  }

  .nav.is-open {
    display: flex;
  }

  .me {
    flex-basis: 100%;
  }

  h1 {
    font-size: 1.35rem;
  }
}

@media print {
  .topbar,
  .actions,
  form {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* --- campaigns --- */
.push-preview { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; background: var(--surface-2); max-width: 420px; }
.push-preview__icon { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.push-preview p { margin: 4px 0 0; white-space: pre-line; }
.campaign-image { max-width: 240px; max-height: 160px; border-radius: 10px; object-fit: cover; }
.form-grid .field--wide { grid-column: 1 / -1; }
