:root {
  --bg: #09111f;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-2: rgba(30, 41, 59, 0.74);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e5eefb;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --success: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 20px 60px rgba(2,6,23,.45);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(99,102,241,.2), transparent 26%),
    radial-gradient(circle at top right, rgba(139,92,246,.18), transparent 22%),
    linear-gradient(180deg, #020617 0%, #08101d 100%);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 290px; padding: 24px; border-right: 1px solid var(--line); background: rgba(2,6,23,.75);
  backdrop-filter: blur(18px); position: sticky; top: 0; height: 100vh; z-index: 5;
}
.mobile-nav-toggle { display: none; }
.brand-card, .sidebar-user, .card, .stat-card, .table-wrap, .hero, .login-card, .table-container, .report-summary, .filter-bar {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.brand-card { display:flex; gap:14px; padding:16px; align-items:center; }
.brand-logo { width:52px; height:52px; object-fit:cover; border-radius:16px; }
.brand-logo-fallback { display:grid; place-items:center; background:linear-gradient(135deg,var(--primary),var(--primary-2)); font-weight:800; }
.brand-title { font-weight: 800; font-size: 18px; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; }
.nav-menu { display:grid; gap:10px; margin-top: 22px; }
.nav-menu a { padding: 14px 16px; border-radius: 16px; color: #d7e4f7; border: 1px solid transparent; background: rgba(15,23,42,.45); }
.nav-menu a:hover, .nav-menu a.active { border-color: rgba(99,102,241,.4); background: rgba(99,102,241,.14); }
.sidebar-user { margin-top: 24px; padding: 16px; display:grid; gap:6px; color: var(--muted); }
.main-content { flex:1; padding: 28px; min-width: 0; }
.auth-layout { display:grid; place-items:center; min-height:100vh; }
.page-header { display:flex; justify-content:space-between; gap:18px; align-items:center; margin-bottom: 24px; flex-wrap: wrap; }
.page-title h1 { margin:0; font-size: clamp(24px, 4vw, 30px); font-weight:800; }
.page-title p { margin:8px 0 0; color: var(--muted); }
.hero { padding: 28px; }
.grid { display:grid; gap:18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card { padding: 22px; position: relative; overflow:hidden; min-width: 0; }
.stat-card::after { content:''; position:absolute; inset:auto -20px -20px auto; width:110px; height:110px; border-radius:50%; background: rgba(99,102,241,.12); }
.stat-label { color:var(--muted); font-size:13px; margin-bottom:12px; }
.stat-value { font-size:34px; font-weight:800; }
.stat-meta { color:#c7d2fe; margin-top:10px; font-size:13px; }
.card { padding: 22px; min-width: 0; }
.card h3, .card h2 { margin:0 0 16px; font-size:18px; }
.table-wrap { overflow:auto; max-width: 100%; }
table { width:100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; border-bottom:1px solid var(--line); text-align:left; vertical-align: top; }
th { color:#cbd5e1; font-size:13px; }
tr:hover td { background: rgba(99,102,241,.05); }
form { display:grid; gap:16px; }
.field-group { display:grid; gap:14px; }
.field-row { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:14px; }
.field-row-3 { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:14px; }
label { display:grid; gap:8px; color:#dbe7f8; font-size:14px; }
input, textarea, select {
  width:100%; padding: 14px 16px; border-radius: 16px; border:1px solid rgba(148,163,184,.2); background: rgba(15,23,42,.8);
  color: var(--text); outline:none;
}
textarea { min-height: 130px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(99,102,241,.7); box-shadow: 0 0 0 4px rgba(99,102,241,.13); }
.btn-row, .actions, .inline-actions { display:flex; gap:12px; flex-wrap:wrap; align-items: center; }
.actions { gap: 8px; justify-content: flex-start; }
.actions > .btn, .actions > a.btn, .actions > form > .btn { padding: 9px 14px; border-radius: 14px; font-size: 13px; line-height: 1.1; min-height: 38px; display:inline-flex; align-items:center; justify-content:center; white-space: nowrap; }
.actions > form { margin: 0; display:block; }
.btn {
  border:none; border-radius: 16px; padding: 12px 18px; font-weight:700; cursor:pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color:white; box-shadow: 0 14px 30px rgba(99,102,241,.32);
}
.btn.secondary, .btn.ghost { background: rgba(30,41,59,.8); box-shadow:none; border:1px solid var(--line); }
.btn.success { background: linear-gradient(135deg, #059669, #16a34a); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #ef4444); }
.btn.warning { background: linear-gradient(135deg, #d97706, #f59e0b); }
.badge { display:inline-flex; align-items:center; padding:8px 12px; border-radius:999px; font-size:12px; font-weight:700; }
.badge.success { background: rgba(22,163,74,.16); color:#86efac; }
.badge.danger { background: rgba(239,68,68,.16); color:#fca5a5; }
.badge.info { background: rgba(99,102,241,.16); color:#c7d2fe; }
.badge.warning { background: rgba(245, 158, 11, .16); color:#fcd34d; }
.alert { padding: 16px 18px; border-radius: 18px; margin-bottom: 18px; }
.alert.success { background: rgba(22,163,74,.15); border:1px solid rgba(22,163,74,.28); color:#bbf7d0; }
.alert.error { background: rgba(239,68,68,.15); border:1px solid rgba(239,68,68,.28); color:#fecaca; }
.login-card { width:min(520px, calc(100vw - 32px)); padding:32px; }
.login-card h1 { margin:0 0 8px; font-size:30px; }
.login-card p { color: var(--muted); margin:0 0 24px; }
.metric-list { display:grid; gap:12px; }
.metric-item { display:flex; justify-content:space-between; gap:20px; padding:14px 0; border-bottom:1px solid var(--line); }
.metric-item:last-child { border-bottom:none; }
.kbd { padding:4px 8px; border-radius:8px; background:rgba(148,163,184,.14); color:#dbeafe; font-size:12px; }
.copy-box { display:flex; gap:10px; align-items:center; flex-wrap: wrap; }
.copy-box code, .code-box { flex:1; padding:12px 14px; border-radius:14px; background: rgba(15,23,42,.8); overflow-wrap:anywhere; }
.small { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.filter-bar { padding: 18px; }
.table-container { padding: 15px; }
.table-header, .table-row { display:grid; grid-template-columns: minmax(160px,2fr) minmax(220px,3fr) minmax(70px,1fr) minmax(90px,1fr) minmax(120px,1.4fr) minmax(160px,2fr); gap: 12px; align-items: center; }
.table-header { padding: 12px; font-size: 13px; color: #94a3b8; border-bottom: 1px solid #1e293b; }
.table-row { padding: 15px 12px; border-bottom: 1px solid #1e293b; transition: .2s; }
.table-row:hover { background: rgba(255,255,255,0.03); }
.link-col { display:flex; flex-direction:column; gap:6px; min-width:0; }
.link-col strong, .url-col, .cell-wrap { overflow-wrap:anywhere; }
.analytics-grid { display:grid; gap:18px; grid-template-columns: repeat(12, minmax(0,1fr)); }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.report-summary { padding: 18px; }
.report-grid { display:grid; gap:14px; grid-template-columns: repeat(3, minmax(0,1fr)); }
.site-footer {
  text-align:center; padding:20px; font-size:14px; color:#98a6bf; border-top:1px solid var(--line);
  margin: 0; background: rgba(2,6,23,.82);
}
.site-footer a { color: #7dd3fc; }
.empty-state { padding: 28px; text-align: center; color: var(--muted); }
.qr-box { max-width: 200px; }
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .analytics-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .span-8, .span-6, .span-4 { grid-column: span 6; }
}
@media (max-width: 980px) {
  .app-shell { display:block; }
  .mobile-nav-toggle {
    display:block; position: sticky; top: 0; z-index: 12; width: calc(100% - 16px); margin: 8px; padding: 14px 16px;
    border-radius: 16px; border:1px solid var(--line); background: rgba(2,6,23,.92); color:var(--text);
  }
  .sidebar { width:100%; height:auto; position: fixed; top: 56px; left: 0; transform: translateY(-120%); transition: .25s ease; padding:16px; }
  .sidebar.open { transform: translateY(0); }
  .field-row, .field-row-3, .grid-2, .grid-4, .report-grid { grid-template-columns: 1fr; }
  .main-content { padding:16px; }
  table { min-width: 680px; }
  .table-header { display:none; }
  .table-row { grid-template-columns: 1fr; gap:8px; padding:12px; border:1px solid #1e293b; border-radius: 16px; margin-bottom: 12px; }
  .link-col { gap: 4px; }
  .link-col strong { font-size: 18px; }
  .url-col { font-size: 14px; }
  .actions, .inline-actions, .btn-row { width:100%; }
  .actions { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:8px; align-items:stretch; }
  .actions > .btn, .actions > a.btn, .actions > form { width:100%; }
  .actions > form > button { width:100%; }
  .actions > .btn, .actions > a.btn, .actions > form > .btn { min-height: 40px; padding: 10px 12px; }
  .btn-row { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:10px; }
  .btn-row .btn, .btn-row a, .btn-row form { width:100%; }
  .url-col, .link-col span, .link-col strong { word-break: break-word; white-space: normal; }
  .analytics-grid { grid-template-columns: 1fr; }
  .span-12, .span-8, .span-6, .span-4 { grid-column: auto; }
}
@media (max-width: 560px) {
  .main-content { padding: 12px; }
  .card, .table-container, .filter-bar, .hero { padding: 16px; }
  .table-row { padding: 10px; border-radius: 14px; }
  .link-col strong { font-size: 17px; }
  .link-col .small { font-size: 12px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions > .btn, .actions > a.btn, .actions > form > .btn { font-size: 12px; min-height: 38px; padding: 9px 10px; border-radius: 12px; }
}


.chart-frame {
  position: relative;
  width: 100%;
  height: 320px;
  min-height: 320px;
  max-height: 320px;
  overflow: hidden;
}
.chart-frame.sm {
  height: 260px;
  min-height: 260px;
  max-height: 260px;
}
.chart-frame canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.card.compact-form form { gap: 14px; }
@media (max-width: 980px) {
  .chart-frame, .chart-frame.sm {
    height: 240px;
    min-height: 240px;
    max-height: 240px;
  }
}

.links-list .table-row > div { min-width: 0; }
.links-list .actions { align-self: center; }
.links-list .actions > form { min-width: 0; }


.pagination {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  align-items:center;
  margin-top:18px;
}
.page-btn {
  min-width:38px;
  height:38px;
  padding:0 12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:12px;
  border:1px solid var(--line);
  background: rgba(30,41,59,.8);
  color:#dbe7f8;
  box-shadow:none;
}
.page-btn:hover {
  border-color: rgba(99,102,241,.45);
  background: rgba(99,102,241,.14);
}
.page-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color:#fff;
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(99,102,241,.28);
}
@media (max-width: 560px) {
  .pagination { justify-content:flex-start; }
  .page-btn { min-width:34px; height:34px; border-radius:10px; font-size:12px; }
}
