:root {
  color-scheme: light;
  --ink: #16243c;
  --muted: #69758b;
  --line: #dde4ef;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --indigo: #3847a7;
  --indigo-soft: #e9ebff;
  --blue: #2878c8;
  --blue-soft: #e8f3ff;
  --teal: #168a83;
  --teal-soft: #ddf7f2;
  --amber: #a66614;
  --amber-soft: #fff1d7;
  --coral: #c4534e;
  --coral-soft: #ffe9e6;
  --shadow: 0 18px 45px rgba(35, 52, 84, 0.09);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 96% 0%, rgba(56, 71, 167, 0.12), transparent 30rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(40, 120, 200, 0.28);
  outline-offset: 2px;
}

.page-shell {
  width: min(1540px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 64px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(105, 117, 139, 0.18);
}

.brand-lockup,
.topbar-actions,
.panel-heading,
.filters,
.state-actions,
.dialog-header {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--indigo);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar h1,
.intro h2,
.panel h2,
.billing-note h2,
.state-card h2,
.dialog-header h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.topbar h1 {
  font-size: clamp(22px, 3vw, 30px);
}

.topbar-actions {
  justify-content: flex-end;
  gap: 14px;
  flex-wrap: wrap;
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.freshness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 5px rgba(22, 138, 131, 0.12);
}

.window-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

select,
input[type="search"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}

select {
  min-height: 42px;
  padding: 0 34px 0 12px;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.primary-button {
  min-height: 42px;
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 18px rgba(22, 36, 60, 0.18);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.secondary-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 0 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 48px;
  align-items: end;
  padding: 54px 0 30px;
}

.intro h2 {
  max-width: 820px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.99;
}

.intro-copy {
  max-width: 790px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.coverage-card {
  min-height: 154px;
  padding: 24px;
  border: 1px solid rgba(56, 71, 167, 0.15);
  border-radius: var(--radius);
  background: linear-gradient(140deg, #182542 0%, #35469d 100%);
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.coverage-label {
  color: #cbd3ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.coverage-card strong {
  margin: 10px 0 6px;
  font-size: 21px;
}

.coverage-card span:last-child {
  color: #dfe5ff;
  font-size: 13px;
  line-height: 1.45;
}

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

.metric-card {
  min-height: 164px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(35, 52, 84, 0.05);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  top: -38px;
  right: -38px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  opacity: 0.58;
}

.metric-card--indigo::after { background: var(--indigo-soft); }
.metric-card--blue::after { background: var(--blue-soft); }
.metric-card--amber::after { background: var(--amber-soft); }
.metric-card--teal::after { background: var(--teal-soft); }
.metric-card--coral::after { background: var(--coral-soft); }

.metric-label,
.metric-detail {
  display: block;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 20px 0 10px;
  font-size: 42px;
  letter-spacing: -0.05em;
}

.metric-detail {
  color: var(--muted);
  font-size: 12px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(330px, 0.8fr);
  gap: 20px;
  margin-bottom: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(35, 52, 84, 0.055);
}

.funnel-panel,
.attention-panel,
.users-panel {
  padding: 26px;
}

.panel-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-heading h2 {
  font-size: 24px;
}

.panel-stat {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.funnel-chart {
  display: grid;
  gap: 15px;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(160px, 230px) minmax(180px, 1fr) 66px;
  gap: 14px;
  align-items: center;
}

.funnel-label {
  font-size: 13px;
  font-weight: 700;
}

.funnel-track {
  height: 11px;
  border-radius: 999px;
  background: #edf1f7;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--indigo), #6877d8);
}

.funnel-value {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.attention-list {
  display: grid;
  gap: 4px;
}

.attention-row {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #edf0f5;
  color: var(--muted);
  font-size: 13px;
}

.attention-row:last-child {
  border-bottom: 0;
}

.attention-row strong {
  color: var(--ink);
  font-size: 20px;
}

.users-panel {
  margin-bottom: 20px;
}

.users-heading {
  margin-bottom: 18px;
}

.filters {
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  border-radius: 15px;
  background: #f6f8fc;
  margin-bottom: 18px;
}

.search-control {
  flex: 1 1 300px;
}

input[type="search"] {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
}

.checkbox-control {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

th {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 16px 10px;
  border-bottom: 1px solid #edf0f5;
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover {
  background: #fafbfe;
}

.account-cell strong,
.account-cell span {
  display: block;
}

.account-cell strong {
  max-width: 270px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.stage-pill,
.attention-chip,
.file-chip,
.mode-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 750;
}

.stage-pill {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
  white-space: nowrap;
}

.stage-pill--strong { background: var(--indigo-soft); color: var(--indigo); }
.stage-pill--progress { background: var(--teal-soft); color: #0e6d67; }
.stage-pill--assigned { background: var(--amber-soft); color: var(--amber); }
.stage-pill--active { background: var(--blue-soft); color: var(--blue); }
.stage-pill--started { background: #eef0f5; color: #536077; }
.stage-pill--new { background: var(--coral-soft); color: var(--coral); }

.metric-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 720;
}

.view-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.billing-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 28px;
  border: 1px solid rgba(22, 138, 131, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e4f7f3 0%, #f6fbff 100%);
}

.billing-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--teal);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
}

.billing-note h2 {
  font-size: 22px;
}

.billing-note p:last-child {
  max-width: 920px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.mode-pill {
  min-height: 32px;
  padding: 0 12px;
  background: rgba(22, 138, 131, 0.13);
  color: #0f6f69;
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}

.state-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(243, 246, 251, 0.9);
  backdrop-filter: blur(8px);
}

.state-card {
  width: min(480px, 100%);
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.state-card p {
  color: var(--muted);
  line-height: 1.55;
}

.state-card--error {
  text-align: left;
}

.state-actions {
  gap: 10px;
  margin-top: 24px;
}

.loading-orbit {
  width: 48px;
  height: 48px;
  margin: 0 auto 22px;
  border: 4px solid var(--indigo-soft);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: orbit 0.8s linear infinite;
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

.user-dialog {
  width: min(900px, calc(100% - 28px));
  max-height: min(860px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(22, 36, 60, 0.28);
}

.user-dialog::backdrop {
  background: rgba(20, 30, 50, 0.55);
  backdrop-filter: blur(5px);
}

.dialog-header {
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  font-size: clamp(20px, 4vw, 28px);
}

.icon-button {
  min-height: 38px;
  padding: 0 13px;
  background: #eef1f6;
  color: var(--ink);
  font-size: 12px;
}

#dialogContent {
  padding: 26px 28px 32px;
  overflow: auto;
}

.dialog-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.dialog-stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbfe;
}

.dialog-stat span,
.dialog-stat strong {
  display: block;
}

.dialog-stat span {
  color: var(--muted);
  font-size: 11px;
}

.dialog-stat strong {
  margin-top: 7px;
  font-size: 24px;
}

.attention-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.attention-chip {
  min-height: 28px;
  padding: 0 10px;
  background: var(--coral-soft);
  color: #9e423e;
  font-size: 11px;
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.file-card-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.file-card h3 {
  margin: 0;
  font-size: 15px;
}

.file-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.file-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 13px;
}

.file-chip {
  min-height: 25px;
  padding: 0 8px;
  background: #edf1f7;
  color: #566176;
  font-size: 10px;
}

.file-chip--yes {
  background: var(--teal-soft);
  color: #0f716a;
}

.hidden {
  display: none !important;
}

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

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

  .insight-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, 1540px);
  }

  .topbar,
  .intro {
    align-items: stretch;
  }

  .topbar {
    padding: 16px 0;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 38px;
  }

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

  .billing-note {
    grid-template-columns: auto 1fr;
  }

  .billing-note .mode-pill {
    grid-column: 2;
    justify-self: start;
  }

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

@media (max-width: 560px) {
  .brand-lockup {
    width: 100%;
  }

  .topbar-actions,
  .window-control,
  .primary-button {
    width: 100%;
  }

  .topbar-actions .primary-button,
  .window-control select {
    flex: 1;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 134px;
  }

  .metric-card strong {
    margin: 14px 0 6px;
  }

  .funnel-panel,
  .attention-panel,
  .users-panel {
    padding: 20px;
  }

  .funnel-row {
    grid-template-columns: 1fr 52px;
    gap: 7px 10px;
  }

  .funnel-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .billing-note {
    grid-template-columns: 1fr;
  }

  .billing-note .mode-pill {
    grid-column: 1;
  }

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

  .file-card-header {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
