:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-soft: #f8faf5;
  --ink: #121713;
  --muted: #657064;
  --subtle: #8b9489;
  --line: #dfe5da;
  --line-strong: #cbd4c5;
  --accent: #1d7a52;
  --accent-dark: #115c3c;
  --accent-soft: #e8f5ee;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #945a04;
  --warning-soft: #fff7e8;
  --shadow: 0 18px 50px rgba(21, 29, 23, 0.08);
  --radius: 8px;
  --sidebar: 272px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(232, 245, 238, 0.8), rgba(244, 246, 241, 0) 360px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

a {
  color: inherit;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  color: var(--muted);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--ink);
  color: #f8fff9;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 438px;
}

.auth-intro {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}

.auth-top {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 800;
}

.auth-copy {
  max-width: 720px;
}

.auth-copy h1 {
  margin: 0 0 18px;
  max-width: 780px;
  font-size: clamp(40px, 6vw, 82px);
  line-height: 0.96;
  letter-spacing: 0;
}

.auth-copy p {
  margin: 0;
  max-width: 580px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.auth-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 820px;
}

.auth-point {
  padding-top: 14px;
  border-top: 1px solid var(--line-strong);
}

.auth-point strong {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
}

.auth-point span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-panel {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 34px;
  background: rgba(255, 255, 255, 0.72);
}

.auth-form-wrap {
  width: 100%;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 28px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tab-button {
  height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab-button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.form-title {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.form-note {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

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

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

.field label {
  color: #303830;
  font-size: 13px;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 122, 82, 0.12);
}

.field input[type="color"] {
  padding: 3px;
}

.field input[type="range"] {
  padding: 0;
}

.field-hint {
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover {
  border-color: #a9b6a6;
  transform: translateY(-1px);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
}

.ghost-button:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-button:hover {
  background: #ffe3df;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.error-box,
.success-box {
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
}

.error-box {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #ffd1cc;
}

.success-box {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #cfe8d9;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: #111713;
  color: #edf5ed;
}

.sidebar .brand-mark {
  background: #f7fff7;
  color: #111713;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  font-size: 18px;
  font-weight: 850;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 6px;
  color: rgba(237, 245, 237, 0.72);
  background: transparent;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  text-align: left;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 14px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-chip {
  display: grid;
  gap: 3px;
}

.user-chip strong {
  font-size: 14px;
}

.user-chip span {
  color: rgba(237, 245, 237, 0.58);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.page-title {
  margin: 0 0 6px;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page-description {
  margin: 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.analytics-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat strong {
  font-size: 28px;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.table-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input {
  height: 38px;
  width: 230px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  outline: none;
}

.qr-table-wrap {
  overflow-x: auto;
}

.qr-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.qr-table th,
.qr-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.qr-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.qr-table td {
  font-size: 14px;
}

.qr-table tbody tr {
  cursor: pointer;
}

.qr-table tbody tr:hover,
.qr-table tbody tr.is-selected {
  background: var(--surface-soft);
}

.qr-name {
  display: grid;
  gap: 4px;
}

.qr-name strong {
  overflow-wrap: anywhere;
}

.qr-name span,
.mono {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.status.paused {
  color: var(--warning);
  background: var(--warning-soft);
}

.design-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.design-chip::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--chip-a), var(--chip-b));
}

.link-cell {
  max-width: 250px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.side-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
}

.editor-panel,
.preview-panel,
.scans-panel {
  padding: 16px;
}

.editor-panel .form-grid {
  gap: 13px;
}

.design-section {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #303830;
  font-size: 13px;
  font-weight: 850;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-button {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.template-button span {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border: 1px solid rgba(18, 23, 19, 0.16);
  border-radius: 6px;
  background:
    linear-gradient(135deg, var(--swatch-a), var(--swatch-b)),
    var(--swatch-bg);
}

.template-button.is-active,
.template-button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 122, 82, 0.08);
}

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

.check-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.danger-check {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #ffd1cc;
}

.logo-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.logo-box strong,
.logo-box span {
  display: block;
}

.logo-box strong {
  margin-bottom: 4px;
  font-size: 13px;
}

.logo-box span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.logo-box img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.qr-preview {
  display: grid;
  place-items: center;
  min-height: 252px;
  margin: 14px 0;
  background:
    linear-gradient(45deg, rgba(17, 23, 19, 0.04) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(17, 23, 19, 0.04) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(17, 23, 19, 0.04) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(17, 23, 19, 0.04) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.qr-preview img {
  width: min(220px, 72vw);
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

.selected-meta {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.selected-meta a {
  color: var(--accent-dark);
  overflow-wrap: anywhere;
}

.scan-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  max-height: 230px;
  overflow: auto;
}

.scan-row {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.scan-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

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

.range-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.analytics-panel {
  padding: 16px;
}

.analytics-panel.wide {
  grid-column: 1 / -1;
}

.analytics-panel .panel-header {
  margin: -16px -16px 14px;
}

.chart-wrap {
  min-height: 260px;
  display: grid;
  gap: 10px;
}

.chart-wrap svg {
  width: 100%;
  height: 240px;
  display: block;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.bar-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.bar-row strong {
  overflow-wrap: anywhere;
}

.bar-row span {
  color: var(--muted);
  font-weight: 800;
}

.bar-row i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7cc89b);
}

.top-list {
  display: grid;
}

.top-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(120px, 220px) 70px;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.top-row:last-child {
  border-bottom: 0;
}

.top-row span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
}

.top-row strong,
.top-row em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-row em {
  color: var(--muted);
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.top-row b {
  text-align: right;
  font-size: 15px;
}

.empty-state {
  padding: 48px 22px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 17px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 14px;
}

.toast.error {
  border-color: #ffd1cc;
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .auth-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    min-height: auto;
    padding: 28px;
    gap: 42px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-panel {
    min-height: auto;
    padding: 22px;
  }

  .auth-points,
  .stats-strip,
  .analytics-stats,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

  .sidebar-brand {
    margin-bottom: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-footer {
    margin-top: 18px;
  }

  .content {
    padding: 20px;
  }

  .topbar {
    display: grid;
  }

  .page-title {
    font-size: 27px;
  }

  .panel-header,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }

  .range-control {
    width: 100%;
  }

  .top-row {
    grid-template-columns: 30px minmax(0, 1fr) 52px;
  }

  .top-row em {
    display: none;
  }
}

@media (max-width: 560px) {
  .auth-copy h1 {
    font-size: 42px;
  }

  .auth-form-wrap {
    padding: 22px;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .button-row,
  .topbar .primary-button {
    width: 100%;
  }

  .button-row > *,
  .topbar .primary-button {
    flex: 1 1 auto;
  }

  .design-columns,
  .template-grid {
    grid-template-columns: 1fr;
  }
}
