:root {
  --bg: #05070b;
  --bg-elevated: #10131a;
  --bg-elevated-soft: #181c25;
  --border-subtle: #272c3a;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.18);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.14);
  --text-main: #f5f7ff;
  --text-muted: #9aa1b8;
  --text-soft: #6f7890;
  --chip-bg: #1f2430;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.6);
  --shadow-subtle: 0 1px 0 rgba(255, 255, 255, 0.03);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #151b2a 0, #05070b 55%);
  color: var(--text-main);
  font-family: var(--font-sans);
}

/* APP SHELL */

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

/* SIDEBAR */

.sidebar {
  background: linear-gradient(180deg, #05070b 0%, #05070b 60%, #07090f 100%);
  border-right: 1px solid #161b27;
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-subtle);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.logo-mark {
  font-weight: 800;
  letter-spacing: 0.06em;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4f8cff, #7b5cff);
  color: white;
}

.logo-text {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
}

.sidebar-nav {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 4px 4px 6px;
}

.nav-item {
  border: none;
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.nav-item:hover {
  background: #171b28;
  color: var(--text-main);
  transform: translateY(-0.5px);
}

.nav-item-active {
  background: linear-gradient(135deg, #191f33, #151b2a);
  color: var(--text-main);
  border: 1px solid #2a3550;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px 6px;
  border-radius: 10px;
  background: rgba(10, 14, 26, 0.9);
  border: 1px solid #171c2b;
}

.sidebar-footer-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.sidebar-footer-user {
  font-size: 13px;
  margin: 0 0 2px;
}

.sidebar-footer-note {
  font-size: 11px;
  color: var(--text-soft);
  margin: 0;
}

/* MAIN */

.main {
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* HEADER */

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.main-header h1 {
  font-size: 22px;
  margin: 0;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.badge {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid #273150;
  background: rgba(22, 26, 40, 0.9);
  color: var(--text-muted);
}

.badge-primary {
  border-color: #4f8cff;
  background: var(--accent-soft);
  color: #d4e0ff;
}

/* KPI ROW */

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

.kpi-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-soft);
  margin: 0 0 2px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  margin: 2px 0;
}

.kpi-value-warning {
  color: var(--danger);
}

.kpi-footnote {
  margin: 0;
  font-size: 11px;
  color: var(--text-soft);
}

/* PANELS */

.middle-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1.1fr);
  gap: 12px;
}

.bottom-row {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(260px, 1.1fr);
  gap: 12px;
}

.panel {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
}

.panel-wide {
  padding: 10px 12px 12px;
}

.panel-narrow,
.panel-notes {
  padding: 10px 12px;
}

.panel-detail {
  padding: 10px 12px 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
}

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

/* FILTERS */

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 11px;
  color: var(--text-soft);
}

select {
  background: #151a24;
  border-radius: var(--radius-sm);
  border: 1px solid #293148;
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 12px;
}

/* PIPELINE TABLE */

.pipeline-table-wrapper {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #232a3a;
  background: #05070b;
}

.pipeline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pipeline-table thead {
  background: #101525;
}

.pipeline-table th,
.pipeline-table td {
  padding: 7px 9px;
  border-bottom: 1px solid #151b29;
}

.pipeline-table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pipeline-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.pipeline-table tbody tr:nth-child(even) {
  background: #090d16;
}

.pipeline-table tbody tr:hover {
  background: #141a29;
}

.pipeline-table tbody tr.selected-row {
  background: #181f32;
}

/* REFERRAL MIX */

.referral-mix-list {
  list-style: none;
  margin: 4px 0 10px;
  padding: 0;
  font-size: 12px;
}

.referral-mix-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #191f2e;
}

.referral-mix-list li span:first-child {
  color: var(--text-muted);
}

.referral-mix-list li span:last-child {
  font-variant-numeric: tabular-nums;
  color: #d4e0ff;
}

.mini-panel h3 {
  margin: 6px 0 4px;
  font-size: 13px;
}

.chip {
  border: none;
  border-radius: 999px;
  padding: 4px 9px;
  margin-right: 6px;
  margin-top: 4px;
  font-size: 11px;
  background: var(--chip-bg);
  color: var(--text-muted);
  cursor: pointer;
}

.chip:hover {
  background: #262c3b;
}

/* DETAIL VIEW */

.detail-empty {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px dashed #30384a;
  color: var(--text-soft);
  font-size: 13px;
}

.detail-content {
  padding: 8px 4px 4px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-intake-id {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 2px;
}

.detail-location {
  font-size: 12px;
  color: var(--text-soft);
  margin: 2px 0 0;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.detail-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 6px;
}

.detail-column h4 {
  margin: 0 0 4px;
  font-size: 13px;
}

.detail-list {
  margin: 0;
  padding: 0;
}

.detail-list div {
  margin-bottom: 4px;
}

.detail-list dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-soft);
}

.detail-list dd {
  margin: 1px 0 0;
  font-size: 12px;
}

/* CHECKLIST */

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 5px;
}

.checklist input {
  margin-top: 2px;
}

/* NOTES PANEL */

.notes-body {
  font-size: 12px;
  color: var(--text-muted);
}

.notes-hint {
  margin-top: 0;
  margin-bottom: 6px;
}

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

/* FOOTER */

.footer {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid #171c2a;
  font-size: 11px;
  color: var(--text-soft);
}

/* UTILS */

.hidden {
  display: none;
}

/* RESPONSIVE */

@media (max-width: 1100px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .middle-row,
  .bottom-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
  .main {
    padding: 12px 12px 14px;
  }
}
