:root {
  --bg: #090a0f;
  --panel: #13171f;
  --panel-2: #1b202a;
  --line: #272f3d;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #60a5fa;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 16px 20px;
  border-radius: 12px;
}

.topbar h1 {
  font-size: 22px;
  color: #fff;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-back {
  margin: 16px 0;
}

.btn:hover {
  border-color: var(--blue);
  background: #232d3f;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-danger {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--red);
  color: #fff;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 6px;
  color: #fff;
}

.panel .sub {
  color: var(--muted);
  margin: 0 0 16px;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.strip .item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.strip .item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.strip .item b {
  display: block;
  font-size: 26px;
  margin-top: 4px;
  color: #fff;
}

.strip .item small {
  color: var(--muted);
  font-size: 12px;
}

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.cols .panel {
  margin-bottom: 0;
}

.head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
  letter-spacing: 0.025em;
}

.b-ok {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
}

.b-mid {
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
}

.b-low {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
}

.b-none {
  color: var(--muted);
  border-color: var(--line);
  background: var(--panel-2);
}

.meter {
  position: relative;
  height: 8px;
  background: var(--panel-2);
  border-radius: 99px;
  margin: 8px 0 6px;
  overflow: hidden;
}

.meter i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.meter u {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #fff;
  z-index: 2;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.f-ok {
  background: var(--green);
}
.f-mid {
  background: var(--amber);
}
.f-low {
  background: var(--red);
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 20px;
  margin: 14px 0;
  font-size: 13px;
}

.kv div {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 5px;
}

.kv span {
  color: var(--muted);
}

.up {
  color: var(--green);
  font-weight: 600;
}
.down {
  color: var(--red);
  font-weight: 600;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 12px;
  background: var(--panel-2);
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--line);
}

.chart .ct {
  stroke: var(--muted);
  stroke-dasharray: 4 4;
  stroke-width: 1;
  opacity: 0.5;
}

.chart .cl {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .cd {
  fill: var(--blue);
  stroke: #fff;
  stroke-width: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.01);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.01);
}

.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cell-bar {
  min-width: 130px;
}

.cell-bar .meter {
  margin: 4px 0 0;
  height: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter a {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  background: var(--panel-2);
}

.filter a.on {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

form.inline {
  display: inline;
}

.form-card {
  max-width: 760px;
  margin: 0 auto;
}

.row2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus,
.btn:focus-visible,
a:focus-visible {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.counter {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.counter b {
  color: var(--text);
}

.msg {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
}

.msg-ok {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
}

.msg-err {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth .panel {
  width: 100%;
  max-width: 380px;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.mode-section {
  display: none;
}

.mode-section.active {
  display: block;
}

.pick {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 6px;
  position: relative;
}

.pick input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

.pick.on {
  border-color: var(--blue);
  background: rgba(79, 140, 255, 0.1);
}

.pick.off {
  opacity: 0.4;
  cursor: not-allowed;
}

.rank {
  margin-left: auto;
  min-width: 20px;
  text-align: center;
  border-radius: 99px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.subgrid-all {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.pagination {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  align-items: center;
  justify-content: center;
}

.pagination a,
.pagination span {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
}

.pagination a:hover {
  border-color: var(--blue);
}

.pagination .active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: bold;
}
@media (max-width: 600px) {
  .kv {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .actions {
    width: 100%;
    justify-content: space-between;
  }
}
