:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e1e8;
  --brand: #1f7a6b;
  --brand-strong: #155e54;
  --blue: #2f6fed;
  --amber: #b7791f;
  --red: #c2413b;
  --green: #2f855a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 760;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
}

#meta {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  height: 36px;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

button {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  font-weight: 680;
  cursor: pointer;
}

.logout-link {
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #4a5564;
  color: #fff;
  padding: 0 14px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
}

.logout-link:hover {
  background: #303946;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.auth-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-panel input,
.auth-panel button {
  width: 100%;
}

#authError {
  min-height: 18px;
  color: var(--red);
  font-size: 12px;
}

.alerts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.alert {
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  padding: 12px 13px;
}

.alert strong {
  display: block;
  font-size: 14px;
  margin-bottom: 5px;
}

.alert span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.alert.warning {
  border-left-color: var(--amber);
}

.alert.critical {
  border-left-color: var(--red);
}

.alert.ok {
  border-left-color: var(--green);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

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

.kpi {
  padding: 14px;
  min-height: 92px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
}

.kpi em {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.kpi em.up {
  color: var(--green);
}

.kpi em.down {
  color: var(--red);
}

.totals-panel {
  margin-bottom: 12px;
}

.panel-note {
  color: var(--muted);
  font-size: 12px;
}

.totals {
  display: grid;
  grid-template-columns: repeat(8, minmax(118px, 1fr));
  gap: 8px;
}

.total-item {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.total-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.total-item strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.total-item.rooms {
  border-left: 3px solid var(--brand);
}

.total-item.matchmaking {
  border-left: 3px solid var(--blue);
}

.total-item.economy,
.total-item.shop {
  border-left: 3px solid var(--amber);
}

.total-item.social,
.total-item.share {
  border-left: 3px solid var(--green);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  padding: 14px;
}

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

.trend-panel canvas {
  width: 100%;
  height: 320px;
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.report {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.report-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #eef3f6;
  color: #43515f;
  font-weight: 700;
}

td:last-child,
th:last-child {
  text-align: right;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pager button {
  width: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

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

  .grid,
  .kpis {
    grid-template-columns: 1fr 1fr;
  }

  .totals {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 16px;
  }

  .filters,
  .filters label,
  .filters button {
    width: 100%;
  }

  input,
  select {
    width: 100%;
  }

  .grid,
  .kpis,
  .totals,
  .alerts {
    grid-template-columns: 1fr;
  }
}
