:root {
  --bg: #e5ddd1;
  --surface: rgba(244, 236, 226, 0.96);
  --surface-strong: #fffdf9;
  --surface-muted: rgba(255, 255, 255, 0.68);
  --text: #21312a;
  --muted: #56685f;
  --line: rgba(23, 26, 24, 0.32);
  --primary: #245f4c;
  --primary-soft: #dcebe4;
  --secondary: #c46d3b;
  --secondary-soft: #f6e3d7;
  --shadow: 0 20px 45px rgba(65, 45, 24, 0.12);
  --radius-lg: 28px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 109, 59, 0.26), transparent 30%),
    radial-gradient(circle at top right, rgba(36, 95, 76, 0.24), transparent 32%),
    linear-gradient(180deg, #e7dfd4 0%, #efe6db 52%, #e2ebe4 100%);
}

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

.auth-card {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 22px;
  padding: 24px;
  background: rgba(255, 252, 246, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-brand,
.auth-form {
  background: var(--surface);
  border-radius: 24px;
  padding: 24px;
}

.auth-insignia {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-bottom: 16px;
}

.auth-copy {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 40ch;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 16px;
  align-content: center;
}

.auth-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(185, 75, 75, 0.12);
  color: #8e3131;
  font-weight: 700;
}

.button-block {
  width: 100%;
}

.app-root[hidden],
.auth-shell[hidden] {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(244, 239, 231, 0.88);
  border-bottom: 1px solid rgba(33, 49, 42, 0.08);
}

.topbar-inner,
.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.app-shell {
  padding: 28px 0 48px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-insignia {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.05;
}

.brand-block h1 {
  font-size: clamp(1.55rem, 2vw, 2.2rem);
}

.eyebrow,
.config-kicker {
  margin: 0 0 10px;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 700;
}

.module-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 22px rgba(36, 95, 76, 0.08);
}

.session-chip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.nav-button,
.button,
.tag button {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.nav-button {
  padding: 12px 18px;
  font-weight: 800;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 20px rgba(36, 95, 76, 0.06);
}

.nav-button.is-active {
  background: var(--primary);
  color: white;
}

.module-panel {
  display: none;
}

.module-panel.is-active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.hero h2 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  max-width: 12ch;
}

.hero-copy,
.panel-heading p,
.domain-count,
.scale-list span,
.summary-label,
.mini-panel p,
.placeholder-card p,
.config-card p,
.empty-message {
  color: var(--muted);
}

.hero-copy {
  max-width: 62ch;
  margin: 16px 0 0;
  font-size: 1.05rem;
}

.hero-card,
.panel,
.summary-card,
.config-card,
.placeholder-card,
.upload-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}

.hero-card,
.panel,
.config-card,
.placeholder-card,
.upload-card {
  padding: 22px;
}

.module-grid,
.placeholder-stack,
.config-grid,
.form-layout,
.domains,
.field-grid,
.signature-grid,
.notes-grid,
.dashboard-grid,
.dashboard-metrics {
  display: grid;
  gap: 20px;
}

.module-grid,
.placeholder-stack,
.config-grid,
.field-grid,
.signature-grid,
.notes-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

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

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

.panel-heading-inline,
.domain-header,
.config-header,
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.panel-heading h2 {
  font-size: 1.7rem;
  margin-bottom: 6px;
}

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

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

.field span {
  font-size: 0.93rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #000;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 14px 15px;
  font: inherit;
  color: inherit;
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.04);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(36, 95, 76, 0.22);
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  min-height: 132px;
}

.legend-inline,
.summary-values,
.actions,
.config-form,
.tag-list,
.followup-summary,
.visit-card-actions,
.assignment-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.assignment-readonly {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #111;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

.legend-inline span,
.summary-values span,
.config-count,
.tag {
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
}

.legend-inline span,
.config-count {
  background: var(--secondary-soft);
  color: #8c4e28;
}

.summary-values span,
.tag {
  background: var(--primary-soft);
  color: var(--primary);
}

.indicator-table {
  border: 1px solid rgba(0, 0, 0, 0.58);
  border-radius: 16px;
  overflow: hidden;
}

.visit-meta-card {
  display: inline-grid;
  gap: 4px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(36, 95, 76, 0.08);
}

.visit-meta-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.indicator-table-head,
.indicator-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, minmax(92px, 108px));
}

.indicator-table-head {
  background: var(--primary);
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
}

.indicator-table-head span,
.indicator-row > * {
  padding: 12px 14px;
}

.indicator-row {
  border-top: 1px solid rgba(0, 0, 0, 0.42);
  background: rgba(255, 255, 255, 0.96);
}

.indicator-table-head span:not(:first-child) {
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.2;
}

.indicator-row:nth-child(even) {
  background: rgba(226, 236, 230, 0.92);
}

.indicator-text {
  display: grid;
  gap: 6px;
}

.indicator-id {
  color: var(--primary);
  font-size: 0.9rem;
}

.indicator-label {
  font-size: 0.95rem;
  line-height: 1.45;
}

.score-options {
  display: contents;
}

.score-option {
  display: grid;
  place-items: center;
  border-left: 1px solid rgba(0, 0, 0, 0.42);
}

.score-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--secondary);
}

.summary-card {
  padding: 18px 20px;
  flex: 1 1 320px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 170px;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -22px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(36, 95, 76, 0.08);
}

.metric-kicker {
  margin: 0 0 10px;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 800;
}

.metric-card h3 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 8px;
}

.metric-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.button {
  padding: 14px 18px;
  font-weight: 800;
}

.table-actions .button {
  padding: 8px 10px;
  font-size: 0.78rem;
  justify-content: center;
}

.button-compact {
  padding: 8px 12px;
  font-size: 0.78rem;
  line-height: 1.1;
}

.button-primary {
  background: var(--primary);
  color: white;
}

.button-secondary {
  background: var(--secondary-soft);
  color: #8c4e28;
}

.button-danger {
  background: #b94b4b;
  color: white;
}

.button-table {
  min-width: 78px;
  border: 1px solid rgba(36, 95, 76, 0.16);
  background: #fffaf4;
  color: var(--primary);
  box-shadow: 0 6px 14px rgba(36, 95, 76, 0.08);
}

.admin-toolbar {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.placeholder-card,
.config-card {
  background: var(--surface-muted);
}

.visits-list {
  margin-top: 20px;
}

.visits-table-shell {
  margin-top: 20px;
  border: 1px solid rgba(33, 49, 42, 0.1);
  border-radius: 20px;
  overflow: auto;
  background: var(--surface-muted);
}

.visits-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

.visits-table th,
.visits-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(33, 49, 42, 0.08);
  vertical-align: middle;
}

.visits-table th {
  background: rgba(36, 95, 76, 0.9);
  color: white;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.visits-table th:nth-child(2),
.visits-table td:nth-child(2) {
  width: 26%;
}

.visits-table th:nth-child(3),
.visits-table td:nth-child(3) {
  width: 22%;
}

.visits-table th:nth-child(5),
.visits-table td:nth-child(5) {
  width: 14%;
}

.assignment-table {
  min-width: 1080px;
}

.assignment-table th:nth-child(1),
.assignment-table td:nth-child(1) {
  width: 26%;
}

.assignment-table th:nth-child(2),
.assignment-table td:nth-child(2) {
  width: 20%;
}

.assignment-table th:nth-child(3),
.assignment-table td:nth-child(3) {
  width: 20%;
}

.assignment-table th:nth-child(4),
.assignment-table td:nth-child(4) {
  width: 17%;
}

.assignment-table th:nth-child(5),
.assignment-table td:nth-child(5) {
  width: 17%;
}

.assignment-sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.assignment-sort-button::after {
  content: "↕";
  font-size: 0.82rem;
  color: var(--muted);
}

.assignment-sort-button.is-active::after {
  content: "↑";
  color: var(--accent);
}

.assignment-sort-button.is-active[data-direction="desc"]::after {
  content: "↓";
}

.visits-table tbody tr:hover {
  background: rgba(220, 235, 228, 0.4);
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  grid-template-columns: 80px minmax(0, 1fr) 52px;
  align-items: center;
}

.chart-label,
.chart-value {
  font-size: 0.88rem;
  font-weight: 700;
}

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

.chart-value {
  color: var(--primary);
  text-align: right;
}

.bar-track {
  height: 14px;
  border-radius: 999px;
  background: rgba(36, 95, 76, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #245f4c 0%, #4d8c75 100%);
}

.donut-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.donut-shell {
  display: grid;
  place-items: center;
}

.donut-chart {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  position: relative;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: #fffaf4;
  box-shadow: inset 0 0 0 1px rgba(33, 49, 42, 0.06);
}

.chart-legend {
  display: grid;
  gap: 12px;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legend-key {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.empty-chart {
  padding: 18px;
  border-radius: 16px;
  background: rgba(36, 95, 76, 0.05);
  color: var(--muted);
}

.visit-id-badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 800;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.status-pill.is-ready {
  background: var(--primary-soft);
  color: var(--primary);
}

.status-pill.is-pending {
  background: var(--secondary-soft);
  color: #8c4e28;
}

.upload-card {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.upload-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.upload-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.upload-help code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(36, 95, 76, 0.08);
}

.config-form input {
  flex: 1 1 220px;
}

.user-form {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

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

.tag button {
  width: 22px;
  height: 22px;
  background: rgba(36, 95, 76, 0.14);
  color: inherit;
  font-weight: 800;
}

@media (max-width: 980px) {
  .auth-card,
  .topbar-inner,
  .panel-heading-inline,
  .domain-header,
  .config-header,
  .toolbar,
  .hero,
  .module-grid,
  .config-grid,
  .field-grid,
  .signature-grid,
  .notes-grid,
  .dashboard-grid,
  .dashboard-metrics,
  .donut-card {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .app-shell {
    width: min(100% - 20px, 1200px);
  }

  .auth-shell {
    padding: 16px;
  }

  .hero-card,
  .panel,
  .config-card,
  .placeholder-card,
  .auth-brand,
  .auth-form {
    padding: 18px;
  }

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

  .indicator-table-head,
  .indicator-row {
    min-width: 620px;
  }
}
