:root {
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

html[data-theme='light'] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #15233f;
  --muted: #6b7488;
  --border: #e3e6ec;
  --primary: #2f6bff;
  --primary-text: #fff;
  --error: #d23b4e;
}

html[data-theme='dark'] {
  --bg: #0f1626;
  --surface: #182238;
  --surface-2: #1f2b45;
  --text: #eef2f9;
  --muted: #93a0bb;
  --border: #2a3756;
  --primary: #4b82ff;
  --primary-text: #fff;
  --error: #ff6b7d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .3s, color .3s;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand {
  font-size: 1.05rem;
  letter-spacing: .2px;
  white-space: nowrap;
}

.brand b {
  color: var(--primary);
}

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

.who {
  color: var(--muted);
  font-size: .9rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1;
  transition: border-color .15s, color .15s, background .15s;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.bi {
  vertical-align: -0.125em;
}

.icon-btn .bi {
  font-size: 1.25rem;
  line-height: 1;
}

.icon-btn.sm {
  width: 34px;
  height: 34px;
}

.icon-btn.sm .bi {
  font-size: 1.05rem;
}

.btn .bi {
  margin-right: 2px;
}

.invite-card h3 .bi,
.sub-banner .bi {
  color: var(--primary);
}

/* Keep long labels from widening flex/grid cards */
.kv li>span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#page {
  overflow-x: hidden;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Login */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}

.login-card {
  max-width: 420px;
  text-align: center;
}

.tg-login {
  display: flex;
  justify-content: center;
  margin: 18px 0;
  min-height: 48px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

/* ===== Sidebar layout ===== */
.layout {
  display: flex;
  align-items: stretch;
  position: relative;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 12px;
  min-height: calc(100vh - 65px);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.side-brand {
  font-size: .98rem;
  font-weight: 600;
  white-space: nowrap;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
}

.signed-as {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 8px;
  padding: 0 4px;
}

.signed-as strong {
  color: var(--text);
}

.side-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  padding: 9px 12px;
  font-size: .92rem;
}

.side-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--muted);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: .97rem;
}

.side-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-link.active {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
  font-weight: 600;
}

.side-link .bi {
  font-size: 1.05rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.content {
  flex: 1;
  min-width: 0;
  max-width: 900px;
  padding: 24px 24px 60px;
  overflow-x: hidden;
}

.sidebar-backdrop {
  display: none;
}

/* Collapsed: hide the sidebar, content takes full width. */
.layout:not(.sidebar-open) .sidebar {
  display: none;
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed;
    top: 65px;
    left: 0;
    bottom: 0;
    z-index: 40;
    width: 240px;
    min-height: 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }

  .layout.sidebar-open .sidebar {
    transform: none;
  }

  .layout.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 65px 0 0 0;
    background: rgba(0, 0, 0, .4);
    z-index: 30;
  }

  .content {
    padding: 18px 16px 60px;
  }
}

/* Page-level sub-tabs (e.g. inside Admin) */
.subtabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin: 6px 0 20px;
  flex-wrap: wrap;
}

.subtab {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 14px;
  font-size: .95rem;
  border-bottom: 2px solid transparent;
}

.subtab:hover {
  color: var(--text);
}

.subtab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

.mt {
  margin-top: 26px;
}

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

.small {
  font-size: .85rem;
}

.strong {
  font-weight: 600;
}

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

/* Tariffs */
/* Payments · pricing cards (equal-height, presentable) */
.tariffs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
  align-items: stretch;
}

.tariff {
  display: flex;
  flex-direction: column;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 22px 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: border-color .15s, transform .12s, box-shadow .15s;
}

.tariff:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .10);
}

.tariff.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1.5px var(--primary), 0 8px 24px rgba(0, 0, 0, .10);
}

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

.tariff-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.tariff-tag {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--primary-text);
  background: var(--primary);
  border-radius: 999px;
  padding: 3px 9px;
}

.tariff-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 14px;
}

.tariff-from {
  font-size: .78rem;
  color: var(--muted);
}

.tariff-amount {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.tariff-amount.free {
  color: var(--text);
}

.tariff-per {
  font-size: .82rem;
  color: var(--muted);
}

.tariff-desc {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
  margin-bottom: 12px;
}

.tariff-feats {
  list-style: none;
  margin: 0 0 14px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text);
}

.tariff-feats li {
  padding-left: 22px;
  position: relative;
  line-height: 1.9;
}

.tariff-feats li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* Push the call-to-action to the bottom so cards align regardless of content. */
.tariff-select {
  margin-top: auto;
  text-align: center;
  font-weight: 600;
  font-size: .9rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
}

.tariff.selected .tariff-select {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

/* Payments · billing period picker */
.billing {
  margin-bottom: 4px;
}

.periods {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0 22px;
}

.period {
  flex: 1 1 0;
  min-width: 130px;
  cursor: pointer;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 18px 16px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: border-color .15s, transform .12s;
}

.period:hover {
  transform: translateY(-2px);
}

.period.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.period-label {
  font-size: .82rem;
  color: var(--muted);
}

.period-price {
  font-weight: 700;
  font-size: 1.25rem;
}

.period-permonth {
  font-size: .78rem;
  color: var(--muted);
}

.billing-note {
  margin: 2px 0 22px;
}

/* Contacts page */
/* Intros need breathing room before the link / form fields below them. */
[data-tab="contacts"] .card>p {
  margin: 4px 0 16px;
}

/* Anchor buttons are inline by default — their vertical padding would bleed over
   the line above. inline-flex makes the box participate in layout properly. */
#supportLink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: 2px;
  text-decoration: none;
}

/* Admin · tariff builder */
.tariff-builder {
  max-width: 680px;
}

/* Breathing room: section intros sit too close to the fields below them. */
.tariff-builder>p {
  margin: 4px 0 16px;
}

.tariff-builder .field-label {
  margin-bottom: 8px;
}

.tariff-builder .tariff-row {
  margin-bottom: 16px;
  padding: 16px;
}

.tariff-row-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.tariff-row.tariff-hidden {
  opacity: .6;
  border-style: dashed;
}

.draft-badge {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.tariff-row-head .t-hide.active {
  color: var(--primary);
}

.tariff-row-head .t-title {
  flex: 1;
  padding: 9px 11px;
  font-size: .95rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tariff-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
}

.tariff-row .field {
  margin-bottom: 12px;
}

.tariff-row select {
  width: 100%;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-transform: capitalize;
}

.tariff-row input:disabled {
  opacity: .5;
}

.t-pricing,
.t-freespan {
  margin-bottom: 12px;
}

.price-field span small {
  color: var(--muted);
  font-weight: 400;
}

.price-total {
  display: block;
  margin-top: 4px;
  font-size: .76rem;
  color: var(--primary);
  min-height: 1em;
}

.freespan-row {
  display: flex;
  gap: 10px;
}

.freespan-row .t-dur-value {
  flex: 0 0 100px;
}

.freespan-row .t-dur-unit {
  flex: 1;
}

/* Admin · feature registry */
.registry-details {
  margin-bottom: 12px;
}

.feature-rows-scroll {
  padding: 10px 12px;
  max-height: 280px;
  overflow-y: auto;
}

.feature-rows-scroll>.muted {
  margin: 4px 0;
}

.feature-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.feature-row:last-child {
  margin-bottom: 0;
}

.feature-row .f-name {
  flex: 0 0 28%;
  min-width: 130px;
}

.feature-row .f-desc {
  flex: 1 1 auto;
  min-width: 0;
}

.feature-row input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
}

/* Per-tariff "Included features" — collapsible list (can be long) */
.feature-details {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.feature-details>summary {
  cursor: pointer;
  padding: 10px 12px;
  font-size: .85rem;
  color: var(--muted);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.feature-details>summary::-webkit-details-marker {
  display: none;
}

.feature-details>summary::before {
  content: '▸';
  font-size: .8rem;
  transition: transform .12s;
}

.feature-details[open]>summary::before {
  transform: rotate(90deg);
}

.feature-details[open]>summary {
  border-bottom: 1px solid var(--border);
}

.feature-count {
  margin-left: auto;
}

.feature-checks {
  padding: 8px 12px;
  max-height: 240px;
  overflow-y: auto;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .88rem;
  cursor: pointer;
}

.feature-item input {
  width: auto;
  flex: 0 0 auto;
}

@media (max-width: 560px) {
  .tariff-row-grid {
    grid-template-columns: 1fr 1fr;
  }

  .feature-row {
    flex-wrap: wrap;
  }

  .feature-row .f-name,
  .feature-row .f-desc {
    flex: 1 1 100%;
  }
}

.methods {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 22px;
}

.method {
  cursor: pointer;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--text);
}

.method.selected {
  border-color: var(--primary);
}

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 22px;
  cursor: pointer;
  font-size: .98rem;
  font-weight: 600;
}

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

.btn.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}

.btn.primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Profile */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}

.kv {
  list-style: none;
}

.kv li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 5px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.45;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sub-status {
  display: flex;
  justify-content: space-between;
  padding-top: 6px;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.mt-sm {
  margin-top: 10px;
}

/* Profile identity block — breathing room between name / username / id */
.profile-id {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.profile-id .strong {
  font-size: 1.1rem;
}

/* Active-subscription banner on the Payments tab */
.sub-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border));
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: .95rem;
}

.sub-banner b {
  color: var(--primary);
}

/* Invite / referral */
.invite-card {
  margin-top: 16px;
}

.invite-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invite-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.invite-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
}

.invite-row .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* Referral code entry on the Payments tab */
.referral-box {
  margin: 6px 0 22px;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 6px;
}

.referral-row {
  display: flex;
  gap: 8px;
  max-width: 420px;
}

.referral-row input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}

.referral-row input:disabled {
  opacity: .6;
}

.referral-box.applied .referral-row {
  display: none;
}

.json {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85rem;
}

/* Login screen */
.signin-title {
  margin-bottom: 12px;
}

.login-note {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
  text-align: left;
}

.login-card a {
  color: var(--primary);
  text-decoration: none;
}

.login-card a:hover {
  text-decoration: underline;
}

/* Referral stats in profile */
.invite-stats {
  display: flex;
  gap: 28px;
  margin-top: 16px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat-label {
  font-size: .82rem;
  color: var(--muted);
  margin-top: 2px;
}

.discount-hint {
  color: var(--primary);
}

/* Admin analytics */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpis>*,
.admin-grid>* {
  min-width: 0;
}

/* let grid items shrink, no overflow */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-num {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary);
}

.kpi-label {
  color: var(--muted);
  font-size: .85rem;
  margin-top: 2px;
}

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

@media (max-width: 640px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.admin-grid .kv li {
  align-items: center;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: .85rem;
}

.bar-day {
  width: 92px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  flex: 1;
  height: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 6px;
}

.bar-n {
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Admin: users table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  min-width: 560px;
}

table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}

table.data tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .78rem;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.ok {
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
  color: var(--primary);
}

.badge.vip {
  background: color-mix(in srgb, #f5a623 22%, var(--surface));
  color: #b9770a;
}

.badge.warn {
  background: color-mix(in srgb, #f5a623 18%, var(--surface));
  color: #b9770a;
}

/* Admin: payment-method kill-switches */
.pm-admin {
  max-width: 640px;
}

/* Collapsible help block above the method switches */
.pm-help {
  margin: 4px 0 16px;
}

.pm-help-body {
  padding: 14px;
}

.pm-help-body p {
  margin: 0;
}

.pm-help-body p + p {
  margin-top: 12px;
}

.pm-methods {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 6px 0 4px;
}

.pm-method {
  padding: 14px 16px;
  transition: opacity .15s;
}

.pm-method.off {
  opacity: .62;
}

.pm-method-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pm-method-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.pm-icon {
  font-size: 1.15rem;
}

.pm-method-desc {
  margin: 4px 0 10px;
}

.pm-services {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.pm-service {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  transition: opacity .15s;
}

.pm-service.off {
  opacity: .55;
}

.pm-service-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 500;
}

/* A disabled whole-method dims its gateway rows but keeps them togglable. */
.pm-method.off .pm-services {
  filter: grayscale(.4);
}

/* Admin: settings form */
.settings-form {
  max-width: 520px;
}

.settings-form .field {
  margin-bottom: 18px;
}

.settings-form input[type="number"],
.settings-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.settings-form textarea {
  min-height: 70px;
  resize: vertical;
  font-family: ui-monospace, Menlo, monospace;
  font-size: .85rem;
}

/* Toggle switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch .track {
  width: 46px;
  height: 26px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  transition: background .15s;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}

.switch input:checked+.track {
  background: color-mix(in srgb, var(--primary) 30%, var(--surface));
  border-color: var(--primary);
}

.switch input:checked+.track::after {
  transform: translateX(20px);
  background: var(--primary);
}

.switch-labels {
  display: flex;
  gap: 8px;
  font-size: .9rem;
}

.save-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* ===== Spacing utilities (Bootstrap-ish) ===== */
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 16px; padding-bottom: 16px; }

/* ===== Notifications ===== */
/* Per-category accent colour (used by the left border, icon and badges). */
.notif-info { --accent: var(--primary); }
.notif-update { --accent: #7c5cff; }
.notif-maintenance { --accent: #f5a623; }
.notif-promo { --accent: #18a957; }
.notif-warning { --accent: var(--error); }

/* Filter chips */
.notif-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 18px;
}

.notif-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.notif-chip:hover { border-color: var(--primary); }

.notif-chip.active {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  border-color: var(--primary);
  color: var(--primary);
}

.notif-chip-n {
  font-size: .72rem;
  opacity: .75;
}

/* Announcement cards */
.notif-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notif-card {
  border-left: 4px solid var(--accent, var(--primary));
  padding: 16px 18px;
}

/* Line 1: "{date} | {type}" + pin/unread markers, kept on a single row. */
.notif-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
}

.notif-sep {
  color: var(--border);
}

.notif-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent, var(--primary));
  text-transform: uppercase;
  letter-spacing: .02em;
}

.notif-markers {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.notif-pin {
  color: var(--accent, var(--muted));
  transform: rotate(35deg);
}

/* Unread dot — removed in place the moment the user expands the card. */
.notif-unread {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent, var(--primary));
  flex-shrink: 0;
}

.notif-date {
  color: var(--muted);
  font-size: .8rem;
}

.notif-title {
  margin: 4px 0 0;
  font-size: 1.05rem;
}

/* Body paragraphs: .py-2 gives the spacing; first/last trim the edges. */
.notif-p {
  margin: 0;
  color: var(--text);
}

.notif-p:first-of-type { padding-top: 0; }
.notif-p:last-of-type { padding-bottom: 0; }

/* Admin · Notifs */
.notif-admin { max-width: 640px; }

.notif-form-row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.notif-cat-field { flex: 1 1 200px; margin-bottom: 0; }

.notif-admin select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.notif-admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notif-admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, var(--border));
  border-radius: 10px;
  background: var(--surface-2);
}

.notif-admin-row.off { opacity: .55; }

.notif-admin-main { min-width: 0; flex: 1; }

.notif-admin-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notif-admin-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.notif-row-date {
  margin-left: 4px;
  white-space: nowrap;
}

/* Body is fully hidden in the collapsed (uniform two-line) state, revealed by
   "Show more" so every card has the same height until the user opens it. */
.notif-collapse {
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}

.notif-card.expanded .notif-collapse {
  max-height: 4000px;
  margin-top: 8px;
}

.link-btn {
  background: none;
  border: 0;
  padding: 4px 0;
  margin-top: 6px;
  color: var(--primary);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* Unread dot on the Notifications sidebar item */
.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-left: auto;
  flex-shrink: 0;
}

/* Pin toggle button (admin create/edit form) */
.pin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.pin-toggle .bi {
  transition: transform .12s;
}

.pin-toggle:hover {
  border-color: var(--primary);
}

.pin-toggle.on {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  border-color: var(--primary);
  color: var(--primary);
}

.pin-toggle.on .bi {
  transform: rotate(35deg);
}

.btn.sm {
  padding: 6px 12px;
  font-size: .85rem;
}

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

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

/* Language toggle shows a short code (EN/RU) instead of an icon. */
.lang-btn {
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .03em;
}

[hidden] {
  display: none !important;
}