:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fbfe;
  --text: #172033;
  --muted: #667085;
  --border: #dde5ef;
  --blue: #1d73e8;
  --blue-soft: #eaf2ff;
  --green: #12863f;
  --shadow: 0 18px 60px rgba(30, 42, 62, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(246, 248, 251, 0.96));
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.svg-icon,
.svg-icon svg {
  width: 20px;
  height: 20px;
  display: inline-block;
}

.svg-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.boot-screen,
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-brand,
.topbar-brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--blue);
  background: var(--blue-soft);
}

.login-brand h1,
.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.login-brand p,
.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-form {
  margin-top: 30px;
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 650;
}

.login-form input[type="email"],
.login-form input[type="password"] {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(29, 115, 232, 0.12);
}

.remember-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  color: var(--muted) !important;
  font-weight: 600 !important;
}

.remember-row input {
  width: 18px;
  height: 18px;
}

.primary-button,
.connect-button,
.icon-button,
.range-filter button {
  border: 0;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease;
}

.primary-button {
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: #0f69dc;
  border-radius: 14px;
  font-weight: 750;
}

.primary-button:hover,
.connect-button:hover,
.icon-button:hover,
.range-filter button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.form-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  color: #ad2b2b;
  background: #fff1f0;
  font-weight: 650;
}

.app-shell {
  width: min(1500px, calc(100% - 40px));
  max-width: calc(100% - 40px);
  margin: 0 auto;
  padding: 24px 0 56px;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 16px 0;
  background: rgba(246, 248, 251, 0.88);
  backdrop-filter: blur(18px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.domain-jump {
  min-width: 260px;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.domain-jump select {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  font-weight: 750;
}

.domain-jump select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(29, 115, 232, 0.12);
}

.range-filter {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.range-filter button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 12px;
  color: #475467;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 700;
}

.range-filter button.active {
  color: #fff;
  background: var(--blue);
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: #344054;
  background: var(--surface);
}

.connect-button {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: #fff;
  background: #172033;
  font-size: 0.9rem;
  font-weight: 800;
}

.overview {
  margin: 18px 0 24px;
}

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

.metric-card {
  min-height: 118px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--blue);
  background: var(--blue-soft);
  flex: 0 0 auto;
}

.metric-content {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.metric-card span,
.chart-metrics span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric-card strong {
  font-size: clamp(1.55rem, 2.4vw, 2.15rem);
  line-height: 1.05;
  font-weight: 800;
}

.metric-card small {
  color: #7b8796;
  font-weight: 650;
}

.state-banner {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.state-banner.error {
  border-color: #ffd1cc;
  color: #ad2b2b;
  background: #fff1f0;
}

.properties-stack {
  display: grid;
  gap: 24px;
}

.property-panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
  scroll-margin-top: 112px;
}

.property-header,
.panel-heading,
.chart-metrics,
.source-line,
.chart-legend {
  display: flex;
  align-items: center;
}

.property-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.property-header h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.property-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.favorite-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: #98a2b3;
  background: #fff;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    transform 0.16s ease;
}

.favorite-button:hover {
  transform: translateY(-1px);
  border-color: #bad2f8;
  color: var(--blue);
}

.favorite-button.active {
  border-color: #f5d27b;
  color: #b7791f;
  background: #fff8e7;
}

.favorite-button.active svg {
  fill: currentColor;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--green);
  background: #eaf8ef;
  font-weight: 800;
  white-space: nowrap;
}

.property-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(340px, 0.8fr);
  gap: 18px;
  min-width: 0;
}

.chart-card,
.side-panel,
.queries-table {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  min-width: 0;
}

.chart-card {
  padding: 18px;
}

.chart-metrics {
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chart-metrics div {
  min-width: 150px;
}

.chart-metrics strong {
  display: block;
  margin-top: 5px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 650;
}

.chart-wrap {
  width: 100%;
  min-height: 350px;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.line-chart {
  width: 100%;
  max-width: 100%;
  height: 320px;
  overflow: visible;
}

.chart-grid line {
  stroke: #edf1f6;
}

.chart-grid text,
.chart-labels text {
  fill: #667085;
  font-size: 12px;
}

.x-label {
  text-anchor: middle;
}

.line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line.current {
  stroke: var(--blue);
  stroke-width: 4;
}

.line.previous {
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-dasharray: 8 8;
  opacity: 0.88;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.chart-hit:focus {
  outline: none;
}

.chart-dot {
  fill: var(--blue);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.chart-hit:hover + .chart-dot,
.chart-hit:focus + .chart-dot {
  opacity: 1;
}

.chart-tooltip {
  position: absolute;
  z-index: 20;
  min-width: 170px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 115, 232, 0.22);
  border-radius: 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(30, 42, 62, 0.14);
  font-size: 0.86rem;
  pointer-events: none;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip strong {
  font-size: 0.9rem;
}

.chart-tooltip span {
  color: var(--muted);
  font-weight: 700;
}

.chart-legend {
  gap: 18px;
  flex-wrap: wrap;
  color: #344054;
  font-weight: 700;
}

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

.chart-legend i {
  width: 28px;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
}

.chart-legend .legend-previous {
  height: 0;
  border-top: 4px dashed var(--blue);
  background: transparent;
}

.side-panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--green);
}

.panel-heading h3,
.panel-heading p {
  margin: 0;
}

.panel-heading h3 {
  color: var(--text);
  font-size: 1rem;
}

.panel-heading p {
  color: #344054;
  font-weight: 800;
}

.source-list {
  display: grid;
}

.source-row {
  padding: 11px 0;
  border-top: 1px solid var(--border);
}

.source-line {
  justify-content: space-between;
  gap: 12px;
  font-weight: 750;
}

.source-line strong {
  font-size: 1rem;
}

.bar-track {
  height: 3px;
  margin-top: 12px;
  border-radius: 999px;
  background: #e7eef8;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.queries-table {
  margin-top: 18px;
  overflow: hidden;
}

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

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

th,
td {
  padding: 15px 18px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  width: 48%;
  text-align: left;
  white-space: normal;
}

th {
  color: #5d6878;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-weight: 650;
}

tbody tr:nth-child(odd) {
  background: rgba(244, 247, 251, 0.72);
}

tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1100px) {
  .property-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: calc(100% - 24px);
    max-width: calc(100% - 24px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    position: static;
  }

  .topbar-actions,
  .domain-jump,
  .range-filter {
    width: 100%;
  }

  .range-filter button {
    flex: 1;
    padding: 0 8px;
    font-size: 0.82rem;
  }

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

  .property-panel {
    padding: 14px;
    border-radius: 18px;
  }

  .property-header,
  .chart-metrics {
    align-items: flex-start;
    flex-direction: column;
  }

  .property-header > div,
  .chart-metrics div {
    width: 100%;
    min-width: 0;
  }

  .chart-metrics strong {
    font-size: 1.6rem;
  }

  .line-chart {
    display: block;
    width: 100%;
    min-width: 0;
  }

  th,
  td {
    padding: 13px 12px;
  }
}
