:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #18202b;
  --muted: #5d6b80;
  --line: #dbe2ee;
  --brand: #0f4b8f;
  --ok: #2e7d32;
  --warn: #a8432b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

.topbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-actions {
  margin-top: 10px;
}

.auth {
  max-width: 480px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

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

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

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

.users-layout {
  align-items: start;
}

h1, h2, h3 {
  margin: 0 0 12px 0;
}

p {
  margin: 0 0 8px 0;
}

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

form.form-grid {
  display: grid;
  gap: 8px;
}

.search-form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto auto;
}

label {
  font-size: 14px;
  color: var(--muted);
}

label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  padding: 4px 0 8px;
}

input,
select,
button,
a.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

button,
a.button {
  cursor: pointer;
  background: var(--panel);
  text-decoration: none;
  color: var(--text);
}

.button-primary {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

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

.action-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
  text-decoration: none;
}

.action-card:hover {
  border-color: var(--brand);
}

.action-card h3 {
  margin-bottom: 6px;
}

.action-card p {
  margin-bottom: 10px;
}

.stat-pill {
  display: inline-block;
  font-size: 12px;
  color: var(--brand);
  background: #ebf2fc;
  border: 1px solid #c8d9f4;
  border-radius: 999px;
  padding: 4px 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

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

.users-table .clickable-row {
  cursor: pointer;
}

.users-table .clickable-row:hover {
  background: #f7faff;
}

.users-table .clickable-row.is-selected {
  background: #e9f2ff;
}

.context-menu {
  position: relative;
}

.context-menu > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--panel);
  user-select: none;
  width: fit-content;
}

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

.context-menu[open] > summary {
  border-color: #b8c8e4;
}

.context-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(24, 32, 43, 0.15);
  z-index: 10;
  overflow: hidden;
}

.right-click-menu {
  position: fixed;
  right: auto;
  top: auto;
  min-width: 220px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.menu-item:hover {
  background: #eef4ff;
}

.menu-form {
  margin: 0;
}

.button-link {
  cursor: pointer;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 23, 35, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.modal-card {
  width: min(1100px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hidden-modal {
  display: none;
}

.qr-modal-card {
  width: min(560px, calc(100vw - 40px));
}

.qr-block {
  display: grid;
  place-items: center;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdff;
}

.qr-block img {
  display: block;
  width: min(320px, 82vw);
  height: auto;
}

.status-tag {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.status-tag.status-ok {
  border-color: #b8e0bc;
  color: var(--ok);
}

.status-tag.status-warn {
  border-color: #f1c1b5;
  color: var(--warn);
}

.json-cell {
  margin: 0;
  max-width: 420px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f8faff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 11px;
}

.alert {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.alert.ok {
  border-color: #b8e0bc;
  color: var(--ok);
}

.alert.error {
  border-color: #f1c1b5;
  color: var(--warn);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

@media (max-width: 900px) {
  .search-form {
    grid-template-columns: 1fr;
  }
}

.sticker-layout {
  max-width: 900px;
}

.sticker-sheet {
  display: grid;
  place-items: center;
}

.intercom-sticker {
  width: 92mm;
  min-height: 132mm;
  border-radius: 14px;
  border: 2px solid #22334d;
  background:
    radial-gradient(120% 90% at 100% -10%, #c6dbff 0%, transparent 48%),
    radial-gradient(100% 100% at -15% 100%, #ffd3a7 0%, transparent 52%),
    #ffffff;
  padding: 10mm 8mm;
  display: grid;
  gap: 8mm;
  box-shadow: 0 20px 36px rgba(24, 32, 43, 0.15);
}

.sticker-head h2 {
  margin: 0 0 6px;
  font-size: 8mm;
}

.sticker-head p {
  margin: 0;
  font-size: 3.9mm;
  line-height: 1.35;
}

.sticker-eyebrow {
  margin: 0 0 2mm;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 2.8mm;
  color: #114d94;
  font-weight: 700;
}

.sticker-qr-block {
  display: grid;
  place-items: center;
  border: 1px solid #c9d3e6;
  border-radius: 10px;
  background: #ffffff;
  padding: 4mm;
}

.sticker-qr-block img {
  width: 58mm;
  height: 58mm;
  display: block;
}

.sticker-foot {
  font-size: 3.4mm;
}

.sticker-foot p {
  margin: 0 0 2mm;
}

.sticker-foot ol {
  margin: 0 0 4mm;
  padding-left: 5mm;
  display: grid;
  gap: 1mm;
}

.sticker-url {
  font-size: 2.6mm;
  color: #5d6b80;
  word-break: break-all;
}

.dual-sheet-layout {
  max-width: 980px;
  display: grid;
  gap: 18px;
}

.dual-sheet {
  border-radius: 14px;
  border: 2px solid #22334d;
  background:
    radial-gradient(115% 92% at 100% -8%, #e4f0ff 0%, transparent 48%),
    radial-gradient(100% 90% at -12% 98%, #ffe2c8 0%, transparent 52%),
    #ffffff;
  padding: 20px;
  display: grid;
  gap: 12px;
  min-height: 265mm;
  align-content: start;
  box-shadow: 0 20px 36px rgba(24, 32, 43, 0.12);
}

.sheet-side-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #0f4b8f;
  font-weight: 700;
  font-size: 12px;
}

.dual-sheet h2 {
  margin: 0;
  font-size: 34px;
}

.sheet-lead {
  margin: 0;
  font-size: 16px;
  max-width: 58ch;
}

.sheet-qr-frame {
  border: 1px solid #c9d3e6;
  border-radius: 12px;
  background: #fff;
  padding: 18px;
  width: fit-content;
}

.sheet-qr-frame img {
  display: block;
  width: 280px;
  height: 280px;
}

.sheet-url {
  margin: 0;
  font-size: 12px;
  color: #5d6b80;
  word-break: break-all;
}

@media print {
  body.sticker-page {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .container {
    margin: 0;
    padding: 0;
  }

  .intercom-sticker {
    box-shadow: none;
    margin: 0;
    break-inside: avoid;
  }

  .dual-sheet-layout {
    margin: 0;
    max-width: none;
    gap: 0;
  }

  .dual-sheet {
    box-shadow: none;
    border-radius: 0;
    min-height: 279mm;
    page-break-after: always;
    break-after: page;
  }

  .dual-sheet:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}
