:root {
  color-scheme: dark;
  --bg: #050505;
  --surface: #0d0d0d;
  --surface-2: #141414;
  --border: #272727;
  --text: #f7f7f7;
  --muted: #b4b4b4;
  --red: #ff2028;
  --red-dark: #9e1016;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 0%, rgba(255, 32, 40, .16), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Rubik, Arial, sans-serif;
  overflow-x: hidden;
}

a {
  color: inherit;
  overflow-wrap: anywhere;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  background: rgba(5, 5, 5, .82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 900;
  min-width: 0;
  text-decoration: none;
  letter-spacing: 0;
}

.topbar__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.topbar__links a,
.topbar__links button {
  color: var(--text);
  background: transparent;
  border: 0;
  text-decoration: none;
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card,
.panel-card {
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(20, 20, 20, .95), rgba(8, 8, 8, .96));
  border-radius: 8px;
  box-shadow: 0 22px 80px rgba(0, 0, 0, .28);
}

.auth-card {
  width: min(100%, 520px);
  padding: clamp(1.4rem, 4vw, 2.5rem);
}

.auth-card h1 {
  font-size: 3.35rem;
  line-height: .98;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.auth-card .muted {
  max-width: 36rem;
}

.page {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) 0;
}

.page-heading {
  margin-bottom: 2rem;
}

.page-heading--split {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  color: var(--red);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin: 0 0 .7rem;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 4rem;
  line-height: .94;
}

h2 {
  font-size: 1.55rem;
  margin-bottom: 1rem;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.form {
  display: grid;
  gap: 1rem;
}

.form label {
  display: grid;
  gap: .45rem;
  color: var(--muted);
  font-size: .95rem;
}

.form input,
.form select,
.form textarea,
.filter-form input {
  width: 100%;
  border: 1px solid var(--border);
  background: #050505;
  color: var(--text);
  border-radius: 6px;
  padding: .9rem 1rem;
  outline: none;
}

.form input:focus,
.form select:focus,
.form textarea:focus,
.filter-form input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 32, 40, .18);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--red);
  background: var(--red);
  color: white;
  border-radius: 6px;
  padding: .95rem 1.2rem;
  font-weight: 900;
  line-height: 1.15;
  min-height: 3.2rem;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button--ghost {
  background: transparent;
}

.button--small {
  min-height: 0;
  padding: .55rem .75rem;
  font-size: .85rem;
}

.form-note {
  color: var(--muted);
  line-height: 1.6;
  margin: 1rem 0 0;
}

.form-note a,
.inline-link {
  color: var(--text);
  font-weight: 900;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.alert {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  line-height: 1.6;
}

.alert--error {
  border-color: var(--red-dark);
  background: rgba(255, 32, 40, .08);
}

.alert--success {
  border-color: rgba(65, 220, 128, .35);
  background: rgba(65, 220, 128, .08);
}

code {
  background: #050505;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .35rem;
}

.stat-grid,
.three-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.three-column {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.stat-grid article,
.panel-card {
  min-width: 0;
  padding: 1.2rem;
}

.stat-grid article {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
}

.stat-grid span,
.stack-list span,
table span {
  display: block;
  color: var(--muted);
  font-size: .9rem;
  margin-top: .25rem;
}

.stat-grid strong {
  display: block;
  font-size: 2rem;
  margin-top: .5rem;
  overflow-wrap: anywhere;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0 0 1rem;
}

.filter-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  padding: .65rem 1rem;
  text-decoration: none;
}

.filter-chip.is-active {
  border-color: var(--red);
  color: var(--text);
  background: rgba(255, 32, 40, .12);
}

.search-card {
  background:
    radial-gradient(circle at top right, rgba(255, 32, 40, .13), transparent 28rem),
    linear-gradient(145deg, rgba(20, 20, 20, .97), rgba(8, 8, 8, .98));
  margin-bottom: 1rem;
  padding: 1.25rem;
}

.search-card__head {
  align-items: end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.search-card__head h2 {
  margin-bottom: 0;
}

.search-card__head .muted {
  margin: 0;
  max-width: 430px;
}

.filter-form {
  display: grid;
  gap: .9rem;
}

.search-field {
  display: grid;
  gap: .55rem;
  color: var(--muted);
  position: relative;
}

.search-field label,
.filter-group p {
  color: var(--text);
  font-size: .86rem;
  font-weight: 900;
  margin: 0;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap::before {
  border: 2px solid var(--muted);
  border-radius: 999px;
  content: "";
  height: .72rem;
  left: 1rem;
  opacity: .7;
  position: absolute;
  top: 50%;
  transform: translateY(-58%);
  width: .72rem;
}

.search-input-wrap::after {
  background: var(--muted);
  content: "";
  height: 2px;
  left: 1.72rem;
  opacity: .7;
  position: absolute;
  top: calc(50% + .34rem);
  transform: rotate(45deg);
  width: .5rem;
}

.search-input-wrap input {
  border-color: rgba(255, 255, 255, .12);
  border-radius: 8px;
  font-size: 1rem;
  padding-left: 2.75rem;
}

.search-input-wrap input:focus {
  border-color: var(--red);
}

.live-search-results {
  background: #070707;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .45);
  display: grid;
  left: 0;
  max-height: 360px;
  overflow: auto;
  padding: .45rem;
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  z-index: 20;
}

.live-search-item {
  border-radius: 6px;
  color: var(--text);
  display: grid;
  gap: .35rem;
  padding: .75rem;
  text-decoration: none;
}

.live-search-item:hover,
.live-search-item:focus {
  background: rgba(255, 32, 40, .12);
  outline: none;
}

.live-search-top {
  align-items: center;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

.live-search-badge {
  border: 1px solid rgba(255, 32, 40, .45);
  border-radius: 999px;
  color: var(--text);
  font-size: .78rem;
  padding: .25rem .5rem;
}

.live-search-meta,
.live-search-empty {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

.live-search-empty {
  padding: .75rem;
}

.filter-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .75rem;
}

.filter-group {
  background: rgba(255, 255, 255, .025);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  display: grid;
  gap: .7rem;
  padding: .85rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.check-pill,
.checkbox-row {
  align-items: center;
  display: inline-flex;
  gap: .55rem;
}

.check-pill {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.check-pill span {
  align-items: center;
  display: inline-flex;
  gap: .45rem;
  padding: .55rem .75rem;
}

.check-pill span::before {
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 4px;
  content: "";
  height: .72rem;
  width: .72rem;
}

.check-pill input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.check-pill:has(input:checked),
.check-pill input:checked + span {
  border-color: var(--red);
  color: var(--text);
  background: rgba(255, 32, 40, .12);
}

.check-pill input:checked + span::before {
  background: var(--red);
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px #050505;
}

.checkbox-row input {
  accent-color: var(--red);
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  width: auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin: -1rem 0 1rem;
}

.client-dashboard {
  display: grid;
  gap: 1.1rem;
}

.client-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 1rem;
  align-items: end;
}

.client-hero__copy h1 {
  max-width: 920px;
}

.client-hero__copy .muted {
  max-width: 720px;
}

.client-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.3rem;
}

.client-status-card,
.client-summary-grid article,
.client-section,
.client-tabs {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(20, 20, 20, .92), rgba(8, 8, 8, .95));
}

.client-status-card {
  min-width: 0;
  padding: 1.25rem;
}

.client-status-card span,
.client-summary-grid span,
.section-head span {
  color: var(--red);
  display: block;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .12em;
  margin-bottom: .5rem;
  text-transform: uppercase;
}

.client-status-card strong {
  display: block;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: .95;
  overflow-wrap: anywhere;
}

.client-status-card p,
.section-head p,
.client-summary-grid p {
  color: var(--muted);
  line-height: 1.55;
  margin: .75rem 0 0;
}

.client-tabs {
  display: flex;
  gap: .45rem;
  overflow-x: auto;
  padding: .45rem;
  position: sticky;
  top: 73px;
  z-index: 4;
  backdrop-filter: blur(16px);
}

.client-tab-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  gap: .45rem;
  min-height: 2.75rem;
  padding: .7rem .95rem;
  text-decoration: none;
  white-space: nowrap;
}

.client-tab-link:hover,
.client-tab-link.is-active {
  background: rgba(255, 32, 40, .12);
  border-color: rgba(255, 32, 40, .5);
  color: var(--text);
}

.client-tab-count {
  align-items: center;
  background: var(--red);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: .72rem;
  font-weight: 900;
  justify-content: center;
  line-height: 1;
  min-width: 1.35rem;
  padding: .28rem .42rem;
}

.client-tab-panels {
  min-width: 0;
}

.client-tab-panel {
  display: none;
}

.client-tab-panel.is-active,
.client-tab-panel:target {
  display: block;
}

.client-tab-panels:has(.client-tab-panel:target) .client-tab-panel--default:not(:target) {
  display: none;
}

.client-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.client-summary-grid article {
  min-width: 0;
  padding: 1rem;
}

.client-summary-grid strong {
  display: block;
  font-size: 2.35rem;
  line-height: 1;
}

.client-overview-grid,
.plan-groups {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.client-section {
  min-width: 0;
  padding: 1.15rem;
}

.client-section--wide {
  grid-column: 1 / -1;
}

.section-head {
  margin-bottom: 1rem;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.section-head h3 {
  font-size: 1.2rem;
  line-height: 1.15;
}

.section-head--compact {
  margin-bottom: .85rem;
}

.client-next-list {
  display: grid;
  gap: .75rem;
}

.client-next-item {
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  display: grid;
  gap: .35rem;
  padding: .9rem;
  text-decoration: none;
}

.client-next-item:hover {
  border-color: rgba(255, 32, 40, .5);
  background: rgba(255, 32, 40, .08);
}

.client-next-item span {
  color: var(--muted);
  line-height: 1.45;
}

.client-dashboard .quick-actions {
  margin: 0;
}

.client-dashboard .quick-actions .button {
  flex: 1 1 190px;
}

.item-head {
  display: flex;
  gap: .8rem;
  justify-content: space-between;
  align-items: flex-start;
}

.status-badge {
  align-items: center;
  border: 1px solid rgba(255, 32, 40, .42);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: .75rem;
  font-weight: 900;
  margin-top: 0;
  padding: .3rem .55rem;
}

.resource-item {
  display: grid;
  gap: .75rem;
}

.compact-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: .9rem .7rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .85rem;
}

.stack-list {
  display: grid;
  gap: .8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stack-list li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem;
  background: rgba(255, 255, 255, .02);
  min-width: 0;
}

.stack-list p {
  color: var(--muted);
  line-height: 1.6;
  margin: .65rem 0;
}

.checklist-row {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.checklist-row form {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.message-list {
  max-height: 420px;
  overflow: auto;
}

.message {
  display: grid;
  gap: .35rem;
}

.message--client {
  border-color: rgba(255, 32, 40, .35);
  background: rgba(255, 32, 40, .06);
}

.message--staff {
  border-color: rgba(255, 255, 255, .1);
}

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

@media (max-width: 900px) {
  h1 {
    font-size: 3.1rem;
  }

  .auth-card h1 {
    font-size: 3rem;
  }

  .stat-grid,
  .two-column,
  .three-column {
    grid-template-columns: 1fr;
  }

  .client-hero,
  .client-overview-grid,
  .plan-groups {
    grid-template-columns: 1fr;
  }

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

  .page-heading--split {
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .auth-shell {
    align-items: start;
    padding: 1rem;
  }

  .auth-card {
    padding: 1.15rem;
  }

  .auth-card h1,
  h1 {
    font-size: 2.45rem;
    line-height: 1;
  }

  .page {
    width: min(100% - 1rem, 1240px);
    padding: 1.25rem 0;
  }

  .search-card__head,
  .checklist-row,
  .item-head {
    align-items: stretch;
    flex-direction: column;
  }

  .client-tabs {
    position: static;
  }

  .client-summary-grid {
    grid-template-columns: 1fr;
  }

  .client-hero__actions {
    width: 100%;
  }

  .form-actions,
  .quick-actions,
  .topbar__links {
    width: 100%;
  }

  .button,
  .form-actions .button,
  .quick-actions .button {
    width: 100%;
  }

  .topbar__links {
    gap: .65rem;
  }
}
