:root {
  color-scheme: light;
  --ink: #15120f;
  --muted: #6e6860;
  --line: #ddd6cb;
  --paper: #f8f5ef;
  --panel: #fffdf8;
  --accent: #08605f;
  --accent-strong: #053f40;
  --mark: #e7b94f;
  --danger: #b8172a;
  --shadow: 0 18px 50px rgba(37, 28, 16, 0.12);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(8, 96, 95, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(8, 96, 95, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  display: block;
  width: min(150px, 82%);
  height: auto;
  margin: 0 auto 24px;
}

.login-panel h1 {
  font-size: 35px;
  line-height: 1;
}

.login-panel label {
  text-align: left;
}

.brand-strip {
  display: grid;
  place-items: center;
  padding: 12px 0 4px;
}

.brand-strip img {
  width: min(250px, 72vw);
  height: auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.92;
  max-width: 720px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

h2 {
  font-size: 1.5rem;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  margin: 18px 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.stack,
.dialog-body {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 96, 95, 0.14);
}

.primary {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  padding: 0 14px;
  background: rgba(255, 253, 248, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 800;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.25rem;
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  vertical-align: middle;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 0 28px;
}

.actions,
.toolbar,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  position: sticky;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  top: 0;
  z-index: 2;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(248, 245, 239, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
}

.search {
  flex: 1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stats div,
.stat-action,
.qr-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(37, 28, 16, 0.07);
}

.stats div,
.stat-action {
  padding: 16px;
}

.stat-action {
  display: grid;
  place-items: center;
  min-height: 86px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}

.stats span {
  display: block;
  font-size: 1.8rem;
  font-weight: 900;
}

.stats small {
  color: var(--muted);
  font-weight: 800;
}

.filter-toggle {
  display: flex;
  align-items: center;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  white-space: nowrap;
}

.filter-toggle input {
  width: 18px;
  min-height: 18px;
}

.list {
  display: grid;
  gap: 12px;
}

.qr-card {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) auto;
  gap: 18px;
  align-items: stretch;
  min-height: 220px;
  padding: 12px;
  border-left: 5px solid var(--accent);
}

.qr-preview {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.qr-preview canvas,
.qr-preview img {
  width: 100%;
  max-width: 200px;
  height: auto;
  max-height: 200px;
}

.qr-main {
  display: grid;
  align-content: center;
  min-width: 0;
}

.qr-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.qr-title-row h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.1;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(8, 96, 95, 0.12);
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
}

.badge.off {
  background: rgba(180, 59, 50, 0.12);
  color: var(--danger);
}

.field-line {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.field-line span {
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field-line strong,
.field-line a {
  min-width: 0;
  font-weight: 400;
}

.url,
.token {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url {
  text-decoration: none;
}

.url:hover {
  color: var(--accent);
  text-decoration: underline;
}

.token {
  color: var(--muted);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.86rem;
  font-weight: 400;
}

.qr-actions {
  align-content: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 253, 248, 0.78);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(21, 18, 15, 0.48);
  backdrop-filter: blur(4px);
}

.dialog-body {
  padding: 24px;
  background: var(--panel);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.status-toggle {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
  min-height: 46px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.status-toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.status-toggle span {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 6px;
  font-weight: 900;
  transition: background 0.18s ease, color 0.18s ease;
}

.status-toggle input:checked ~ span:first-of-type,
.status-toggle input:not(:checked) ~ span:last-of-type {
  background: var(--accent);
  color: #fff;
}

.status-toggle input:not(:checked) ~ span:last-of-type {
  background: var(--danger);
}

.format-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.compact-dialog {
  gap: 22px;
}

.dialog-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100% - 36px));
  padding: 13px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 640px);
    padding-top: 12px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar {
    grid-template-columns: 1fr;
    position: static;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .qr-card {
    grid-template-columns: 120px 1fr;
    min-height: 170px;
  }

  .qr-preview {
    min-height: 145px;
  }

  .qr-preview canvas,
  .qr-preview img {
    width: 108px;
    height: 108px;
  }

  .qr-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, 1fr);
  }
}
