:root {
  --bg: #f3f8fb;
  --surface: #ffffff;
  --surface-soft: #eef8f8;
  --ink: #282958;
  --muted: #667085;
  --line: #dbe8ee;
  --nav: #ffffff;
  --nav-soft: #eef9f9;
  --teal: #39bbb8;
  --teal-dark: #159693;
  --blue: #046bd2;
  --navy: #282958;
  --rose: #b8445b;
  --amber: #b06f16;
  --green: #23714f;
  --shadow: 0 18px 45px rgba(40, 41, 88, 0.11);
  --radius: 8px;
  --radius-sm: 6px;
  --sidebar-rail: 14px;
  --sidebar-open: 292px;
  --font: "Montserrat Alternates", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(57, 187, 184, 0.07), rgba(255, 255, 255, 0) 340px),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  z-index: 12;
  width: var(--sidebar-rail);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  background: var(--nav);
  color: var(--navy);
  border-right: 1px solid var(--line);
  box-shadow: 10px 0 34px rgba(40, 41, 88, 0.05);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 180ms ease, box-shadow 180ms ease;
}

.sidebar:before {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 4px;
  background: var(--teal);
  content: "";
}

.sidebar:hover,
.sidebar:focus-within {
  width: var(--sidebar-open);
  box-shadow: 18px 0 44px rgba(40, 41, 88, 0.14);
}

.sidebar:not(:hover):not(:focus-within) {
  padding-right: 0;
  padding-left: 0;
}

.brand-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  min-width: calc(var(--sidebar-open) - 28px);
  padding: 10px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: min(220px, 100%);
  max-width: none;
  height: auto;
  display: block;
  transition: width 180ms ease, transform 180ms ease;
}

.sidebar:not(:hover):not(:focus-within) .brand-logo {
  width: 172px;
  transform: translateX(-2px);
}

.sidebar:not(:hover):not(:focus-within) .brand-block,
.sidebar:not(:hover):not(:focus-within) .side-nav,
.sidebar:not(:hover):not(:focus-within) .sidebar-footer,
.sidebar:not(:hover):not(:focus-within) .brand-block > div {
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.brand-block h1 {
  margin: 2px 0 0;
  color: var(--navy);
  font-size: 19px;
  line-height: 1.1;
  display: none;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.72;
}

.side-nav {
  display: grid;
  gap: 3px;
  min-width: calc(var(--sidebar-open) - 28px);
}

.nav-button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #334155;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.sidebar:not(:hover):not(:focus-within) .nav-button {
  width: 48px;
  grid-template-columns: 34px;
  justify-content: center;
  padding: 0 7px;
}

.sidebar:not(:hover):not(:focus-within) .nav-button span:not(.nav-icon) {
  display: none;
}

.nav-button:hover,
.nav-button.active {
  background: var(--nav-soft);
  color: var(--navy);
}

.nav-button.active {
  box-shadow: inset 4px 0 0 var(--teal);
}

.nav-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 5px;
  background: rgba(57, 187, 184, 0.12);
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
}

.nav-count {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--teal);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(57, 187, 184, 0.25);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(57, 187, 184, 0.12), rgba(4, 107, 210, 0.06));
  min-width: calc(var(--sidebar-open) - 28px);
  transition: opacity 160ms ease;
}

.sidebar:not(:hover):not(:focus-within) .sidebar-footer {
  opacity: 0;
  pointer-events: none;
}

.sidebar-footer strong,
.sidebar-footer span {
  display: block;
}

.sidebar-footer strong {
  margin-top: 8px;
}

.sidebar-footer span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 74px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 132px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

.topbar-brand img {
  width: 132px;
  height: auto;
}

.topbar-search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  max-width: 780px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(40, 41, 88, 0.04);
}

.topbar-search span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button,
.profile-button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  min-height: 38px;
  border-radius: var(--radius-sm);
  font-weight: 750;
}

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy);
}

.icon-button:hover,
.secondary-button:hover,
.profile-button:hover {
  border-color: rgba(57, 187, 184, 0.45);
  background: #f6fcfc;
}

.notification-button {
  width: 42px;
  padding: 0;
}

.bell-svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notification-button.has-pending {
  border-color: rgba(57, 187, 184, 0.28);
  background: #eafafa;
  color: var(--teal-dark);
}

.notification-button.has-pending:after {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #d92d20;
  content: "";
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.profile-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--navy);
}

.save-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #e5f7f7;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.view-root {
  padding: 22px;
}

.view-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.view-header h2 {
  margin: 4px 0 0;
  color: var(--navy);
  font-size: 30px;
  letter-spacing: 0;
}

.view-header p {
  max-width: 920px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  padding: 0 14px;
}

.primary-button {
  border: 1px solid var(--teal-dark);
  background: var(--teal);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(184, 68, 91, 0.3);
  background: #fff1f4;
  color: var(--rose);
}

.ghost-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--teal-dark);
}

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

.metric-card,
.panel,
.table-panel,
.detail-card,
.module-card,
.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(40, 41, 88, 0.05);
}

.metric-card {
  padding: 14px;
}

.metric-card.kpi-action {
  width: 100%;
  appearance: none;
  text-align: left;
}

.metric-card.kpi-action:hover,
.metric-card.kpi-action:focus-visible {
  border-color: rgba(57, 187, 184, 0.55);
  box-shadow: 0 14px 34px rgba(40, 41, 88, 0.1);
  transform: translateY(-1px);
}

.metric-card.kpi-action small:after {
  content: " | Click to view";
  color: var(--teal-dark);
  font-weight: 800;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.metric-card.attention {
  border-color: rgba(184, 68, 91, 0.28);
  background: linear-gradient(135deg, #fff7f8, #ffffff);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 14px;
  margin-top: 14px;
}

.panel,
.chart-card {
  padding: 16px;
}

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

.panel-header h3 {
  margin: 0;
  font-size: 17px;
}

.panel-header span {
  color: var(--muted);
  font-size: 13px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.field,
.field-wide {
  display: grid;
  gap: 6px;
}

.field label,
.field-wide label {
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.field-wide input,
.field-wide select,
.field-wide textarea,
.filter-row select,
.filter-row input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--navy);
  padding: 8px 10px;
  outline-color: var(--teal);
  box-shadow: 0 1px 2px rgba(40, 41, 88, 0.04);
}

.field textarea,
.field-wide textarea {
  min-height: 92px;
  resize: vertical;
}

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

.form-grid .field-wide {
  grid-column: 1 / -1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 850;
  padding: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.tag.green {
  background: #e5f5ec;
  color: var(--green);
}

.tag.blue {
  background: #eaf2fb;
  color: var(--blue);
}

.tag.amber {
  background: #fff4df;
  color: var(--amber);
}

.tag.rose {
  background: #fff0f3;
  color: var(--rose);
}

.tag.teal {
  background: #dff6f3;
  color: var(--teal-dark);
}

.tag.dark {
  background: #e8eeee;
  color: #34413e;
}

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

.progress-list,
.timeline,
.compact-list,
.template-list,
.audit-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eeee;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 218px;
  padding-top: 12px;
}

.mini-bar {
  position: relative;
  flex: 1;
  min-width: 20px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--teal), var(--navy));
}

.mini-bar span {
  position: absolute;
  right: 0;
  bottom: -22px;
  left: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.funnel {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 128px 1fr 42px;
  gap: 10px;
  align-items: center;
}

.funnel-bar {
  min-height: 34px;
  border-radius: 5px;
  background: var(--teal);
}

.attention-list article,
.compact-list article,
.template-list article,
.audit-list article,
.timeline article {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.attention-list article + article {
  margin-top: 8px;
}

.attention-list h4,
.compact-list h4,
.template-list h4,
.timeline h4 {
  margin: 0 0 5px;
  font-size: 14px;
}

.attention-list p,
.compact-list p,
.template-list p,
.timeline p,
.audit-list p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 14px;
}

.layout-three {
  display: grid;
  grid-template-columns: 0.85fr 1.1fr 0.75fr;
  gap: 14px;
}

.detail-card {
  padding: 16px;
}

.lead-identity {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.lead-identity h3 {
  margin: 0;
  font-size: 22px;
}

.lead-identity p {
  margin: 4px 0 0;
  color: var(--muted);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.info-item {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #f5fbfc;
}

.info-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.info-item strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.timeline article {
  position: relative;
  padding-left: 38px;
}

.timeline article:before {
  position: absolute;
  top: 14px;
  left: 12px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: #e1f8f8;
  color: var(--teal);
  content: "";
}

.task-stack {
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.task-item strong,
.task-item span {
  display: block;
}

.task-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

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

.module-card {
  padding: 14px;
}

.module-card h3 {
  margin: 0 0 8px;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-root {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(40, 41, 88, 0.42);
}

.modal-root[hidden] {
  display: none;
}

.modal {
  width: min(860px, 100%);
  max-height: min(840px, calc(100vh - 44px));
  overflow: auto;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid,
  .layout-two,
  .layout-three {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    overflow-x: visible;
  }

  .sidebar:hover,
  .sidebar:focus-within {
    width: auto;
    box-shadow: 10px 0 34px rgba(40, 41, 88, 0.05);
  }

  .sidebar:before {
    display: none;
  }

  .brand-block,
  .side-nav,
  .sidebar-footer {
    min-width: 0;
  }

  .sidebar:not(:hover):not(:focus-within) .brand-logo {
    width: min(220px, 100%);
    transform: none;
  }

  .sidebar:not(:hover):not(:focus-within) .brand-block,
  .sidebar:not(:hover):not(:focus-within) .side-nav,
  .sidebar:not(:hover):not(:focus-within) .sidebar-footer,
  .sidebar:not(:hover):not(:focus-within) .brand-block > div {
    height: auto;
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar:not(:hover):not(:focus-within) .nav-button {
    width: 100%;
    grid-template-columns: 34px 1fr auto;
    justify-content: stretch;
    padding: 0 10px 0 6px;
  }

  .sidebar:not(:hover):not(:focus-within) .nav-button span:not(.nav-icon) {
    display: inline-flex;
  }

  .sidebar:not(:hover):not(:focus-within) .sidebar-footer {
    opacity: 1;
    pointer-events: auto;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .view-header {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    overflow-x: auto;
  }

  .form-grid,
  .info-grid,
  .module-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
