:root {
  color-scheme: dark;

  --mt-violet: #7c3aed;
  --mt-violet-600: #6d28d9;
  --mt-whatsminer: #ef4444;
  --mt-telegram: #229ed9;
  --mt-telegram-hover: #1b8ec4;

  --bg: #17191c;
  --panel: #23262e;
  --panel-soft: #1b1e24;
  --text: #c1c4c9;
  --text-strong: #ffffff;
  --muted: #878a92;
  --line: #343841;
  --line-strong: #454a55;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.18);
  --warn: #f59e0b;
  --code-bg: #101216;
  --code-text: #d9e7e4;
  --code-muted: #8ea09c;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.app-viewport {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 22px;
  background: rgba(23, 25, 28, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.brand-link:hover .brand-title {
  color: var(--accent);
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.logo svg {
  display: block;
}

.brand-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-link {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.topbar-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--mt-telegram);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}

.tg-btn:hover {
  background: var(--mt-telegram-hover);
}

.tg-btn svg {
  display: block;
}

.site-footer {
  padding: 16px 22px 20px;
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.footer-lead {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 20px;
  font-size: 13px;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-note {
  max-width: 760px;
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: 6px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  color: var(--text-strong);
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search {
  display: grid;
  gap: 6px;
}

.search span,
.model-filter label,
.compare-controls label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.search input,
.model-filter select,
.compare-controls select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.search input:focus,
.model-filter select:focus,
.compare-controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.tab {
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.tab.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(10, 20, 24, 0.12);
}

.model-filter {
  display: grid;
  gap: 6px;
}

.file-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.file-group {
  margin-bottom: 16px;
}

.file-group h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 6px;
  padding: 8px 2px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  margin-bottom: 4px;
  padding: 8px 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.file-item:hover {
  background: var(--panel-soft);
}

.file-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-name {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 650;
}

.file-sub {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.file-size {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 24px 4px;
  color: var(--muted);
  font-size: 14px;
}

.viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.details,
.stats,
.viewbar,
.power-insights {
  flex: none;
}

.code-pane {
  flex: 1 1 auto;
}

.details,
.stats,
.power-insights,
.viewbar {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.details {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
}

.file-heading {
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
}

.file-heading h2 {
  overflow-wrap: anywhere;
  margin: 8px 0 4px;
  color: var(--text-strong);
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.file-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
  gap: 8px;
}

.actions button {
  min-width: 92px;
  height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
}

.actions button:hover:not(:disabled) {
  border-color: var(--accent);
}

.actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.stats div {
  min-width: 0;
  padding: 12px 24px;
  background: var(--panel);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.stats strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.power-insights {
  min-width: 0;
  padding: 16px 24px;
}

.power-insights[hidden] {
  display: none;
}

.power-insights-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 520px);
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.power-insights h3 {
  margin: 8px 0 4px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.power-insights p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.psu-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 6px;
}

.psu-list-label {
  margin-right: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.psu-chip {
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.psu-chip.is-empty {
  color: var(--muted);
  font-family: inherit;
}

.power-subhead {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.power-settings-wrap {
  margin-bottom: 16px;
}

.column-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.column-notes-wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.column-note {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.column-note strong,
.column-note span {
  display: block;
}

.column-note strong {
  margin-bottom: 3px;
  font-size: 12px;
}

.column-note span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.power-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.power-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 12px;
}

.decoded-table {
  min-width: 760px;
}

.power-table th,
.power-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.power-table th {
  position: sticky;
  top: 0;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 750;
  text-transform: uppercase;
}

.power-table tr:last-child td {
  border-bottom: 0;
}

.compare-table tr.is-diff td,
.compare-table td.is-diff {
  background: rgba(124, 58, 237, 0.14);
}

.compare-table .cmp-missing {
  color: var(--muted);
}

.viewbar {
  display: flex;
  align-items: end;
  gap: 16px;
  padding: 14px 24px;
}

.view-controls {
  display: grid;
  gap: 6px;
}

.view-controls > span,
.compare-controls label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.view-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 4px;
  height: 38px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.view-toggle button.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(10, 20, 24, 0.12);
}

.view-toggle button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.compare-controls {
  display: grid;
  width: min(420px, 100%);
  gap: 6px;
}

.compare-hint {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 9px;
}

.code-pane {
  min-height: 360px;
  overflow: auto;
  background: var(--code-bg);
}

.code-pane[hidden] {
  display: none;
}

.code-pane pre {
  min-height: 100%;
  margin: 0;
  padding: 20px 24px 40px;
}

.code-pane code {
  color: var(--code-text);
  font: 13px/1.55 "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.code-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  min-height: 100%;
  background: var(--line);
}

.code-column {
  min-width: 0;
  background: var(--code-bg);
}

.code-column header {
  position: sticky;
  top: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--code-muted);
  font-size: 12px;
  font-weight: 700;
}

.code-column pre {
  padding: 16px 14px 40px;
}

.mark-option {
  color: #7dd6c8;
}

.mark-config {
  color: #f6d365;
}

.mark-value {
  color: #f2a7a7;
}

@media (max-width: 860px) {
  .app-viewport {
    height: auto;
    overflow: visible;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    flex: none;
    min-height: 0;
    height: auto;
  }

  .sidebar {
    grid-template-rows: auto auto auto auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .file-list {
    max-height: 55vh;
  }

  .viewer {
    min-height: 620px;
  }

  .details,
  .viewbar {
    display: grid;
  }

  .actions {
    justify-content: start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats div {
    padding: 12px 16px;
  }

  .code-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 10px 14px;
  }

  .topbar-link {
    display: none;
  }

  .tg-btn .tg-btn-label {
    display: none;
  }
}

@media (max-width: 340px) {
  .brand-title {
    display: none;
  }
}

@media (max-width: 520px) {
  .sidebar,
  .details,
  .viewbar {
    padding: 14px;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .power-insights {
    padding: 14px;
  }

  .power-insights-head,
  .column-notes,
  .column-notes-wide {
    grid-template-columns: 1fr;
  }

  .file-heading h2 {
    font-size: 18px;
  }
}
