:root {
  color-scheme: light;
  --bg: #f6f4f9;
  --panel: #ffffff;
  --panel-2: #f0ebf7;
  --ink: #272727;
  --muted: #6f6777;
  --line: #ded8e7;
  --header: #663399;
  --footer: #2a0b49;
  --accent: #663399;
  --accent-2: #2a0b49;
  --button: #272727;
  --star: #ffb74a;
  --danger: #e34f4f;
  --sold-out: #bebdb9;
  --shadow: 0 18px 60px rgba(42, 11, 73, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: linear-gradient(180deg, rgba(102, 51, 153, 0.1), transparent 280px), var(--bg);
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 42px;
}

.auth-layout {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 0.65fr);
  align-items: center;
  gap: 36px;
}

.brand-pane {
  display: grid;
  gap: 28px;
  align-content: center;
}

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

.brand-copy h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 6.1rem);
  line-height: 0.92;
  letter-spacing: 0;
  color: var(--footer);
}

.brand-copy p {
  max-width: 560px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 660px;
}

.metric {
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 8px;
}

.metric strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-card,
.panel,
.link-card,
.qr-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.auth-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-tabs button.active {
  background: #fff;
  color: var(--footer);
  box-shadow: 0 6px 20px rgba(42, 11, 73, 0.12);
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

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

.field span {
  color: #334155;
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
}

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

.secondary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

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

.danger {
  color: var(--danger);
  background: #fff7f6;
  border-color: #fecdca;
}

.error {
  min-height: 22px;
  color: var(--danger);
  font-size: 0.9rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--header);
  color: #fff;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.app-brand p {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
}

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

.panel {
  box-shadow: none;
}

.panel-head,
.panel-body {
  padding: 18px;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  background: rgba(102, 51, 153, 0.06);
}

.panel-head h2,
.link-title h3,
.qr-card h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-head p,
.link-title p,
.qr-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.create-form {
  display: grid;
  gap: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary {
  min-height: 84px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
}

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

.link-card {
  box-shadow: none;
  padding: 16px;
}

.link-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.link-title {
  min-width: 0;
}

.short-url,
.target-url {
  overflow-wrap: anywhere;
}

.short-url {
  display: inline-flex;
  margin-top: 8px;
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.target-url {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

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

.analytics-block {
  min-width: 0;
}

.analytics-block h4 {
  margin: 0 0 8px;
  color: #334155;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(70px, 0.7fr) minmax(80px, 1fr) 32px;
  gap: 8px;
  align-items: center;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecf3;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.qr-card {
  box-shadow: none;
  padding: 16px;
  position: sticky;
  top: 16px;
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 288px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.qr-image {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(24, 32, 47, 0.1);
  image-rendering: pixelated;
}

.qr-designer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.qr-wide-control {
  grid-column: 1 / -1;
}

.compact-field {
  gap: 6px;
}

.compact-field span,
.color-field span {
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
}

.compact-field select {
  min-height: 38px;
  background: #fff;
}

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

.color-field input {
  width: 100%;
  min-height: 38px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.logo-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.logo-control > span {
  grid-column: 1 / -1;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 800;
}

.logo-upload {
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.logo-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.logo-clear {
  min-height: 40px;
  color: var(--danger);
}

.qr-warning {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.35;
}

.qr-actions {
  display: grid;
  gap: 8px;
}

.empty {
  min-height: 230px;
  display: grid;
  place-items: center;
  padding: 26px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--footer);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 160ms ease;
}

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

@media (max-width: 980px) {
  .auth-layout,
  .dashboard,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .qr-card {
    position: static;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 22px, 1180px);
    padding-top: 12px;
  }

  .metric-strip,
  .summary-grid,
  .analytics {
    grid-template-columns: 1fr;
  }

  .app-header,
  .link-top {
    align-items: stretch;
    flex-direction: column;
  }

  .link-actions {
    justify-content: flex-start;
  }
}
