:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --line: #e5eaf3;
  --text: #1f2a44;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --danger-soft: #fef2f2;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.sidebar {
  width: 248px;
  background: #fff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-section {
  margin: 0 6px 10px;
  padding: 10px;
  border: 1px solid #e8eef9;
  border-radius: 12px;
  background: #fbfdff;
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7b8aa3;
}

.project-dropdown-toggle {
  width: 100%;
  border: 1px solid #dbe6f5;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-caret {
  color: #64748b;
  font-size: 12px;
  line-height: 1;
}

.project-dropdown-toggle.open .project-caret {
  transform: rotate(180deg);
}

.project-dropdown-menu {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  transition: max-height 0.24s ease, opacity 0.18s ease, margin-top 0.24s ease;
  will-change: max-height, opacity;
}

.project-dropdown-menu.open {
  max-height: 320px;
  opacity: 1;
  margin-top: 8px;
}

.project-count {
  background: #f1f5f9;
  color: #64748b;
  border-radius: 999px;
  font-size: 10px;
  padding: 2px 7px;
  font-weight: 700;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  margin: 4px 8px 18px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.nav-group-title {
  margin: 16px 10px 8px;
  color: #9ca3af;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin: 2px 4px;
  border-radius: 10px;
  font-size: 14px;
  color: #334155;
}

.nav-item:hover {
  background: #f8fafc;
}

.nav-item.active {
  background: var(--brand-soft);
  color: #1d4ed8;
  font-weight: 600;
}

.nav-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.badge {
  margin-left: auto;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.project-search {
  width: 100%;
  margin-bottom: 7px;
  padding: 7px 9px;
}

.project-list {
  display: grid;
  gap: 4px;
  max-height: 250px;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 11px;
  line-height: 1.2;
}

.project-item:hover {
  background: #f8fafc;
}

.project-item.active {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.project-avatar {
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}

.project-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-actions .btn {
  min-height: 31px;
}

.sidebar-nav {
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  padding: 8px 12px;
  font-weight: 600;
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.btn.disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.main {
  flex: 1;
  min-width: 0;
}

.top-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}

.warning {
  margin: 14px 18px 0;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  color: #991b1b;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 14px 18px;
}

.page-head h1 {
  font-size: 22px;
  margin: 0;
}

.page-head .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.filters {
  margin: 0 18px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

input,
select,
textarea {
  border: 1px solid #d1d9e6;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
  color: #334155;
}

.content {
  margin: 0 18px 18px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.kpi-title {
  font-size: 12px;
  color: var(--muted);
}

.kpi-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 700;
}

.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.placeholder-chart {
  height: 180px;
  border: 1px dashed #cdd6e5;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #edf1f7;
  padding: 10px 8px;
  text-align: left;
  font-size: 13px;
}

th {
  color: #6b7280;
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
}

.session-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.play-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid #bfdbfe;
  color: var(--brand);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #d5deeb;
  background: #fff;
  color: #475569;
  font-size: 13px;
}

.tab.active {
  background: var(--brand-soft);
  color: #1d4ed8;
  border-color: #bfdbfe;
  font-weight: 600;
}

.layout-replay {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 300px;
  gap: 12px;
}

.layout-replay > .panel {
  min-width: 0;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.prop-table {
  width: 100%;
  table-layout: fixed;
}

.prop-table td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.timeline {
  position: relative;
  height: 40px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  margin-top: 10px;
}

.marker {
  position: absolute;
  top: 7px;
  width: 8px;
  height: 24px;
  border-radius: 5px;
  background: #2563eb;
  opacity: 0.8;
  cursor: pointer;
}
.marker-rage { background: #ef4444; }
.marker-dead { background: #f97316; }
.marker-custom { background: #3b82f6; }
.marker-saved { background: #8b5cf6; }

.heatmap-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
}

.heatmap-stage {
  position: relative;
  min-height: 620px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.heatmap-canvas {
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.muted {
  color: var(--muted);
}

.list {
  padding-left: 18px;
  margin: 0;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top, #e8efff, #f4f7fb 55%);
}

.login-card {
  width: min(420px, 92vw);
  border-radius: 16px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.sidebar-toggle {
  display: none;
}

.settings-tabs {
  margin-bottom: 12px;
  padding: 10px 12px;
}

.settings-wrap {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

.settings-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.settings-title {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid #edf1f7;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fbfdff;
}

.setting-row.slim {
  min-height: 54px;
}

.setting-row .chev {
  color: #2563eb;
  font-weight: 700;
  font-size: 20px;
}

.setting-label {
  font-weight: 600;
  color: #1f3a75;
}

.setting-note {
  font-size: 12px;
  color: #72809a;
}

.mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-kpi {
  border: 1px solid #e7eef9;
  border-radius: 12px;
  text-align: center;
  padding: 12px 10px;
  background: #fbfdff;
}

.mini-kpi .v {
  font-weight: 700;
  font-size: 20px;
}

.switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #d7dfea;
  position: relative;
}

.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  top: 2px;
  left: 2px;
}

.switch.on {
  background: #2563eb;
}

.switch.on::after {
  left: 18px;
}

.member-row {
  display: grid;
  grid-template-columns: 40px 1fr 160px 40px;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #edf1f7;
  padding-top: 10px;
  margin-top: 10px;
}

.member-table {
  border: 1px solid #e8eef9;
  border-radius: 12px;
  overflow: hidden;
}

.member-head,
.member-line {
  display: grid;
  grid-template-columns: 44px 1fr 180px 44px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.member-head {
  background: #f8fbff;
  border-bottom: 1px solid #e8eef9;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.member-line {
  border-top: 1px solid #edf2fb;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #dbe6fb;
  background: #f7fbff;
  font-size: 12px;
  color: #2755b5;
  font-weight: 600;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.integration-card {
  border: 1px solid #e7eef9;
  border-radius: 12px;
  min-height: 92px;
  display: grid;
  place-items: center;
  background: #fbfdff;
  color: #29437a;
  font-weight: 600;
}

.cs-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 80;
}

/* Force-hide modal/backdrop when hidden attr is present (prevents click-blocking overlays). */
.cs-modal-backdrop[hidden],
.cs-modal[hidden] {
  display: none !important;
}

.cs-modal {
  width: min(560px, 100%);
  background: #fff;
  border: 1px solid #dbe6f5;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
}

.mini-bar-col {
  flex: 1;
  min-width: 0;
}

.mini-bar {
  width: 100%;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  min-height: 8px;
}

.mini-bar-label {
  margin-top: 6px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
}

.mini-bar-value {
  margin-top: 2px;
  font-size: 11px;
  color: #334155;
  text-align: center;
  font-weight: 600;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
}

.donut-ring {
  width: 132px;
  height: 132px;
  border-radius: 999px;
  position: relative;
  margin: 0 auto;
}

.donut-ring::after {
  content: "";
  position: absolute;
  inset: 26px;
  background: #fff;
  border-radius: 999px;
  border: 1px solid #edf2fb;
}

.legend-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.legend-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

@media (max-width: 1260px) {
  .settings-wrap {
    grid-template-columns: 1fr;
  }
  .mini-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .integration-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1260px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .layout-replay {
    grid-template-columns: 1fr;
  }
  .heatmap-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .sidebar {
    width: 86px;
  }
  .brand span,
  .nav-item .text,
  .nav-group-title,
  .btn.btn-side-label {
    display: none;
  }
  .badge {
    display: none;
  }
  .nav-item {
    justify-content: center;
  }
  .project-search,
  .project-name,
  .sidebar-section-head,
  .project-caret {
    display: none;
  }
  .project-item {
    justify-content: center;
    padding: 6px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 30;
    transition: left 0.2s;
  }
  .sidebar.open {
    left: 0;
    width: 248px;
  }
  .sidebar.open .brand span,
  .sidebar.open .nav-item .text,
  .sidebar.open .nav-group-title,
  .sidebar.open .btn.btn-side-label,
  .sidebar.open .badge {
    display: inline;
  }
  .sidebar.open .project-search,
  .sidebar.open .project-name {
    display: block;
  }
  .sidebar.open .sidebar-section-head {
    display: flex;
  }
  .sidebar.open .project-caret {
    display: inline;
  }
  .sidebar.open .project-item {
    justify-content: flex-start;
  }
  .sidebar-toggle {
    display: inline-flex;
  }
}
