/* Shortener admin UI. Dark theme, purple accent. */
:root {
  --bg: #0b0b0f;
  --surface: #14141b;
  --surface-2: #1a1a22;
  --text: #e9e9ee;
  --muted: #8b8b97;
  --border: #262630;
  --border-strong: #34343f;
  --accent: #7c5cff;
  --accent-hover: #6b4af0;
  --accent-soft: rgba(124, 92, 255, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0;
  color: var(--text);
}

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.inline-form { display: inline; margin: 0; }

/* Navigation */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; font-size: 15px; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-dim { color: var(--muted); font-weight: 500; }
.nav-right { display: flex; align-items: center; gap: 14px; }

/* Containers */
.container { max-width: 1160px; margin: 0 auto; padding: 28px; }
.breadcrumb { display: inline-block; margin-bottom: 16px; color: var(--muted); font-size: 13px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-title { margin: 0 0 14px; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.api-hint pre { font-size: 12px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; }
.form input,
.form-inline input,
.form-inline select,
.search-input {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.form input::placeholder, .form-inline input::placeholder, .search-input::placeholder { color: var(--muted); }
.form input:focus,
.form-inline input:focus,
.form-inline select:focus,
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-inline .grow { flex: 1 1 260px; min-width: 240px; }

/* Buttons */
.btn-primary, .btn-danger {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, opacity 120ms;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.link-btn { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 0 4px; font-family: inherit; }
.link-btn:hover { color: var(--accent); text-decoration: underline; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}
.tab:hover { text-decoration: none; border-color: var(--border-strong); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.tab.active .tab-count { color: rgba(255, 255, 255, 0.85); }

/* Search */
.search-bar { margin-bottom: 16px; }
.search-input { width: 100%; }

.tab-summary { font-size: 13.5px; margin-bottom: 14px; color: var(--text); }
.tab-summary strong { font-size: 15px; }

/* Auto badge */
.badge-auto {
  display: inline-block;
  padding: 1px 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #b7a4ff;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; font-size: 13.5px; border: 1px solid transparent; }
.alert.ok { background: var(--success-soft); border-color: rgba(52, 211, 153, 0.25); color: #6ee7b7; }
.alert.error { background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.25); color: #fca5a5; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border-strong); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .slug { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: #c9b8ff; }
.slug-cell { white-space: nowrap; }
.target { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ua, .ref { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { text-align: right; }

/* Login */
.login-shell { min-height: calc(100vh - 90px); display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; max-width: 100%; }
.login-title { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.login-sub { margin: 0 0 18px; font-size: 13px; }

/* Link detail */
.link-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 18px; }
.stat-big { text-align: right; }
.stat-value { font-size: 36px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }
.meta { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }
.chart-wrap { position: relative; height: 240px; }

/* Stat tiles / group bits (kept from groups feature) */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.form-spaced { margin-bottom: 14px; }
.field-label { color: var(--muted); font-size: 13px; }
.group-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

.stat-split { margin-top: 8px; font-size: 12px; color: var(--muted); }
.stat-split strong { color: var(--success); }

/* Two-column layout for breakdowns + QR */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }

/* Breakdown blocks (country / device / browser / source) */
.bd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 22px; }
.bd-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.bd-list { list-style: none; margin: 0; padding: 0; }
.bd-list li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.bd-list li:last-child { border-bottom: none; }
.bd-key { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.sm { font-size: 12px; }

/* QR card */
.qr-card { text-align: center; }
.qr-img { width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 8px; }
.qr-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.btn-secondary {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Bot rows dimmed in the click log */
.row-bot { opacity: 0.5; }

/* Dashboard overview strip */
.overview { padding: 16px 22px; }
.ov-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.ov-item { display: flex; flex-direction: column; }
.ov-value { font-size: 26px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.ov-label { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.ov-geo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.ov-chip { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.ov-chip b { font-variant-numeric: tabular-nums; color: var(--accent); }

/* Mobile */
@media (max-width: 640px) {
  .container { padding: 16px; }
  .nav { padding: 12px 16px; }
  .link-head { flex-direction: column; align-items: flex-start; }
  .stat-big { text-align: left; }
  .meta { grid-template-columns: 1fr; }
  .target { max-width: 200px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .bd-grid { grid-template-columns: 1fr; }
  .ov-geo { margin-left: 0; }
}
