:root {
  color-scheme: light;
  --navy: #102f5f;
  --blue: #2f72d6;
  --gold: #d8a63c;
  --ink: #172033;
  --muted: #6f7887;
  --line: #dfe5ee;
  --panel: #ffffff;
  --bg: #f4f7fb;
  --danger: #b83131;
  --success: #27805f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--navy);
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.muted,
.eyebrow {
  color: var(--muted);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button,
.ghost-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  text-align: left;
}

.nav-button {
  padding: 12px 14px;
  font-weight: 700;
}

.nav-button.is-active {
  background: #eaf1fb;
  color: var(--navy);
}

.screen-switcher {
  display: none;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.auth-summary {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--navy);
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  color: var(--navy);
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 800;
}

.panel,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.signed-out {
  max-width: 620px;
  min-height: 420px;
  display: grid;
  align-content: center;
  gap: 28px;
}

.auth-actions,
.email-form {
  display: grid;
  gap: 10px;
}

.auth-error {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #f0c8c8;
  border-radius: 8px;
  color: var(--danger);
  background: #fff0f0;
  font-weight: 800;
}

.email-form {
  grid-template-columns: 1fr 1fr auto;
}

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

.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 10px;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--navy);
  color: #ffffff;
}

.secondary-button {
  background: #eaf1fb;
  color: var(--navy);
}

.ghost-button {
  padding: 8px 0;
  font-weight: 700;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #e4c06d;
  background: #fff7df;
  color: #70521a;
  border-radius: 8px;
  font-weight: 700;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 18px;
}

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

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

.metric-card {
  padding: 16px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 28px;
  line-height: 1;
}

.metric-card.warning strong {
  color: var(--danger);
}

.two-column,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.chart-mode-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chart-controls,
.chart-custom-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-date-control input {
  width: 138px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  background: #ffffff;
}

.chart-date-control input[type="number"] {
  width: 96px;
}

#homeCountryDestinationSelect {
  min-width: 190px;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: #eaf1fb;
  border-radius: 8px;
}

.segment-button {
  border: 0;
  border-radius: 6px;
  min-height: 32px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment-button.is-active {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 1px 4px rgba(16, 47, 95, 0.12);
}

.diagnostic-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-chip strong {
  color: var(--navy);
}

.summary-chip.warning {
  border-color: #efd39a;
  background: #fff8e8;
  color: #7a5515;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

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

.list-row strong {
  color: var(--navy);
}

.search-input {
  min-width: 320px;
}

.search-stack {
  display: grid;
  gap: 5px;
}

.search-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.table-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: -2px 0 14px;
}

.column-menu {
  position: relative;
}

.column-menu summary {
  display: inline-flex;
  align-items: center;
  list-style: none;
}

.column-menu summary::-webkit-details-marker {
  display: none;
}

.column-menu-panel {
  position: absolute;
  z-index: 2;
  top: calc(100% + 6px);
  left: 0;
  width: 220px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(16, 47, 95, 0.14);
  display: grid;
  gap: 4px;
}

.column-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.column-toggle input {
  min-height: auto;
}

.column-menu-done {
  width: 100%;
  margin-top: 6px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  scrollbar-gutter: stable;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.table-header-tools {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.table-sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
}

.value-filter-menu {
  position: relative;
}

.value-filter-button {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--navy);
  font-size: 11px;
  font-weight: 800;
  list-style: none;
  text-transform: none;
}

.value-filter-button::-webkit-details-marker {
  display: none;
}

.value-filter-panel {
  position: absolute;
  z-index: 3;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  max-height: 330px;
  overflow: auto;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(16, 47, 95, 0.14);
  text-transform: none;
}

.value-filter-menu-right .value-filter-panel {
  left: auto;
  right: 0;
}

.value-filter-clear {
  width: 100%;
  padding: 0 0 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--navy);
}

.value-filter-options {
  display: grid;
  gap: 4px;
}

.value-filter-empty {
  padding: 8px 6px;
  text-transform: none;
}

.orders-table {
  table-layout: fixed;
  width: 2070px;
  min-width: 2070px;
}

.orders-table th,
.orders-table td {
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: keep-all !important;
}

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

.chart-panel-wide {
  grid-column: 1 / -1;
}

.bar-chart {
  min-height: 260px;
}

.vertical-chart {
  display: flex;
  align-items: end;
  gap: 10px;
  overflow-x: auto;
  padding-top: 8px;
  scrollbar-gutter: stable;
}

.bar-column {
  min-width: 58px;
  height: 240px;
  display: grid;
  grid-template-rows: 24px 1fr 34px;
  justify-items: center;
  gap: 8px;
}

.bar-value,
.bar-row-value {
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.bar-track {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}

.bar-fill {
  width: 32px;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: var(--blue);
}

.revenue-chart .bar-fill,
.bar-row-fill {
  background: var(--success);
}

.grouped-vertical-chart {
  display: grid;
  gap: 10px;
}

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

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--series-color, var(--blue));
}

.legend-dot-revenue,
.grouped-bar-revenue {
  --series-color: var(--success);
}

.legend-dot-profit,
.grouped-bar-profit {
  --series-color: var(--gold);
}

.legend-dot-size-1gb,
.grouped-bar-size-1gb {
  --series-color: #2f72d6;
}

.legend-dot-size-3gb,
.grouped-bar-size-3gb {
  --series-color: #6f55d9;
}

.legend-dot-size-5gb,
.grouped-bar-size-5gb {
  --series-color: #27805f;
}

.legend-dot-size-10gb,
.grouped-bar-size-10gb {
  --series-color: #d8a63c;
}

.legend-dot-size-20gb,
.grouped-bar-size-20gb {
  --series-color: #c76640;
}

.legend-dot-size-50gb,
.grouped-bar-size-50gb {
  --series-color: #102f5f;
}

.legend-dot-size-unknown,
.grouped-bar-size-unknown {
  --series-color: #6f7887;
}

.grouped-bars {
  display: flex;
  align-items: end;
  gap: 12px;
  overflow-x: auto;
  padding-top: 2px;
  scrollbar-gutter: stable;
}

.grouped-bar-column {
  min-width: 82px;
  height: 260px;
  display: grid;
  grid-template-rows: 42px 1fr 34px;
  justify-items: center;
  gap: 8px;
}

.grouped-bar-values {
  display: grid;
  gap: 2px;
  color: var(--navy);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.grouped-bar-column.no-value-labels {
  height: 240px;
  grid-template-rows: 1fr 34px;
}

.grouped-bar-track {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.grouped-bar-fill {
  width: 24px;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: var(--series-color, var(--blue));
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.horizontal-chart {
  display: grid;
  gap: 10px;
  align-content: start;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 180px) minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
}

.bar-row-label {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row-track {
  height: 16px;
  overflow: hidden;
  border-radius: 6px;
  background: #eaf1fb;
}

.bar-row-fill {
  height: 100%;
  min-width: 2px;
}

.bar-row-value {
  text-align: right;
}

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

.orders-col-purchased {
  width: 150px;
}

.orders-col-user {
  width: 145px;
}

.orders-col-email {
  width: 250px;
}

.orders-col-order {
  width: 180px;
}

.orders-col-country {
  width: 150px;
}

.orders-col-gb {
  width: 80px;
}

.orders-col-days {
  width: 80px;
}

.orders-col-plan {
  width: 310px;
}

.orders-col-status {
  width: 120px;
}

.orders-col-promo {
  width: 120px;
}

.orders-col-revenue,
.orders-col-commission {
  width: 125px;
}

.form-panel {
  align-self: start;
}

.form-panel,
.form-panel label {
  display: grid;
  gap: 8px;
}

.form-panel label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  min-height: auto;
}

.promo-list {
  display: grid;
  gap: 10px;
}

.promo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.promo-card-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.promo-card strong {
  color: var(--navy);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  background: #e9f6ef;
  color: var(--success);
}

.badge.off {
  background: #fbeaea;
  color: var(--danger);
}

.promo-actions {
  display: flex;
  gap: 8px;
}

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

  .sidebar {
    position: static;
    height: auto;
    gap: 16px;
  }

  .nav {
    display: none;
  }

  .screen-switcher {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .sidebar-footer {
    margin-top: 0;
  }

  .metric-grid,
  .two-column,
  .split-layout,
  .chart-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .email-form,
  .panel-header {
    display: grid;
    grid-template-columns: 1fr;
  }

  .chart-controls,
  .chart-custom-controls {
    justify-content: start;
  }

  #homeCountryDestinationSelect {
    width: 100%;
    min-width: 0;
  }

  .search-input {
    min-width: 0;
    width: 100%;
  }
}
