:root {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --surface-soft: #edf2f9;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe6f0;
  --blue: #2f5fd0;
  --blue-soft: #e8eefc;
  --cyan: #2f8ab7;
  --coral: #c0697a;
  --gold: #b88a2d;
  --violet: #6e63a6;
  --shadow: 0 18px 48px rgba(28, 42, 68, 0.08);
  --shadow-soft: 0 6px 18px rgba(28, 42, 68, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(47, 95, 208, 0.09), transparent 34rem),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 34rem);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px clamp(18px, 4vw, 54px) 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 252, 255, 0.82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
}

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

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(78px, 1fr));
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-solid);
  box-shadow: var(--shadow-soft);
}

.range-button {
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  min-height: 40px;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
}

.range-button:last-child {
  border-right: 0;
}

.range-button.active {
  background: var(--blue);
  color: white;
}

.date-input {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.date-input input,
#tableSearch {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.date-input input:focus,
#tableSearch:focus {
  border-color: rgba(47, 95, 208, 0.55);
  outline: 3px solid rgba(47, 95, 208, 0.12);
}

.primary-button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--blue), #244bb2);
  color: white;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(47, 95, 208, 0.22);
}

.ghost-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.ghost-button:hover {
  border-color: rgba(47, 95, 208, 0.36);
  color: var(--blue);
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at top left, rgba(47, 95, 208, 0.16), transparent 32rem),
    rgba(245, 247, 251, 0.86);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 28px 70px rgba(28, 42, 68, 0.16);
}

.auth-card h2 {
  font-size: 28px;
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-card input {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--surface-solid);
  color: var(--ink);
  font-size: 20px;
  letter-spacing: 0.12em;
}

.auth-card input:focus {
  border-color: rgba(47, 95, 208, 0.55);
  outline: 3px solid rgba(47, 95, 208, 0.12);
}

.auth-error {
  border: 1px solid rgba(198, 95, 70, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(198, 95, 70, 0.1);
  color: #833928;
  font-size: 13px;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 3vw, 42px) 42px;
}

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

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface-solid);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow-soft);
}

.status-pill.ok {
  border-color: rgba(47, 95, 208, 0.3);
  background: rgba(47, 95, 208, 0.09);
  color: var(--blue);
}

.status-pill.bad {
  border-color: rgba(198, 95, 70, 0.35);
  background: rgba(198, 95, 70, 0.1);
  color: var(--coral);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.error-banner {
  border: 1px solid rgba(198, 95, 70, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: rgba(198, 95, 70, 0.1);
  color: #833928;
}

.hidden {
  display: none;
}

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

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.kpi {
  min-height: 122px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 16px;
}

.kpi span,
.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  display: block;
  min-width: 0;
  font-size: clamp(19px, 2vw, 27px);
  line-height: 1.05;
  overflow-wrap: anywhere;
  color: #111b2f;
}

.kpi small {
  color: var(--muted);
}

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

.panel {
  grid-column: span 4;
  min-width: 0;
  padding: 18px;
}

.panel-wide {
  grid-column: span 8;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-box {
  position: relative;
  height: 300px;
}

.chart-box.tall {
  height: 342px;
}

.insights {
  display: grid;
  gap: 10px;
}

.metric-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
}

.metric-line:last-child {
  border-bottom: 0;
}

.metric-line span {
  color: var(--muted);
}

.metric-line strong {
  text-align: right;
}

.flow {
  display: grid;
  grid-template-columns: 0.8fr 1.3fr 1.1fr;
  gap: 14px;
  min-height: 310px;
}

.flow-column {
  display: grid;
  align-content: start;
  gap: 9px;
}

.flow-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.flow-node {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  background: var(--surface-soft);
}

.flow-node.total {
  min-height: 88px;
  display: grid;
  align-content: center;
  background: var(--blue-soft);
  border-color: rgba(47, 95, 208, 0.25);
}

.flow-node strong,
.flow-node span {
  display: block;
}

.flow-node span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.flow-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(47, 95, 208, 0.13);
  overflow: hidden;
  margin-top: 8px;
}

.flow-bar i {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--blue);
}

.leaderboard,
.item-list {
  display: grid;
  gap: 9px;
  max-height: 360px;
  overflow: auto;
  padding-right: 3px;
}

.rank-row,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 4px 0 11px;
}

.rank-row:last-child,
.item-row:last-child {
  border-bottom: 0;
}

.rank-row strong,
.item-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row span,
.item-row span {
  color: var(--muted);
  font-size: 12px;
}

.category-chip {
  display: inline-block;
  border: 1px solid var(--chip-border, rgba(49, 81, 143, 0.28));
  border-radius: 999px;
  padding: 1px 7px;
  background: var(--chip-bg, var(--blue-soft));
  color: var(--chip-color, #31518f);
  font-size: 11px;
  font-weight: 700;
}

.amount {
  font-weight: 800;
  text-align: right;
  color: #1f3f8c;
}

.table-head {
  align-items: center;
}

#tableSearch {
  width: min(340px, 100%);
}

.table-wrap {
  max-height: 470px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.66);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td.num {
  text-align: right;
  white-space: nowrap;
}

.category-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--badge-bg, var(--blue-soft));
  color: var(--badge-color, #31518f);
  border: 1px solid var(--badge-border, rgba(49, 81, 143, 0.28));
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .controls {
    justify-content: start;
  }

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

  .panel,
  .panel-wide {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
  }

  .controls,
  .segmented {
    width: 100%;
  }

  .date-input {
    width: calc(50% - 5px);
  }

  .primary-button {
    width: 100%;
  }

  .status-row,
  .panel-head,
  .table-head {
    align-items: start;
    flex-direction: column;
  }

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

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

  .chart-box,
  .chart-box.tall {
    height: 280px;
  }

  th:nth-child(2),
  td:nth-child(2),
  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(6),
  td:nth-child(6) {
    display: none;
  }
}
