:root {
  --bg: #efe9dc;
  --paper: rgba(255, 250, 242, 0.94);
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #171717;
  --muted: #61584f;
  --accent: #f45a2a;
  --accent-strong: #d84c21;
  --line: rgba(23, 23, 23, 0.12);
  --success: #235b3d;
  --success-bg: rgba(35, 91, 61, 0.12);
  --error: #932f13;
  --error-bg: rgba(244, 90, 42, 0.12);
  --info: #214f8a;
  --info-bg: rgba(33, 79, 138, 0.12);
  --shadow: 0 28px 70px rgba(41, 29, 16, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(244, 90, 42, 0.17), transparent 26%),
    radial-gradient(circle at bottom right, rgba(20, 20, 20, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f2e8 0%, #e9e0d1 100%);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

body.workspace-mode-portal {
  background: linear-gradient(180deg, #eef7f4 0%, #e8efe1 48%, #f5eee3 100%);
}

body.workspace-mode-admin {
  background: linear-gradient(180deg, #fff4ee 0%, #eee2d6 52%, #e5ddcf 100%);
}

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

button,
a {
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.app-shell {
  width: min(1400px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.view[hidden] {
  display: none !important;
}

.auth-screen {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
}

.auth-card,
.panel,
.subpanel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(100%, 540px);
  padding: 40px 36px;
  display: grid;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.brand-logo {
  width: 292px;
  height: auto;
}

.brand-logo.small {
  width: 148px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  max-width: 13ch;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  line-height: 0.96;
}

h2 {
  font-size: clamp(1.3rem, 1.5vw, 1.9rem);
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.support-copy {
  max-width: 44ch;
}

.auth-form,
label {
  display: grid;
  gap: 8px;
  width: 100%;
}

label {
  text-align: left;
  font-weight: 700;
  color: var(--ink);
}

label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(23, 23, 23, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  padding: 13px 14px;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(244, 90, 42, 0.7);
  box-shadow: 0 0 0 4px rgba(244, 90, 42, 0.14);
}

.button,
.link-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 800;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button:hover,
.link-button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: #222;
}

.button.wide {
  width: 100%;
}

.link-button {
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message-panel {
  width: 100%;
}

#message-box,
#workspace-message-box {
  border-radius: 18px;
  padding: 14px 16px;
}

.banner.error {
  background: var(--error-bg);
  color: var(--error);
}

.banner.success {
  background: var(--success-bg);
  color: var(--success);
}

.banner.info {
  background: var(--info-bg);
  color: var(--info);
}

.recovery-preview {
  width: 100%;
  padding: 16px;
  border: 1px dashed rgba(23, 23, 23, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  text-align: left;
}

.recovery-preview a {
  color: var(--accent-strong);
  font-weight: 800;
}

.workspace {
  display: grid;
  gap: 18px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.workspace-title {
  font-size: clamp(1.15rem, 1.7vw, 1.8rem);
}

.brand-lockup,
.workspace-actions,
.section-head,
.section-head.compact,
.chip-row,
.checkbox-group,
.capability-list,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-lockup {
  align-items: center;
}

.workspace-actions {
  justify-content: flex-end;
  align-items: center;
}

.session-pill,
.status,
.tag,
.capability-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.session-pill {
  background: rgba(23, 23, 23, 0.06);
}

.status {
  background: rgba(244, 90, 42, 0.14);
  color: var(--accent-strong);
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.08);
  border: 1px solid rgba(23, 23, 23, 0.08);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #1f7a55);
  transition: width 260ms ease;
}

.rps-sync-panel {
  display: grid;
  gap: 14px;
}

.sync-warning-list {
  display: grid;
  gap: 6px;
  color: var(--error);
  font-size: 0.9rem;
  line-height: 1.35;
}

.tag,
.capability-pill {
  background: rgba(23, 23, 23, 0.08);
}

.module-filter-pill {
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.module-filter-pill:hover {
  transform: translateY(-1px);
  background: rgba(244, 90, 42, 0.12);
}

.module-filter-pill.selected {
  color: var(--ink);
  border-color: rgba(244, 90, 42, 0.55);
  background: linear-gradient(135deg, rgba(244, 90, 42, 0.2), rgba(255, 255, 255, 0.94));
  box-shadow: 0 12px 26px rgba(244, 90, 42, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.content-stack,
.module-stack,
.session-overview {
  display: grid;
  gap: 18px;
}

.session-overview {
  gap: 14px;
  padding: 20px 24px;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.workspace-mode-portal .session-overview {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(229, 247, 240, 0.96));
  border-color: rgba(31, 122, 85, 0.28);
  box-shadow: 0 26px 64px rgba(31, 122, 85, 0.12);
}

.workspace-mode-admin .session-overview {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 236, 226, 0.96));
  border-color: rgba(244, 90, 42, 0.3);
  box-shadow: 0 26px 64px rgba(244, 90, 42, 0.13);
}

.session-mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  border: 1px solid transparent;
}

.workspace-mode-portal .mode-badge {
  color: #0e5a3d;
  background: rgba(31, 122, 85, 0.14);
  border-color: rgba(31, 122, 85, 0.24);
}

.workspace-mode-admin .mode-badge {
  color: var(--accent-strong);
  background: rgba(244, 90, 42, 0.14);
  border-color: rgba(244, 90, 42, 0.26);
}

.workspace-mode-portal #show-portal.button.primary {
  background: #1f7a55;
  border-color: #1f7a55;
  box-shadow: 0 12px 24px rgba(31, 122, 85, 0.18);
}

.workspace-mode-portal #show-portal.button.primary:hover {
  background: #176945;
}

.workspace-mode-admin #show-admin.button.primary {
  background: var(--ink);
  border-color: rgba(244, 90, 42, 0.45);
  box-shadow: 0 12px 24px rgba(244, 90, 42, 0.17);
}

.session-stack {
  display: grid;
  gap: 4px;
  align-items: start;
}

.session-overview h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
}

#session-summary {
  font-size: 0.96rem;
}

.capability-list {
  gap: 10px;
}

.panel {
  padding: 24px;
}

.subpanel {
  padding: 20px;
  background: var(--panel);
}

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

.metrics-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric-card,
.list-item,
.question-card,
.detail-box {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.question-card {
  display: grid;
  gap: 14px;
}

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

.survey-option-list-scale {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.survey-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 800;
  cursor: pointer;
}

.survey-option:hover,
.survey-option:focus-within {
  border-color: rgba(244, 90, 42, 0.36);
  background: rgba(244, 90, 42, 0.08);
}

.survey-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.metric-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  overflow: hidden;
}

.metric-card.interactive {
  cursor: pointer;
}

.metric-card.interactive:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 90, 42, 0.4);
}

.metric-card.alert {
  background: rgba(244, 90, 42, 0.12);
  border-color: rgba(244, 90, 42, 0.26);
}

.metric-value {
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.25;
}

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

.split-fixed {
  align-items: start;
}

.simple-list,
.stack {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  gap: 6px;
  width: 100%;
  text-align: left;
}

.list-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.button-like {
  cursor: pointer;
}

.button-like:hover {
  border-color: rgba(244, 90, 42, 0.4);
  transform: translateY(-1px);
}

.list-toolbar {
  margin-bottom: 12px;
}

.scroll-list {
  max-height: 360px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 6px;
}

.portal-panel {
  min-height: 520px;
}

.portal-scroll {
  max-height: 440px;
  overflow-y: auto;
  padding-right: 6px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-field {
  display: grid;
  gap: 10px;
}

.upload-dropzone {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed rgba(23, 23, 23, 0.25);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
}

.upload-dropzone.dragover {
  border-color: rgba(244, 90, 42, 0.9);
  background: rgba(244, 90, 42, 0.08);
}

.upload-dropzone strong,
.upload-dropzone span,
.upload-dropzone small {
  display: block;
}

.upload-dropzone small {
  color: var(--muted);
}

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

.flag-grid {
  display: grid;
  margin: 8px 0 2px;
}

.role-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  cursor: pointer;
}

.role-card span {
  font-weight: 700;
  line-height: 1.35;
}

.role-card-static {
  width: 100%;
}

.role-card input,
.company-check input,
.group-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.target-picker {
  display: grid;
  gap: 14px;
  margin: 10px 0 16px;
}

.target-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.target-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
}

.target-group-head {
  display: grid;
  gap: 8px;
}

.target-group-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.target-group-list {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.target-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 248, 242, 0.82));
  font-weight: 800;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.target-item:hover {
  transform: translateY(-1px);
  border-color: rgba(244, 90, 42, 0.32);
  box-shadow: 0 10px 22px rgba(23, 23, 23, 0.06);
}

.target-item:has(input:checked) {
  border-color: rgba(244, 90, 42, 0.6);
  background: linear-gradient(135deg, rgba(244, 90, 42, 0.18), rgba(255, 255, 255, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.target-item input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.target-item span {
  min-width: 0;
  line-height: 1.25;
}

.category-target-list {
  max-height: 260px;
}

.company-check,
.group-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 700;
}

.company-check {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(23, 23, 23, 0.04);
}

.company-check small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.group-toggle {
  font-size: 0.9rem;
  align-items: center;
  white-space: normal;
  width: fit-content;
}

.target-group-title {
  display: grid;
  gap: 2px;
}

.target-group-title strong {
  font-size: 1rem;
}

.target-group-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

.empty {
  padding: 28px;
  border-radius: 20px;
  border: 1px dashed rgba(23, 23, 23, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.table-wrap {
  max-height: 460px;
  overflow: auto;
}

.metric-explorer-wrap {
  max-height: 560px;
}

.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.state-row-published,
.state-row-notified {
  background: rgba(255, 243, 220, 0.82);
}

.state-row-accessed,
.state-row-downloaded {
  background: rgba(225, 241, 255, 0.86);
}

.state-row-confirmed {
  background: rgba(226, 245, 232, 0.9);
}

.state-row-expired {
  background: rgba(255, 232, 224, 0.9);
}

.followup-cell {
  min-width: 260px;
}

.tracking-stack {
  display: grid;
  gap: 10px;
}

.tracking-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tracking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.tracking-badge strong {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tracking-badge-download {
  color: #174b78;
  background: rgba(60, 142, 204, 0.16);
  border-color: rgba(60, 142, 204, 0.34);
}

.tracking-badge-ack {
  color: #205b35;
  background: rgba(62, 151, 91, 0.16);
  border-color: rgba(62, 151, 91, 0.34);
}

.tracking-badge-receipt {
  color: #14605f;
  background: rgba(43, 162, 157, 0.16);
  border-color: rgba(43, 162, 157, 0.34);
}

.tracking-badge-expiry {
  color: #7c4313;
  background: rgba(226, 143, 51, 0.18);
  border-color: rgba(226, 143, 51, 0.36);
}

.tracking-badge-muted {
  color: #706a62;
  background: rgba(23, 23, 23, 0.06);
  border-color: rgba(23, 23, 23, 0.1);
}

.followup-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  font-weight: 700;
  white-space: nowrap;
}

.followup-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 23, 23, 0.38);
  backdrop-filter: blur(8px);
}

.modal-sheet {
  width: min(960px, 100%);
  max-height: min(85vh, 920px);
  overflow: hidden;
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.list-item[hidden],
tr[hidden],
.company-check[hidden] {
  display: none !important;
}

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

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

.data-table th {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .split,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

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

  .workspace-header {
    flex-direction: column;
    align-items: stretch;
  }

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    padding: 10px 0 24px;
  }

  .auth-card,
  .panel,
  .subpanel {
    border-radius: 22px;
  }

  .auth-card,
  .panel {
    padding: 22px;
  }

  .scroll-list,
  .target-group-list {
    max-height: 260px;
  }

  .target-group {
    padding: 12px;
  }

  h1 {
    max-width: 100%;
    font-size: 2rem;
  }
}
