:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 36rem),
    linear-gradient(135deg, #f8fafc 0%, var(--bg) 100%);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.eyebrow,
.section-label {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(2.4rem, 8vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

h2 {
  margin-bottom: 0;
}

.lede {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.7;
}

.card,
.stats-card {
  border: 1px solid rgba(229, 231, 235, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.card {
  padding: 24px;
}

.stats-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
}

.stats-number {
  color: var(--brand);
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
}

.stats-label,
.muted,
.hint {
  color: var(--muted);
}

.shorten-form {
  display: grid;
  gap: 10px;
}

.lookup-card {
  margin-top: 24px;
}

.lookup-form {
  display: grid;
  gap: 16px;
}

.lookup-form .muted {
  margin-bottom: 0;
}

label {
  font-weight: 800;
}

label span {
  color: var(--muted);
  font-weight: 600;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px 16px;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

button,
#downloadQr {
  border: 0;
  border-radius: 16px;
  padding: 15px 18px;
  color: #fff;
  background: var(--brand);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s, background 0.2s;
}

button:hover,
#downloadQr:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

button.secondary {
  color: var(--ink);
  background: #eaf0ff;
}

button.secondary:hover {
  background: #dbe7ff;
}

button.ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

button.ghost:hover {
  color: var(--ink);
  background: #f8fafc;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--brand);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  margin-top: 24px;
}

.result-card,
.qr-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.short-url {
  overflow-wrap: anywhere;
  color: var(--brand);
  font-size: clamp(1.5rem, 5vw, 2.7rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.qr-card img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

#analyticsSection {
  margin-top: 24px;
}

.chart {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 170px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8fafc;
}

.analytics-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbfdff;
}

.analytics-filters label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
}

.filter-actions,
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination {
  justify-content: flex-end;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 800;
}

.pagination span {
  min-width: 180px;
  text-align: center;
}

.bar {
  position: relative;
  flex: 1;
  min-width: 14px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.bar span {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td:last-child {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 28px 0;
  }

  .hero,
  .grid,
  .input-row,
  .analytics-filters {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .pagination {
    flex-direction: column;
  }
}
