* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f172a; --bg-card: #1e293b; --bg-hover: #334155;
  --text: #f1f5f9; --text-muted: #94a3b8; --text-dim: #64748b;
  --primary: #6366f1; --primary-hover: #818cf8;
  --success: #22c55e; --danger: #ef4444; --warning: #f59e0b;
  --border: #334155; --radius: 12px;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-container { width: 100%; max-width: 400px; padding: 1rem; }
.login-card { background: var(--bg-card); border-radius: var(--radius); padding: 2rem; border: 1px solid var(--border); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 2rem; background: linear-gradient(135deg, var(--primary), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-header p { color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; color: var(--text-muted); font-size: 0.875rem; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 0.75rem 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem; transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input::placeholder { color: var(--text-dim); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1.25rem;
  border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s; color: white;
}
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.error-msg { color: var(--danger); margin-top: 0.75rem; font-size: 0.875rem; text-align: center; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-card); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem; display: flex; flex-direction: column; position: fixed; height: 100vh; overflow-y: auto;
}
.sidebar-logo { font-size: 1.5rem; font-weight: 700; padding: 0 0.5rem 1.5rem; background: linear-gradient(135deg, var(--primary), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-nav { flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem;
  border-radius: 8px; color: var(--text-muted); cursor: pointer; transition: all 0.2s; margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active { background: var(--bg-hover); color: var(--text); }
.nav-item .icon { font-size: 1.1rem; width: 24px; text-align: center; }
.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border); }
.main { flex: 1; margin-left: 240px; padding: 2rem; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 2rem; font-weight: 700; margin-top: 0.25rem; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-title { font-size: 1.1rem; font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 0.75rem 1rem; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:hover td { background: var(--bg-hover); }
.link-url { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* Tags */
.tag { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.tags-wrap { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 22px; transition: 0.2s;
}
.toggle-slider:before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 90%; max-width: 550px; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Toolbar */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; align-items: center; flex-wrap: wrap; }
.search-input { max-width: 300px; }

/* Chart placeholder */
.chart-bar { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 1rem; }
.chart-col { flex: 1; min-width: 12px; background: var(--primary); border-radius: 3px 3px 0 0; transition: height 0.3s; position: relative; }
.chart-col:hover { background: var(--primary-hover); }
.chart-col .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--bg); padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.7rem; white-space: nowrap; }
.chart-col:hover .tip { display: block; }

/* Analytics grid */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.analytics-list { list-style: none; }
.analytics-list li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.analytics-list li:last-child { border-bottom: none; }

/* Badge */
.badge { display: inline-flex; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); }

/* QR */
.qr-container { text-align: center; padding: 1rem; }
.qr-container img { border-radius: 8px; background: white; padding: 1rem; }

/* Copy button */
.copy-btn { cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 4px; background: var(--bg-hover); border: none; color: var(--text-muted); font-size: 0.8rem; }
.copy-btn:hover { color: var(--text); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
}

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1.25rem; border-radius: 8px; color: white; font-size: 0.9rem; animation: slideIn 0.3s ease; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
