:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #17201d;
  --muted: #61706b;
  --line: #d9dfd8;
  --accent: #166a5b;
  --accent-strong: #0f4d42;
  --warning: #b45129;
  --soft: #e9f2ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.login-panel,
.app {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgb(23 32 29 / 8%);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  align-items: center;
  min-height: 420px;
  margin-top: 8vh;
  padding: 48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

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

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fbfcfb;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(22 106 91 / 16%);
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

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

button.secondary {
  color: var(--accent-strong);
  background: var(--soft);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--warning);
  font-size: 14px;
}

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

.topbar h1 {
  font-size: 30px;
}

.userbox {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 28px 0;
  border-bottom: 1px solid var(--line);
}

.tab {
  color: var(--muted);
  background: transparent;
  border-radius: 6px 6px 0 0;
}

.tab:hover,
.tab.is-active {
  color: var(--accent-strong);
  background: var(--soft);
}

.tab-panel {
  padding: 28px;
}

#dashboardTab {
  display: flex;
  flex-direction: column;
}

#telegramParserBlock {
  order: 1;
}

#dashboardTab .rabbit-panel {
  order: 2;
}

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

.metric {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 30px;
}

.metric-warning {
  border-color: #e0b394;
  background: #fff9f5;
}

.metric-ok {
  border-color: #9ac7b8;
  background: #f5fbf8;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.service-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.dashboard-group {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f1;
}

.dashboard-heading h2 {
  margin-bottom: 0;
}

.status-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.status-panel h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

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

.status-heading h3 {
  margin: 0;
}

.badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: #eef1ef;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-ok {
  color: #0f5c45;
  background: #dff3eb;
}

.badge-warning {
  color: #934016;
  background: #ffe7d8;
}

.status-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.status-inline {
  gap: 14px;
}

.status-list div {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.status-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.status-inline .status-inline-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-inline .status-inline-row div {
  display: grid;
  gap: 4px;
  padding: 0;
  border: 0;
}

.metric-line {
  font-weight: 700;
}

.channels-list {
  margin: 0;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 8.2rem;
}

.status-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.stack-form {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.rabbit-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.rabbit-header h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.rabbit-header,
.rabbit-layout,
.chart-legend {
  display: flex;
  gap: 16px;
}

.rabbit-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.rabbit-header h2 {
  margin-bottom: 6px;
}

.range-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.range-button {
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.range-button:hover,
.range-button.is-active {
  color: #fff;
  background: var(--accent);
}

.rabbit-layout {
  align-items: stretch;
}

.chart-wrap {
  min-width: 0;
  flex: 1;
}

#rabbitChart {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.chart-legend {
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}

.legend-dot.publish {
  background: #166a5b;
}

.legend-dot.parsed {
  background: #9f4f24;
}

.queue-card {
  display: grid;
  align-content: center;
  min-width: 190px;
  padding: 20px;
  border: 1px solid #bfd1c9;
  border-radius: 8px;
  background: #f5fbf8;
}

.queue-card span,
.queue-card small,
.rabbit-status {
  color: var(--muted);
}

.queue-card span {
  font-size: 13px;
  font-weight: 800;
}

.queue-card strong {
  margin: 12px 0 4px;
  font-size: 46px;
  line-height: 1;
}

.queue-card small {
  overflow-wrap: anywhere;
}

.rabbit-status {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
}

.empty-state {
  min-height: 220px;
  padding: 28px;
  border: 1px dashed #b9c4bf;
  border-radius: 8px;
  background: #fbfcfb;
}

.empty-state p {
  color: var(--muted);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

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

tr:last-child td {
  border-bottom: 0;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 1120px);
    padding: 10px 0;
  }

  .login-panel {
    grid-template-columns: 1fr;
    margin-top: 0;
    padding: 24px;
  }

  .topbar,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .tabs {
    overflow-x: auto;
    padding-inline: 16px;
  }

  .tab-panel,
  .topbar {
    padding-inline: 16px;
  }

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

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

  .rabbit-header,
  .rabbit-layout {
    align-items: stretch;
    flex-direction: column;
  }

  .queue-card {
    min-width: 0;
  }

  .status-inline .status-inline-row {
    grid-template-columns: 1fr;
  }
}
