:root {
  color-scheme: dark;
  --bg: #070b1d;
  --panel: rgba(12, 18, 40, 0.9);
  --panel-2: rgba(16, 24, 52, 0.94);
  --line: rgba(102, 255, 204, 0.14);
  --line-strong: rgba(102, 255, 204, 0.24);
  --text: #eef5ff;
  --muted: #9eaccc;
  --accent: #63ffd1;
  --accent-2: #4aa3ff;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(43, 106, 255, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(99, 255, 209, 0.1), transparent 28%),
    linear-gradient(180deg, #050816 0%, #080d1f 45%, #060914 100%);
  color: var(--text);
}

a {
  text-decoration: none;
}

.crm-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
}

.crm-sidebar {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(8, 13, 29, 0.92);
  padding: 14px;
}

.crm-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.crm-brand-copy {
  min-width: 0;
}

.crm-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111d;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.crm-brand-title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.crm-brand-subtitle {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  flex: 0 0 auto;
}

.crm-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.crm-nav-link.active {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(99, 255, 209, 0.08);
}

.crm-nav-link.is-muted {
  opacity: 0.58;
  cursor: default;
}

.crm-nav-icon {
  width: 18px;
  text-align: center;
  font-weight: 800;
  flex: 0 0 auto;
}

.crm-nav-text {
  white-space: nowrap;
}

.crm-main {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.crm-topbar,
.crm-filters-card,
.table-card,
.empty-card,
.info-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(13, 20, 44, 0.94), rgba(10, 15, 32, 0.92));
  box-shadow: var(--shadow);
  border-radius: 16px;
}

.crm-topbar,
.crm-filters-card,
.table-card,
.empty-card,
.info-card {
  padding: 12px;
}

.crm-badge,
.section-badge {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(99, 255, 209, 0.08);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 8px;
}

.crm-title,
.section-title {
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.crm-title {
  font-size: 22px;
}

.section-title {
  font-size: 16px;
}

.crm-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.rop-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.rop-filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.compact-field .field-label {
  font-size: 10px;
}

.field-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  outline: none;
  font-size: 12px;
}

input:focus,
select:focus {
  border-color: rgba(99, 255, 209, 0.45);
  box-shadow: 0 0 0 4px rgba(99, 255, 209, 0.08);
}

.filters-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.compact-actions {
  align-self: end;
}

.primary-btn,
.ghost-btn,
.toggle-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 12px;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111d;
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.toggle-filter-btn {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.toggle-filter-btn.is-active {
  border-color: var(--line-strong);
  background: rgba(99, 255, 209, 0.08);
  color: var(--accent);
}

.filter-popover-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.range-popover {
  display: none;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.range-popover.is-open {
  display: grid;
}

.summary-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.summary-pill {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-pill span {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-pill strong {
  font-size: 18px;
  font-weight: 900;
  flex: 0 0 auto;
}

.summary-pill-soft {
  background: rgba(255, 255, 255, 0.03);
}

.summary-pill-blue {
  border-color: rgba(74, 163, 255, 0.18);
}

.compact-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.compact-list-head,
.compact-list-row {
  display: grid;
  grid-template-columns: 64px 110px 80px minmax(220px, 1.5fr) 140px 90px 90px;
  gap: 8px;
  align-items: center;
}

.compact-list-head {
  padding: 0 10px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.compact-list-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.compact-list-row {
  padding: 9px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transition: 0.16s ease;
  min-height: 50px;
}

.compact-list-row:hover {
  border-color: var(--line-strong);
  background: rgba(99, 255, 209, 0.05);
}

.row-main {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.row-small {
  font-size: 10px;
}

.empty-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}

.empty-text {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.info-card-wide {
  grid-column: 1 / -1;
}

.card-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-lines > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-lines span {
  color: var(--muted);
  font-size: 12px;
}

.card-lines strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.files-placeholder {
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

@media (max-width: 1199px) {
  .compact-list-head {
    display: none;
  }

  .compact-list-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
  }
}

@media (min-width: 1200px) {
  .crm-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .crm-sidebar {
    min-height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 0;
    position: sticky;
    top: 0;
  }

  .crm-shell.is-collapsed {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .crm-shell.is-collapsed .crm-brand-copy,
  .crm-shell.is-collapsed .crm-nav-text {
    display: none;
  }

  .crm-shell.is-collapsed .crm-nav {
    flex-direction: column;
  }

  .crm-shell.is-collapsed .crm-nav-link {
    justify-content: center;
    padding: 0;
  }

  .crm-shell.is-collapsed .crm-sidebar-top {
    flex-direction: column;
    align-items: center;
  }

  .crm-shell.is-collapsed .crm-brand {
    justify-content: center;
  }

  .crm-shell.is-collapsed .sidebar-toggle {
    width: 40px;
  }

  .crm-main {
    padding: 14px;
    gap: 10px;
  }

  .rop-filters-grid {
    grid-template-columns:
      112px
      1fr
      1fr
      1fr
      132px
      132px
      auto;
    align-items: start;
  }

  .range-popover {
    grid-template-columns: 1fr 1fr;
  }

  .summary-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: 1fr 1fr;
  }
}
