:root {
  --bg: #f3efe3;
  --panel: rgba(255, 251, 243, 0.9);
  --panel-border: rgba(108, 87, 49, 0.18);
  --text: #2c2418;
  --muted: #6c604e;
  --primary: #1f6f5f;
  --primary-dark: #184f44;
  --accent: #d48f3f;
  --danger: #a84c3d;
  --success: #2f7d4b;
  --info: #325f96;
  --shadow: 0 20px 45px rgba(56, 41, 18, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(212, 143, 63, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(31, 111, 95, 0.2), transparent 25%),
    linear-gradient(145deg, #f5f0e5 0%, #e7ded0 100%);
  min-height: 100vh;
}

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

.page-shell-narrow {
  width: min(820px, calc(100% - 32px));
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  padding: 28px 32px;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(31, 111, 95, 0.95), rgba(24, 79, 68, 0.92)),
    linear-gradient(45deg, rgba(255, 255, 255, 0.08), transparent);
  box-shadow: var(--shadow);
  color: #fff8ed;
}

.hero-compact {
  align-items: center;
}

.hero h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  opacity: 0.78;
}

.hero-copy {
  margin: 14px 0 0;
  max-width: 760px;
  font-size: 1.02rem;
  opacity: 0.9;
}

.hero-badge {
  min-width: 240px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 248, 237, 0.14);
  border: 1px solid rgba(255, 248, 237, 0.2);
  backdrop-filter: blur(10px);
}

.hero-badge span {
  display: block;
  font-size: 0.88rem;
  opacity: 0.8;
}

.hero-badge strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.hero-actions {
  display: flex;
  align-items: center;
}

.hero-actions-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.badge-copy {
  margin-top: 6px;
}

.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.section-subtabs {
  margin-top: 10px;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 251, 243, 0.88);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 700;
}

.section-tab-active {
  background: linear-gradient(135deg, rgba(31, 111, 95, 0.95), rgba(24, 79, 68, 0.92));
  color: #fff8ed;
}

.section-subtab {
  min-height: 40px;
  padding: 0 16px;
  background: rgba(255, 251, 243, 0.74);
  box-shadow: none;
}

.section-subtab.section-tab-active {
  background: linear-gradient(135deg, #f4d79b, #ebc27a);
  border-color: rgba(108, 87, 49, 0.28);
  box-shadow: 0 10px 22px rgba(108, 87, 49, 0.16);
  color: #2c2418;
}

.flash-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.flash-success {
  background: rgba(47, 125, 75, 0.12);
  border: 1px solid rgba(47, 125, 75, 0.2);
}

.flash-error {
  background: rgba(168, 76, 61, 0.12);
  border: 1px solid rgba(168, 76, 61, 0.2);
}

.panel-grid,
.table-grid,
.stats-grid,
.details-grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.panel-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel-grid-single {
  grid-template-columns: 1fr;
}

.table-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.3fr);
}

.observer-table-grid {
  grid-template-columns: repeat(3, minmax(320px, 1fr));
}

.details-grid {
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
}

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

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

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

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

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

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

.panel {
  padding: 22px;
  backdrop-filter: blur(18px);
}

.panel-wide {
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.secondary-link,
.mini-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.entry-form,
.filter-form,
.backup-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.backup-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(108, 87, 49, 0.14);
}

.stats-picker-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(108, 87, 49, 0.14);
}

.stats-picker-form {
  padding: 18px;
  border-radius: 18px;
  background: rgba(108, 87, 49, 0.05);
}

.bps-filter-form {
  grid-template-columns: 1fr;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

input,
select,
button,
a.ghost-button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(108, 87, 49, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 111, 95, 0.24);
  border-color: rgba(31, 111, 95, 0.5);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-row-tight {
  gap: 8px;
}

.primary-button,
.ghost-button,
.mini-button,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #e7b260);
  color: #2b1d08;
  font-weight: 700;
}

.ghost-button,
.mini-button {
  background: rgba(31, 111, 95, 0.08);
  color: var(--primary-dark);
}

.ghost-button-light {
  background: rgba(255, 248, 237, 0.18);
  color: #fff8ed;
  border: 1px solid rgba(255, 248, 237, 0.2);
}

.status-badge {
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.88rem;
  font-weight: 700;
}

.badge-edited {
  background: rgba(50, 95, 150, 0.12);
  color: var(--info);
}

.badge-adjustment {
  background: rgba(212, 143, 63, 0.16);
  color: #8b5c18;
}

.badge-linked {
  background: rgba(31, 111, 95, 0.14);
  color: var(--primary-dark);
}

.info-stripe-list {
  display: grid;
  gap: 12px;
}

.info-stripe {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(31, 111, 95, 0.12);
  color: var(--text);
}

.info-stripe span {
  color: var(--text);
}

.info-stripe strong {
  font-size: 1.1rem;
}

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

.bps-info-card {
  padding: 14px;
  border-radius: 20px;
  background: rgba(108, 87, 49, 0.06);
  border: 1px solid rgba(108, 87, 49, 0.12);
}

.bps-info-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.bps-info-link {
  color: inherit;
  text-decoration: none;
}

.bps-info-link:hover {
  text-decoration: underline;
}

.bps-info-lines {
  display: grid;
  gap: 6px;
}

.bps-info-lines p {
  margin: 0;
  line-height: 1.4;
}

.primary-button:hover,
.ghost-button:hover,
.mini-button:hover,
.mini-link:hover,
.secondary-link:hover,
.status-badge:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  color: var(--muted);
  display: block;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1;
}

.accent-green strong {
  color: var(--success);
}

.accent-red strong {
  color: var(--danger);
}

.accent-blue strong {
  color: var(--primary);
}

.accent-gold strong {
  color: #9a6a1a;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(108, 87, 49, 0.12);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: rgba(247, 240, 229, 0.98);
  z-index: 1;
}

.empty-state,
.empty-note,
.muted-text,
.cell-copy {
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 24px 14px;
}

.empty-note {
  margin: 0;
  line-height: 1.5;
}

.cell-copy {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: start;
}

.action-stack form {
  margin: 0;
}

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

.detail-list div {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(108, 87, 49, 0.12);
}

.detail-list-single {
  grid-template-columns: 1fr;
}

.observer-summary-list dd div + div {
  margin-top: 8px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-list dd {
  margin: 8px 0 0;
  font-weight: 600;
}

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

.history-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(108, 87, 49, 0.12);
}

.history-time {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.history-columns h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.history-columns pre {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(44, 36, 24, 0.06);
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.45;
}

@media (max-width: 1220px) {
  .stats-grid,
  .stats-grid-wide,
  .stats-grid-five,
  .stats-grid-six,
  .stats-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .observer-table-grid {
    grid-template-columns: repeat(2, minmax(320px, 1fr));
  }
}

@media (max-width: 1080px) {
  .table-grid,
  .observer-table-grid,
  .details-grid,
  .stats-grid,
  .stats-grid-wide,
  .stats-grid-five,
  .stats-grid-six,
  .stats-grid-three {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1450px);
    padding-top: 18px;
  }

  .panel {
    padding: 18px;
  }

  .entry-form,
  .filter-form,
  .backup-form,
  .detail-list,
  .history-columns {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 560px;
  }
}
