/* ============================================================
   SpineLegal Client Portal — design tokens + My Matters
   Sourced from spinelegal-client-portal-design-spec
   ============================================================ */
:root {
  --cp-navy-900: #0F2440;
  --cp-navy-800: #173252;
  --cp-navy-700: #22405F;
  --cp-accent-600: #2563EB;
  --cp-accent-700: #1D4ED8;
  --cp-accent-050: #EFF4FE;
  --cp-bg: #F4F6F8;
  --cp-surface: #FFFFFF;
  --cp-surface-sunken: #F7F9FB;
  --cp-border: #E5E8EC;
  --cp-border-strong: #D5DAE0;
  --cp-text: #1A2433;
  --cp-text-muted: #6B7280;
  --cp-text-faint: #9AA3AF;
  --cp-st-neutral-bg: #EFF1F4;
  --cp-st-neutral-fg: #4B5563;
  --cp-st-progress-bg: #FEF3C7;
  --cp-st-progress-fg: #92400E;
  --cp-st-done-bg: #DCFCE7;
  --cp-st-done-fg: #166534;
  --cp-st-alert-bg: #FEE2E2;
  --cp-st-alert-fg: #991B1B;
  --cp-r-sm: 6px;
  --cp-r-md: 8px;
  --cp-r-lg: 12px;
  --cp-r-pill: 999px;
  --cp-shadow-raise: 0 1px 2px rgba(15, 36, 64, .06);
  --cp-s2: 8px;
  --cp-s3: 12px;
  --cp-s4: 16px;
  --cp-s5: 20px;
  --cp-s6: 24px;
  --cp-s8: 32px;
  --cp-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --cp-page-max: 1180px;
}

.cp-matters {
  font-family: var(--cp-font);
  color: var(--cp-text);
  width: 100%;
  max-width: none;
  -webkit-font-smoothing: antialiased;
}

.cp-matters * { box-sizing: border-box; }

/* Page header */
.cp-pagehead { margin-bottom: var(--cp-s6); }
.cp-pagehead__row {
  display: flex;
  align-items: flex-start;
  gap: var(--cp-s4);
  flex-wrap: wrap;
}
.cp-pagehead h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--cp-navy-900);
}
.cp-pagehead p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--cp-text-muted);
  max-width: 62ch;
}
.cp-pagehead__aside { margin-left: auto; }

/* Search */
.cp-search { position: relative; width: 270px; max-width: 100%; }
.cp-search input {
  width: 100%;
  height: 38px;
  padding: 0 var(--cp-s3) 0 36px;
  font: inherit;
  font-size: 13.5px;
  color: var(--cp-text);
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-strong);
  border-radius: var(--cp-r-md);
  outline: none;
}
.cp-search input::placeholder { color: var(--cp-text-faint); }
.cp-search input:focus {
  border-color: var(--cp-accent-600);
  box-shadow: 0 0 0 3px var(--cp-accent-050);
}
.cp-search svg {
  position: absolute;
  left: 11px;
  top: 11px;
  width: 15px;
  height: 15px;
  color: var(--cp-text-faint);
  pointer-events: none;
}

/* Summary tiles */
.cp-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--cp-s4);
  margin-bottom: var(--cp-s8);
}
.cp-tile {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-lg);
  padding: var(--cp-s5);
  display: flex;
  align-items: center;
  gap: var(--cp-s4);
}
.cp-tile__icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: var(--cp-r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cp-tile__icon svg { width: 18px; height: 18px; }
.cp-tile__icon--accent { background: var(--cp-accent-050); color: var(--cp-accent-700); }
.cp-tile__icon--progress { background: var(--cp-st-progress-bg); color: var(--cp-st-progress-fg); }
.cp-tile__icon--done { background: var(--cp-st-done-bg); color: var(--cp-st-done-fg); }
.cp-tile__num {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--cp-navy-900);
}
.cp-tile__label {
  font-size: 13px;
  color: var(--cp-text-muted);
  margin-top: 2px;
}

/* Filters */
.cp-filters {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  margin-bottom: var(--cp-s4);
  flex-wrap: wrap;
}
.cp-filters__label {
  font-size: 15px;
  font-weight: 600;
  color: var(--cp-navy-900);
  margin-right: var(--cp-s2);
}
.cp-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 var(--cp-s4);
  background: var(--cp-surface);
  border: 1px solid var(--cp-border-strong);
  border-radius: var(--cp-r-pill);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--cp-text-muted);
  cursor: pointer;
  transition: all .12s;
}
.cp-filter:hover { color: var(--cp-navy-900); border-color: var(--cp-text-faint); }
.cp-filter__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--cp-r-pill);
  background: var(--cp-st-neutral-bg);
  color: var(--cp-st-neutral-fg);
  font-size: 11px;
  font-weight: 600;
}
.cp-filter[aria-pressed="true"] {
  background: var(--cp-accent-600);
  border-color: var(--cp-accent-600);
  color: #fff;
}
.cp-filter[aria-pressed="true"] .cp-filter__n {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

/* Matter grid + cards */
.cp-mattergrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--cp-s4);
}
.cp-matter {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-lg);
  padding: var(--cp-s5);
  display: flex;
  flex-direction: column;
  gap: var(--cp-s4);
  transition: border-color .12s, box-shadow .12s;
  height: 100%;
}
.cp-matter:hover {
  border-color: var(--cp-border-strong);
  box-shadow: var(--cp-shadow-raise);
}
.cp-matter__top {
  display: flex;
  align-items: flex-start;
  gap: var(--cp-s3);
}
.cp-matter__icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--cp-r-md);
  background: var(--cp-accent-050);
  color: var(--cp-accent-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cp-matter__icon svg { width: 16px; height: 16px; }
.cp-matter__name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--cp-navy-900);
  line-height: 1.3;
}
.cp-matter__ref {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.cp-matter__chip { margin-left: auto; flex-shrink: 0; }
.cp-matter__stage {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  margin-bottom: 7px;
  gap: var(--cp-s2);
}
.cp-matter__stagename { font-weight: 500; color: var(--cp-text); }
.cp-matter__stagecount {
  color: var(--cp-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cp-matter__foot {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  margin-top: auto;
  flex-wrap: wrap;
}
.cp-matter__link {
  margin-left: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 var(--cp-s2);
  background: transparent;
  color: var(--cp-accent-700);
  border: 1px solid transparent;
  border-radius: var(--cp-r-md);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s;
}
.cp-matter__link:hover { background: var(--cp-accent-050); color: var(--cp-accent-700); }

/* Progress bar */
.cp-bar {
  height: 6px;
  background: var(--cp-st-neutral-bg);
  border-radius: var(--cp-r-pill);
  overflow: hidden;
}
.cp-bar__fill {
  height: 100%;
  background: var(--cp-accent-600);
  border-radius: var(--cp-r-pill);
  transition: width .2s ease;
}

/* Status chips */
.cp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--cp-r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.cp-chip--neutral { background: var(--cp-st-neutral-bg); color: var(--cp-st-neutral-fg); }
.cp-chip--progress { background: var(--cp-st-progress-bg); color: var(--cp-st-progress-fg); }
.cp-chip--done { background: var(--cp-st-done-bg); color: var(--cp-st-done-fg); }
.cp-chip--alert { background: var(--cp-st-alert-bg); color: var(--cp-st-alert-fg); }

/* Action-needed line */
.cp-needs {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: var(--cp-r-pill);
  background: var(--cp-st-progress-bg);
  color: var(--cp-st-progress-fg);
  font-size: 12.5px;
  font-weight: 500;
}
.cp-needs svg { width: 13px; height: 13px; flex: 0 0 13px; }
.cp-needs--clear {
  background: var(--cp-st-neutral-bg);
  color: var(--cp-st-neutral-fg);
}

/* Empty state */
.cp-empty {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-lg);
  padding: var(--cp-s8) var(--cp-s5);
  text-align: center;
  color: var(--cp-text-muted);
  font-size: 14px;
}
.cp-empty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: var(--cp-s4);
  height: 36px;
  padding: 0 var(--cp-s4);
  background: var(--cp-navy-900);
  color: #fff;
  border: 1px solid var(--cp-navy-900);
  border-radius: var(--cp-r-md);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.cp-empty__btn:hover { background: var(--cp-navy-800); }

@media (max-width: 992px) {
  .cp-tiles,
  .cp-mattergrid { grid-template-columns: 1fr; }
  .cp-pagehead__aside { margin-left: 0; width: 100%; }
  .cp-search { width: 100%; }
}

@media (min-width: 993px) and (max-width: 1200px) {
  .cp-mattergrid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   DOCUMENTS
   ============================================================ */
.cp-docs {
  font-family: var(--cp-font);
  color: var(--cp-text);
  width: 100%;
  max-width: none;
  -webkit-font-smoothing: antialiased;
}
.cp-docs__intro { margin-bottom: var(--cp-s5); }
.cp-docs__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--cp-navy-900);
  margin: 0;
}
.cp-docs__subtitle {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  margin-top: 4px;
}

.cp-segment {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: var(--cp-s5);
  background: var(--cp-surface-sunken);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-md);
}
.cp-segment button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 var(--cp-s4);
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cp-text-muted);
  border-radius: var(--cp-r-sm);
  cursor: pointer;
}
.cp-segment button[aria-selected="true"] {
  background: var(--cp-surface);
  color: var(--cp-navy-900);
  font-weight: 600;
  box-shadow: var(--cp-shadow-raise);
}
.cp-segment__badge {
  height: 18px;
  min-width: 18px;
  padding: 0 6px;
  justify-content: center;
  font-size: 11px;
}

.cp-listhead {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  margin-bottom: var(--cp-s3);
  flex-wrap: wrap;
}
.cp-listhead__count { font-size: 13px; color: var(--cp-text-muted); }
.cp-listhead__end { margin-left: var(--cp-s3); display: flex; gap: var(--cp-s3); }

.cp-doclist {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-lg);
  overflow: hidden;
}
.cp-docrow {
  display: flex;
  align-items: center;
  gap: var(--cp-s4);
  padding: var(--cp-s4) var(--cp-s5);
  border-top: 1px solid var(--cp-border);
  transition: background .12s;
}
.cp-docrow:first-child { border-top: 0; }
.cp-docrow:hover { background: var(--cp-surface-sunken); }
.cp-docrow__icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: var(--cp-r-md);
  background: var(--cp-surface-sunken);
  border: 1px solid var(--cp-border);
  color: var(--cp-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cp-docrow__main { min-width: 0; flex: 1; }
.cp-docrow__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--cp-navy-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-docrow__meta {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.cp-docrow__flag {
  font-size: 12.5px;
  color: var(--cp-st-alert-fg);
  margin-top: 3px;
}
.cp-docrow__end {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  flex-shrink: 0;
}
.cp-chip--info { background: var(--cp-accent-050); color: var(--cp-accent-700); }
.cp-metaline {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  margin-top: var(--cp-s3);
}

.cp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 var(--cp-s4);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--cp-r-md);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.cp-btn--sm { height: 32px; font-size: 13px; padding: 0 var(--cp-s3); }
.cp-btn--secondary {
  background: var(--cp-surface);
  color: var(--cp-navy-900);
  border: 1px solid var(--cp-border-strong);
}
.cp-btn--secondary:hover { background: var(--cp-surface-sunken); }
.cp-btn--icon {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  color: var(--cp-text-muted);
}
.cp-btn--icon:hover {
  background: var(--cp-surface-sunken);
  border-color: var(--cp-border);
  color: var(--cp-navy-900);
}
.cp-doc-menu { position: relative; }
.cp-doc-menu .dropdown-menu {
  font-size: 13px;
  border-radius: var(--cp-r-md);
  border-color: var(--cp-border);
  box-shadow: var(--cp-shadow-raise);
}
.cp-doc-menu .dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 14px;
  color: var(--cp-text);
  cursor: pointer;
}
.cp-doc-menu .dropdown-item:hover { background: var(--cp-surface-sunken); }

@media (max-width: 820px) {
  .cp-docrow { flex-wrap: wrap; }
  .cp-docrow__end { width: 100%; margin-left: 52px; }
}

/* ============================================================
   Questionnaire
   ============================================================ */
.cp-q {
  font-family: var(--cp-font);
  color: var(--cp-text);
  width: 100%;
  max-width: none;
  -webkit-font-smoothing: antialiased;
}
.cp-q * { box-sizing: border-box; }

.cp-btn--primary {
  background: var(--cp-navy-900);
  color: #fff;
  border: 1px solid var(--cp-navy-900);
}
.cp-btn--primary:hover {
  background: var(--cp-navy-800);
  border-color: var(--cp-navy-800);
  color: #fff;
}

.cp-qcard {
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-lg);
  box-shadow: var(--cp-shadow-raise);
  margin-bottom: var(--cp-s4);
  overflow: hidden;
}
.cp-qcard__head {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  width: 100%;
  padding: var(--cp-s5);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.cp-qcard[data-open="true"] .cp-qcard__head,
.cp-qcard:has(.cp-qcard__body) .cp-qcard__head {
  border-bottom-color: var(--cp-border);
}
.cp-qcard__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--cp-navy-900);
}
.cp-qcard__chev {
  margin-left: auto;
  display: inline-flex;
  color: var(--cp-text-muted);
  flex-shrink: 0;
}
.cp-qcard__body { padding: var(--cp-s5); }
.cp-qcard__foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--cp-s3);
  padding: var(--cp-s4) var(--cp-s5);
  border-top: 1px solid var(--cp-border);
  background: var(--cp-surface-sunken);
}

.cp-accordion {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-md);
  overflow: hidden;
}
.cp-accordion + .cp-accordion { margin-top: var(--cp-s3); }
.cp-accordion__head {
  display: flex;
  align-items: center;
  gap: var(--cp-s3);
  width: 100%;
  padding: var(--cp-s4);
  background: var(--cp-surface-sunken);
  border: 0;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--cp-navy-900);
  cursor: pointer;
  text-align: left;
}
.cp-accordion__head svg { width: 15px; height: 15px; color: var(--cp-text-muted); flex-shrink: 0; }
.cp-accordion__name { flex: 0 1 auto; }
.cp-accordion__chev { margin-left: auto; }
.cp-accordion__body {
  padding: var(--cp-s5);
  border-top: 1px solid var(--cp-border);
  background: var(--cp-surface);
}

.cp-field + .cp-field { margin-top: var(--cp-s5); }
.cp-field__label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cp-text);
  margin-bottom: 7px;
}
.cp-field__num {
  color: var(--cp-accent-700);
  font-weight: 600;
  margin-right: 2px;
  font-variant-numeric: tabular-nums;
}
.cp-field__req { color: var(--cp-st-alert-fg); }
.cp-field__hint {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  margin-top: 6px;
}
.cp-field__hint-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cp-text-muted);
  margin-bottom: 6px;
}
.cp-field__option { margin-top: 8px; }
.cp-field__control .e-input-group,
.cp-field__control .e-control-wrapper,
.cp-field__control .e-ddl {
  max-width: 520px;
}
.cp-field__reject {
  padding: var(--cp-s3);
  background: var(--cp-st-alert-bg);
  border-radius: var(--cp-r-md);
  border: 1px solid #fecaca;
}

@media (max-width: 640px) {
  .cp-qcard__foot { justify-content: stretch; }
  .cp-qcard__foot .cp-btn { flex: 1 1 auto; }
}

/* ============================================================
   Document requests
   ============================================================ */
.cp-req {
  font-family: var(--cp-font);
  color: var(--cp-text);
  width: 100%;
  max-width: none;
  -webkit-font-smoothing: antialiased;
}
.cp-req * { box-sizing: border-box; }

.cp-drop {
  display: flex;
  flex-direction: column;
  gap: var(--cp-s3);
  padding: var(--cp-s5);
  background: var(--cp-surface-sunken);
  border: 1.5px dashed var(--cp-border-strong);
  border-radius: var(--cp-r-md);
}
.cp-drop:hover {
  border-color: var(--cp-accent-600);
  background: var(--cp-accent-050);
}
.cp-drop__meta {
  font-size: 12.5px;
  color: var(--cp-text-faint);
}
.cp-drop .e-upload,
.cp-drop .e-file-select-wrap {
  margin: 0;
}
.cp-drop .e-file-select-wrap .e-btn,
.cp-drop .e-css.e-btn {
  background: var(--cp-surface) !important;
  color: var(--cp-navy-900) !important;
  border: 1px solid var(--cp-border-strong) !important;
  border-radius: var(--cp-r-md) !important;
  height: 32px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: none !important;
  text-transform: none !important;
}
.cp-drop .e-file-select-wrap .e-btn:hover,
.cp-drop .e-css.e-btn:hover {
  background: var(--cp-surface) !important;
  border-color: var(--cp-accent-600) !important;
}
.cp-drop .e-file-drop {
  font-size: 13.5px;
  color: var(--cp-text-muted);
}

.cp-uploaded { margin-top: var(--cp-s4); }
.cp-uploaded__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--cp-text-muted);
  margin-bottom: 8px;
}
.cp-uploaded__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-uploaded__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--cp-surface-sunken);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-r-md);
}
.cp-uploaded__name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cp-text);
}
.cp-uploaded__reason {
  flex: 1 1 100%;
  font-size: 12.5px;
  color: var(--cp-st-alert-fg);
}
