@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&family=Playfair+Display:wght@600;700&display=swap");

:root {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-alt: #f6f8fb;
  --text: #0b1221;
  --muted: #5b6a84;
  --accent: #0f5fff;
  --accent-strong: #0b49c4;
  --accent-alt: #0fb982;
  --border: #dde4f0;
  --shadow: 0 20px 45px rgba(20, 32, 61, 0.12);
  --radius-lg: 22px;
  --radius-sm: 12px;
  --focus-ring: 0 0 0 3px rgba(15, 95, 255, 0.2);
}

html,
body {
  height: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #f9fbff 0%, #eef2f8 48%, #e7edf7 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

body::before {
  top: -180px;
  right: -120px;
  background: radial-gradient(circle, rgba(15, 95, 255, 0.28), transparent 65%);
}

body::after {
  bottom: -220px;
  left: -160px;
  background: radial-gradient(circle, rgba(15, 185, 130, 0.32), transparent 60%);
}

.navbar {
  position: relative;
  z-index: 1;
  box-shadow: 0 10px 25px rgba(20, 32, 61, 0.08);
  border-bottom: 1px solid rgba(13, 18, 35, 0.08);
}

.layout {
  position: relative;
  z-index: 1;
  display: flex;
  height: calc(100vh - var(--affix-stack-height, 56px));
  min-width: 0;
}

.sidebar {
  flex: 0 0 340px;
  width: 340px;
  min-width: 280px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(246, 248, 251, 0.95));
  border-right: 1px solid var(--border);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 18px 0 35px rgba(18, 29, 55, 0.08);
  transition: width 0.12s ease-out, flex-basis 0.12s ease-out, transform 0.12s ease-out;
}

.sidebar-header {
  padding: 18px 20px 10px;
}

.sidebar-header h1 {
  font-family: "Playfair Display", "Times New Roman", serif;
  font-size: 1.0rem;
  letter-spacing: 0.02em;
  color: #1a2340;
}

.sidebar-body {
  padding: 0 20px 80px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(246, 248, 251, 0.95);
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.sidebar * {
  min-width: 0;
}

.content {
  flex: 1;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.filters-toggle {
  border-radius: 999px;
  white-space: normal;
  line-height: 1.1;
  padding: 0.35rem 0.55rem;
}

.layout.filters-collapsed .sidebar {
  flex-basis: 74px;
  width: 74px;
  min-width: 74px;
  box-shadow: none;
  transform: none;
}

.layout.filters-collapsed .sidebar form {
  display: none !important;
}

.layout.filters-collapsed .sidebar .sidebar-header {
  padding: 12px 8px;
  justify-content: center;
}

.layout.filters-collapsed .sidebar .sidebar-header h1 {
  display: none;
}

.layout.filters-collapsed .sidebar .sidebar-header .filters-toggle {
  width: 100%;
  font-size: 0.72rem;
  padding: 0.28rem 0.32rem;
  border-radius: 0.55rem;
  word-break: break-word;
}

.content h2 {
  font-family: "Playfair Display", "Times New Roman", serif;
  color: #18203a;
  letter-spacing: 0.01em;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(221, 228, 240, 0.7);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(221, 228, 240, 0.7);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-card {
  border-radius: calc(var(--radius-sm) + 4px);
  border: 1px solid var(--border);
  background: linear-gradient(140deg, #ffffff 0%, #f7f9fd 100%);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 25px rgba(15, 24, 44, 0.08);
}

.result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-card__title {
  font-family: "Playfair Display", "Times New Roman", serif;
  font-size: 1.05rem;
  margin: 0;
  color: rgb(70, 124, 179);
}

.result-card__title a {
  color: inherit;
  text-decoration: none;
}

.result-card__title a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.result-card__grid {
  margin: 0;
  display: grid;
  gap: 12px 20px;
  grid-template-columns: 1fr;
}

.result-card__grid div {
  min-width: 0;
}

.result-card__grid dt {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.result-card__grid dd {
  margin: 0;
  font-size: 0.95rem;
  color: #17203a;
  word-break: break-word;
}

.semantic-list {
  max-height: 320px;
  overflow: auto;
}

.table {
  margin: 0;
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-alt);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.70rem;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: #f3f6fb;
}

.table a {
  color: var(--accent-strong);
}

.form-label {
  color: #24304a;
  font-weight: 600;
}

.form-control,
.form-select,
.select2-container {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.select2-container {
  display: block !important;
  box-sizing: border-box;
}

.select2-container .select2-selection {
  max-width: 100% !important;
  box-sizing: border-box;
}

.form-control,
.form-select,
.select2-container--default .select2-selection--single {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.select2-container--default .select2-selection--single {
  height: 38px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  color: var(--text);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border: none;
  box-shadow: 0 10px 25px rgba(15, 95, 255, 0.25);
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, #165dff, #0a40a5);
}

.btn-outline-secondary {
  border-color: rgba(24, 32, 58, 0.18);
  color: #1f2a44;
}

.btn-outline-secondary:hover {
  background: rgba(24, 32, 58, 0.06);
}

.pagination {
  --bs-pagination-active-bg: var(--accent);
  --bs-pagination-active-border-color: var(--accent);
}

.modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.nav-tabs {
  border-bottom: 1px solid var(--border);
}

.nav-tabs .nav-link {
  color: var(--muted);
  font-weight: 600;
}

.nav-tabs .nav-link.active {
  color: var(--text);
  border-color: var(--border) var(--border) var(--surface);
}

th {
  position: sticky;
  top: 0;
}

.rid-modal .modal-dialog,
.tr-modal .modal-dialog,
.nioktr-modal .modal-dialog {
  width: 80vw;
  max-width: 80vw;
}

.rid-modal .modal-content,
.tr-modal .modal-content,
.nioktr-modal .modal-content {
  max-height: 80vh;
}

.rid-modal .modal-body,
.tr-modal .modal-body,
.nioktr-modal .modal-body {
  max-height: calc(80vh - 140px);
  overflow: auto;
}

.rid-modal th,
.tr-modal th,
.nioktr-modal th {
  position: static;
}

.rid-name-col {
  width: 220px;
  max-width: 220px;
}

.rid-name-col a {
  display: block;
  white-space: normal;
  word-break: break-word;
}

.task-col {
  width: 260px;
  max-width: 260px;
}

.task-col a {
  display: block;
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 768px) {
  .layout {
    flex-direction: column;
    height: auto;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    box-shadow: none;
  }

  .content {
    padding: 16px;
  }

  .layout.filters-collapsed .sidebar {
    transform: none;
  }

  .rid-modal .modal-dialog,
  .tr-modal .modal-dialog,
  .nioktr-modal .modal-dialog {
    width: 95vw;
    max-width: 95vw;
  }

  .card-list {
    padding: 12px;
  }

  .result-card {
    padding: 16px;
  }

  .result-card__grid {
    grid-template-columns: 1fr;
  }
}
