:root {
  color-scheme: dark;
  --bg: #08111c;
  --bg-soft: #0d1827;
  --panel: rgba(17, 29, 46, 0.82);
  --panel-strong: rgba(21, 35, 54, 0.96);
  --line: rgba(147, 176, 211, 0.18);
  --text: #eef5ff;
  --muted: #9cadc4;
  --teal: #4fe0cf;
  --blue: #76a9ff;
  --pink: #ff8bbd;
  --danger: #ff8e8e;
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 12% 0%, rgba(42, 153, 170, 0.17), transparent 33%), radial-gradient(circle at 91% 13%, rgba(194, 76, 137, 0.13), transparent 30%);
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-link { color: inherit; text-decoration: none; }
.brand-link:hover .brand-name, .brand-link:focus-visible .brand-name { color: var(--teal); }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 1px solid rgba(79, 224, 207, 0.58); color: var(--teal); border-radius: 9px; font-weight: 800; letter-spacing: 0; overflow: hidden; }
.brand-mark img { width: 30px; height: 30px; display: block; object-fit: contain; }
.brand-copy { flex: 1 1 auto; min-width: 0; }
.brand-name { overflow: visible; font-size: 16px; font-weight: 700; letter-spacing: 0; line-height: 1.25; white-space: nowrap; text-overflow: clip; }
.brand-subtitle { overflow: visible; color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.35; white-space: nowrap; }
.auth-heading { margin: 38px 0 8px; font-size: 30px; letter-spacing: 0; }
.auth-copy { color: var(--muted); margin: 0 0 28px; line-height: 1.65; }
.field { display: grid; gap: 8px; margin-top: 16px; }
.field label { color: var(--muted); font-size: 13px; }
.field input { width: 100%; min-height: 44px; padding: 0 13px; color: var(--text); background: rgba(5, 12, 22, 0.68); border: 1px solid var(--line); border-radius: 7px; outline: none; }
.field input:focus { border-color: rgba(79, 224, 207, 0.8); box-shadow: 0 0 0 3px rgba(79, 224, 207, 0.12); }
.auth-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 25px; }
.language-switch { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: rgba(7, 14, 24, 0.7); }
.language-switch button { border: 0; border-radius: 5px; padding: 6px 9px; color: var(--muted); background: transparent; font-size: 12px; }
.language-switch button.active { color: var(--text); background: rgba(118, 169, 255, 0.2); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 15px; color: var(--text); border: 1px solid var(--line); border-radius: 7px; background: rgba(22, 38, 59, 0.78); text-decoration: none; line-height: 1; transition: border-color .18s ease, transform .18s ease, background .18s ease; }
.btn:hover { border-color: rgba(118, 169, 255, .7); background: rgba(30, 52, 79, .9); transform: translateY(-1px); }
.btn-primary { color: #061416; background: var(--teal); border-color: var(--teal); font-weight: 700; }
.btn-primary:hover { background: #7cf1e2; border-color: #7cf1e2; }
.btn-danger { color: var(--danger); border-color: rgba(255, 142, 142, .35); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.error-text { min-height: 18px; margin-top: 14px; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; min-width: 300px; padding: 26px 18px; border-right: 1px solid var(--line); background: rgba(7, 15, 26, .68); backdrop-filter: blur(22px); }
.sidebar .brand { padding: 0 7px; }
.side-nav { display: grid; gap: 6px; margin-top: 52px; }
.side-nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; color: var(--muted); border: 1px solid transparent; border-radius: 7px; background: transparent; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.side-nav-item.active { color: var(--text); border-color: rgba(79, 224, 207, .22); background: rgba(79, 224, 207, .08); }
.side-footer { margin-top: auto; padding: 14px 7px 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.side-footer-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.feedback-link { display: inline-flex; align-items: center; gap: 7px; color: var(--teal); text-decoration: none; }
.account-password-link { padding: 0; color: var(--blue); border: 0; background: transparent; font-size: 12px; line-height: 1.65; }
.feedback-link:hover, .feedback-link:focus-visible, .account-password-link:hover, .account-password-link:focus-visible { color: #7cf1e2; text-decoration: underline; }
.side-footer-account { min-width: 0; }
.side-footer-account strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.main { min-width: 0; padding: 28px clamp(20px, 4vw, 56px) 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 36px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--teal); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.page-title { margin: 7px 0 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: 0; }
.page-copy { margin: 8px 0 0; color: var(--muted); }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 25px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-bottom: 26px; }
.stat-card { min-height: 116px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 32px rgba(0,0,0,.16); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 14px; font-size: 30px; font-weight: 700; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 32px rgba(0,0,0,.16); backdrop-filter: blur(18px); }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-title { margin: 0; font-size: 15px; }
.panel-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.qr-list { display: grid; gap: 1px; }
.qr-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding: 17px 20px; border-bottom: 1px solid rgba(147, 176, 211, .1); cursor: pointer; }
.qr-item:last-child { border-bottom: 0; }
.qr-item:hover, .qr-item.selected { background: rgba(118, 169, 255, .07); }
.qr-edit-btn { min-width: 72px; }
.qr-name { font-size: 14px; font-weight: 650; }
.qr-url { max-width: 450px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.qr-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; color: #7f91aa; font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--teal); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.status.paused { color: var(--pink); }
.empty-state { padding: 44px 22px; color: var(--muted); text-align: center; line-height: 1.7; }
.detail-panel { min-height: 420px; }
.detail-body { padding: 20px; }
.qr-preview { display: grid; place-items: center; min-height: 245px; padding: 18px; border: 1px solid var(--line); background: #fff; border-radius: 7px; }
.qr-preview img { width: min(100%, 240px); height: auto; display: block; }
.detail-url { margin: 18px 0 0; padding: 10px 12px; overflow-wrap: anywhere; color: var(--teal); background: rgba(5, 12, 22, .6); border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; height: 150px; margin-top: 18px; padding: 0 3px; }
.chart-bar { display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 100%; min-width: 0; text-align: center; color: var(--muted); font-size: 10px; }
.bar-track { display: flex; align-items: end; justify-content: center; height: 100%; }
.bar-fill { width: min(24px, 70%); min-height: 3px; background: var(--blue); border-radius: 3px 3px 0 0; box-shadow: 0 0 20px rgba(118,169,255,.34); }
.breakdown { display: grid; gap: 10px; margin-top: 24px; }
.breakdown-row { display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.breakdown-track { height: 5px; overflow: hidden; background: rgba(147, 176, 211, .13); border-radius: 3px; }
.breakdown-fill { height: 100%; background: var(--teal); }
.admin-panel { margin-top: 0; }
.admin-body { padding: 20px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.inline-form .field { margin: 0; }
.customer-list { display: grid; gap: 8px; }
.customer-row { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 12px 14px; background: rgba(5, 12, 22, .4); border: 1px solid rgba(147, 176, 211, .11); border-radius: 6px; }
.customer-info { min-width: 0; }
.customer-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.customer-status { font-size: 11px; font-weight: 600; }
.customer-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.customer-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.customer-email { color: var(--muted); font-size: 12px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 18px; background: rgba(1, 6, 12, .76); backdrop-filter: blur(10px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(560px, 100%); padding: 24px; background: var(--panel-strong); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: start; gap: 15px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-close { width: 34px; height: 34px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; background: transparent; }
.modal-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.field input:disabled { color: #7f91aa; background: rgba(5, 12, 22, .38); cursor: not-allowed; }
.modal-actions { display: flex; justify-content: end; gap: 9px; margin-top: 24px; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: 20px; max-width: min(360px, calc(100vw - 40px)); padding: 12px 15px; color: var(--text); background: #17283d; border: 1px solid rgba(79,224,207,.35); border-radius: 7px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.small-note { margin-top: 9px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.view-section { display: none; }
.view-section.view-active { display: block; }
.view-section.stats-grid.view-active { display: grid; }
.view-section.page-heading.view-active { display: flex; }
.view-section.content-grid.view-active { display: grid; }
.analytics-section { margin-top: 0; }
.analytics-heading { margin-bottom: 25px; }
.analytics-filter { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.analytics-filter select { min-width: 190px; max-width: 280px; min-height: 36px; padding: 0 30px 0 10px; color: var(--text); background: rgba(5, 12, 22, .68); border: 1px solid var(--line); border-radius: 6px; outline: none; }
.analytics-filter select:focus { border-color: rgba(79, 224, 207, 0.8); box-shadow: 0 0 0 3px rgba(79, 224, 207, 0.12); }
.analytics-stack { display: grid; gap: 18px; }
.trend-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 0; }
.custom-range-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 12px; padding: 14px 20px 0; }
.custom-range-controls[hidden] { display: none; }
.analytics-date-field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.analytics-date-field input { min-height: 36px; padding: 0 9px; color: var(--text); background: rgba(5, 12, 22, .68); border: 1px solid var(--line); border-radius: 6px; outline: none; }
.analytics-date-field input:focus { border-color: rgba(79, 224, 207, 0.8); box-shadow: 0 0 0 3px rgba(79, 224, 207, 0.12); }
.analytics-range-error { min-height: 18px; color: var(--danger); font-size: 12px; }
.metric-switch { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: rgba(7, 14, 24, .7); }
.metric-switch button { min-height: 32px; padding: 0 11px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; font-size: 12px; }
.metric-switch button.active { color: var(--text); background: rgba(118, 169, 255, .2); }
.line-chart-wrap { padding: 12px 20px 18px; }
.line-chart { width: 100%; min-height: 230px; display: block; overflow: visible; }
.chart-grid-line { stroke: rgba(147, 176, 211, .15); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 9px; font-weight: 400; letter-spacing: 0; }
.chart-date-label { fill: var(--muted); font-size: 8px; font-weight: 400; letter-spacing: 0; }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 3px rgba(118, 169, 255, .28)); }
.chart-point { fill: var(--blue); stroke: var(--panel-strong); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.line-chart-empty { min-height: 230px; display: grid; place-items: center; color: var(--muted); }
.analytics-breakdown-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.breakdown-panel { min-width: 0; }
.breakdown-body { display: grid; gap: 10px; padding: 18px 20px 22px; }
.ranking-body { display: grid; gap: 11px; padding: 18px 20px 22px; }
.ranking-row { display: grid; grid-template-columns: 24px minmax(110px, 1fr) minmax(100px, 2fr) auto; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.ranking-position { color: var(--teal); font-weight: 700; text-align: center; }
.ranking-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ranking-track { height: 7px; overflow: hidden; background: rgba(147, 176, 211, .13); border-radius: 3px; }
.ranking-fill { height: 100%; background: var(--blue); box-shadow: 0 0 12px rgba(118, 169, 255, .32); }
.admin-monitoring-page { display: grid; gap: 18px; }
.monitoring-filter-panel { padding: 18px 20px; }
.monitoring-filters { display: flex; flex-wrap: wrap; gap: 16px 22px; align-items: end; }
.monitoring-filters .analytics-filter { flex: 1 1 220px; }
.monitoring-filters .analytics-filter select { width: 100%; max-width: none; }
.monitoring-stats-grid { margin: 0; }
.monitoring-trend-panel { min-width: 0; }
.monitoring-breakdown-grid { margin: 0; }
.table-wrap { overflow-x: auto; padding: 0 20px 20px; }
.monitoring-table { width: 100%; border-collapse: collapse; min-width: 620px; color: var(--muted); font-size: 12px; }
.monitoring-table th { padding: 11px 10px; color: var(--muted); font-weight: 600; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.monitoring-table td { padding: 13px 10px; border-bottom: 1px solid rgba(147, 176, 211, .09); white-space: nowrap; }
.monitoring-table td:first-child { color: var(--teal); font-weight: 700; width: 36px; }
.monitoring-table td:nth-child(3) { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.monitoring-table strong { color: var(--text); }
.table-empty { text-align: center; padding: 28px 10px !important; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; min-width: 0; flex-direction: row; align-items: center; gap: 18px; padding: 15px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { display: flex; flex: 1 1 auto; min-width: 0; overflow-x: auto; gap: 6px; margin-top: 0; }
  .side-nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .side-footer { margin: 0 0 0 auto; padding: 0; }
  .side-footer-actions { flex-direction: row; align-items: center; margin: 0; white-space: nowrap; }
  .side-footer-account { max-width: 150px; }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .main { padding: 22px 15px 40px; }
  .topbar { align-items: start; flex-direction: column; margin-bottom: 28px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading .btn { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .qr-item { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .btn { width: 100%; }
  .modal-form-grid { grid-template-columns: 1fr; }
  .customer-row { align-items: start; flex-direction: column; }
  .customer-actions { width: 100%; justify-content: start; }
  .analytics-filter { width: 100%; align-items: start; flex-direction: column; white-space: normal; }
  .analytics-filter select { width: 100%; max-width: none; }
  .analytics-breakdown-grid { grid-template-columns: 1fr; gap: 18px; }
  .monitoring-filters { align-items: stretch; }
  .monitoring-filters .analytics-filter { flex-basis: 100%; }
  .ranking-row { grid-template-columns: 24px minmax(90px, 1fr) minmax(60px, 1.5fr) auto; }
  .sidebar .brand-subtitle { display: none; }
  .side-footer-account { display: none; }
  .auth-card { padding: 25px; }
}
