:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #d8deea;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --success: #16a34a;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #111827; color: white; padding: 24px; }
.sidebar .brand { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.sidebar nav { display: grid; gap: 10px; }
.sidebar nav a { color: #dbeafe; padding: 10px 12px; border-radius: 10px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.content { flex: 1; padding: 32px; }
.content.full { display: flex; align-items: center; justify-content: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: 0 12px 30px rgba(15,23,42,.05); margin-bottom: 24px; }
.card.subtle { background: #f8faff; }
.login-card { width: 100%; max-width: 420px; }
.flash { border-radius: 12px; padding: 14px 16px; margin-bottom: 18px; }
.flash.success { background: #ecfdf5; color: #166534; }
.flash.error { background: #fef2f2; color: #991b1b; }
.stack-form { display: grid; gap: 12px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: white; }
button, .button-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--primary); color: white; border: none; border-radius: 12px; padding: 12px 16px; cursor: pointer; }
.button-link.secondary, .danger-outline { background: white; color: var(--text); border: 1px solid var(--line); }
.danger-outline { color: var(--danger); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head.no-margin { margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: linear-gradient(135deg, #eef2ff, #ffffff); border: 1px solid #c7d2fe; border-radius: 18px; padding: 20px; }
.stat-card span { display: block; color: var(--muted); font-size: 14px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 34px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.qr-thumb { width: 72px; height: 72px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.qr-preview { width: 220px; max-width: 100%; }
.target-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; margin-top: 10px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.layout-split { align-items: start; }
.center { text-align: center; }
.muted { color: var(--muted); }
.bundle-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.bundle-card { max-width: 680px; width: 100%; }
.bundle-links { display: grid; gap: 12px; margin-top: 20px; }
.bundle-link { display: block; padding: 14px 16px; background: #eef2ff; border-radius: 14px; font-weight: 600; }
.category-children { margin-top: 16px; display: grid; gap: 12px; }
.category-block.depth-2 { margin-left: 20px; }
.category-block.depth-3 { margin-left: 40px; }
.compact-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.analytics-header { align-items: flex-start; }
.analytics-caption { margin: 6px 0 0; }
.analytics-filter-card { padding-bottom: 18px; }
.analytics-toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: end; flex-wrap: wrap; }
.analytics-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.analytics-form-grid { display: grid; grid-template-columns: repeat(2, minmax(180px, 220px)) auto; gap: 12px; align-items: end; }
.analytics-actions { display: flex; align-items: end; }
.analytics-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.analytics-stats-grid-qr { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card small { display: block; margin-top: 8px; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text); }
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .stats-grid, .two-col, .three-col, .target-row, .compact-stats, .analytics-stats-grid, .analytics-stats-grid-qr, .analytics-form-grid { grid-template-columns: 1fr; }
  .content { padding: 20px; }
  .category-block.depth-2, .category-block.depth-3 { margin-left: 0; }
}
