/* =========================================================
   Shorter — Fresh New Look
   Completely redesigned from scratch
   ========================================================= */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-deep: #08090c;
  --bg-base: #0d0f14;
  --bg-elevated: #14171f;
  --bg-card: #1a1d28;
  --surface: #222734;
  --surface-hover: #2a2f3d;
  --border: #2e3342;
  --border-light: #3d4256;
  --text: #e8eaed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --primary: #f97316;
  --primary-hover: #fb923c;
  --primary-glow: rgba(249, 115, 22, 0.25);
  --accent: #22d3ee;
  --accent-secondary: #a78bfa;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  
  --nav-height: 64px;
  --font-main: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--primary-glow);
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   Ambient Background
   ========================================================= */

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -10;
  overflow: hidden;
  pointer-events: none;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  top: -200px;
  left: -100px;
  animation: float-orb 20s ease-in-out infinite;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.2) 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation: float-orb 25s ease-in-out infinite reverse;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.15) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: pulse-orb 15s ease-in-out infinite;
}

@keyframes float-orb {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, -30px) scale(1.1); }
}

@keyframes pulse-orb {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.2); }
}

/* =========================================================
   Topbar Navigation
   ========================================================= */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.topbar__left {
  display: flex;
  align-items: center;
}

.topbar__center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
}

.brand__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #ea580c);
  box-shadow: var(--shadow-glow);
}

.brand__icon svg {
  color: white;
}

.brand__text {
  letter-spacing: -0.02em;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-xs);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-link.active {
  color: var(--text);
  background: var(--surface);
}

.nav-user {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.2s;
}

.btn:hover::before { opacity: 1; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), #ea580c);
  color: white;
  box-shadow: var(--shadow-glow);
}

.btn--primary:hover {
  box-shadow: 0 0 40px var(--primary-glow);
  transform: translateY(-1px);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(248, 113, 113, 0.25);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--surface);
}

.btn--sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.btn--lg {
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

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

/* =========================================================
   Main Content
   ========================================================= */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--nav-height) + 3rem) 2rem 4rem;
  min-height: 100vh;
  animation: fadeIn 0.4s ease;
}

.main-content--analytics {
  max-width: none;
  padding-left: clamp(1rem, 3vw, 2.5rem);
  padding-right: clamp(1rem, 3vw, 2.5rem);
}

.main-content--admin {
  max-width: 1400px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Typography
   ========================================================= */

h1, h2, h3 {
  font-family: var(--font-main);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

/* =========================================================
   Hero Section (Home Page)
   ========================================================= */

.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 4rem;
  align-items: center;
  margin-bottom: 5rem;
}

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 2.5rem; }
}

.hero__content {
  padding: 1rem 0;
}

.hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.25);
  border-radius: 999px;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.8rem;
  margin-bottom: 1.25rem;
}

.hero__title {
  font-size: clamp(2.4rem, 4.5vw, 3.6rem);
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__subtitle {
  color: var(--text-secondary);
  font-size: 1.15rem;
  max-width: 50ch;
  margin-bottom: 1.5rem;
  line-height: 1.7;
}

.hero__cta {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Hero Panel */
.hero__panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}

.hero__panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.mini-ui__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  position: relative;
  z-index: 1;
}

.mini-ui__label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mini-ui__value {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.mini-ui__value--big {
  font-size: 2rem;
  font-weight: 800;
  font-family: var(--font-main);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mini-ui__bars {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  height: 90px;
  align-items: end;
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(249, 115, 22, 0.05);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(249, 115, 22, 0.1);
  position: relative;
  z-index: 1;
}

.mini-ui__bars span {
  display: block;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--primary), #ea580c);
  transition: height 0.3s ease;
}

.mini-ui__note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

/* =========================================================
   Sections
   ========================================================= */

.section {
  padding: 3.5rem 0;
}

.section__head {
  margin-bottom: 2rem;
}

.section__title {
  font-size: 1.85rem;
  margin-bottom: 0.5rem;
}

.section__sub {
  color: var(--text-secondary);
  max-width: 60ch;
  font-size: 1.05rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1020px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } }

.feature-card {
  padding: 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.25s ease;
}

.feature-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature-card__title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.feature-card__body {
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.9rem;
}

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

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

.step {
  padding: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.step__n {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(249, 115, 22, 0.05));
  border: 1px solid rgba(249, 115, 22, 0.25);
  font-weight: 800;
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.step__t {
  font-weight: 700;
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

.step__d {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =========================================================
   Footer
   ========================================================= */

.site-footer {
  padding: 3rem 0 1.5rem;
  margin-top: 3rem;
  border-top: 1px solid var(--border);
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: start;
}

.site-footer__brand {
  font-weight: 800;
  color: var(--text);
  margin-top: 1rem;
  font-size: 1.1rem;
}

.site-footer__links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.site-footer__links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

.site-footer__links a:hover {
  color: var(--text);
}

.site-footer__copy {
  grid-column: 1 / -1;
  margin-top: 0.75rem;
  padding-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* =========================================================
   Auth Pages
   ========================================================= */

.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height));
  padding-top: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
}

.auth-card__header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card__header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.auth-card__header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* =========================================================
   Forms
   ========================================================= */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.form-switch-link {
  color: var(--primary);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}

.form-switch-link:hover {
  text-decoration: underline;
}

.form-select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* =========================================================
   Dashboard
   ========================================================= */

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dash-header__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#workspace-select {
  min-width: 200px;
  font-size: 0.85rem;
}

.dash-header h1 {
  font-size: 1.65rem;
  color: var(--text);
}

/* Stats Strip */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.35rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-card__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.stat-card__value {
  font-size: 1.75rem;
  font-weight: 800;
}

.stat-card__value--primary { color: var(--primary); }
.stat-card__value--accent { color: var(--accent); }
.stat-card__value--success { color: var(--success); }
.stat-card__value--pink { color: var(--accent-secondary); }

/* URL Create Form */
.create-url-form {
  margin-bottom: 2rem;
}

.create-url-form .form-inline {
  display: flex;
  gap: 0.85rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.create-url-form .form-inline .form-group {
  margin-bottom: 0;
}

.create-url-form .form-inline .form-group--url {
  flex: 2;
  min-width: 250px;
}

.create-url-form .form-inline .form-group--short {
  flex: 1;
  min-width: 140px;
}

.create-url-form .form-inline .form-group--expiry {
  flex: 1;
  min-width: 150px;
}

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* =========================================================
   Tables
   ========================================================= */

.url-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.url-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.url-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.url-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.url-table tbody tr {
  transition: background 0.15s ease;
}

.url-table tbody tr:hover {
  background: var(--surface);
}

.url-short {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.url-short:hover {
  text-decoration: underline;
}

.url-dest {
  color: var(--text-secondary);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-size: 0.85rem;
}

.url-expiry {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.url-expiry--expired { color: var(--danger); }
.url-expiry--active { color: var(--success); }

.url-actions {
  display: flex;
  gap: 0.35rem;
}

.link-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
  text-transform: uppercase;
}

.link-type-badge--redirect {
  background: rgba(249, 115, 22, 0.12);
  color: var(--primary);
  border-color: rgba(249, 115, 22, 0.2);
}

.link-type-badge--bio {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent-secondary);
  border-color: rgba(167, 139, 250, 0.2);
}

.bio-btn-row,
.bio-social-row,
.bio-embed-row {
  align-items: stretch;
}

.bio-btn-row .bio-label,
.bio-social-row .bio-social-label {
  min-width: 160px;
  flex: 1 1 160px;
}

.bio-btn-row .bio-url,
.bio-social-row .bio-social-url,
.bio-embed-row .bio-embed-url {
  min-width: 220px;
  flex: 2 1 240px;
}

.bio-btn-row .bio-icon {
  width: 84px;
  flex: 0 0 84px;
  text-align: center;
}

.bio-embed-row .bio-embed-type {
  min-width: 140px;
  flex: 0 0 140px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state__text {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.empty-state__sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Clicks Badge */
.clicks-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.clicks-badge:hover {
  background: var(--surface-hover);
}

/* =========================================================
   Copy Button
   ========================================================= */

.copy-btn {
  position: relative;
}

.copy-btn::after {
  content: "Copied!";
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: var(--success);
  color: var(--bg-deep);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}

.copy-btn.copied::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* =========================================================
   Modal
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 2rem);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.25s ease;
}

.modal--wide { max-width: 620px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal__header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .modal {
    max-height: calc(100vh - 1rem);
    padding: 1.1rem;
    border-radius: 12px;
  }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Toast
   ========================================================= */

.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 1rem);
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  animation: slideIn 0.25s ease, fadeOut 0.3s ease 3.5s forwards;
  max-width: 360px;
  word-break: break-word;
  box-shadow: var(--shadow-lg);
}

.toast--success {
  background: rgba(52, 211, 153, 0.15);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--success);
}

.toast--error {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
}

.toast--info {
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--accent);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* =========================================================
   Stats / Analytics
   ========================================================= */

.stats-page {
  max-width: 1300px;
  margin: 0 auto;
}

.stats-page--full {
  flex: 1;
  min-height: 0;
  max-width: none;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.stats-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stats-header h1 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
}

.stats-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.stats-toolbar--full {
  flex-shrink: 0;
}

.stats-date-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.stats-date-range .stats-date-input {
  width: 140px;
}

.stats-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.stats-tab {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.stats-tab:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.stats-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stats-detail {
  padding: 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stats-detail__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  font-weight: 600;
}

.stats-detail__value {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-all;
}

/* Overview */
.stats-overview-grid {
  display: grid;
  grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

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

.stats-kpi-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stats-kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}

.stats-chart-card {
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: clamp(160px, 28vh, 260px);
  margin-top: 0.75rem;
  min-height: 160px;
}

.stats-chart-bar {
  flex: 1;
  min-width: 4px;
  background: var(--accent);
  border-radius: 3px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.stats-chart-bar:hover { opacity: 1; }

.stats-chart-labels {
  display: flex;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.stats-chart-label {
  flex: 1;
  text-align: center;
  min-width: 0;
}

/* Tables */
.stats-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow: hidden;
}

.stats-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.stats-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stats-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr:hover { background: var(--surface); }

.stats-cell-referrer {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-cell-time {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.stats-empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem !important;
}

/* Pagination */
.stats-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.stats-pagination__meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 11rem;
  text-align: center;
}

/* =========================================================
   404 / Maintenance
   ========================================================= */

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height) - 4rem);
  text-align: center;
  padding: 2rem;
}

.error-page__code {
  font-size: 7rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-page__title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.error-page__desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  max-width: 400px;
}

.error-page__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* =========================================================
   Status Badge
   ========================================================= */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-badge--online {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
}

.status-badge--offline {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
}

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.status-badge--online .status-dot { background: var(--success); }
.status-badge--offline .status-dot { background: var(--danger); }

/* =========================================================
   Spinner
   ========================================================= */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner--lg {
  width: 28px;
  height: 28px;
  border-width: 2.5px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
}

/* =========================================================
   Rotation / A/B Testing
   ========================================================= */

.rotation-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rotation-badge--equal {
  background: rgba(34, 211, 238, 0.12);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.2);
}

.rotation-badge--weighted {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent-secondary);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.rotation-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.rotation-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.rotation-section__title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.rotation-target-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.rotation-target-row .form-input--url {
  flex: 1;
  min-width: 0;
}

.rotation-target-row .form-input--pct {
  width: 70px;
  text-align: center;
}

.rotation-target-row .btn--remove {
  flex-shrink: 0;
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
}

.rotation-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.78rem;
}

.rotation-total__value { font-weight: 700; }
.rotation-total__value--ok { color: var(--success); }
.rotation-total__value--warn { color: var(--warning); }
.rotation-total__value--err { color: var(--danger); }

/* Rotation targets list */
.rotation-targets-list {
  margin-top: 0.5rem;
}

.rotation-target-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.8rem;
}

.rotation-target-item + .rotation-target-item {
  border-top: 1px solid var(--border);
}

.rotation-target-item__url {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rotation-target-item__pct {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--accent);
  width: 40px;
  text-align: right;
}

.rotation-target-item__clicks {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--primary);
  width: 65px;
  text-align: right;
}

/* Rotation bar */
.rotation-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.rotation-bar__seg {
  height: 100%;
}

.rotation-bar__seg:nth-child(1) { background: var(--accent); }
.rotation-bar__seg:nth-child(2) { background: var(--accent-secondary); }
.rotation-bar__seg:nth-child(3) { background: var(--primary); }
.rotation-bar__seg:nth-child(4) { background: var(--success); }
.rotation-bar__seg:nth-child(5) { background: var(--warning); }

/* =========================================================
   Admin
   ========================================================= */

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.admin-tab.active {
  background: rgba(249, 115, 22, 0.12);
  border-color: rgba(249, 115, 22, 0.25);
  color: var(--primary);
}

.admin-toolbar__actions {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  justify-content: flex-end;
}

.admin-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.admin-pager {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 768px) {
  .topbar {
    padding: 0 1rem;
  }
  .topbar__center {
    display: none;
  }
  .main-content {
    padding: calc(var(--nav-height) + 1.5rem) 1rem 2.5rem;
  }
  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }
  #workspace-select {
    min-width: 100%;
  }
  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }
  .create-url-form .form-inline {
    flex-direction: column;
  }
  .url-table th:nth-child(3),
  .url-table td:nth-child(3) {
    display: none;
  }
}

@media (max-width: 480px) {
  .stat-strip {
    grid-template-columns: 1fr;
  }
  .auth-card {
    padding: 1.5rem !important;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* =========================================================
   Utility
   ========================================================= */

.hidden { display: none !important; }
.text-dim { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.8rem; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* =========================================================
   Feature badges (password, max_clicks, tags, etc.)
   ========================================================= */

.feature-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.feature-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.5;
  white-space: nowrap;
}

.feature-badge--lock {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.feature-badge--cap {
  background: rgba(249, 115, 22, 0.12);
  color: var(--primary);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.feature-badge--302 {
  background: rgba(34, 211, 238, 0.1);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.25);
}

.feature-badge--pub {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.feature-badge--tag {
  background: rgba(167, 139, 250, 0.12);
  color: var(--accent-secondary);
  border: 1px solid rgba(167, 139, 250, 0.25);
}

/* =========================================================
   Bulk action bar
   ========================================================= */

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bulk-bar span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.bulk-check-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-right: 4px;
}

.bulk-check-wrap input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-checkbox-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.form-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}
