:root {
  --bg: #f4efe7;
  --panel: rgba(255, 252, 246, 0.94);
  --panel-strong: #fffaf3;
  --text: #1f1b16;
  --muted: #6c6258;
  --line: rgba(79, 58, 37, 0.14);
  --brand: #7d2e20;
  --brand-dark: #5b1f16;
  --accent: #184d47;
  --shadow: 0 24px 60px rgba(75, 49, 26, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(232, 195, 162, 0.45), transparent 28%),
    radial-gradient(circle at top right, rgba(24, 77, 71, 0.12), transparent 26%),
    linear-gradient(180deg, #f8f2ea 0%, #efe5d8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(125, 46, 32, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 46, 32, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 90%);
}

.page-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.hero,
.layout-grid {
  display: grid;
  gap: 24px;
}

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

.layout-grid {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.admin-layout {
  display: grid;
  gap: 24px;
  align-items: start;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.tab-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(125, 46, 32, 0.08);
  border: 1px solid rgba(125, 46, 32, 0.12);
}

.tab-button {
  padding: 12px 20px;
  background: transparent;
  color: var(--brand-dark);
  box-shadow: none;
}

.tab-button.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff8f1;
  box-shadow: 0 12px 24px rgba(125, 46, 32, 0.2);
}

.tab-panel {
  display: none;
  gap: 24px;
  width: 100%;
}

.tab-panel.active {
  display: grid;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

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

.home-grid {
  display: grid;
  gap: 24px;
  align-content: center;
  min-height: calc(100vh - 96px);
}

.home-hero {
  justify-items: center;
  text-align: center;
}

.hero-copy,
.hero-card,
.form-card,
.result-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
}

.hero-copy,
.hero-card,
.form-card,
.result-card {
  padding: 20px;
}

.hero-copy {
  position: relative;
  overflow: hidden;
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background:
    linear-gradient(
      90deg,
      #f14d57 0 18%,
      #ff9f1c 18% 36%,
      #ffe14a 36% 54%,
      #15a84a 54% 72%,
      #233f9a 72% 100%
    );
}

.hero-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

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

.brand-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  flex: 0 0 auto;
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--brand);
}

h1,
h2 {
  margin: 0;
}

h3 {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 4rem);
  line-height: 0.98;
  max-width: none;
}

.hero-text,
.section-heading p,
.helper-text {
  color: var(--muted);
}

.hero-text {
  margin: 16px 0 0;
  line-height: 1.65;
  max-width: 58ch;
}

.admin-layout > * {
  width: 100%;
}

.brand-stack {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.large-logo {
  width: 132px;
  height: 132px;
}

.home-hero h1 {
  max-width: none;
}

.home-hero .hero-text {
  max-width: 34ch;
}

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

.access-card {
  display: grid;
  gap: 12px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  min-height: 220px;
  align-content: start;
}

.access-card strong {
  font-size: 1.6rem;
  line-height: 1.1;
}

.access-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(125, 46, 32, 0.08);
  color: var(--brand-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-card {
  background:
    linear-gradient(135deg, rgba(125, 46, 32, 0.96), rgba(62, 24, 16, 0.96)),
    var(--panel);
  color: #fff8f1;
}

.admin-card .access-kicker {
  color: #f6e5dc;
}

.admin-card .access-kicker {
  background: rgba(255, 255, 255, 0.12);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff8f1;
  text-decoration: none;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
}

.admin-link-header {
  color: var(--brand-dark);
  border-color: rgba(125, 46, 32, 0.18);
  background: rgba(125, 46, 32, 0.08);
  white-space: nowrap;
}

.hero-actions {
  margin-top: 18px;
}

.strong-link {
  color: #fff8f1;
  border-color: rgba(125, 46, 32, 0.22);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 22px rgba(125, 46, 32, 0.18);
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(125, 46, 32, 0.1);
  color: var(--brand-dark);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.form-card,
.side-panel {
  display: grid;
  gap: 24px;
}

.section-block {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

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

.section-heading p {
  margin: 8px 0 0;
  line-height: 1.6;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.field-span-2 {
  grid-column: span 2;
}

.field span,
.field-group legend {
  font-weight: 700;
  font-size: 0.96rem;
}

.card-title {
  display: block;
  text-align: left;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(79, 58, 37, 0.18);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px 15px;
  font: inherit;
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(125, 46, 32, 0.55);
  box-shadow: 0 0 0 4px rgba(125, 46, 32, 0.12);
}

input[readonly] {
  background: #f4f4f4;
  color: #4f4b46;
}

textarea {
  resize: vertical;
}

.field-group {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px 16px;
  background: rgba(255, 255, 255, 0.88);
  min-height: 100%;
}

.structure-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
}

.mini-heading {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.inline-options {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 8px;
  align-items: center;
  min-height: 42px;
}

.inline-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

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

.check-chip {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: 68px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--muted);
}

.check-chip input {
  justify-self: center;
}

.check-chip span {
  display: block;
  text-align: center;
  line-height: 1.2;
}

.structure-card {
  min-height: 110px;
}

.field.structure-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 16px 16px;
}

.inline-detail {
  margin-top: 14px;
}

.member-count-card {
  align-content: start;
}

.member-count-card input {
  min-height: 52px;
  max-width: 220px;
}

.structure-grid {
  margin-top: 16px;
  align-items: stretch;
}

.structure-grid-secondary {
  margin-top: 16px;
  align-items: stretch;
}

.selected-address {
  margin-top: 14px;
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(24, 77, 71, 0.08);
  border: 1px solid rgba(24, 77, 71, 0.16);
  color: #17322f;
  line-height: 1.6;
}

.helper-text {
  margin: 10px 0 0;
  line-height: 1.6;
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  box-shadow: 0 14px 28px rgba(125, 46, 32, 0.2);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-height: 50px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: 800;
  background: rgba(125, 46, 32, 0.06);
  border: 1px solid rgba(125, 46, 32, 0.16);
  color: var(--brand-dark);
}

.result-card pre {
  margin: 0;
  min-height: 180px;
  border-radius: var(--radius-lg);
  padding: 20px;
  background: #1f1b16;
  color: #f8efe0;
  overflow: auto;
  line-height: 1.55;
  font-family: "Consolas", "Courier New", monospace;
}

.privacy-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(24, 77, 71, 0.08);
  border: 1px solid rgba(24, 77, 71, 0.14);
  color: #17322f;
  line-height: 1.6;
}

.privacy-inline strong {
  font-size: 0.98rem;
}

.admin-login-card {
  width: min(100%, 560px);
  max-width: 560px;
  justify-self: center;
}

.admin-login-form,
.admin-panel {
  display: grid;
  gap: 18px;
}

.dashboard-card {
  display: grid;
  gap: 10px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 196px;
  align-content: start;
}

.dashboard-card-highlight {
  background: linear-gradient(135deg, rgba(125, 46, 32, 0.96), rgba(62, 24, 16, 0.96));
  color: #fff8f1;
}

.dashboard-card-highlight .dashboard-label,
.dashboard-card-highlight .dashboard-note {
  color: rgba(255, 248, 241, 0.88);
}

.dashboard-label {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
}

.dashboard-value {
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
}

.dashboard-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-detail-card {
  gap: 16px;
  min-height: 100%;
}

.dashboard-heading {
  margin-bottom: 6px;
}

.dashboard-list {
  display: grid;
  gap: 12px;
  align-content: start;
}

.dashboard-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
}

.dashboard-list-item span {
  color: var(--muted);
  font-weight: 600;
}

.dashboard-list-item strong {
  color: var(--text);
  white-space: nowrap;
}

.dashboard-empty {
  margin: 0;
  padding: 18px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(79, 58, 37, 0.2);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.chart-block {
  display: grid;
  gap: 14px;
  align-content: start;
}

.protocol-panel {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(125, 46, 32, 0.06);
  border: 1px solid rgba(125, 46, 32, 0.12);
}

.protocol-copy {
  display: grid;
  gap: 6px;
}

.protocol-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
}

.protocol-history-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.protocol-history-heading {
  margin-bottom: 0;
}

.protocol-history-list {
  display: grid;
  gap: 12px;
}

.protocol-history-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(79, 58, 37, 0.1);
}

.protocol-history-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.protocol-history-top span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 77, 71, 0.08);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.protocol-history-grid div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #faf6f0;
}

.protocol-history-grid span {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.protocol-history-grid strong {
  line-height: 1.5;
}

.record-detail-card {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 243, 0.92);
  border: 1px solid var(--line);
}

.record-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.record-kicker {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
}

.record-header h3 {
  font-size: 1.4rem;
  line-height: 1.15;
}

.record-date {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(125, 46, 32, 0.08);
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.record-section h4 {
  margin: 0;
  font-size: 1rem;
}

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

.record-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(79, 58, 37, 0.1);
}

.record-item-full {
  grid-column: 1 / -1;
}

.record-item span {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.record-item strong {
  font-size: 0.98rem;
  line-height: 1.45;
}

.record-photo-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.record-photo-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.record-photo-card {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(79, 58, 37, 0.1);
}

.record-photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #f3ece3;
}

.record-photo-card figcaption {
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

.record-notes,
.record-empty {
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(79, 58, 37, 0.1);
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.comparison-row {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
}

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

.comparison-header strong {
  font-size: 0.98rem;
}

.comparison-header span {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.comparison-series {
  display: grid;
  gap: 10px;
}

.comparison-bar {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(79, 58, 37, 0.08);
}

.comparison-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
}

.comparison-bar-base .comparison-bar-fill {
  background: linear-gradient(135deg, rgba(24, 77, 71, 0.92), rgba(24, 77, 71, 0.68));
}

.comparison-bar-updated .comparison-bar-fill {
  background: linear-gradient(135deg, rgba(125, 46, 32, 0.94), rgba(125, 46, 32, 0.72));
}

.comparison-bar small {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.table-shell {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

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

.sheet-table thead {
  background: rgba(125, 46, 32, 0.08);
}

.sheet-table th,
.sheet-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.sheet-table th {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .hero,
  .layout-grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

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

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

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

  .dashboard-grid,
  .dashboard-grid-secondary {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    align-items: stretch;
  }

  .admin-toolbar .actions {
    width: 100%;
    justify-content: stretch;
  }

  .admin-toolbar .actions > * {
    flex: 1 1 0;
  }

  .tab-switcher {
    width: 100%;
    justify-content: center;
  }

  .tab-button {
    flex: 1 1 0;
  }

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

  .record-header {
    flex-direction: column;
    justify-content: flex-start;
  }

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

  .record-photo-gallery {
    grid-template-columns: 1fr;
  }

  .protocol-history-top,
  .protocol-history-grid {
    grid-template-columns: 1fr;
  }

  .protocol-history-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .record-item-full {
    grid-column: auto;
  }

  .brand-lockup {
    width: 100%;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .page-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 24px;
  }

  .hero-copy,
  .form-card,
  .result-card {
    padding: 22px;
  }

  .section-block {
    padding: 20px;
  }
}
