:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #687480;
  --line: #dbe4e8;
  --soft: #eef4f5;
  --green: #12805c;
  --blue: #1f6feb;
  --amber: #b7791f;
  --red: #c2413b;
  --teal: #0f766e;
  --shadow: 0 14px 34px rgba(31, 48, 64, 0.08);
}

* {
  box-sizing: border-box;
}

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

body.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #10202b;
  color: #eef6f7;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f7c948;
  color: #132530;
  font-weight: 800;
}

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

.brand small,
.sidebar-footer a {
  color: #a9c0c8;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a,
.sidebar-footer a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav-list a:hover,
.sidebar-footer a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 4px;
  font-size: 14px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.global-search {
  width: min(460px, 100%);
}

.global-search label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.global-search div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.filterbar label {
  min-width: 180px;
}

input,
button {
  min-height: 42px;
  border-radius: 8px;
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 13px;
}

select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  font: inherit;
}

button,
.link-button {
  border: 0;
  background: #10202b;
  color: #fff;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.alert {
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #fff4f2;
  border: 1px solid #f0b8af;
  color: #8f231d;
}

.alert span {
  display: block;
  margin-top: 4px;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-brand {
  margin-bottom: 24px;
  color: var(--ink);
}

.login-card h1 {
  margin-bottom: 18px;
  font-size: 28px;
}

.login-card form {
  display: grid;
  gap: 14px;
}

.login-card label span,
.filterbar label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

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

.kpi-card {
  min-height: 136px;
  padding: 16px;
  display: grid;
  align-content: space-between;
  border-top: 4px solid var(--teal);
}

.kpi-card span,
.metric-row span,
.task-row span,
.result-row span {
  color: var(--muted);
}

.kpi-card strong {
  font-size: clamp(21px, 2vw, 30px);
  line-height: 1;
}

.kpi-card small {
  color: #52606d;
  font-weight: 800;
}

.kpi-card.money { border-top-color: var(--green); }
.kpi-card.orders { border-top-color: var(--blue); }
.kpi-card.warning { border-top-color: var(--amber); }
.kpi-card.products { border-top-color: var(--teal); }
.kpi-card.users { border-top-color: #6d5bd0; }
.kpi-card.support { border-top-color: var(--red); }

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

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-wide {
  min-height: 320px;
}

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

.refresh-note,
.empty {
  color: var(--muted);
  font-size: 13px;
}

.chart-wrap {
  height: 260px;
}

.chart-wrap.compact {
  height: 210px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

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

.service-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.service-row strong,
.service-row small {
  display: block;
}

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

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--red);
}

.status-dot.ok {
  background: var(--green);
}

.signal {
  padding: 13px;
  border-radius: 8px;
  border-left: 4px solid var(--teal);
  background: var(--soft);
}

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

.signal span {
  margin-top: 4px;
  color: var(--muted);
}

.signal.warning { border-left-color: var(--amber); }
.signal.danger { border-left-color: var(--red); }
.signal.success { border-left-color: var(--green); }

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

.result-row,
.task-row,
.metric-row {
  display: grid;
  gap: 4px;
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
  background: var(--soft);
}

.task-row strong,
.metric-row strong,
.result-row strong {
  font-size: 17px;
}

.task-row small,
.metric-row small {
  color: var(--muted);
}

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

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td:first-child {
  min-width: 220px;
  white-space: normal;
  overflow-wrap: anywhere;
}

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

td a {
  color: var(--blue);
  font-weight: 800;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: #31414f;
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  background: #e3f6ed;
  color: #0d6848;
}

.badge.warning {
  background: #fff4d9;
  color: #8a5b00;
}

.badge.danger {
  background: #ffe3df;
  color: #9e2a23;
}

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

.attention-grid a {
  min-height: 94px;
  display: grid;
  align-content: space-between;
  padding: 14px;
  border-radius: 8px;
  background: var(--soft);
}

.attention-grid span {
  color: var(--muted);
}

.attention-grid strong {
  font-size: 26px;
}

@media (max-width: 1240px) {
  .kpi-grid,
  .content-grid.equal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

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

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

  .kpi-grid,
  .content-grid.equal,
  .search-grid,
  .attention-grid {
    grid-template-columns: 1fr;
  }

  .global-search div {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 26px;
  }
}
