@font-face { font-family: Inter; src: url('/static/vendor/inter/Inter-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url('/static/vendor/inter/Inter-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url('/static/vendor/inter/Inter-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: Inter; src: url('/static/vendor/inter/Inter-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --brand-navy: #031239;
  --brand-navy-alt: #071a45;
  --brand-blue: #016afd;
  --brand-sky: #0399fc;
  --brand-teal: #03d8df;
  --brand-white: #fff;
  --brand-surface: #f7f9fc;
  --brand-muted: #667085;
  --border: #d8dee9;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --sidebar-width: 264px;
  --bs-font-sans-serif: Inter, system-ui, sans-serif;
  --bs-body-color: var(--brand-navy);
  --bs-body-bg: var(--brand-surface);
  --bs-primary: var(--brand-blue);
  --bs-primary-rgb: 1, 106, 253;
  --bs-border-radius: 6px;
}

* { letter-spacing: 0; }
body { margin: 0; min-height: 100vh; background: var(--brand-surface); color: var(--brand-navy); font: 14px/1.45 Inter, system-ui, sans-serif; }
a { color: #005bd7; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
code { color: #344054; white-space: pre-wrap; overflow-wrap: anywhere; }

.admin-sidebar { --bs-offcanvas-width: var(--sidebar-width); --bs-offcanvas-bg: var(--brand-navy); --bs-offcanvas-color: #fff; width: var(--sidebar-width); height: 100dvh; background-color: var(--brand-navy) !important; color: #fff; border: 0; }
.sidebar-body { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 18px 14px 14px; overflow: hidden; background-color: var(--brand-navy); }
.brand-link { flex: 0 0 auto; display: block; padding: 4px 10px 22px; }
.brand-link img { display: block; width: 190px; height: auto; }
.sidebar-nav { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; min-height: 0; padding-right: 4px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; -ms-overflow-style: none; }
.sidebar-nav::-webkit-scrollbar { display: none; width: 0; height: 0; }
.nav-section { margin: 18px 10px 5px; color: #8ea2ca; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.nav-entry { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 8px 10px; border-radius: 6px; color: #dce6fb; font-weight: 500; text-decoration: none; }
.nav-entry:hover { background: #102858; color: #fff; text-decoration: none; }
.nav-entry.active { background: var(--brand-blue); color: #fff; }
.nav-entry img, .sidebar-logout img { width: 18px; height: 18px; filter: brightness(0) invert(1); opacity: .9; }
.sidebar-account { flex: 0 0 auto; margin-top: 12px; padding: 14px 10px 2px; border-top: 1px solid #1f3561; }
.sidebar-account > a { display: block; margin-bottom: 10px; color: #fff; overflow-wrap: anywhere; }
.sidebar-account form { margin: 0; }
.sidebar-logout { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: transparent; color: #bdcbed; }
.admin-workspace { min-height: 100vh; }
.content { width: min(1460px, 100%); margin: 0 auto; padding: 26px 30px 48px; }

.mobile-header { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 14px; height: 58px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: #fff; }
.mobile-logo { width: 154px; height: auto; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.icon-button img { width: 20px; height: 20px; }

.application-status { position: sticky; top: 0; z-index: 1010; border-bottom: 1px solid; background: #fff; }
.application-status > summary { display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 9px 30px; cursor: pointer; font-weight: 600; list-style: none; }
.application-status > summary::-webkit-details-marker { display: none; }
.application-status-ok { border-color: #abefc6; background: #ecfdf3; color: var(--success); }
.application-status-warning { border-color: #fedf89; background: #fffaeb; color: var(--warning); }
.application-status-danger { border-color: #fecdca; background: #fef3f2; color: var(--danger); }
.status-indicator { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status-indicator-warning { color: var(--warning); }
.status-indicator-danger { color: var(--danger); }
.status-issues { display: grid; gap: 7px; padding: 0 30px 12px 48px; }
.status-issues a { display: flex; align-items: center; gap: 9px; color: inherit; font-weight: 500; }

.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; line-height: 1.25; font-weight: 700; }
h2 { font-size: 19px; line-height: 1.35; font-weight: 650; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 650; }
.page-head p, .table-summary, .text-muted { color: var(--brand-muted) !important; }
.section { margin-top: 28px; }
.section + .section { padding-top: 4px; }
.narrow { max-width: 560px; }

.user-history-tabs { margin-bottom: 0; border-color: var(--border); }
.user-history-tabs .nav-link { color: #475467; font-weight: 600; }
.user-history-tabs .nav-link.active { color: var(--brand-navy); }
.telegram-history { position: relative; border: 1px solid var(--border); border-top: 0; background: #dfe5e8; }
.telegram-history-loading { position: absolute; z-index: 2; top: 12px; left: 50%; translate: -50% 0; padding: 6px 10px; border: 1px solid #cbd5dc; border-radius: 6px; background: #fff; color: var(--brand-muted); box-shadow: 0 2px 8px rgba(3, 18, 57, .08); }
.telegram-dialog { height: clamp(420px, 66vh, 680px); padding: 18px max(14px, 5%); overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.telegram-date-separator, .telegram-action, .telegram-history-error { width: fit-content; max-width: 90%; margin: 10px auto; padding: 5px 9px; border-radius: 6px; background: rgba(255, 255, 255, .9); color: #475467; font-size: 12px; text-align: center; box-shadow: 0 1px 2px rgba(3, 18, 57, .08); }
.telegram-action.is-failed, .telegram-history-error { border: 1px solid #fecdca; background: #fef3f2; color: var(--danger); }
.telegram-message-row { display: flex; margin: 7px 0; }
.telegram-message-row.is-user { justify-content: flex-end; }
.telegram-message-row.is-bot { justify-content: flex-start; }
.telegram-message { width: fit-content; max-width: min(76%, 720px); padding: 8px 11px 6px; border: 1px solid #cbd5dc; border-radius: 6px; background: #fff; box-shadow: 0 1px 2px rgba(3, 18, 57, .08); overflow-wrap: anywhere; }
.telegram-message-row.is-user .telegram-message { border-color: #b7d9b2; background: #dff4dc; }
.telegram-message.is-failed { border-color: #fda29b; background: #fef3f2; }
.telegram-message-author { margin-bottom: 3px; color: #475467; font-size: 12px; font-weight: 700; }
.telegram-message-text { white-space: pre-wrap; }
.telegram-message-action { color: #344054; font-style: italic; }
.telegram-message-file { margin-bottom: 4px; font-weight: 600; }
.telegram-message-buttons { display: grid; gap: 4px; margin-top: 8px; }
.telegram-message-button { min-height: 30px; padding: 5px 8px; border: 1px solid #b8c1cf; border-radius: 4px; background: #f8fafc; color: #005bd7; text-align: center; }
.telegram-message-meta { margin-top: 4px; color: #667085; font-size: 11px; text-align: right; }
.telegram-empty { padding: 48px 16px; color: #475467; text-align: center; }

@media (max-width: 575.98px) {
  .telegram-dialog { height: 62vh; padding-inline: 10px; }
  .telegram-message { max-width: 88%; }
  .user-history-tabs .nav-link { flex: 1 1 0; padding-inline: 8px; text-align: center; }
}

.metrics { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 12px; margin-bottom: 28px; }
.metrics article { min-height: 92px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.metrics strong { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.metrics span { color: var(--brand-muted); }

.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 14px 0 18px; border-top: 1px solid var(--border); }
.filters label { min-width: 170px; }
.filter-field { display: grid; gap: 5px; min-width: 210px; }
.filter-label { color: #475467; font-weight: 600; }
.tag-filter-toggle { width: 100%; max-width: 280px; display: flex; align-items: center; justify-content: space-between; }
.tag-filter-toggle [data-tag-filter-label] { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-filter-menu { width: min(300px, calc(100vw - 32px)); max-height: 320px; overflow-y: auto; }
.tag-filter-option { min-width: 0 !important; display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 4px; color: var(--brand-navy); font-weight: 500; white-space: normal; }
.tag-filter-option .form-check-input { flex: 0 0 auto; min-height: auto; margin: 0; }
.tag-filter-clear { padding-inline: 8px; text-decoration: none; }
.create-row { padding: 16px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
label { display: grid; gap: 5px; color: #475467; font-weight: 600; }
.form-control, .form-select { min-height: 38px; border-color: #b8c1cf; color: var(--brand-navy); }
.form-control:focus, .form-select:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 .2rem rgba(1, 106, 253, .16); }
textarea.form-control { min-height: 140px; resize: vertical; }
.btn { min-height: 38px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--brand-blue); --bs-btn-border-color: var(--brand-blue); --bs-btn-hover-bg: #0058d4; --bs-btn-hover-border-color: #0058d4; }
.btn-danger { --bs-btn-bg: var(--danger); --bs-btn-border-color: var(--danger); }
.button { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 10px; border: 1px solid #b8c1cf; border-radius: 5px; background: #fff; color: var(--brand-navy); text-decoration: none; }
.check-row { display: flex; align-items: flex-start; gap: 8px; color: var(--brand-navy); }
.check-row .form-check-input { min-height: auto; margin-top: 3px; }
.field-help { margin: 0; color: var(--brand-muted); font-size: 12px; font-weight: 400; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 11px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #eef3fa; color: #344054; font-size: 12px; text-transform: uppercase; }
.group-row th { background: #e3eaf5; color: var(--brand-navy); text-transform: none; }
tbody tr:last-child td { border-bottom: 0; }
.server-table { min-width: 1240px; table-layout: fixed; }
.server-table .server-column { width: 16%; }
.server-table .roles-column { width: 18%; }
.server-table .state-column { width: 8%; }
.server-table .versions-column { width: 14%; }
.server-table .load-column { width: 32%; }
.server-table .heartbeat-column { width: 12%; }
.server-name { display: block; margin-bottom: 4px; font-size: 15px; }
.server-id { display: block; color: #475467; font-size: 12px; overflow-wrap: anywhere; }
.server-role-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.server-role { min-width: 0; }
.server-role .status { display: block; width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.role-heartbeat { display: block; margin-top: 3px; color: var(--brand-muted); font-size: 11px; }
.role-error { display: block; margin-top: 3px; color: var(--danger); font-size: 11px; overflow-wrap: anywhere; }
.server-version-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; margin: 0; }
.server-version-list dt { margin-top: 7px; color: var(--brand-muted); font-size: 12px; font-weight: 500; }
.server-version-list dt:first-child { margin-top: 0; }
.server-version-list dd { min-width: 0; margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.server-load-list { display: grid; gap: 9px; }
.server-load-item { min-width: 0; }
.server-load-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; color: #475467; font-size: 12px; font-weight: 600; }
.server-load-heading strong { flex: 0 0 auto; color: var(--brand-navy); font-size: 12px; font-variant-numeric: tabular-nums; }
.server-load-progress, .server-load-empty { display: block; width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 999px; background: #e3eaf5; }
.server-load-progress { appearance: none; }
.server-load-progress::-webkit-progress-bar { border-radius: 999px; background: #e3eaf5; }
.server-load-progress::-webkit-progress-value { border-radius: 999px; background: var(--brand-blue); }
.server-load-progress::-moz-progress-bar { border-radius: 999px; background: var(--brand-blue); }
.server-load-progress.warning::-webkit-progress-value { background: var(--warning); }
.server-load-progress.warning::-moz-progress-bar { background: var(--warning); }
.server-load-divider { height: 1px; margin: 1px 0; background: var(--border); }
.server-service-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #475467; font-size: 12px; font-weight: 600; }
.server-service-row .status { flex: 0 0 auto; font-weight: 500; }
.server-last-error { margin-top: 6px; color: var(--danger); overflow-wrap: anywhere; }
.status { display: inline-block; padding: 2px 7px; border: 1px solid currentColor; border-radius: 4px; white-space: nowrap; }
.status.ok { color: var(--success); }
.status.warn { color: var(--warning); }
.status.danger { color: var(--danger); }
.status.muted { color: var(--brand-muted); }
.alert { padding: 11px 13px; border-radius: 6px; }
.alert-error, .alert-danger { color: var(--danger); border: 1px solid #fecdca; background: #fef3f2; }
.alert-warning { color: var(--warning); border: 1px solid #fedf89; background: #fffaeb; }
.alert-success { color: var(--success); border: 1px solid #abefc6; background: #ecfdf3; }
.stack-form { display: grid; gap: 14px; }
.legal-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.legal-document-text { max-width: 920px; padding: 20px; border: 1px solid var(--border); border-radius: 6px; background: #fff; line-height: 1.65; }
.notification-message-section { margin-bottom: 28px; }
.notification-message { max-width: 760px; padding: 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; line-height: 1.55; }
.notification-message-title { display: block; margin-bottom: 10px; }
.notification-message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.notification-message-note { max-width: 760px; margin: 9px 0 0; color: var(--brand-muted); font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.settings-group { padding: 0; margin: 0 0 24px; border: 0; }
.settings-group legend { width: 100%; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--border); font-size: 18px; font-weight: 650; }
.managed-text-form { padding-top: 8px; }
.managed-text-tabs { padding-top: 22px; }
.managed-text-list { display: grid; gap: 14px; }
.managed-text-field { padding: 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.managed-text-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--brand-navy); }
.managed-text-field code { color: #475467; font-size: 12px; overflow-wrap: anywhere; }
.managed-text-field textarea { min-height: 110px; }
.managed-text-reset { width: fit-content; }
.managed-text-actions { position: sticky; bottom: 0; padding: 12px 0; background: var(--brand-surface); }
.text-validation-error { white-space: pre-wrap; }
.danger-zone { padding: 16px; border-left: 4px solid var(--danger); background: #fff; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--brand-surface); }
.login-panel { width: min(400px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.login-logo { display: block; width: 220px; max-width: 100%; height: auto; margin-bottom: 22px; }
.mfa-panel { width: min(460px, 100%); }
.mfa-intro { color: #475467; }
.mfa-qr { display: block; width: 252px; max-width: 100%; height: auto; margin: 20px auto; border: 1px solid var(--border); }
.manual-secret { margin: 0 0 18px; color: #475467; }
.manual-secret summary { cursor: pointer; font-weight: 600; }
.manual-secret code { display: block; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--brand-surface); color: var(--brand-navy); font-size: 14px; overflow-wrap: anywhere; }
.otp-input { font-size: 20px; font-variant-numeric: tabular-nums; }
.login-back { display: inline-block; margin-top: 18px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin: 20px 0 24px; padding: 16px 16px 16px 34px; border: 1px solid var(--border); border-radius: 6px; background: var(--brand-surface); }
.recovery-codes code { color: var(--brand-navy); font-size: 13px; }
.product-name { color: var(--brand-blue); font-weight: 700; }

@media (min-width: 992px) {
  .admin-sidebar { position: fixed; inset: 0 auto 0 0; transform: none !important; visibility: visible !important; }
  .admin-workspace { margin-left: var(--sidebar-width); }
}

@media (max-width: 991.98px) {
  .sidebar-body { height: calc(100dvh - 56px); }
  .application-status { top: 58px; }
  .application-status > summary { padding-inline: 16px; }
  .status-issues { padding-inline: 34px 16px; }
  .content { padding: 22px 16px 40px; }
  .metrics { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}

@media (max-width: 560px) {
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head form, .page-head button { width: 100%; }
  .metrics { grid-template-columns: 1fr; }
  .filters > label, .filters > button, .filters > .filter-field { width: 100%; }
  .tag-filter-toggle { max-width: none; }
  h1 { font-size: 24px; }
  .recovery-codes { grid-template-columns: 1fr; }
}
