* {
  box-sizing: border-box;
}

body[data-page="module-preferences"] {
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 255, 255, 0.92) 0%, rgba(242, 246, 251, 0.85) 32%, rgba(237, 243, 250, 0.98) 100%),
    linear-gradient(135deg, #eef4fa 0%, #f8fbff 100%);
  color: #10243d;
}

body[data-page="module-preferences"] .main {
  margin-top: 0;
  height: auto;
  min-height: 100vh;
}

.content {
  padding: 16px;
}

.module-prefs-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.module-prefs-shell {
  border: 1px solid rgba(198, 212, 228, 0.95);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 42px rgba(14, 31, 53, 0.09);
  backdrop-filter: blur(10px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100vh - 116px);
}

.module-prefs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0;
}

.module-prefs-head-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 840px;
}

.module-prefs-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.04;
  color: #09203a;
  letter-spacing: -0.02em;
}

.module-prefs-subtitle {
  font-size: 13px;
  line-height: 1.45;
  color: #617992;
  max-width: 640px;
}

.module-prefs-ops {
  border: 1px solid #d8e2ef;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.module-prefs-ops-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.module-prefs-ops-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.module-prefs-ops-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.module-prefs-ops-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid #d8e2ef;
  background: #ffffff;
  color: #506984;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.module-prefs-ops-pill.is-strong {
  background: #123e69;
  border-color: #123e69;
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(18, 62, 105, 0.16);
}

.module-prefs-ops-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, auto));
  gap: 8px;
}

.module-prefs-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 10px;
  border-radius: 14px;
  background: rgba(248, 251, 255, 0.9);
  border: 1px solid #e1e9f3;
  min-width: 0;
}

.module-prefs-stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #70849a;
}

.module-prefs-stat-value {
  font-size: 12px;
  font-weight: 700;
  color: #10243d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-prefs-stat-value.is-recent {
  color: #0f5a36;
}

.prefs-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.prefs-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  position: sticky;
  top: 12px;
  align-self: start;
}

.prefs-nav-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.prefs-nav-title {
  font-size: 18px;
  font-weight: 700;
  color: #10243d;
  line-height: 1.1;
}

.prefs-nav-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: #627891;
}

.prefs-nav-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #123e69;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(18, 62, 105, 0.16);
}

.prefs-nav-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prefs-nav-search-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6c8198;
}

.prefs-nav-search input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid #d8e2ef;
  background: rgba(255, 255, 255, 0.92);
  padding: 11px 12px;
  font: inherit;
  color: #10243d;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.prefs-nav-search input:focus {
  border-color: rgba(14, 165, 233, 0.65);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
  background: #ffffff;
}

.prefs-menu-wrap {
  border: 1px solid #d8e2ef;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(248, 251, 255, 0.98) 0%, rgba(242, 247, 253, 0.98) 100%);
  padding: 10px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  min-height: 0;
}

.prefs-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding-right: 2px;
}

.prefs-menu-empty {
  margin: 4px 0 8px;
  border: 1px dashed #cfd9e6;
  border-radius: 14px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #6c8198;
  background: rgba(255, 255, 255, 0.86);
}

.prefs-item {
  position: relative;
  padding: 11px 12px 11px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #516983;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.prefs-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
  transition: background-color 0.15s ease;
}

.prefs-item:hover {
  background: rgba(255, 255, 255, 0.88);
  color: #294966;
  transform: translateX(2px);
}

.prefs-item.active {
  background: #ffffff;
  color: #123e69;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.prefs-item.active::before {
  background: #20c0d9;
}

.prefs-workspace {
  border: 1px solid #d8e2ef;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.prefs-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #e2e9f3;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  flex-wrap: wrap;
}

.prefs-workspace-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.prefs-workspace-title {
  font-size: 16px;
  font-weight: 700;
  color: #0b223a;
  line-height: 1.1;
}

.prefs-workspace-subtitle {
  font-size: 11px;
  line-height: 1.35;
  color: #6f8398;
}

.prefs-workspace-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #d8e2ef;
  background: #ffffff;
  color: #4f6883;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.prefs-workspace-status.is-recent {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.28);
  color: #166534;
}

.prefs-panel {
  padding: 12px 16px 16px;
  min-height: 0;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.prefs-panel > h4:first-of-type,
.prefs-panel > p:first-of-type {
  display: none;
}

.prefs-section-filter {
  margin-bottom: 10px !important;
  padding: 8px 10px !important;
  border-radius: 12px !important;
  background: #f8fbff !important;
}

.prefs-section-filter .prefs-label {
  margin-bottom: 4px !important;
  font-size: 10px !important;
  letter-spacing: 0.05em !important;
}

.prefs-section-filter input {
  padding: 7px 10px !important;
  border-radius: 10px !important;
}

.prefs-panel h4 {
  font-size: 20px;
  font-weight: 700;
  color: #0b223a;
  margin-bottom: 6px;
}

.prefs-panel p {
  font-size: 13px;
  line-height: 1.6;
  color: #627891;
  margin-bottom: 12px;
}

.prefs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.prefs-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid #e3ebf5;
  background: #f8fbff;
}

.prefs-label {
  font-size: 11px;
  color: #5e748d;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.prefs-field input,
.prefs-field select,
.prefs-field .select-sm,
.prefs-panel input,
.prefs-panel select {
  width: 100%;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid #d8e2ef;
  background: #ffffff;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  color: #10243d;
  outline: none;
}

.prefs-field select,
.prefs-panel select {
  padding-top: 0;
  padding-bottom: 0;
  line-height: normal;
}

.prefs-field input:focus,
.prefs-field select:focus,
.prefs-panel input:focus,
.prefs-panel select:focus {
  border-color: rgba(14, 165, 233, 0.65);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.prefs-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  font-size: 12px;
  color: #516983;
}

.prefs-checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid #e4ebf5;
  background: #ffffff;
}

.prefs-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e4ebf5;
  background: #f8fbff;
  font-size: 12px;
  font-weight: 600;
  color: #516983;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #c9d4e3;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
  transition: transform 0.15s ease;
}

.toggle.on {
  background: #123e69;
}

.toggle.on .toggle-knob {
  transform: translateX(18px);
}

@media (max-width: 1240px) {
  .module-prefs-ops-stats {
    grid-template-columns: repeat(2, minmax(160px, auto));
  }
}

@media (max-width: 1120px) {
  .prefs-layout {
    grid-template-columns: 1fr;
  }

  .prefs-nav {
    position: static;
  }

  .prefs-menu,
  .prefs-panel {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 12px;
  }

  .module-prefs-shell {
    padding: 14px;
  }

  .module-prefs-title {
    font-size: 22px;
  }

  .module-prefs-ops-side,
  .module-prefs-ops-actions,
  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .module-prefs-ops-side .btn,
  .module-prefs-ops-actions .btn,
  .topbar-actions .btn {
    flex: 1;
  }

  .module-prefs-ops-stats {
    grid-template-columns: 1fr;
    width: 100%;
  }
}
