:root {
  --bg: #090d0c;
  --surface: #111816;
  --surface-2: #17211e;
  --line: #25332f;
  --text: #edf7f2;
  --muted: #8da39a;
  --accent: #35e58b;
  --accent-soft: rgba(53, 229, 139, 0.12);
  --warning: #f3bd57;
  --danger: #ff7474;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: radial-gradient(circle at 70% 0%, #14231e 0, var(--bg) 36%); min-height: 100vh; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; display: flex; flex-direction: column; padding: 28px 20px; background: rgba(12, 18, 16, 0.96); border-right: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; margin-bottom: 42px; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 3px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent); color: #062314; font-weight: 900; letter-spacing: -1px; box-shadow: 0 0 32px rgba(53, 229, 139, .18); }
.brand-mark.large { width: 58px; height: 58px; border-radius: 16px; margin-bottom: 24px; }
nav { display: grid; gap: 7px; }
nav a { color: var(--muted); text-decoration: none; padding: 12px 14px; border-radius: 9px; font-weight: 650; }
nav a:hover, nav a.active { color: var(--text); background: var(--surface-2); }
.logout-form { margin-top: auto; display: grid; gap: 12px; }
.user-label { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.main-content { margin-left: 260px; padding: 48px clamp(28px, 5vw, 72px); max-width: 1500px; }
.auth-main { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 430px); padding: 40px; border: 1px solid var(--line); border-radius: 22px; background: rgba(17, 24, 22, .94); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.045em; margin-bottom: 12px; }
h2 { letter-spacing: -.025em; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .13em; font-size: .72rem; font-weight: 800; margin-bottom: 9px; }
.muted { color: var(--muted); line-height: 1.6; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.pill { display: inline-flex; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .82rem; font-weight: 750; white-space: nowrap; }
.pill.safe { color: var(--accent); border-color: rgba(53, 229, 139, .35); background: var(--accent-soft); }
.pill.pending { color: var(--warning); border-color: rgba(243, 189, 87, .35); background: rgba(243, 189, 87, .09); }
.pill.danger { color: #ffdada; border-color: rgba(255, 116, 116, .4); background: rgba(255, 116, 116, .1); }
.hero-panel, .panel, .metric-card, .link-grid a, .empty-state { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(23, 33, 30, .95), rgba(13, 19, 17, .95)); border-radius: 16px; }
.hero-panel { display: grid; grid-template-columns: 1.5fr 1fr; gap: 30px; padding: 32px; margin-bottom: 20px; }
.hero-panel p { color: var(--muted); line-height: 1.6; }
.notice { padding: 16px; border-radius: 10px; background: rgba(255,255,255,.035); color: var(--muted); align-self: center; line-height: 1.5; }
.notice strong { color: var(--text); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 42px; }
.metric-card { padding: 20px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; color: var(--accent); font-size: 1.3rem; margin: 9px 0; overflow-wrap: anywhere; }
.section-heading { margin-bottom: 16px; }
.link-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.link-grid a { display: grid; gap: 8px; padding: 22px; text-decoration: none; transition: transform .15s ease, border-color .15s ease; }
.link-grid a:hover { transform: translateY(-2px); border-color: rgba(53, 229, 139, .45); }
.link-grid span { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.panel { padding: 26px; margin-bottom: 18px; }
.stack { display: grid; }
.status-row { display: flex; justify-content: space-between; gap: 30px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.status-row:last-child { border-bottom: 0; }
.status-row span { color: var(--muted); }
.path { display: block; overflow-wrap: anywhere; padding: 14px; margin-bottom: 14px; border-radius: 8px; background: #090d0c; color: var(--accent); }
.empty-state { text-align: center; padding: 70px 28px; color: var(--muted); }
.empty-state h1, .empty-state h2 { color: var(--text); }
.empty-state.compact { border: 0; background: transparent; padding: 50px 20px; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 900; }
.stack-form { display: grid; gap: 10px; }
.stack-form label { margin-top: 8px; color: var(--muted); font-size: .88rem; font-weight: 700; }
input, textarea, select { width: 100%; padding: 13px 14px; color: var(--text); background: #0a0f0d; border: 1px solid var(--line); border-radius: 9px; outline: none; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, textarea:disabled, select:disabled { opacity: .62; cursor: not-allowed; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 800; cursor: pointer; text-decoration: none; }
.button.primary { color: #062314; background: var(--accent); margin-top: 12px; }
.button.ghost { color: var(--text); background: transparent; border-color: var(--line); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.alert { padding: 13px 14px; border-radius: 9px; margin: 18px 0; }
.alert.error { color: #ffdada; background: rgba(255, 116, 116, .1); border: 1px solid rgba(255, 116, 116, .25); }
.alert.success { color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(53, 229, 139, .25); }
.alert.warning { color: var(--warning); background: rgba(243, 189, 87, .09); border: 1px solid rgba(243, 189, 87, .25); }
.alert.test-alert { color: #ffdada; background: rgba(255, 116, 116, .08); border: 1px solid rgba(255, 116, 116, .28); }
.alert.danger-alert { color: #fff; background: rgba(255, 116, 116, .18); border: 1px solid rgba(255, 116, 116, .55); font-size: 1.08rem; }
.alert ul { margin: 10px 0 0; padding-left: 20px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.toolbar p { margin: 6px 0 0; }
.button.compact { min-height: 36px; margin: 0; padding: 7px 11px; }
.button.danger { color: #ffdada; background: rgba(255, 116, 116, .08); border-color: rgba(255, 116, 116, .28); }
.button.test { color: #fff; background: #b93636; border-color: #e16666; }
.qr-panel { text-align: center; }
.qr-panel img { display: block; width: min(100%, 320px); margin: 20px auto 0; border: 12px solid white; border-radius: 10px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
fieldset { min-width: 0; margin: 12px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 8px; color: var(--muted); font-size: .88rem; font-weight: 750; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.group-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice { display: flex; align-items: flex-start; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(0, 0, 0, .12); cursor: pointer; }
.choice input { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
.choice span, .choice strong, .choice small { display: block; min-width: 0; overflow-wrap: anywhere; }
.choice small { margin-top: 4px; color: var(--muted); }
.message-list { display: grid; gap: 16px; }
.message-card { margin: 0; }
.message-card-header, .message-actions, .badge-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.badge-row, .message-actions { flex-wrap: wrap; justify-content: flex-end; }
.message-preview { max-width: 850px; margin: 18px 0; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.message-meta { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.message-meta strong, .message-meta span { display: block; }
.message-meta span { margin-top: 5px; color: var(--muted); line-height: 1.5; }
.message-actions { margin-top: 18px; }
.filter-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) auto auto; align-items: end; gap: 12px; }
.group-search-form { grid-template-columns: minmax(260px, 1fr) auto auto; }
.filter-form label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .82rem; font-weight: 750; }
.result-code { max-width: min(100%, 760px); color: var(--accent); white-space: normal; overflow-wrap: anywhere; text-align: right; }
.telegram-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.telegram-heading h2 { margin-bottom: 0; }
.operational-lock { margin-bottom: 20px; }
.status-row.vertical { display: block; }
.status-row.vertical > span { display: block; margin-bottom: 12px; }
.confirmation-message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.confirmation-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

@media (max-width: 980px) {
  .sidebar { position: static; width: auto; min-height: auto; }
  .sidebar nav { grid-template-columns: repeat(5, minmax(max-content, 1fr)); overflow-x: auto; }
  .brand { margin-bottom: 20px; }
  .logout-form { margin-top: 20px; grid-template-columns: 1fr auto; align-items: center; }
  .main-content { margin-left: 0; }
  .metric-grid, .link-grid, .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .main-content { padding: 30px 18px; }
  .page-header, .status-row, .toolbar, .message-card-header, .telegram-heading { flex-direction: column; align-items: stretch; }
  .hero-panel, .metric-grid, .link-grid, .field-grid, .choice-grid, .message-meta, .filter-form { grid-template-columns: 1fr; }
  .badge-row, .message-actions { justify-content: flex-start; }
  .result-code { text-align: left; }
  .login-card { padding: 28px 22px; }
}
