:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #182230;
  --muted: #667085;
  --line: #d7dde5;
  --primary: #0b6bcb;
  --primary-dark: #084d92;
  --danger: #b42318;
  --success: #067647;
  --shadow: 0 16px 48px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
a {
  font: inherit;
}

button,
.button-link {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

.ghost,
.button-link.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.ghost:hover,
.button-link.secondary:hover {
  background: #eef3f8;
  border-color: #c7d2df;
}

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1,
.panel h2 {
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0;
}

.topbar h1 {
  font-size: 34px;
}

.panel h2 {
  font-size: 22px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.narrow {
  margin: 10vh auto 0;
  max-width: 460px;
}

.narrow p,
.hint,
.empty,
.detail-empty {
  color: var(--muted);
}

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

label {
  color: #344054;
  display: grid;
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
}

input {
  background: #ffffff;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  color: var(--text);
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.16);
  outline: none;
}

input[type="color"] {
  min-width: 96px;
  padding: 4px;
}

.hint {
  font-size: 12px;
  font-weight: 500;
}

.app-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr) minmax(320px, 420px);
}

.create-panel {
  position: sticky;
  top: 20px;
}

.stats-panel {
  display: grid;
  gap: 12px;
  grid-column: 2 / 4;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 26px;
  line-height: 1.1;
}

.list-panel {
  grid-column: 2;
}

.detail-panel {
  grid-column: 3;
  position: sticky;
  top: 20px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.color-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

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

.code-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.code-card.active {
  border-color: rgba(11, 107, 203, 0.45);
  box-shadow: 0 0 0 3px rgba(11, 107, 203, 0.08);
}

.code-card-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.code-card h3 {
  font-size: 18px;
  line-height: 1.25;
  margin: 0 0 6px;
}

.code-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.badge {
  border-radius: 999px;
  color: var(--success);
  background: #dcfae6;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.badge.off {
  background: #fee4e2;
  color: var(--danger);
}

.code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.code-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.qr-preview {
  align-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  margin: 0 auto 16px;
  max-width: 260px;
  padding: 14px;
  width: 100%;
}

.detail-content {
  display: grid;
  gap: 14px;
}

.detail-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.scan-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.scan-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 130px 1fr;
  padding: 10px 12px;
}

.scan-row + .scan-row {
  border-top: 1px solid var(--line);
}

.scan-row span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.toast {
  background: #101828;
  border-radius: 8px;
  bottom: 24px;
  color: #ffffff;
  left: 50%;
  opacity: 0;
  padding: 12px 16px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 16px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .app-grid {
    grid-template-columns: minmax(280px, 380px) minmax(420px, 1fr);
  }

  .stats-panel,
  .detail-panel,
  .list-panel {
    grid-column: auto;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .app-grid,
  .stats-panel {
    grid-template-columns: 1fr;
  }

  .create-panel {
    position: static;
  }

  .color-row,
  .detail-actions,
  .scan-row {
    grid-template-columns: 1fr;
  }
}
