:root,
html[data-theme="dark"] {
  --primary: #172026;
  --secondary: #22313a;
  --accent: #2fb7a4;
  --primary-fg: #f6fbfa;
  --body-fg: #e6efed;
  --body-bg: #101719;
  --body-quiet-color: #a8b8b6;
  --link-fg: #5dd6c5;
  --link-hover-color: #85e7d9;
  --header-color: #f6fbfa;
  --header-branding-color: #ffffff;
  --breadcrumbs-bg: #22313a;
  --breadcrumbs-fg: #d6e7e4;
  --breadcrumbs-link-fg: #ffffff;
  --button-bg: #0f766e;
  --button-hover-bg: #0b5f59;
  --default-button-bg: #0f766e;
  --default-button-hover-bg: #0b5f59;
  --object-tools-bg: #0f766e;
  --object-tools-hover-bg: #0b5f59;
  --radius-nav-selected-bg: #2f464a;
  --radius-nav-selected-fg: #f4fbfa;
  --radius-nav-selected-mark: #2fb7a4;
  color-scheme: dark;
}

#header {
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 1px 0 rgba(23, 32, 38, 0.08);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
}

.module {
  border: 1px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
}

/* #content-related is taller than the actual recent-actions card (it
   stretches to match the main content column), so its own background must
   match the page instead of standing out below the card. */
#content-related {
  background: var(--body-bg);
}

/* Same background as the dashboard's alternating-row shade below, instead
   of the default admin sidebar color. Scoped to the card (.module), not
   #content-related itself, so the color stays inside the rounded/bordered
   frame instead of leaking past its bottom edge. */
#content-related .module {
  background: #141c20;
}

/* Recent-actions title bar matches the same color as the left-hand section
   caption bars. */
#content-related .module h2 {
  background: var(--header-bg);
}

/* Dashboard app-list rows only ([class^="app-"], not changelist/other
   .module tables): replace the lighter alternating-row shade
   (default admin's tr:nth-child(even), var(--darkened-bg)) with the same
   background as the recent-actions card, instead of touching
   --darkened-bg itself (used widely elsewhere: forms, autocomplete,
   changelist filters, campaigns/*.css). */
[class^="app-"].module table tr:nth-child(even) {
  background: #141c20;
}

#changelist.module {
  border: 0;
  border-radius: 0;
  overflow: visible;
}

#changelist-form,
#changelist-filter {
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-sizing: border-box;
  overflow: hidden;
}

#changelist #changelist-filter {
  border: 1px solid var(--accent);
  background: #141c20;
}

#changelist-form .results {
  border-radius: 0;
}

#changelist-form .results table {
  margin-bottom: 0;
}

/* Changelist result rows: same alternating-row shade as the dashboard,
   instead of the default admin's tr:nth-child(even)/var(--darkened-bg). */
#changelist-form .results tr:nth-child(even) {
  background: #141c20;
}

/* Column header row, and a visibly lighter shade for whichever column is
   currently sorted (already a distinct color in default admin CSS, just
   pointed at var(--darkened-bg)/var(--selected-bg) - reuse --secondary,
   already used for section headers/login card, instead of a new color). */
#changelist-form .results thead th {
  background: #141c20;
}

#changelist-form .results thead th.sorted {
  background: var(--secondary);
}

/* Changelist search toolbar ("Найти") - brighter than the rest, as a
   distinct zone, instead of the default var(--darkened-bg). */
/* #changelist prefix (same trick as #changelist #changelist-filter above):
   admin/css/changelists.css defines the same #toolbar selectors but loads
   AFTER this file on changelist pages (change_list.html's extrastyle block
   calls block.super - which brings in this file - before adding
   changelists.css), so equal specificity would let changelists.css win by
   source order. */
#changelist #toolbar {
  background: var(--secondary);
  border-radius: 8px;
}

/* The "Найти" submit button has its own more specific default rule
   (#toolbar form input[type="submit"]) independent of #toolbar's own
   background above, so it needs its own override too. */
#changelist #toolbar form input[type="submit"] {
  background: #141c20;
}

/* Nav-sidebar model filter input, above the app-list sections. */
#nav-filter {
  background-color: #141c20;
  border-radius: 6px;
  box-sizing: border-box;
  margin: 10px 10px;
  width: calc(100% - 20px);
}

#nav-filter:focus-visible {
  outline: 2px solid #85e7d9;
  outline-offset: 2px;
}

#nav-sidebar,
.toggle-nav-sidebar {
  border-right: 0;
}

#nav-sidebar .module tr,
#nav-sidebar .module th,
#nav-sidebar .module td {
  background: var(--body-bg);
}

#nav-sidebar .current-model,
#nav-sidebar .current-model th,
#nav-sidebar .current-model td {
  background: var(--radius-nav-selected-bg);
}

#nav-sidebar .current-model th {
  box-shadow: inset 4px 0 0 var(--radius-nav-selected-mark);
}

#nav-sidebar .current-model a:link,
#nav-sidebar .current-model a:visited {
  color: var(--radius-nav-selected-fg);
  font-weight: 600;
}

.radius-admin-brand {
  font-weight: 700;
  letter-spacing: 0;
}

#branding {
  grid-column: 1;
  grid-row: 1;
}

.radius-admin-primary-nav {
  align-items: center;
  background: rgba(10, 25, 29, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  display: inline-flex;
  gap: 4px;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  padding: 4px;
}

.radius-admin-primary-nav__link:link,
.radius-admin-primary-nav__link:visited {
  border-radius: 6px;
  color: var(--header-link-color);
  font-weight: 700;
  padding: 7px 12px;
  text-decoration: none;
}

.radius-admin-primary-nav__link:hover,
.radius-admin-primary-nav__link.is-active {
  background: var(--accent);
  color: #06211e;
  text-decoration: none;
}

#user-tools.radius-admin-tools {
  align-items: center;
  display: flex;
  gap: 12px;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  margin: 0;
  text-align: initial;
}

.radius-admin-tools .radius-language-switcher {
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  padding-right: 12px;
}

.radius-language-switcher {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

.radius-language-switcher__button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--header-link-color);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 6px;
}

.radius-language-switcher__button:hover,
.radius-language-switcher__button.is-active {
  border-color: var(--accent);
  color: #ffffff;
}

.radius-admin-profile {
  position: relative;
}

.radius-admin-profile summary {
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  gap: 7px;
  letter-spacing: 0.5px;
  list-style: none;
  padding: 6px 9px;
  text-transform: uppercase;
}

.radius-admin-profile summary::-webkit-details-marker {
  display: none;
}

.radius-admin-profile summary::after {
  content: "▾";
  font-size: 10px;
}

.radius-admin-profile[open] summary {
  border-color: var(--accent);
}

.radius-admin-profile__menu {
  background: var(--secondary);
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  min-width: 190px;
  overflow: hidden;
  padding: 5px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 1000;
}

#user-tools .radius-admin-profile__menu a,
#user-tools .radius-admin-profile__menu button {
  border: 0;
  border-radius: 5px;
  box-sizing: border-box;
  color: var(--header-link-color);
  display: block;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.3;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
  text-transform: none;
  width: 100%;
}

#user-tools .radius-admin-profile__menu a:hover,
#user-tools .radius-admin-profile__menu button:hover {
  background: var(--radius-nav-selected-bg);
  color: #ffffff;
  margin: 0;
}

.radius-admin-profile__menu #logout-form {
  display: block;
}

.aligned .radius-location-full-value {
  color: var(--body-quiet-color);
  line-height: 1.45;
  margin: 6px 0 0 170px;
  max-width: 760px;
  overflow-wrap: anywhere;
  padding-left: 10px;
  white-space: normal;
}

.login #header {
  display: flex;
  justify-content: center;
}

/* Higher specificity than admin/css/login.css's plain `.login` /
   `.login #container` (loaded after this file) so these rules win without
   `!important` regardless of stylesheet order. */
body.login {
  background:
    radial-gradient(circle at 8% 12%, rgba(47, 183, 164, 0.15), transparent 31rem),
    radial-gradient(circle at 91% 86%, rgba(34, 49, 58, 0.95), transparent 32rem),
    var(--body-bg);
}

body.login #container {
  background: var(--secondary);
  border: 1px solid rgba(47, 183, 164, 0.45);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

body.login #content {
  padding: 32px 28px;
}

body.login #id_username,
body.login #id_password {
  background: var(--body-bg);
  border: 1px solid rgba(47, 183, 164, 0.45);
}

body.login #id_username:focus-visible,
body.login #id_password:focus-visible {
  outline: 2px solid #85e7d9;
  outline-offset: 2px;
}

.radius-login-back-link {
  align-items: center;
  color: var(--link-fg);
  display: inline-flex;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 6px;
  left: 24px;
  position: fixed;
  text-decoration: none;
  top: 24px;
}

.radius-login-back-link:hover {
  color: var(--link-hover-color);
  text-decoration: underline;
}

.radius-login-back-link:focus-visible {
  border-radius: 4px;
  outline: 2px solid #85e7d9;
  outline-offset: 4px;
}

@media (max-width: 767px) {
  #header {
    gap: 10px 16px;
    grid-template-columns: 1fr auto;
  }

  #branding {
    grid-column: 1;
    grid-row: 1;
  }

  #user-tools.radius-admin-tools {
    grid-column: 2;
    grid-row: 1;
  }

  .radius-admin-primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .aligned .radius-location-full-value {
    margin-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 520px) {
  #header {
    gap: 10px;
  }

  .radius-admin-tools .radius-language-switcher {
    padding-right: 8px;
  }

  #user-tools.radius-admin-tools {
    gap: 8px;
  }

  .radius-admin-primary-nav {
    justify-self: stretch;
  }

  .radius-admin-primary-nav__link {
    flex: 1;
    text-align: center;
  }
}

div.breadcrumbs {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

input,
select,
textarea {
  border-radius: 6px;
}

.change-form.model-telegramactionsettings .form-row input[type="number"] {
  box-sizing: border-box;
  height: 1.875rem;
  min-height: 1.875rem;
  padding-bottom: 3px;
  padding-top: 3px;
}

.button,
input[type="submit"],
input[type="button"],
.submit-row input,
a.button {
  border-radius: 6px;
  font-weight: 600;
}

.radius-operator-page .module {
  margin-bottom: 16px;
}

.radius-operator-page .module h2 {
  margin-bottom: 0;
}

.radius-result-module h3 {
  color: var(--body-quiet-color);
  font-size: 0.8125rem;
  margin: 16px 0 8px;
  text-transform: uppercase;
}

.radius-result-table {
  width: 100%;
}

.radius-result-table th {
  width: 220px;
}

.radius-technical-details {
  background: var(--darkened-bg);
  border-radius: 6px;
  color: var(--body-quiet-color);
  padding: 10px 12px;
}

.radius-technical-details p {
  margin: 4px 0;
}

.radius-private-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.radius-private-message {
  background: var(--darkened-bg);
  border-radius: 6px;
  padding: 8px 10px;
}

.radius-private-message__meta {
  color: var(--body-quiet-color);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
  margin-bottom: 4px;
}

.radius-private-message__text {
  color: var(--body-fg);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.radius-write-action-page .module {
  padding: 10px 12px;
}

.radius-write-action-page .module h2 {
  margin: -10px -12px 10px;
}

.radius-write-action-page .form-row {
  padding-bottom: 6px;
  padding-top: 6px;
}

.radius-write-action-page .aligned div.help,
.radius-write-action-page .aligned p.help {
  margin-left: 160px;
  padding-left: 10px;
}

.radius-write-action-page .radius-readiness-row {
  padding-left: 0;
}

.radius-write-action-page .radius-readiness-card {
  background: var(--body-bg);
  border: 1px solid var(--hairline-color);
  border-radius: 6px;
  box-sizing: border-box;
  color: var(--body-fg);
  font-size: 13px;
  line-height: 1.4;
  margin: 8px auto 0;
  max-width: 760px;
  padding: 12px 14px;
  width: min(100%, 760px);
}

.radius-write-action-page .radius-readiness-card * {
  font-size: 13px;
}

.radius-write-action-page .radius-readiness-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.radius-write-action-page .radius-readiness-status {
  font-weight: 600;
  text-align: right;
}

.radius-write-action-page .radius-readiness-card.is-ready .radius-readiness-status {
  color: #0a7a2f;
}

.radius-write-action-page .radius-readiness-card.is-not-ready .radius-readiness-status {
  color: #b35a00;
}

.radius-write-action-page .radius-readiness-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.radius-write-action-page .radius-readiness-details:empty {
  display: block;
  margin-top: 0;
}

.radius-write-action-page .radius-readiness-grid {
  margin-top: 0;
}

.radius-write-action-page .radius-readiness-line {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.radius-write-action-page .radius-readiness-line:first-child {
  margin-top: 0;
}

.radius-write-action-page .radius-readiness-line strong {
  color: var(--body-quiet-color);
  font-weight: 600;
}

.radius-write-action-page .radius-readiness-reasons {
  color: #b00020 !important;
  margin: 0;
  padding: 0;
}

.radius-write-action-page .radius-readiness-reason {
  color: #b00020 !important;
  margin-top: 4px;
}

.radius-write-action-page .radius-readiness-reason:first-child {
  margin-top: 0;
}

.radius-write-action-page .radius-readiness-actions {
  display: block;
  margin-top: 0;
  padding-top: 0;
}

.radius-write-action-page .radius-readiness-action-gap {
  display: block;
  font-size: 1px;
  height: 14px;
  line-height: 14px;
}

.radius-write-action-page .radius-readiness-actions .button {
  display: inline-block;
  font-size: 13px;
  line-height: 1.3;
  padding-bottom: 6px;
  padding-top: 6px;
}

.radius-write-action-page .radius-readiness-button--disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.radius-write-action-page .radius-readiness-action-reason {
  color: var(--body-quiet-color);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.radius-operator-page .aligned .form-row > div {
  width: 100%;
}

.radius-operator-page .checkbox-row {
  align-items: center;
  gap: 7px;
}

.radius-operator-page .checkbox-row input[type="checkbox"] {
  margin: 0;
}

.radius-operator-page .checkbox-row label.vCheckboxLabel {
  color: var(--body-fg);
  min-width: 0;
  padding: 0;
  width: auto;
}

.radius-operator-page .checkbox-row + div.help {
  margin-left: 0;
  padding-left: 24px;
}
