:root {
  color-scheme: dark;
  --bg: #0b1117;
  --panel: #121b24;
  --panel-2: #172331;
  --line: #263545;
  --text: #e8edf3;
  --muted: #93a4b5;
  --accent: #31c48d;
  --accent-2: #4ea1ff;
  --danger: #ef6a6a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button,
input {
  font: inherit;
}

.login-page,
.connect-page {
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.connect-shell {
  width: min(980px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
}

.login-panel,
.connect-hero,
.connect-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #193428;
  color: var(--accent);
  font-weight: 800;
}

.login-panel h1,
.connect-hero h1 {
  margin: 18px 0 8px;
  font-size: 28px;
}

.login-panel p,
.connect-hero p,
.topbar p,
.brand span,
.panel-head span,
small {
  color: var(--muted);
}

label {
  display: block;
  margin: 26px 0 8px;
  color: var(--muted);
}

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

button {
  width: 100%;
  height: 44px;
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #04130d;
  cursor: pointer;
  font-weight: 700;
}

.connect-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 360px;
}

.connect-hero h1 {
  max-width: 560px;
  font-size: 42px;
  line-height: 1.12;
}

.connect-panel {
  align-self: start;
}

.result {
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: #101922;
}

.result.success {
  border-color: #1d6248;
}

.result.error {
  border-color: #6e2f35;
}

.result span {
  color: var(--muted);
  font-size: 13px;
}

.result h2 {
  margin: 8px 0;
}

.bind-code,
code {
  display: block;
  padding: 12px;
  border-radius: 6px;
  background: #081018;
  color: var(--accent);
  font-family: Consolas, Monaco, monospace;
  overflow-wrap: anywhere;
}

.connect-success h2 {
  line-height: 1.25;
}

.next-steps {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.next-steps article {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #203244;
  border-radius: 8px;
  background: #0d151d;
}

.next-steps strong {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #123326;
  color: var(--accent);
}

.next-steps h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.next-steps p {
  margin: 0;
}

.telegram-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  background: var(--accent-2);
  color: #06121e;
  font-weight: 800;
}

.admin-connect-body {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.admin-connect-body form {
  padding: 16px;
  border: 1px solid #203244;
  border-radius: 8px;
  background: #101922;
}

.table-link {
  color: var(--accent-2);
}

.inline-code {
  display: inline-block;
  padding: 7px 10px;
  white-space: nowrap;
}

.form-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-note a {
  color: var(--accent-2);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.app-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #0d141b;
}

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

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

nav {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

nav a {
  padding: 11px 12px;
  border-radius: 6px;
  color: var(--muted);
}

nav a:hover {
  background: var(--panel-2);
  color: var(--text);
}

.content {
  padding: 26px;
  max-width: 1480px;
  width: 100%;
}

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

.topbar h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.topbar p {
  margin: 0;
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #123326;
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
}

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

.metric,
.panel,
.session-item,
.feed-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.metric strong {
  font-size: 30px;
}

.panel {
  margin-top: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid #1c2a37;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #101922;
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  padding: 16px;
}

.session-item {
  padding: 14px;
}

.session-item span {
  display: block;
  color: var(--accent-2);
  margin-top: 4px;
}

.session-item p,
.feed-item p {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.feed {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.feed.compact {
  gap: 8px;
}

.feed-item {
  padding: 14px;
}

.feed-item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.feed-item span {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  padding: 18px;
}

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

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

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

  .connect-shell {
    grid-template-columns: 1fr;
  }

  .admin-connect-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 16px;
  }

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

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