:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #111c2d;
  --ink-2: #4b5768;
  --muted: #7c8798;
  --line: #e5eaf2;
  --line-strong: #d5dde8;
  --primary: #00a1ff;
  --primary-strong: #0088d8;
  --primary-soft: #e5f5ff;
  --purple: #8965e5;
  --purple-soft: #efe9fc;
  --teal: #00ceb6;
  --teal-soft: #e0f9f6;
  --orange: #ffae1f;
  --orange-soft: #fff4e0;
  --pink: #ff6692;
  --pink-soft: #ffe9ef;
  --ok: #00a693;
  --warn: #e0507a;
  --radius: 20px;
  --radius-sm: 10px;
  --shadow: 0 1px 4px rgba(133, 146, 173, 0.2);
  --shadow-lg: 0 24px 60px rgba(17, 28, 45, 0.18);
  --sidebar: 264px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  font-weight: 600;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 17px;
}

p {
  margin: 0;
}

.sprite {
  display: none;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

/* ---------- Кнопки и поля ---------- */

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.edit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.primary-button {
  border: 0;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  padding: 0 18px;
}

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

.primary-button .icon {
  width: 18px;
  height: 18px;
}

.primary-button.wide {
  width: 100%;
  height: 46px;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
  font-weight: 500;
  padding: 0 16px;
}

.ghost-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.ghost-button:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--line-strong);
  color: var(--ink);
}

.danger-button {
  border: 0;
  background: var(--pink-soft);
  color: var(--warn);
  font-weight: 600;
  padding: 0 16px;
}

.danger-button:hover {
  background: var(--warn);
  color: #ffffff;
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-2);
}

.icon-button.plain {
  border-color: transparent;
  background: transparent;
}

.icon-button:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.edit-button {
  height: 34px;
  border: 0;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  padding: 0 14px 0 11px;
}

.edit-button .icon {
  width: 16px;
  height: 16px;
}

.edit-button:hover {
  background: var(--primary);
  color: #ffffff;
}

.row-actions {
  display: inline-flex;
  gap: 8px;
}

.test-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
  padding: 0 14px 0 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.test-button.icon-only {
  width: 34px;
  justify-content: center;
  padding: 0;
}

.test-button.icon-only:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.test-button .icon {
  width: 16px;
  height: 16px;
}

.test-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.test-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.test-button.ok {
  border-color: transparent;
  background: var(--teal-soft);
  color: var(--ok);
}

.test-button.fail {
  border-color: transparent;
  background: var(--pink-soft);
  color: var(--warn);
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: #a3adbb;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 161, 255, 0.14);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
  box-shadow: none;
  cursor: pointer;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.status-line,
.status-text,
.error-text {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.error-text {
  color: var(--warn);
}

.hint-text {
  color: var(--muted);
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  width: fit-content;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--ink-2);
  background: #eef2f7;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok {
  color: var(--ok);
  background: var(--teal-soft);
}

.badge.warn {
  color: var(--warn);
  background: var(--pink-soft);
}

.avatar {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
}

.avatar.large {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.tone-blue { background: var(--primary-soft); color: var(--primary); }
.tone-teal { background: var(--teal-soft); color: var(--ok); }
.tone-purple { background: var(--purple-soft); color: var(--purple); }
.tone-orange { background: var(--orange-soft); color: #e39200; }
.tone-pink { background: var(--pink-soft); color: var(--warn); }

/* ---------- Логотип ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #00a1ff, #8965e5);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
}

.brand strong {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Страница входа ---------- */

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr);
  background: #ffffff;
}

.login-art {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 36px 48px;
  background:
    radial-gradient(circle at 15% 85%, rgba(137, 101, 229, 0.16), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(0, 161, 255, 0.18), transparent 50%),
    #f1f6fd;
}

.login-illustration {
  width: min(460px, 100%);
  align-self: center;
  display: grid;
  gap: 16px;
}

.ill-card {
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 12px 34px rgba(80, 104, 140, 0.14);
}

.ill-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ill-line {
  height: 10px;
  border-radius: 999px;
  background: #e8eef6;
}

.ill-line.w40 { width: 40%; }
.ill-line.w50 { width: 50%; }
.ill-line.w60 { width: 60%; }

.ill-bars {
  height: 150px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.ill-bars i {
  flex: 1;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #00a1ff, #7fd0ff);
}

.ill-bars i:nth-child(even) {
  background: linear-gradient(180deg, #8965e5, #c6b3f5);
}

.ill-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.ill-dot.blue { background: var(--primary-soft); box-shadow: inset 0 0 0 10px #bfe6ff; }
.ill-dot.teal { background: var(--teal-soft); box-shadow: inset 0 0 0 10px #a9eee5; }

.ill-num {
  font-size: 24px;
  font-weight: 700;
}

.login-tagline h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

.login-tagline p {
  max-width: 420px;
  color: var(--ink-2);
}

.login-side {
  display: grid;
  place-items: center;
  padding: 32px 24px;
}

.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 18px;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 700;
}

.login-card .muted {
  margin-top: -10px;
}

.login-card-brand {
  display: none;
  margin-bottom: 8px;
}

/* ---------- Каркас ---------- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  transition: grid-template-columns 0.2s;
}

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

.sidebar .brand {
  padding: 0 8px 22px;
}

.nav {
  display: grid;
  gap: 2px;
}

.nav-caption {
  margin: 16px 12px 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.nav-caption:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  padding: 0 16px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.nav-item:hover {
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-collapsed {
  --sidebar: 84px;
}

.sidebar-collapsed .brand-name,
.sidebar-collapsed .nav-item span {
  display: none;
}

.sidebar-collapsed .nav-caption {
  height: 1px;
  margin: 12px 14px;
  overflow: hidden;
  color: transparent;
  background: var(--line);
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0;
}

.sidebar-collapsed .sidebar .brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar-backdrop {
  display: none;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 70px;
  padding: 0 24px;
  background: rgba(244, 247, 251, 0.88);
  backdrop-filter: blur(8px);
}

.topbar-spacer {
  flex: 1;
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 0 12px 0 6px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.session-chip:hover {
  background: var(--primary-soft);
}

.session-lock {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.session-text {
  display: grid;
  line-height: 1.25;
}

.session-text strong {
  font-size: 14px;
  font-weight: 600;
}

.session-text span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  display: grid;
  gap: 24px;
  padding: 0 24px 32px;
}

.view {
  display: grid;
  gap: 24px;
  align-content: start;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card.padded {
  padding: 24px;
}

.card.padded h2 {
  margin-bottom: 16px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px;
}

.page-header p {
  margin-top: 4px;
  color: var(--muted);
}

.crumbs {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.crumbs span {
  margin: 0 6px;
}

.crumbs b {
  color: var(--primary);
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
}

.toolbar-group,
.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar select {
  width: auto;
  min-width: 160px;
}

.toolbar.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}

.toolbar-group {
  flex: 1 1 auto;
}

.search-field {
  position: relative;
  display: block;
  width: 300px;
  max-width: 100%;
}

.search-field .icon {
  position: absolute;
  left: 13px;
  top: 11px;
  color: var(--muted);
}

.search-field input {
  padding-left: 42px;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 10px;
}

.card-heading p {
  margin-top: 4px;
}

/* ---------- Таблицы ---------- */

.table-card {
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  height: 52px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

td {
  color: var(--ink-2);
}

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

tbody tr:hover td {
  background: #f9fbfe;
}

.actions-head,
.actions-cell {
  width: 1%;
  text-align: right;
}

.empty-row {
  height: 96px;
  color: var(--muted);
  text-align: center;
}

.table-footer {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-cell strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
}

.user-cell > div span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Главная ---------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 24px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
}

.metric-icon {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 16px;
}

.metric-icon .icon {
  width: 24px;
  height: 24px;
}

.metric-card span:not(.metric-icon) {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 2px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

/* ---------- Окна ---------- */

.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.modal-wide {
  width: min(860px, calc(100vw - 32px));
}

.modal-narrow {
  width: min(480px, calc(100vw - 32px));
}

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

.modal::backdrop {
  background: rgba(17, 28, 45, 0.45);
  backdrop-filter: blur(2px);
}

.modal[open] {
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-box {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  flex: 1;
  min-width: 0;
}

.modal-title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-title p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-icon {
  width: 46px;
  height: 46px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px;
}

/* Окна с вкладками не прыгают по высоте при переключении */
.modal-wide .modal-body,
.modal-tabbed .modal-body {
  min-height: 400px;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.modal-footer .status-text {
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.modal-footer.centered {
  justify-content: center;
  border-top: 0;
  background: #ffffff;
  padding-top: 4px;
  padding-bottom: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  align-content: start;
}

.form-grid.one {
  grid-template-columns: 1fr;
}

.form-grid.three {
  grid-template-columns: 1.4fr 1fr 1fr;
}

.span-2 {
  grid-column: 1 / -1;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
}

.tab {
  position: relative;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  color: var(--primary);
}

.tab.active {
  color: var(--primary);
  font-weight: 600;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}

.tab-count:not(:empty) {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 4px;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}

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

.usage-table table {
  min-width: 520px;
}

.usage-table th {
  height: 44px;
  background: #fbfcfe;
}

.usage-table td {
  height: 54px;
}

.tab-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.access-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

.check-list {
  display: grid;
  gap: 2px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  background: #fbfcfe;
}

.check-list .empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.check-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.check-item:hover {
  background: #ffffff;
}

.check-item input {
  margin-top: 1px;
}

.check-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.subscription-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.subscription-row:last-child {
  border-bottom: 0;
}

.subscription-row span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.subscription-row .ghost-button {
  height: 34px;
}

.ask-body {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 30px 28px 18px;
  text-align: center;
}

.ask-body p {
  color: var(--ink-2);
}

.ask-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--orange-soft);
  color: #e39200;
}

.ask-icon .icon {
  width: 28px;
  height: 28px;
}

#askDialog[data-tone="danger"] .ask-icon {
  background: var(--pink-soft);
  color: var(--warn);
}

/* ---------- Двухфакторная авторизация ---------- */

.security-body {
  display: grid;
  gap: 14px;
}

.qr-image {
  width: 200px;
  height: 200px;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: #ffffff;
}

.secret-key {
  display: block;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #f4f7fb;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 14px;
  letter-spacing: 1px;
  overflow-wrap: anywhere;
  user-select: all;
}

.backup-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 24px;
  margin: 0;
  border-radius: 14px;
  padding: 14px 14px 14px 36px;
  background: #f4f7fb;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
}

.two-factor-row,
.license-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--teal-soft);
}

.license-row {
  background: var(--primary-soft);
}

.two-factor-row strong,
.license-row strong {
  display: block;
  font-weight: 600;
}

.two-factor-row span,
.license-row span {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 12px;
}

.login-card .modal-icon {
  margin-bottom: -4px;
}

/* ---------- Прочее ---------- */

.endpoint-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.endpoint-list span,
.system-list dd {
  margin: 0;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: #f4f7fb;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.system-list {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: center;
  gap: 10px 16px;
  margin: 0;
}

.system-list dt {
  color: var(--ink-2);
  font-weight: 500;
}

/* ---------- Узкие экраны ---------- */

@media (max-width: 980px) {
  .app-shell,
  .sidebar-collapsed {
    --sidebar: 264px;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 20;
    width: var(--sidebar);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .sidebar-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(17, 28, 45, 0.35);
  }

  .sidebar-collapsed .brand-name,
  .sidebar-collapsed .nav-item span {
    display: initial;
  }

  .sidebar-collapsed .nav-caption {
    height: auto;
    margin: 16px 12px 6px;
    color: var(--ink);
    background: none;
  }

  .sidebar-collapsed .nav-item {
    justify-content: flex-start;
    padding: 0 16px;
  }

  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-art {
    display: none;
  }

  .login-card-brand {
    display: flex;
  }
}

@media (max-width: 680px) {
  .topbar,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content,
  .view,
  .dashboard-grid {
    gap: 16px;
  }

  .session-text,
  .crumbs {
    display: none;
  }

  .page-header {
    padding: 18px 20px;
  }

  .toolbar,
  .toolbar-group,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar select,
  .search-field {
    width: 100%;
  }

  .form-grid,
  .form-grid.three,
  .access-columns {
    grid-template-columns: 1fr;
  }

  /* 16px — иначе iOS увеличивает страницу при фокусе на поле */
  input,
  select {
    font-size: 16px;
  }

  /* Окна редактирования — на весь экран; окно вопроса остаётся карточкой по центру */
  .modal:not(.modal-small) {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .modal:not(.modal-small) .modal-box {
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .modal[open] {
    animation: none;
  }

  .modal-header {
    gap: 12px;
    padding: 14px 16px;
  }

  .modal-icon,
  .avatar.large {
    width: 40px;
    height: 40px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-wide .modal-body,
  .modal-tabbed .modal-body {
    min-height: 0;
  }

  .tabs {
    padding: 0 8px;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 1 0 auto;
    padding: 0 10px;
  }

  .modal-footer {
    flex-wrap: wrap;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .modal-footer .status-text {
    flex-basis: 100%;
    order: -1;
  }

  .modal-footer > button {
    flex: 1 1 0;
    padding: 0 10px;
  }

  .subscription-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .subscription-row .ghost-button {
    grid-column: 1 / -1;
  }

  .system-list {
    grid-template-columns: 1fr;
  }
}

/* Планшет и телефон: строки таблиц — карточками, чтобы кнопки Test / Edit не уходили за край */
@media (max-width: 980px) {
  /* подпись поля из data-label (берётся из заголовка колонки в app.js) */
  .table-wrap table,
  .usage-table table {
    min-width: 0;
  }

  .table-wrap thead,
  .usage-table thead {
    display: none;
  }

  .table-wrap tbody tr,
  .usage-table tbody tr {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap tbody tr:last-child,
  .usage-table tbody tr:last-child {
    border-bottom: 0;
  }

  .table-wrap td,
  .usage-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: auto;
    min-height: 34px;
    padding: 3px 0;
    border: 0;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .table-wrap td::before,
  .usage-table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 12px;
    text-align: left;
  }

  tbody tr:hover td {
    background: none;
  }

  /* Номер записи виден в шапке окна редактирования */
  .table-wrap td[data-label="ID"] {
    display: none;
  }

  .table-wrap td:has(.user-cell),
  .usage-table td:has(.user-cell) {
    justify-content: flex-start;
    padding-bottom: 6px;
    text-align: left;
  }

  .table-wrap td:has(.user-cell)::before,
  .usage-table td:has(.user-cell)::before,
  .actions-cell::before,
  .empty-row::before {
    display: none;
  }

  .actions-cell {
    width: auto;
    padding-top: 8px !important;
  }

  .row-actions {
    display: flex;
    width: 100%;
  }

  .row-actions > button {
    flex: 1 1 0;
    justify-content: center;
  }

  .table-wrap td.empty-row,
  .usage-table td.empty-row {
    justify-content: center;
    min-height: 72px;
  }
}
