/* ============================================================
   QR Studio — UI system (sharp / modern)
   ============================================================ */
:root {
  --bg: #060609;
  --bg-elev: #0c0c13;
  --panel: #0d0d15;
  --card: #12121d;
  --card-2: #171724;

  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --hairline: rgba(255, 255, 255, 0.05);

  --text: #f5f5fa;
  --muted: #8b8ba6;
  --faint: #5c5c74;

  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-3: #22d3ee;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --grad-soft: linear-gradient(135deg, rgba(139,92,246,.18), rgba(236,72,153,.14));

  --radius: 12px;
  --radius-sm: 9px;
  --radius-xs: 7px;
  --shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.75);
  --glow: 0 0 0 1px rgba(139,92,246,.35), 0 8px 30px -6px rgba(139,92,246,.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

/* Fondo: grid fino + glows de acento */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--hairline) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(1000px 700px at 70% 0%, #000 30%, transparent 80%);
  z-index: 0;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 480px at 82% -8%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(620px 420px at 12% 108%, rgba(236, 72, 153, 0.14), transparent 60%);
  z-index: 0;
  pointer-events: none;
}

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; height: 64px; padding: 0 22px;
  background: rgba(9, 9, 15, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 4px; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: none; color: var(--muted);
  padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .18s var(--ease);
}
.nav-tab:hover { color: var(--text); }
.nav-tab.active { background: var(--grad); color: #fff; box-shadow: 0 4px 14px -3px rgba(139,92,246,.6); }
.count-badge {
  font-size: 11px; font-weight: 700; background: rgba(255,255,255,.2);
  padding: 1px 7px; border-radius: 20px; font-variant-numeric: tabular-nums;
}

.view.hidden { display: none !important; }

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 372px 1fr;
  min-height: calc(100vh - 64px);
}

/* ---------------- Panel ---------------- */
.panel {
  background: linear-gradient(180deg, rgba(13,13,21,.92), rgba(9,9,15,.92));
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--border);
  padding: 8px 18px 64px;
  overflow-y: auto;
  height: calc(100vh - 64px);
  position: sticky;
  top: 64px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-weight: 800; font-size: 15px; letter-spacing: -0.5px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 8px 22px -6px rgba(139, 92, 246, 0.7),
              inset 0 1px 0 rgba(255,255,255,.35);
}
.logo::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 1px solid rgba(255,255,255,.18);
}
.brand h1 {
  font-size: 16px; font-weight: 700; letter-spacing: -0.4px;
  background: linear-gradient(90deg, #fff, #c9c9e6);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.brand p {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.brand p::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-3); box-shadow: 0 0 8px var(--accent-3);
}

/* Grupos */
.group {
  border-top: 1px solid var(--border);
  padding: 18px 2px;
}
.group:first-of-type { border-top: none; }
.group-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted); font-weight: 700; margin-bottom: 15px;
}
.group-title svg { width: 15px; height: 15px; color: var(--accent); opacity: .9; }

.field { display: block; margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.field > span {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text); margin-bottom: 7px; font-weight: 500;
}
.field > span em {
  color: var(--muted); font-style: normal; font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--card); padding: 1px 7px; border-radius: 20px; border: 1px solid var(--border);
}

/* Inputs */
input[type="text"], input[type="number"], input[type="email"], input[type="tel"],
select, textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.16);
  background: var(--card-2);
}
textarea { resize: vertical; min-height: 66px; line-height: 1.5; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8ba6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}

input[type="file"] { width: 100%; font-size: 12px; color: var(--muted); }
input[type="file"]::file-selector-button {
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: 8px 13px; margin-right: 10px; cursor: pointer; font-family: inherit;
  font-weight: 600; font-size: 12px; transition: all .15s;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: #fff; }

/* Range */
input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--card-2); border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
  transition: transform .12s var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.18); }

/* Color */
input[type="color"] {
  -webkit-appearance: none; width: 44px; height: 38px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: none; cursor: pointer; transition: transform .12s var(--ease);
}
input[type="color"]:hover { transform: scale(1.05); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

.color-row { display: flex; align-items: center; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; align-items: end; }

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
  transition: color .15s;
}
.check:hover { color: var(--text); }
.check.tall { padding-bottom: 9px; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* Segmented */
.segmented {
  display: inline-flex; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px;
  width: 100%;
}
.segmented.small { width: auto; }
.seg {
  flex: 1; border: none; background: none; color: var(--muted);
  padding: 8px 12px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .18s var(--ease); white-space: nowrap;
  position: relative;
}
.seg:hover { color: var(--text); }
.seg.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px -3px rgba(139, 92, 246, 0.6), inset 0 1px 0 rgba(255,255,255,.25);
}

.hint { font-size: 11.5px; color: var(--muted); margin: 8px 0 12px; line-height: 1.55; }

.gradient-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 13px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatch {
  height: 30px; width: 44px; border-radius: var(--radius-xs); cursor: pointer;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
  transition: transform .15s var(--ease), box-shadow .15s;
}
.swatch:hover { transform: translateY(-3px) scale(1.06); box-shadow: 0 6px 16px -4px rgba(0,0,0,.6); }

/* ---------------- Stage ---------------- */
.stage {
  display: flex; flex-direction: column; align-items: center;
  padding: 44px 32px 60px; gap: 28px;
}
.stage-inner { display: flex; flex-direction: column; align-items: center; gap: 24px; }

.qr-frame {
  position: relative;
  background: #fff;
  padding: 22px;
  border-radius: 24px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.06);
  transition: transform .3s var(--ease);
  animation: floatIn .6s var(--ease) both;
}
.qr-frame:hover { transform: translateY(-4px); }
.qr-frame::before {
  content: ""; position: absolute; inset: -1px; border-radius: 25px;
  padding: 1px; background: var(--grad);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .5; pointer-events: none;
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.qr-frame.transparent {
  background:
    linear-gradient(45deg, #1c1c2b 25%, transparent 25%),
    linear-gradient(-45deg, #1c1c2b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1c1c2b 75%),
    linear-gradient(-45deg, transparent 75%, #1c1c2b 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}
#qr canvas, #qr svg { display: block; border-radius: 8px; }

.dynamic-info {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 18px; width: 100%; max-width: 440px;
  text-align: center; box-shadow: 0 10px 30px -12px rgba(0,0,0,.6);
}
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .7px;
  text-transform: uppercase; color: #fff; padding: 4px 11px; border-radius: 20px;
  background: var(--grad); margin-bottom: 11px;
  box-shadow: 0 4px 12px -3px rgba(139,92,246,.6);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.short { display: flex; align-items: center; gap: 8px; justify-content: center; }
.short code {
  background: var(--bg-elev); padding: 8px 11px; border-radius: var(--radius-xs);
  font-size: 12px; color: #d6bcff; max-width: 280px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--border);
  font-family: "SF Mono", ui-monospace, monospace;
}

.export-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: 100%; max-width: 440px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.export-controls .field.mini { margin-bottom: 0; }
.export-controls .field.mini > span {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 700;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all .18s var(--ease);
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--card-2); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: var(--grad);
  border: none; color: #fff;
  box-shadow: 0 8px 22px -6px rgba(139, 92, 246, 0.65), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn.primary:hover { box-shadow: var(--glow); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--card); }
.btn.tiny { padding: 7px 12px; font-size: 12px; }

/* ---------------- Admin ---------------- */
.admin {
  width: 100%; max-width: 660px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  box-shadow: 0 14px 40px -16px rgba(0,0,0,.6);
}
.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.admin-head h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.2px; }
.links { display: flex; flex-direction: column; gap: 11px; }
.link-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 15px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  transition: border-color .15s;
}
.link-card:hover { border-color: var(--border-strong); }
.link-card .meta { min-width: 0; }
.link-card .short-code {
  font-size: 12px; color: #d6bcff; font-family: ui-monospace, monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-card .target-input { margin-top: 7px; font-size: 12px; padding: 8px 10px; }
.link-card .stats { font-size: 11px; color: var(--faint); margin-top: 6px; font-variant-numeric: tabular-nums; }
.link-actions { display: flex; flex-direction: column; gap: 6px; }

.hidden { display: none !important; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(24px);
  background: rgba(20, 20, 30, 0.92);
  backdrop-filter: blur(14px);
  color: #fff; padding: 13px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all .3s var(--ease); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .panel { height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .stage { padding: 30px 16px 50px; }
}

.btn.full { width: 100%; justify-content: center; margin-top: 4px; }

/* ---------------- Biblioteca ---------------- */
.library-view {
  position: relative; z-index: 1;
  max-width: 920px; margin: 0 auto; padding: 34px 22px 60px;
}
.library-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.library-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.library-head-actions { display: flex; gap: 8px; }

.links { display: flex; flex-direction: column; gap: 12px; }
.link-card {
  display: grid;
  grid-template-columns: 120px 1fr auto auto;
  gap: 18px; align-items: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  transition: border-color .15s, transform .15s var(--ease);
}
.link-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.link-card .thumb {
  width: 120px; height: 120px; border-radius: 12px; background: #fff;
  display: grid; place-items: center; overflow: hidden; padding: 8px;
  color: #999; font-weight: 700; font-size: 12px;
}
.link-card .thumb canvas { width: 100% !important; height: 100% !important; border-radius: 4px; }
.link-card .meta { min-width: 0; }
.link-card .name { font-size: 15px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.2px; }
.link-card .short-code {
  font-size: 12px; color: #d6bcff; font-family: ui-monospace, monospace;
  text-decoration: none; display: inline-block; margin-bottom: 8px;
}
.link-card .short-code:hover { text-decoration: underline; }
.dest-row { display: flex; align-items: center; gap: 8px; }
.dest-arrow { color: var(--faint); }
.dest-row .target-input { flex: 1; font-size: 12px; padding: 7px 10px; min-width: 0; max-width: 340px; }
.link-card .scans { text-align: center; padding: 0 6px; }
.link-card .scans strong { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.link-card .scans span { font-size: 11px; color: var(--muted); }
.link-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-size: 14px; transition: all .15s;
  display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--accent); background: var(--card-2); transform: translateY(-2px); }
.icon-btn.txt { font-size: 10px; font-weight: 800; letter-spacing: .3px; color: var(--muted); }
.icon-btn.txt:hover { color: #fff; }
.icon-btn.danger:hover { border-color: #f43f5e; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* ---------------- Modal estadísticas ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 4, 8, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn .2s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: 100%; max-width: 900px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 26px; box-shadow: var(--shadow);
  animation: floatIn .3s var(--ease);
}
.modal-close {
  position: absolute; top: 18px; right: 18px; width: 34px; height: 34px;
  border-radius: 9px; background: var(--card); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 15px; transition: all .15s;
}
.modal-close:hover { color: #fff; border-color: var(--accent); }

.stats-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.stats-title h3 { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; margin: 8px 0 4px; }
.stats-title a { font-size: 12.5px; color: #d6bcff; text-decoration: none; font-family: ui-monospace, monospace; }
.stats-title a:hover { text-decoration: underline; }
.stats-kpis { display: flex; gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 20px; min-width: 130px;
}
.kpi span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.kpi strong { display: block; font-size: 28px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #fff, #c9b8ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.stats-tools { display: flex; gap: 8px; margin-bottom: 20px; }

.stats-block {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.stats-block-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 14px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats-grid .stats-block:first-child { grid-column: 1 / -1; }

.chart { width: 100%; }
.chart-empty { color: var(--faint); font-size: 13px; text-align: center; padding: 40px 0; }
.chart-legend { display: flex; gap: 16px; margin-bottom: 6px; }
.lg { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ""; width: 14px; height: 3px; border-radius: 2px; }
.lg-total::before { background: var(--accent); }
.lg-unique::before { background: var(--accent-3); }
.area-svg { width: 100%; height: 200px; display: block; }
.area-svg .grid { stroke: var(--border); stroke-width: 1; }
.area-svg .ax { fill: var(--faint); font-size: 10px; font-family: "Inter", sans-serif; }

/* Barras (SO) */
.bar-row { display: grid; grid-template-columns: 90px 1fr 48px; gap: 10px; align-items: center; margin-bottom: 11px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-label { font-size: 12.5px; color: var(--text); }
.bar-track { height: 9px; background: var(--card-2); border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #fb7185, #f43f5e); min-width: 3px; transition: width .5s var(--ease); }
.bar-val { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Ranking (países / ciudades) */
.rank-row { display: grid; grid-template-columns: 20px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--hairline); font-size: 12.5px; }
.rank-row:last-child { border-bottom: none; }
.rank-i { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-scans { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-pct { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr; }
  .link-card { grid-template-columns: 96px 1fr; }
  .link-card .thumb { width: 96px; height: 96px; }
  .link-card .scans, .link-actions { grid-column: 2; justify-self: start; }
}

/* Scrollbar */
.panel::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
.panel::-webkit-scrollbar-thumb:hover { background: var(--faint); background-clip: padding-box; }

/* ==================== Login ==================== */
.login-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 38px 32px;
  box-shadow: var(--shadow); animation: floatIn .4s var(--ease);
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 15px;
  font-weight: 800; font-size: 19px; color: #fff; background: var(--grad);
  box-shadow: 0 8px 22px -6px rgba(139,92,246,.7), inset 0 1px 0 rgba(255,255,255,.35);
}
.login-card h1 { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.login-sub { font-size: 13px; color: var(--muted); margin: 6px 0 24px; }
.login-field { display: block; text-align: left; margin-bottom: 18px; }
.login-field span { display: block; font-size: 12px; font-weight: 600; margin-bottom: 7px; color: var(--text); }
.login-error {
  background: rgba(244,63,94,.12); border: 1px solid rgba(244,63,94,.4);
  color: #fda4af; font-size: 12.5px; font-weight: 500;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 18px;
}
.login-btn { margin-top: 4px; padding: 12px; font-size: 14px; }

/* ==================== Logout (topbar) ==================== */
.logout-btn {
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none; color: var(--muted);
  background: var(--card); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: all .18s var(--ease);
}
.logout-btn:hover { color: #fff; border-color: #f43f5e; transform: translateY(-1px); }

/* ==================== Dashboard ==================== */
.dashboard-view {
  position: relative; z-index: 1;
  max-width: 960px; margin: 0 auto; padding: 34px 22px 60px;
}
.dash-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.6px; }
.dash-head p { font-size: 13.5px; color: var(--muted); margin-top: 4px; }

.dash-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 22px 0; }
.dash-total-card {
  background: linear-gradient(135deg, rgba(139,92,246,.14), rgba(236,72,153,.10));
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 18px 20px;
}
.dash-total-card span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.dash-total-card strong {
  display: block; font-size: 30px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg,#fff,#c9b8ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.dash-period {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; margin-bottom: 20px;
}
.dash-period-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.dash-period-head h3 { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }
.dash-since { font-size: 12px; color: var(--faint); }

.dash-kpis { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 20px; }
.dash-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 16px; }
.dash-kpi span { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; }
.dash-kpi strong { display: block; font-size: 22px; font-weight: 800; margin-top: 5px; font-variant-numeric: tabular-nums; }

.dash-top-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.dash-top { display: flex; flex-direction: column; gap: 10px; }
.dash-row {
  display: grid; grid-template-columns: 24px 104px 1fr auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 16px;
  transition: border-color .15s, transform .15s var(--ease);
}
.dash-row:hover { border-color: var(--border-strong); transform: translateX(2px); }
.dash-rank { font-size: 15px; font-weight: 800; color: var(--accent); text-align: center; font-variant-numeric: tabular-nums; }
.dash-thumb { width: 104px; height: 104px; background: #fff; border-radius: 12px; padding: 7px; display: grid; place-items: center; color: #999; font-size: 11px; font-weight: 700; }
.dash-thumb canvas { width: 100% !important; height: 100% !important; border-radius: 5px; }
.dash-row-meta { min-width: 0; }
.dash-row-name { font-size: 14.5px; font-weight: 700; margin-bottom: 3px; letter-spacing: -0.2px; }
.dash-row-url { font-size: 11.5px; color: #d6bcff; text-decoration: none; font-family: ui-monospace, monospace; display: inline-block; margin-bottom: 8px; }
.dash-row-url:hover { text-decoration: underline; }
.dash-bar { height: 7px; background: var(--card-2); border-radius: 10px; overflow: hidden; }
.dash-bar-fill { height: 100%; border-radius: 10px; background: var(--grad); transition: width .5s var(--ease); }
.dash-row-scans { text-align: center; padding-left: 6px; }
.dash-row-scans strong { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dash-row-scans span { font-size: 10.5px; color: var(--muted); }

@media (max-width: 640px) {
  .dash-totals, .dash-kpis { grid-template-columns: 1fr; }
  .dash-row { grid-template-columns: 20px 84px 1fr; }
  .dash-thumb { width: 48px; height: 48px; }
  .dash-row-scans { grid-column: 3; text-align: left; }
}
