:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ef;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --shadow: 0 24px 80px rgba(15, 23, 42, 0.08);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.16), transparent 34rem),
    radial-gradient(circle at top right, rgba(6, 182, 212, 0.12), transparent 30rem),
    var(--bg);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
svg {
  display: block;
}

.site-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 26px 0 12px;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(219, 227, 239, 0.75);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  box-shadow: 0 12px 25px rgba(79, 70, 229, 0.26);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  padding: 42px 0 24px;
}

.hero-copy,
.card {
  border: 1px solid rgba(219, 227, 239, 0.78);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  padding: clamp(28px, 5vw, 54px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 16px;
  font-size: clamp(2.5rem, 8vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.hero-copy > p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.07rem;
  line-height: 1.7;
}

.card {
  padding: clamp(20px, 4vw, 30px);
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 22px;
}

.card-title h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.card-title p {
  margin-bottom: 0;
  color: var(--muted);
}

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

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

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  color: #334155;
  font-size: 0.9rem;
  font-weight: 750;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: white;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

.input-prefix {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  overflow: hidden;
}

.input-prefix span {
  padding-left: 14px;
  color: var(--muted);
  font-size: 0.94rem;
  white-space: nowrap;
}

.input-prefix input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.input-prefix:focus-within {
  border-color: rgba(79, 70, 229, 0.55);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.13);
}

.input-prefix:focus-within input {
  box-shadow: none;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, opacity 160ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  box-shadow: 0 14px 28px rgba(79, 70, 229, 0.26);
}

.btn-secondary {
  color: #1e293b;
  background: #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
  background: #dbe3ef;
}

.btn-danger {
  color: #991b1b;
  background: var(--danger-soft);
}

.btn-danger:hover:not(:disabled) {
  color: white;
  background: var(--danger);
}

.btn-wide {
  width: 100%;
}

.alert {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 700;
  line-height: 1.45;
}

.alert[hidden] {
  display: none;
}

.alert-success {
  color: var(--success);
  background: var(--success-soft);
}

.alert-error {
  color: #991b1b;
  background: var(--danger-soft);
}

.alert-neutral {
  color: var(--muted);
  background: var(--panel-soft);
}

.result-card {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff, #eef2ff);
}

.result-card[hidden] {
  display: none;
}

.result-header,
.link-main,
.details-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.result-header h2,
.details-header h2 {
  max-width: 760px;
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.15rem, 3vw, 1.6rem);
  letter-spacing: -0.04em;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1.6fr 0.7fr 1fr;
  gap: 14px;
  margin: 18px 0 0;
}

.meta-grid.compact {
  grid-template-columns: 1.8fr 0.7fr 1fr;
}

.meta-grid div,
.stats-list div {
  min-width: 0;
  padding: 14px;
  border-radius: 16px;
  background: rgba(241, 245, 249, 0.82);
}

dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.status-grid {
  display: grid;
  gap: 10px;
}

.status-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
}

.status-pill span {
  color: var(--muted);
  font-size: 0.9rem;
}

.status-pill.is-ok {
  color: var(--success);
  background: var(--success-soft);
}

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

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 38px 0 22px;
}

.page-head h1 {
  max-width: none;
  margin-bottom: 10px;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
}

.page-head p {
  max-width: 64ch;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.links-list {
  display: grid;
  gap: 14px;
}

.links-list[hidden] {
  display: none;
}

.link-card {
  padding: 20px;
  border: 1px solid rgba(219, 227, 239, 0.86);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 50px rgba(15, 23, 42, 0.05);
}

.link-main h2 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}

.short-url {
  display: inline-block;
  color: var(--primary-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.clicks-badge {
  flex: 0 0 auto;
  min-width: 92px;
  padding: 12px 14px;
  border-radius: 18px;
  text-align: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.clicks-badge span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.clicks-badge strong {
  display: block;
  margin-top: 2px;
  font-size: 1.5rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.68);
}

.empty-state[hidden] {
  display: none;
}

.pager {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 20px 0;
}

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 18px;
}

.stats-toolbar select {
  width: auto;
  min-width: 160px;
}

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

.stat-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-soft);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
}

.details-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(79, 70, 229, 0.18);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
}

.details-panel[hidden] {
  display: none;
}

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

.loading-line {
  padding: 18px;
  border-radius: 16px;
  color: var(--muted);
  background: var(--panel-soft);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(10px);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border-radius: 28px;
  background: white;
  box-shadow: 0 24px 90px rgba(15, 23, 42, 0.28);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin-bottom: 6px;
  letter-spacing: -0.04em;
}

.modal-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  color: var(--muted);
  background: var(--panel-soft);
}

.footer {
  padding: 36px 0 50px;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer code {
  padding: 3px 6px;
  border-radius: 8px;
  background: #e2e8f0;
}

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

  .toolbar {
    grid-template-columns: 1fr 120px;
  }

  .toolbar .btn {
    width: 100%;
  }

  .meta-grid,
  .meta-grid.compact,
  .stats-grid,
  .stats-list {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .site-shell {
    width: min(100% - 22px, 1120px);
  }

  .navbar,
  .nav-links,
  .result-header,
  .link-main,
  .details-header {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    gap: 6px;
  }

  .nav-links a {
    text-align: center;
  }

  .field-row,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .clicks-badge {
    width: 100%;
  }

  .card-actions .btn {
    flex: 1 1 140px;
  }

  .hero {
    padding-top: 26px;
  }

  h1 {
    font-size: clamp(2.35rem, 16vw, 4rem);
  }
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.qr-modal-panel {
  width: min(520px, 100%);
}

.qr-preview {
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}

.qr-preview canvas {
  width: min(100%, 320px);
  height: auto;
  border-radius: 16px;
  background: #ffffff;
}

.qr-link {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
  text-align: center;
}

.qr-actions {
  justify-content: center;
}

@media (max-width: 640px) {
  .result-actions {
    width: 100%;
    justify-content: stretch;
  }

  .result-actions .btn {
    flex: 1 1 140px;
  }

  .qr-actions .btn {
    width: 100%;
  }
}
body.auth-pending .site-header,
body.auth-pending main,
body.auth-pending .footer {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(79, 70, 229, 0.18), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.14), transparent 30rem),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  text-align: center;
}

.auth-brand {
  justify-content: center;
  margin-bottom: 28px;
}

.auth-card h1 {
  max-width: none;
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 8vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.6;
}

.google-login-box {
  display: grid;
  place-items: center;
  min-height: 48px;
  margin: 24px 0 10px;
}

.auth-message {
  min-height: 24px;
  margin: 14px 0 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.auth-user span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-user button {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 850;
}

@media (max-width: 720px) {
  .auth-user {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }
}
.auth-screen[hidden] {
  display: none !important;
}