:root {
  --green:       #22c55e;
  --green-dark:  #16a34a;
  --green-light: #dcfce7;
  --green-dim:   #bbf7d0;
  --white:       #ffffff;
  --gray-50:     #f9fafb;
  --gray-100:    #f3f4f6;
  --gray-200:    #e5e7eb;
  --gray-400:    #9ca3af;
  --gray-600:    #4b5563;
  --gray-800:    #1f2937;
  --gray-900:    #111827;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.10);
  --font:        'Sora', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --transition:  .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, textarea { font-family: var(--font); }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.main { flex: 1; padding: 48px 0 64px; }

.header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header__inner {
  display: flex; align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo__icon { font-size: 20px; }
.logo__text { font-size: 18px; font-weight: 700; letter-spacing: -.4px; color: var(--gray-900); }
.logo__accent { color: var(--green); }
.nav { display: flex; gap: 4px; }
.nav__link {
  padding: 6px 14px; border-radius: 8px; font-size: 14px;
  font-weight: 500; color: var(--gray-600); transition: var(--transition);
}
.nav__link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav__link--active { background: var(--green-light); color: var(--green-dark); }

.footer { background: var(--white); border-top: 1px solid var(--gray-200); padding: 20px 0; }
.footer__inner {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--gray-400);
}
.footer__tag {
  font-family: var(--mono); font-size: 12px;
  background: var(--green-light); color: var(--green-dark);
  padding: 3px 10px; border-radius: 20px;
}

.hero { text-align: center; margin-bottom: 48px; }
.hero__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700; line-height: 1.15; letter-spacing: -.04em;
  color: var(--gray-900); margin-bottom: 16px;
}
.hero__title span { color: var(--green); }
.hero__sub { font-size: 17px; color: var(--gray-600); max-width: 480px; margin: 0 auto; }

.stats-bar {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 40px;
}
.stat-pill {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 50px; padding: 8px 20px;
  font-size: 14px; color: var(--gray-600);
  display: flex; align-items: center; gap: 6px;
}
.stat-pill strong { color: var(--green-dark); font-weight: 700; }

.card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); box-shadow: var(--shadow-md);
  padding: 32px;
}

.tabs { display: flex; gap: 4px; margin-bottom: 28px; }
.tab-btn {
  padding: 8px 20px; border-radius: 8px; font-size: 14px;
  font-weight: 600; border: none; background: var(--gray-100);
  color: var(--gray-600); transition: var(--transition);
}
.tab-btn:hover { background: var(--gray-200); }
.tab-btn.active { background: var(--green); color: var(--white); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700, #374151); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-200); font-size: 15px;
  background: var(--white); color: var(--gray-900);
  transition: var(--transition); outline: none;
}
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.textarea {
  width: 100%; padding: 12px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-200); font-size: 14px;
  font-family: var(--mono); background: var(--white); color: var(--gray-900);
  resize: vertical; min-height: 140px; outline: none; transition: var(--transition);
}
.textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.input-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

select.input {
  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='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.file-import-label {
  font-size: 12px; font-weight: 600; color: var(--green-dark);
  background: var(--green-light); border: 1px solid var(--green-dim);
  padding: 4px 12px; border-radius: 6px; cursor: pointer;
  transition: var(--transition);
}
.file-import-label:hover { background: var(--green-dim); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius);
  font-size: 15px; font-weight: 600; border: none;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(34,197,94,.3); }
.btn-primary:active { transform: none; }
.btn-outline { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn-outline:hover { background: var(--green-light); }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1.5px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger { background: transparent; color: #ef4444; border: 1.5px solid #fca5a5; padding: 6px 12px; font-size: 13px; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

.result-box {
  margin-top: 24px; background: var(--green-light);
  border: 1.5px solid var(--green-dim); border-radius: var(--radius-lg);
  padding: 20px 24px; display: none;
}
.result-box.show { display: block; animation: fadeIn .25s ease; }
.result-box__label { font-size: 12px; font-weight: 700; color: var(--green-dark); letter-spacing: .5px; text-transform: uppercase; margin-bottom: 10px; }
.result-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border-radius: var(--radius);
  padding: 10px 14px; border: 1px solid var(--green-dim);
  min-width: 0;
}
.result-url {
  flex: 1; font-family: var(--mono); font-size: 15px;
  color: var(--green-dark); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.bulk-results { margin-top: 24px; display: none; }
.bulk-results.show { display: block; animation: fadeIn .25s ease; }

.bulk-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: var(--transition);
  overflow: hidden;
  min-width: 0;
}
.bulk-card:hover { border-color: var(--green-dim); box-shadow: var(--shadow); }
.bulk-card__index {
  width: 26px; height: 26px; flex-shrink: 0;
  background: var(--green-light); color: var(--green-dark);
  border-radius: 50%; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.bulk-card__body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bulk-card__original {
  font-size: 12px; color: var(--gray-400);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bulk-card__short {
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--green-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.bulk-card__short:hover { text-decoration: underline; }
.bulk-card .btn { flex-shrink: 0; }

.dashboard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.dashboard-title { font-size: 24px; font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.kpi { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 20px 24px; box-shadow: var(--shadow); }
.kpi__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-400); margin-bottom: 6px; }
.kpi__value { font-size: 28px; font-weight: 700; color: var(--green-dark); }

.filters { margin-bottom: 20px; }
.filters__form { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.input--sm { padding: 8px 12px; font-size: 13px; min-width: 140px; }
select.input--sm {
  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='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--gray-400); padding: 10px 16px;
  border-bottom: 1px solid var(--gray-200);
}
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.td-url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-600); }
.td-short { font-family: var(--mono); color: var(--green-dark); font-size: 13px; font-weight: 600; }
.badge-clicks { background: var(--green-light); color: var(--green-dark); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; display: inline-block; }
.td-actions { display: flex; gap: 6px; }

.badge-group {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.chart-title { font-size: 15px; font-weight: 700; color: var(--gray-800); margin-bottom: 14px; }
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { min-width: 90px; color: var(--gray-600); text-align: right; }
.bar-track { flex: 1; background: var(--gray-100); border-radius: 4px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width .6s ease; display: flex; align-items: center; padding-left: 8px; }
.bar-count { font-size: 12px; font-weight: 700; color: white; }
.device-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.device-pill { display: flex; align-items: center; gap: 8px; background: var(--gray-100); border-radius: 8px; padding: 8px 16px; font-size: 14px; }
.device-pill__val { font-weight: 700; color: var(--green-dark); }

.empty { text-align: center; padding: 60px 0; color: var(--gray-400); }
.empty__icon { font-size: 40px; margin-bottom: 12px; }
.empty__text { font-size: 16px; }

.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--gray-900); color: var(--white);
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 999;
  display: flex; align-items: center; gap: 8px;
  transform: translateY(80px); opacity: 0;
  transition: .3s cubic-bezier(.34,1.56,.64,1);
}
.toast.show { transform: none; opacity: 1; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid #ef4444; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .3s ease; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: white; border-radius: 50%;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .header__inner { height: 52px; }
  .nav__link { padding: 5px 10px; font-size: 13px; }
  .card { padding: 20px; }
  .footer__tag { display: none; }
  .bulk-card { flex-wrap: wrap; }
}