:root {
  --bg: #050b16;
  --bg-grid: rgba(61, 174, 255, 0.07);
  --panel: rgba(16, 31, 53, 0.88);
  --panel-strong: rgba(20, 43, 73, 0.95);
  --line: rgba(78, 154, 236, 0.36);
  --text: #f5f8ff;
  --muted: #b5c8e8;
  --cyan: #3dcfff;
  --blue: #236fc4;
  --green: #24d37a;
  --gold: #ecb940;
  --danger: #ff647c;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(115deg, rgba(3, 7, 15, 0.92), rgba(7, 20, 38, 0.94), rgba(9, 49, 78, 0.82)),
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 96px 96px, 96px 96px, auto;
}

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

button,
input,
select {
  font: inherit;
}

button,
a {
  border-radius: 8px;
}

.modal-open {
  overflow: hidden;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-shell {
  width: min(760px, 100%);
}

.login-card,
.panel,
.toolbar,
.metric {
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--panel-strong), rgba(8, 17, 31, 0.94));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.login-card {
  border-radius: 22px;
  padding: clamp(24px, 5vw, 48px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(61, 207, 255, 0.36);
  padding: 8px;
}

.brand-logo.small {
  width: 70px;
  height: 70px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.eyebrow,
.label {
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.notice {
  display: grid;
  gap: 8px;
  margin: 28px 0;
  padding: 22px;
  border: 1px solid rgba(78, 154, 236, 0.34);
  border-radius: 16px;
  background: rgba(3, 10, 22, 0.62);
  color: var(--muted);
  font-size: 19px;
  line-height: 1.45;
}

.notice strong {
  color: var(--text);
  font-size: 26px;
}

.form-stack {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 54px;
  border: 1px solid rgba(130, 172, 225, 0.46);
  border-radius: 10px;
  background: #eaf2ff;
  color: #031021;
  padding: 0 16px;
  font-weight: 700;
}

button,
.top-actions a {
  min-height: 48px;
  border: 1px solid rgba(78, 154, 236, 0.62);
  background: linear-gradient(120deg, #38c8e8, #236fc4);
  color: #02101f;
  padding: 0 22px;
  font-weight: 900;
  cursor: pointer;
}

.top-actions button {
  border-color: rgba(255, 100, 124, 0.5);
  background: rgba(255, 100, 124, 0.08);
  color: var(--text);
}

.ghost-button,
.link-button {
  background: rgba(11, 23, 42, 0.74);
  color: var(--text);
}

.link-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: #7fcfff;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  color: var(--cyan);
  text-decoration: underline;
}

.connected,
.muted {
  color: var(--muted);
}

.connected {
  margin: 28px 0 0;
  text-align: center;
}

.error {
  color: var(--danger);
  font-weight: 800;
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 52px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(78, 154, 236, 0.24);
}

.top-actions {
  display: flex;
  gap: 12px;
}

.top-actions a {
  display: grid;
  place-items: center;
  background: rgba(11, 23, 42, 0.74);
  color: var(--text);
}

.status-grid,
.metric-grid,
.content-grid {
  display: grid;
  gap: 16px;
}

.status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 28px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0;
}

.content-grid {
  grid-template-columns: 1fr;
}

.panel,
.metric,
.toolbar {
  border-radius: 10px;
  padding: 22px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(160px, 0.7fr) repeat(2, minmax(140px, 0.55fr)) auto;
  align-items: end;
  margin-top: 18px;
}

.metric {
  border-top: 4px solid var(--cyan);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  display: block;
  margin: 8px 0;
  color: var(--text);
  font-size: 42px;
  line-height: 1;
}

.live-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 14px;
}

.live-chart-header h2,
.chart-title h3 {
  margin: 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.chart-card {
  min-height: 300px;
  border: 1px solid rgba(78, 154, 236, 0.24);
  border-radius: 10px;
  background:
    linear-gradient(140deg, rgba(18, 48, 82, 0.86), rgba(7, 17, 33, 0.92)),
    rgba(8, 18, 34, 0.88);
  padding: 20px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.wide-chart {
  grid-column: span 3;
}

.chart-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-title h3 {
  color: #dcecff;
  font-size: 20px;
}

.chart-title span {
  color: var(--cyan);
  font-weight: 900;
}

.donut-chart,
.pie-chart {
  display: grid;
  place-items: center;
  min-height: 190px;
}

.donut-chart svg,
.pie-chart svg {
  width: 190px;
  height: 190px;
  overflow: visible;
}

.chart-track,
.chart-progress,
.pie-slice {
  fill: none;
  stroke-width: 18;
}

.chart-track {
  stroke: rgba(255, 255, 255, 0.08);
}

.chart-progress {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke: url("#chartGradient");
  stroke: var(--green);
  stroke-linecap: round;
}

.pie-slice {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  stroke-width: 52;
}

.pie-hole {
  fill: rgba(6, 16, 31, 0.96);
}

.donut-chart text,
.pie-chart text {
  fill: var(--text);
  font-size: 22px;
  font-weight: 900;
}

.pie-chart .chart-small {
  fill: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.bar-chart {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  min-height: 210px;
  padding: 18px 4px 0;
}

.bar-item {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 52px;
  flex: 1;
}

.bar-item span {
  width: min(42px, 68%);
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--cyan), #2977d9);
  box-shadow: 0 10px 28px rgba(61, 207, 255, 0.18);
}

.bar-item strong {
  color: var(--text);
}

.bar-item small {
  color: var(--muted);
  font-weight: 800;
}

.hbar-chart {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.hbar-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(120px, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.hbar-row span {
  overflow: hidden;
  color: var(--muted);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-row div {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hbar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), #2977d9);
}

.hbar-row strong {
  color: var(--text);
  text-align: right;
}

.empty-chart {
  display: grid;
  min-height: 150px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  background: rgba(36, 211, 122, 0.14);
  color: var(--green);
  padding: 0 14px;
  font-weight: 900;
}

.visitor-filters {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(180px, 0.7fr) minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 18px 0 8px;
}

.visitor-summary {
  margin: 0 0 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(78, 154, 236, 0.18);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

pre {
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(78, 154, 236, 0.24);
  border-radius: 10px;
  background: rgba(2, 8, 18, 0.72);
  color: #dcecff;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(2, 6, 14, 0.76);
  backdrop-filter: blur(8px);
}

.visitor-modal {
  width: min(1120px, 100%);
  max-height: min(88vh, 980px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(18, 38, 65, 0.98), rgba(7, 15, 28, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
  border-bottom: 1px solid rgba(78, 154, 236, 0.24);
}

.modal-header h2 {
  margin: 0;
}

.modal-body {
  max-height: calc(88vh - 92px);
  overflow: auto;
  padding: 26px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-item,
.session-card {
  border: 1px solid rgba(78, 154, 236, 0.24);
  border-radius: 10px;
  background: rgba(4, 12, 26, 0.62);
  padding: 16px;
}

.detail-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 86px;
  background:
    linear-gradient(135deg, rgba(61, 207, 255, 0.08), rgba(41, 119, 217, 0.06)),
    rgba(4, 12, 26, 0.72);
}

.detail-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(61, 207, 255, 0.28);
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, rgba(61, 207, 255, 0.2), rgba(41, 119, 217, 0.08) 50%, rgba(5, 15, 31, 0.86));
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 10px 24px rgba(0, 0, 0, 0.22);
}

.detail-icon svg {
  width: 25px;
  height: 25px;
}

.detail-item span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-item strong {
  color: var(--text);
  line-height: 1.35;
}

.modal-section {
  margin-top: 24px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.keyword-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  background: rgba(61, 207, 255, 0.12);
  border: 1px solid rgba(61, 207, 255, 0.24);
  color: #dcecff;
  padding: 0 12px;
  font-weight: 800;
}

.session-card {
  margin-top: 12px;
}

.session-card h3 {
  margin: 0 0 12px;
  color: #dcecff;
}

.page-list {
  display: grid;
  gap: 8px;
}

.page-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, auto);
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid rgba(78, 154, 236, 0.16);
}

.page-row span {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.page-row strong {
  text-align: right;
}

@media (max-width: 980px) {
  .topbar,
  .brand-row {
    align-items: flex-start;
  }

  .topbar,
  .status-grid,
  .metric-grid,
  .chart-grid,
  .content-grid,
  .toolbar,
  .visitor-filters,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .wide-chart {
    grid-column: auto;
  }

  .topbar {
    display: grid;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 24px, 1480px);
  }

  .brand-row {
    display: grid;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .live-chart-header,
  .chart-title {
    display: grid;
  }

  .bar-chart {
    gap: 8px;
    overflow-x: auto;
    justify-content: start;
  }

  .bar-item {
    min-width: 48px;
  }

  .hbar-row {
    grid-template-columns: 1fr;
  }

  .hbar-row strong {
    text-align: left;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .modal-header {
    align-items: start;
  }

  .page-row {
    grid-template-columns: 1fr;
  }

  .detail-item {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .detail-icon {
    width: 42px;
    height: 42px;
  }

  .page-row strong {
    text-align: left;
  }
}
