:root {
  --color-bg-deep: #050303;
  --color-bg-primary: #0b0909;
  --color-bg-panel: #151313;
  --color-bg-elevated: #242121;
  --color-border-dark: #352c2a;
  --color-border-metal: #5a504d;
  --color-text-primary: #d1ccca;
  --color-text-secondary: #918987;
  --color-text-muted: #625b59;
  --color-accent-dark: #4a0d0a;
  --color-accent: #d63f35;
  --color-accent-bright: #f05242;
  --color-accent-core: #ffe1d8;
  --color-success: #8fa99a;
  --sidebar-width: 282px;
  --motion-fast: 160ms;
  --motion-normal: 260ms;
  --motion-atmospheric: 1800ms;
  --glow-accent: 0 0 8px rgba(214, 63, 53, 0.65),
    0 0 24px rgba(214, 63, 53, 0.28);
  --shadow-panel: 0 18px 50px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

html {
  min-height: 100%;
  background: var(--color-bg-deep);
  scrollbar-color: var(--color-border-metal) var(--color-bg-deep);
}

body.rfocp-bg.theme-dark {
  min-height: 100vh;
  margin: 0;
  color: var(--color-text-primary);
  background:
    radial-gradient(circle at 55% 10%, rgba(112, 20, 15, 0.16), transparent 36%),
    linear-gradient(180deg, #0d0b0b 0%, var(--color-bg-deep) 58%, #020101 100%);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
}

body.rfocp-bg.theme-dark::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  opacity: 0.25;
  background:
    repeating-linear-gradient(118deg, transparent 0 42px, rgba(255, 255, 255, 0.012) 43px, transparent 44px),
    repeating-linear-gradient(28deg, transparent 0 67px, rgba(133, 123, 120, 0.018) 68px, transparent 70px);
  mix-blend-mode: screen;
}

::selection {
  color: var(--color-accent-core);
  background: var(--color-accent-dark);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-deep);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--color-border-metal), var(--color-border-dark));
  border: 2px solid var(--color-bg-deep);
}

a {
  color: #c8b8b4;
  transition: color var(--motion-fast) ease, opacity var(--motion-fast) ease;
}

a:hover {
  color: var(--color-accent-bright);
  text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6,
.card-header,
.module-title,
.panel-title {
  color: var(--color-text-primary);
  font-family: "Rajdhani", "Inter", sans-serif;
  font-weight: 700;
  letter-spacing: 0.055em;
}

.rf-ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.rf-ambient::before,
.rf-ambient::after {
  content: "";
  position: absolute;
  inset: auto 8% -28% 28%;
  width: 70vw;
  height: 55vh;
  background: radial-gradient(ellipse, rgba(103, 17, 12, 0.15), transparent 64%);
  filter: blur(30px);
  animation: rf-ember-breathe 9s ease-in-out infinite alternate;
}

.rf-ambient::after {
  inset: 0;
  width: auto;
  height: auto;
  opacity: 0.22;
  filter: none;
  background-image:
    radial-gradient(circle at 8% 85%, rgba(240, 82, 66, 0.6) 0 1px, transparent 2px),
    radial-gradient(circle at 33% 73%, rgba(214, 63, 53, 0.45) 0 1px, transparent 2px),
    radial-gradient(circle at 76% 88%, rgba(240, 82, 66, 0.42) 0 1px, transparent 2px),
    radial-gradient(circle at 92% 66%, rgba(214, 63, 53, 0.35) 0 1px, transparent 2px);
  background-size: 260px 240px, 310px 270px, 280px 230px, 370px 290px;
  animation: rf-embers 18s linear infinite;
}

@keyframes rf-ember-breathe {
  to { transform: translate3d(-4%, -5%, 0) scale(1.08); opacity: 0.72; }
}

@keyframes rf-embers {
  to { background-position: 30px -220px, -20px -250px, 40px -210px, -30px -270px; }
}

.rf-shell {
  display: flex;
  min-height: 100vh;
}

.rf-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(21, 18, 18, 0.985), rgba(5, 3, 3, 0.995)),
    var(--color-bg-primary);
  border-right: 1px solid rgba(133, 123, 120, 0.2);
  box-shadow: 22px 0 70px rgba(0, 0, 0, 0.42), inset -1px 0 rgba(214, 63, 53, 0.04);
}

.rf-sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  right: -1px;
  width: 1px;
  height: 34%;
  background: linear-gradient(transparent, var(--color-accent), transparent);
  opacity: 0.7;
  box-shadow: var(--glow-accent);
}

.rf-brand {
  display: flex;
  min-height: 112px;
  align-items: center;
  gap: 14px;
  padding: 24px 24px 20px;
  color: var(--color-text-primary);
  border-bottom: 1px solid rgba(133, 123, 120, 0.16);
  background: linear-gradient(145deg, rgba(69, 59, 57, 0.1), transparent 52%);
}

.rf-brand:hover {
  color: var(--color-accent-core);
}

.rf-brand-mark {
  position: relative;
  display: grid;
  width: 52px;
  height: 60px;
  flex: 0 0 52px;
  place-items: center;
  color: var(--color-accent-core);
  background: linear-gradient(145deg, #292524, #0b0909);
  border: 1px solid var(--color-border-metal);
  clip-path: polygon(50% 0, 100% 19%, 89% 83%, 50% 100%, 11% 83%, 0 19%);
  box-shadow: inset 0 0 18px rgba(214, 63, 53, 0.2);
}

.rf-brand-mark::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 50%;
  width: 1px;
  background: var(--color-accent-bright);
  box-shadow: var(--glow-accent);
}

.rf-brand-mark span {
  position: relative;
  z-index: 1;
  padding: 2px 4px;
  background: #171313;
  font-family: "Rajdhani", sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.rf-brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.rf-brand-copy strong {
  overflow: hidden;
  font-family: "Rajdhani", sans-serif;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.09em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.rf-brand-copy small,
.rf-command-meta small,
.rf-sidebar-foot small {
  color: var(--color-text-muted);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.rf-sidebar-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 24px 10px;
  color: var(--color-text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.rf-sidebar-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--color-border-dark), transparent);
}

.rf-sidebar .menu-inner-box {
  width: auto;
  margin: 0;
  padding: 4px 14px 24px;
  overflow-x: visible;
  overflow-y: auto;
  white-space: normal;
}

.rf-sidebar #navbarResponsive {
  width: 100%;
  flex-direction: column;
  align-items: stretch;
}

.rf-sidebar .navbar-nav,
.rf-sidebar .nav.navbar-nav {
  display: flex;
  width: 100%;
  flex-direction: column;
  margin: 0 !important;
  padding: 0;
}

.rf-sidebar .nav-item {
  width: 100%;
  margin: 2px 0;
}

.rf-sidebar .nav-link {
  position: relative;
  display: flex;
  min-height: 46px;
  align-items: center;
  padding: 11px 14px 11px 16px !important;
  color: var(--color-text-secondary) !important;
  font-family: "Rajdhani", sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  border: 1px solid transparent;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: color var(--motion-fast), background var(--motion-normal), border-color var(--motion-normal), transform var(--motion-fast);
}

.rf-sidebar .nav-link::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 0;
  width: 2px;
  background: var(--color-accent-bright);
  opacity: 0;
  box-shadow: var(--glow-accent);
}

.rf-sidebar .nav-link i {
  width: 21px;
  color: var(--color-text-muted);
  text-align: center;
}

.rf-sidebar .nav-link:hover,
.rf-sidebar .nav-link.active,
.rf-sidebar .dropdown.show > .nav-link {
  color: var(--color-accent-core) !important;
  background: linear-gradient(90deg, rgba(74, 13, 10, 0.65), rgba(36, 33, 33, 0.35));
  border-color: rgba(214, 63, 53, 0.24);
  transform: translateX(2px);
}

.rf-sidebar .nav-link:hover::before,
.rf-sidebar .nav-link.active::before,
.rf-sidebar .dropdown.show > .nav-link::before {
  opacity: 1;
}

.rf-sidebar .dropdown-toggle::after {
  margin-left: auto;
  border-top-color: var(--color-text-muted);
}

.rf-sidebar .dropdown-menu,
.theme-dark .rf-sidebar .dropdown-menu {
  position: static !important;
  width: calc(100% - 12px);
  margin: 3px 0 8px 12px;
  padding: 4px;
  transform: none !important;
  background: rgba(5, 3, 3, 0.82);
  border: 0;
  border-left: 1px solid var(--color-border-dark);
  border-radius: 0;
  box-shadow: none;
}

.rf-sidebar .dropdown-item {
  padding: 9px 12px;
  color: var(--color-text-secondary);
  font-size: 12px;
  white-space: normal;
  border-left: 1px solid transparent;
}

.rf-sidebar .dropdown-item:hover,
.rf-sidebar .dropdown-item.active {
  color: var(--color-accent-core);
  background: rgba(74, 13, 10, 0.44);
  border-left-color: var(--color-accent);
}

.rf-sidebar-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 20px 24px;
  border-top: 1px solid rgba(133, 123, 120, 0.14);
  background: rgba(0, 0, 0, 0.24);
}

.rf-sidebar-foot > span:last-child {
  display: flex;
  flex-direction: column;
}

.rf-sidebar-foot strong {
  color: var(--color-text-secondary);
  font-family: "Rajdhani", sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
}

.rf-status-light {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  background: var(--color-accent-bright);
  transform: rotate(45deg);
  box-shadow: var(--glow-accent);
  animation: rf-status 2.8s ease-in-out infinite;
}

@keyframes rf-status {
  50% { opacity: 0.45; box-shadow: 0 0 4px rgba(214, 63, 53, 0.35); }
}

.rf-workspace {
  display: flex;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  flex-direction: column;
  margin-left: var(--sidebar-width);
}

.rf-commandbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: flex-end;
  padding: 0 28px;
  background: rgba(8, 6, 6, 0.82);
  border-bottom: 1px solid rgba(133, 123, 120, 0.14);
  backdrop-filter: blur(14px);
}

.rf-commandbar::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  width: min(38vw, 520px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(214, 63, 53, 0.72));
}

.rf-command-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.rf-command-meta > span:last-child {
  display: flex;
  flex-direction: column;
}

.rf-command-meta strong {
  color: var(--color-text-secondary);
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.rf-command-line {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-accent));
  box-shadow: 0 0 8px rgba(214, 63, 53, 0.5);
}

.rf-nav-toggle,
.rf-mobile-brand,
.rf-sidebar-backdrop {
  display: none;
}

.rf-main {
  width: 100%;
  flex: 1;
  padding: 30px clamp(18px, 3vw, 48px) 42px;
}

#panel-container {
  width: 100%;
  max-width: 1680px;
  min-height: 220px;
  margin: 0 auto;
}

.rf-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  padding: 14px clamp(18px, 3vw, 48px);
  color: var(--color-text-muted);
  background: rgba(4, 2, 2, 0.72);
  border-top: 1px solid rgba(133, 123, 120, 0.12);
}

.rf-footer span {
  color: var(--color-text-secondary);
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.rf-footer small {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Public gateway */
.rf-main:has(.rf-auth-stage) {
  padding: 0;
}

#panel-container:has(.rf-auth-stage) {
  max-width: none;
  min-height: calc(100vh - 128px);
}

.rf-auth-stage {
  position: relative;
  display: grid;
  min-height: calc(100vh - 128px);
  grid-template-columns: minmax(280px, 1.25fr) minmax(390px, 0.75fr);
  align-items: center;
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(50px, 7vw, 100px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(5, 3, 3, 0.1) 0%, rgba(5, 3, 3, 0.18) 42%, rgba(5, 3, 3, 0.94) 76%, #050303 100%),
    linear-gradient(180deg, rgba(5, 3, 3, 0.12), rgba(5, 3, 3, 0.76)),
    url("../images/codex-fortress.png") center center / cover no-repeat;
}

.rf-auth-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 31% 65%, rgba(214, 63, 53, 0.14), transparent 26%),
    linear-gradient(180deg, transparent 65%, rgba(2, 1, 1, 0.82));
}

.rf-auth-manifest,
.rf-auth-console {
  position: relative;
  z-index: 1;
}

.rf-auth-manifest {
  max-width: 570px;
  align-self: end;
  padding-bottom: 6vh;
  text-shadow: 0 2px 18px #000;
}

.rf-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--color-accent-bright);
  font-family: "Rajdhani", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.rf-eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--color-accent-bright);
  box-shadow: var(--glow-accent);
}

.rf-auth-manifest h1 {
  margin: 15px 0 12px;
  color: #e1dcda;
  font-size: clamp(44px, 5vw, 76px);
  line-height: 0.88;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.rf-auth-manifest h1 em {
  color: var(--color-accent-core);
  font-style: normal;
  text-shadow: 0 0 24px rgba(214, 63, 53, 0.3);
}

.rf-auth-manifest > p {
  max-width: 500px;
  color: #a79e9b;
  font-size: 14px;
}

.rf-manifest-rule {
  display: flex;
  max-width: 480px;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.rf-manifest-rule span {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--color-accent), transparent);
}

.rf-manifest-rule small {
  color: var(--color-text-muted);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.rf-auth-console {
  width: 100%;
  max-width: 470px;
  justify-self: end;
  padding: clamp(28px, 3.4vw, 48px);
  background: linear-gradient(145deg, rgba(36, 33, 33, 0.97), rgba(11, 9, 9, 0.985));
  border: 1px solid rgba(133, 123, 120, 0.28);
  box-shadow: var(--shadow-panel), -12px 0 48px rgba(74, 13, 10, 0.14);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}

.rf-auth-console::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  width: 35%;
  height: 1px;
  background: linear-gradient(90deg, var(--color-accent-bright), transparent);
  box-shadow: var(--glow-accent);
}

.rf-console-heading {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border-dark);
}

.rf-console-heading h2 {
  margin: 8px 0 2px;
  font-size: 32px;
  text-transform: uppercase;
}

.rf-console-heading p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.rf-auth-console .form-group {
  margin-bottom: 18px;
}

.rf-auth-console label {
  margin-bottom: 7px;
  color: var(--color-text-secondary);
  font-family: "Rajdhani", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rf-auth-console .form-control,
.rf-auth-console select,
.rf-auth-console .select2-container,
.rf-auth-console .select-menu {
  width: 100% !important;
}

/* Legacy custom server selector */
.theme-dark .select-menu {
  --background: #080606;
  --text: #d1ccca;
  --icon: #918987;
  --icon-active: #f05242;
  --list: #151313;
  --list-text: #918987;
  --list-text-hover: #ffe1d8;
  min-height: 44px;
  border: 1px solid var(--color-border-dark);
  border-radius: 0;
  background: rgba(5, 3, 3, 0.92);
}

.theme-dark .select-menu .button {
  min-height: 42px;
  padding: 10px 38px 10px 12px;
  color: var(--color-text-primary);
  background: rgba(5, 3, 3, 0.92);
  border-radius: 0;
}

.theme-dark .select-menu > ul {
  color: var(--color-text-secondary);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-metal);
  border-radius: 0;
  box-shadow: var(--shadow-panel);
}

.theme-dark .select-menu > ul li:hover,
.theme-dark .select-menu > ul li.active {
  color: var(--color-accent-core);
  background: rgba(214, 63, 53, 0.12);
}

.rf-auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 26px;
}

.rf-auth-actions .btn,
.rf-auth-actions a.btn {
  width: 100%;
  margin: 0 !important;
}

.rf-auth-actions .btn-index {
  grid-column: span 1;
}

/* Core surfaces */
.theme-dark .card,
.theme-dark .panel,
.theme-dark .modal-content,
.theme-dark .list-group-item,
.theme-dark .well,
.theme-dark .jumbotron {
  color: var(--color-text-primary);
  background: linear-gradient(145deg, rgba(39, 35, 34, 0.96), rgba(15, 13, 13, 0.98)) !important;
  border: 1px solid rgba(133, 123, 120, 0.22) !important;
  border-radius: 0 !important;
  box-shadow: var(--shadow-panel);
}

.theme-dark .card,
.theme-dark .panel,
.theme-dark .modal-content {
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
}

.theme-dark .card-header,
.theme-dark .panel-heading,
.theme-dark .modal-header {
  color: var(--color-text-primary);
  background: linear-gradient(90deg, rgba(69, 59, 57, 0.25), rgba(11, 9, 9, 0.2)) !important;
  border-bottom: 1px solid rgba(133, 123, 120, 0.2) !important;
}

.theme-dark .card-header h1,
.theme-dark .card-header h2,
.theme-dark .card-header h3,
.theme-dark .card-header h4,
.theme-dark .panel-heading h1,
.theme-dark .panel-heading h2,
.theme-dark .panel-heading h3,
.theme-dark .panel-heading h4 {
  margin: 0;
  text-transform: uppercase;
}

.module-title {
  position: relative;
  display: inline-block;
  padding: 0 0 10px;
  font-size: clamp(22px, 2.4vw, 34px);
  text-transform: uppercase;
}

.module-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 52px;
  height: 2px;
  background: var(--color-accent);
  box-shadow: var(--glow-accent);
  transform: translateX(-50%);
}

.theme-dark hr {
  border-top-color: var(--color-border-dark);
}

/* Forms */
.theme-dark .form-control,
.theme-dark input[type="text"],
.theme-dark input[type="password"],
.theme-dark input[type="email"],
.theme-dark input[type="number"],
.theme-dark input[type="search"],
.theme-dark textarea,
.theme-dark select,
.theme-dark .custom-select,
.theme-dark .select2-container .select2-choice,
.theme-dark .select2-container-multi .select2-choices {
  min-height: 44px;
  color: var(--color-text-primary) !important;
  background: rgba(5, 3, 3, 0.82) !important;
  border: 1px solid var(--color-border-dark) !important;
  border-radius: 0 !important;
  box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.25) !important;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background var(--motion-fast);
}

.theme-dark .form-control:focus,
.theme-dark input:focus,
.theme-dark textarea:focus,
.theme-dark select:focus,
.theme-dark .select2-container-active .select2-choice {
  color: var(--color-accent-core) !important;
  background: #090606 !important;
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 2px rgba(214, 63, 53, 0.12), inset 0 0 16px rgba(74, 13, 10, 0.15) !important;
  outline: none !important;
}

.theme-dark .form-control::placeholder,
.theme-dark input::placeholder,
.theme-dark textarea::placeholder {
  color: var(--color-text-muted);
}

.theme-dark .input-group-text {
  color: var(--color-text-secondary);
  background: var(--color-bg-elevated);
  border-color: var(--color-border-dark);
  border-radius: 0;
}

.theme-dark label {
  color: var(--color-text-secondary);
}

/* Buttons */
.theme-dark .btn {
  min-height: 40px;
  padding: 9px 16px;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  border-radius: 0 !important;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  transition: transform var(--motion-fast), box-shadow var(--motion-normal), background var(--motion-fast), border-color var(--motion-fast);
}

.theme-dark .btn:hover {
  transform: translateY(-1px);
}

.theme-dark .btn-primary,
.theme-dark .btn-danger {
  color: #fff1ed;
  background: linear-gradient(180deg, #b72c25, #6b1511) !important;
  border: 1px solid #e34c40 !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.16), 0 0 18px rgba(214, 63, 53, 0.2);
}

.theme-dark .btn-primary:hover,
.theme-dark .btn-danger:hover {
  color: #fff;
  background: linear-gradient(180deg, #d83c32, #811b16) !important;
  box-shadow: var(--glow-accent);
}

.theme-dark .btn-secondary,
.theme-dark .btn-success,
.theme-dark .btn-warning,
.theme-dark .btn-info,
.theme-dark .btn-dark,
.theme-dark [class*="btn-outline-"] {
  color: var(--color-text-primary) !important;
  background: linear-gradient(180deg, #2c2928, #151313) !important;
  border: 1px solid var(--color-border-metal) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05);
}

.theme-dark .btn-secondary:hover,
.theme-dark .btn-success:hover,
.theme-dark .btn-warning:hover,
.theme-dark .btn-info:hover,
.theme-dark .btn-dark:hover,
.theme-dark [class*="btn-outline-"]:hover {
  color: var(--color-accent-core) !important;
  background: linear-gradient(180deg, #383230, #1a1413) !important;
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 14px rgba(214, 63, 53, 0.16);
}

.theme-dark .btn:disabled,
.theme-dark .btn.disabled {
  filter: grayscale(0.7);
  opacity: 0.48;
}

/* Tables and technical data */
.theme-dark .table {
  color: var(--color-text-primary);
  background: rgba(11, 9, 9, 0.7);
}

.theme-dark .table thead th,
.theme-dark .table .table-info th,
.theme-dark .table .table-info td,
.theme-dark .thead,
.theme-dark .thead-dark th {
  color: #c8c1bf !important;
  background: linear-gradient(180deg, #2a2625, #191616) !important;
  border-color: var(--color-border-metal) !important;
  font-family: "Rajdhani", sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-dark .table td,
.theme-dark .table th {
  border-color: rgba(90, 80, 77, 0.34) !important;
}

.theme-dark .table-striped tbody tr:nth-of-type(odd) {
  background: rgba(255, 255, 255, 0.018);
}

.theme-dark .table-hover tbody tr:hover {
  color: var(--color-accent-core);
  background: rgba(74, 13, 10, 0.26);
}

.theme-dark .dataTables_wrapper,
.theme-dark .dataTables_info,
.theme-dark .dataTables_length,
.theme-dark .dataTables_filter {
  color: var(--color-text-secondary);
}

.theme-dark .page-item .page-link {
  color: var(--color-text-secondary);
  background: var(--color-bg-panel) !important;
  border-color: var(--color-border-dark) !important;
  border-radius: 0 !important;
}

.theme-dark .page-item.active .page-link,
.theme-dark .page-item .page-link:hover {
  color: var(--color-accent-core);
  background: var(--color-accent-dark) !important;
  border-color: var(--color-accent) !important;
}

/* Navigation inside modules */
.theme-dark .nav-tabs,
.theme-dark .nav-pills {
  border-color: var(--color-border-dark);
}

.theme-dark .nav-tabs .nav-link,
.theme-dark .nav-pills .nav-link {
  color: var(--color-text-secondary);
  background: transparent;
  border-color: transparent;
  border-radius: 0;
}

.theme-dark .nav-tabs .nav-link.active,
.theme-dark .nav-pills .nav-link.active,
.theme-dark .nav-tabs .nav-link:hover,
.theme-dark .nav-pills .nav-link:hover {
  color: var(--color-accent-core);
  background: rgba(74, 13, 10, 0.36);
  border-color: transparent transparent var(--color-accent);
}

.theme-dark .badge {
  border-radius: 0;
  font-weight: 600;
}

.theme-dark .badge-primary,
.theme-dark .badge-danger {
  color: var(--color-accent-core);
  background: var(--color-accent-dark);
  border: 1px solid rgba(214, 63, 53, 0.32);
}

.theme-dark .badge-success {
  color: #d8e4dc;
  background: #29362f;
}

.theme-dark .alert {
  color: var(--color-text-primary);
  background: rgba(21, 19, 19, 0.94);
  border: 1px solid var(--color-border-metal);
  border-left: 3px solid var(--color-accent);
  border-radius: 0;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.theme-dark .alert-success { border-left-color: var(--color-success); }
.theme-dark .alert-warning { border-left-color: #b78a52; }
.theme-dark .alert-info { border-left-color: var(--color-border-metal); }

.theme-dark .close {
  color: var(--color-text-primary);
  text-shadow: none;
}

.theme-dark .modal-backdrop.show {
  opacity: 0.82;
}

.theme-dark .dropdown-menu:not(.gamecp-header-submenu),
.theme-dark .select2-drop,
.theme-dark .select2-dropdown-open .select2-choice {
  color: var(--color-text-primary);
  background: var(--color-bg-panel) !important;
  border-color: var(--color-border-metal) !important;
  border-radius: 0 !important;
  box-shadow: var(--shadow-panel);
}

/* Keep semantic race and item artwork intact */
.theme-dark .sprite,
.theme-dark .equipment-bg-black,
.theme-dark .popover-content {
  background-color: #0c0a0a;
}

@media (min-width: 992px) {
  .rf-sidebar #navbarResponsive.collapse {
    display: flex !important;
  }
}

@media (max-width: 991.98px) {
  :root { --sidebar-width: 278px; }

  .rf-sidebar {
    transform: translateX(-102%);
    transition: transform var(--motion-normal) ease;
  }

  body:has(#navbarResponsive.show) .rf-sidebar,
  body:has(#navbarResponsive.collapsing) .rf-sidebar {
    transform: translateX(0);
  }

  .rf-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1030;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(0, 0, 0, 0.74);
    border: 0;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(3px);
    transition: opacity var(--motion-normal);
  }

  body:has(#navbarResponsive.show) .rf-sidebar-backdrop,
  body:has(#navbarResponsive.collapsing) .rf-sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .rf-workspace {
    width: 100%;
    margin-left: 0;
  }

  .rf-commandbar {
    justify-content: space-between;
    padding: 0 18px;
  }

  .rf-nav-toggle {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 11px;
    place-content: center;
    gap: 5px;
    color: var(--color-text-primary);
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border-metal);
    clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  }

  .rf-nav-toggle span {
    display: block;
    width: 18px;
    height: 1px;
    background: var(--color-text-primary);
  }

  .rf-mobile-brand {
    display: block;
    color: var(--color-text-primary);
    font-family: "Rajdhani", sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .rf-command-meta { display: none; }

  .rf-auth-stage {
    min-height: calc(100vh - 128px);
    grid-template-columns: 1fr;
    padding: 56px clamp(20px, 7vw, 70px);
    background-position: 36% center;
  }

  .rf-auth-manifest {
    max-width: 480px;
    align-self: start;
    padding: 0;
  }

  .rf-auth-manifest h1 { font-size: clamp(42px, 9vw, 64px); }

  .rf-auth-console {
    max-width: 520px;
    justify-self: end;
  }
}

@media (max-width: 575.98px) {
  body.rfocp-bg.theme-dark { font-size: 13px; }

  .rf-main { padding: 18px 12px 28px; }

  .rf-auth-stage {
    min-height: calc(100vh - 120px);
    gap: 32px;
    padding: 42px 14px;
    background-position: 30% center;
  }

  .rf-auth-stage::before {
    background: linear-gradient(180deg, rgba(5, 3, 3, 0.42), rgba(5, 3, 3, 0.94) 52%, #050303 100%);
  }

  .rf-auth-manifest {
    padding: 0 14px;
  }

  .rf-auth-manifest h1 { font-size: 42px; }
  .rf-auth-manifest > p { display: none; }

  .rf-auth-console {
    padding: 28px 22px 32px;
  }

  .rf-auth-actions { grid-template-columns: 1fr; }

  .rf-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .theme-dark .card,
  .theme-dark .panel,
  .theme-dark .modal-content {
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
