:root {
  --paper: #f4f0ea;
  --surface: #fffdf9;
  --ink: #292522;
  --ink-soft: #625b55;
  --ink-faint: #837a73;
  --chrome: #211f1e;
  --chrome-soft: #302d2b;
  --rose: #a8564d;
  --rose-dark: #86443e;
  --rose-soft: #f2dfda;
  --sage: #4f6d48;
  --sage-soft: #e7eee3;
  --amber: #815c2d;
  --amber-soft: #f3e9d7;
  --danger: #a13f39;
  --danger-soft: #f5e3df;
  --line: rgba(41, 37, 34, 0.14);
  --line-strong: rgba(41, 37, 34, 0.24);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "Manrope", "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

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

button {
  color: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
p,
dl,
dd,
ol {
  margin: 0;
}

ol {
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid #c4786e;
  outline-offset: 3px;
}

.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;
}

.shell {
  width: min(1240px, 100%);
  margin-inline: auto;
  padding-inline: 24px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.admin-header {
  min-height: 64px;
  position: sticky;
  z-index: 30;
  top: 0;
  background: var(--chrome);
  color: #f8f3ed;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  flex: 0 0 auto;
  color: #fffaf5;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.brand span {
  color: #dc8d82;
}

.header-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
}

.header-context {
  color: #bdb5ae;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.header-actions {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 5px;
  color: #ded6cf;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.header-link:hover {
  background: var(--chrome-soft);
  color: #fff;
}

.header-link svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

main {
  min-height: calc(100vh - 64px);
}

.state-view {
  min-height: calc(100vh - 64px);
}

.state-shell {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(420px, 1.15fr);
  align-items: center;
  gap: 72px;
  padding-block: 64px;
}

.state-shell-compact {
  width: min(720px, 100%);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 14px;
}

.state-copy {
  min-width: 0;
}

.eyebrow,
.section-index {
  color: var(--rose-dark);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.state-copy h1,
.state-shell-compact h1,
.dashboard-heading h1,
.registry-heading h2 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
}

.state-copy h1,
.state-shell-compact h1 {
  max-width: 620px;
  margin-top: 10px;
  font-size: 48px;
}

.state-copy p:last-child,
.state-shell-compact > p:not(.eyebrow) {
  max-width: 560px;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 16px;
}

.loading-mark {
  width: 34px;
  height: 34px;
  display: block;
  margin-bottom: 28px;
  border: 3px solid var(--rose-soft);
  border-top-color: var(--rose);
  border-radius: 50%;
  animation: rotate 0.9s linear infinite;
}

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

.loading-layout {
  min-width: 0;
  display: grid;
  gap: 14px;
}

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

.skeleton {
  min-height: 88px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e7e0d8 25%, #f2ece5 50%, #e7e0d8 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.skeleton-wide {
  min-height: 48px;
}

.skeleton-chart {
  min-height: 210px;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

.state-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--amber);
}

.state-icon-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.state-icon svg {
  width: 22px;
  height: 22px;
}

.button,
.refresh-button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.button,
.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.button svg,
.refresh-button svg,
.icon-button svg {
  width: 16px;
  height: 16px;
}

.button-primary {
  margin-top: 8px;
  background: var(--rose);
  color: #fff;
}

.button-primary:hover {
  background: var(--rose-dark);
}

.button:disabled,
.refresh-button:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.dashboard-shell {
  padding-block: 42px 72px;
}

.inline-alert,
.stale-notice {
  margin-bottom: 18px;
  padding: 11px 14px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.stale-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.stale-notice svg {
  width: 16px;
  height: 16px;
}

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 26px;
}

.heading-copy {
  min-width: 0;
}

.dashboard-heading h1 {
  margin-top: 4px;
  font-size: 44px;
}

.freshness {
  margin-top: 10px;
  color: var(--ink-faint);
  font-size: 11px;
}

.freshness[data-tone="stale"] {
  color: var(--amber);
}

.heading-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-control {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.7);
}

.range-control button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.range-control button.is-active {
  background: var(--chrome);
  color: #fff;
}

.refresh-button {
  background: var(--rose);
  color: #fff;
}

.refresh-button:hover {
  background: var(--rose-dark);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line-strong);
}

.kpi-item {
  min-width: 0;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.kpi-item:first-child {
  padding-left: 0;
}

.kpi-item:last-child {
  padding-right: 0;
  border-right: 0;
}

.kpi-item dt {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi-item dd {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

.report-section {
  min-width: 0;
  padding-block: 28px;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.registry-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-heading h2,
.registry-heading h2 {
  margin-top: 3px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

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

.section-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--ink-faint);
  font-size: 11px;
}

.traffic-chart {
  height: 214px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding-top: 18px;
  border-bottom: 1px solid var(--line-strong);
}

.traffic-bar-item {
  min-width: 2px;
  height: 100%;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}

.traffic-bar {
  width: 100%;
  min-height: 2px;
  height: calc(var(--bar-ratio) * 100%);
  display: block;
  border-radius: 2px 2px 0 0;
  background: var(--rose);
  transition: height 180ms ease, background 160ms ease;
}

.traffic-bar-item:hover .traffic-bar {
  background: var(--chrome);
}

.traffic-bar-label {
  display: none;
  padding-top: 7px;
  color: var(--ink-faint);
  font-size: 9px;
}

.traffic-bar-item:first-child .traffic-bar-label,
.traffic-bar-item:last-child .traffic-bar-label {
  display: block;
}

.empty-copy,
.records-message,
.records-loading {
  padding: 22px 0;
  color: var(--ink-faint);
  font-size: 12px;
}

.report-grid {
  display: grid;
  gap: 36px;
}

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

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

.funnel-list {
  display: grid;
  gap: 13px;
}

.funnel-header,
.revenue-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.funnel-label,
.funnel-note,
.revenue-note,
.revenue-count {
  color: var(--ink-faint);
  font-size: 10px;
}

.funnel-value {
  font-size: 13px;
}

.funnel-rail {
  height: 5px;
  display: block;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e3dcd5;
}

.funnel-fill {
  width: calc(var(--funnel-ratio) * 100%);
  height: 100%;
  display: block;
  background: var(--rose);
}

.funnel-note {
  display: block;
  margin-top: 4px;
}

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

.revenue-card {
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 249, 0.65);
}

.revenue-amount {
  display: block;
  margin-top: 16px;
  font-size: 20px;
  line-height: 1.1;
}

.revenue-note {
  margin-top: 6px;
}

.table-scroll,
.records-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.compact-table,
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.compact-table th,
.records-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

.compact-table td,
.records-table td {
  max-width: 280px;
  padding: 11px 10px;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.compact-table th:first-child,
.compact-table td:first-child,
.records-table th:first-child,
.records-table td:first-child {
  padding-left: 0;
}

.compact-table th:last-child,
.compact-table td:last-child,
.records-table th:last-child,
.records-table td:last-child {
  padding-right: 0;
}

.numeric-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.metric-list {
  display: grid;
}

.metric-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

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

.metric-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.metric-label {
  color: var(--ink-soft);
  font-size: 11px;
}

.metric-note {
  color: var(--ink-faint);
  font-size: 9px;
}

.metric-value {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.registry-section {
  padding-top: 48px;
}

.registry-heading h2 {
  font-size: 34px;
}

.registry-heading > p {
  color: var(--ink-faint);
  font-size: 11px;
}

.entity-tabs {
  max-width: 100%;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line-strong);
  scrollbar-width: thin;
}

.entity-tabs button {
  min-height: 42px;
  flex: 0 0 auto;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.entity-tabs button.is-active {
  border-bottom-color: var(--rose);
  color: var(--ink);
}

.records-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto;
  gap: 10px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.search-field {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}

.search-field svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--ink-faint);
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.status-field {
  min-width: 0;
}

.status-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}

.filter-button {
  background: var(--chrome);
  color: #fff;
}

.filter-button:hover {
  background: var(--chrome-soft);
}

.records-stage {
  min-height: 260px;
  position: relative;
}

.records-loading {
  color: var(--rose-dark);
  font-weight: 600;
}

.records-message {
  color: var(--ink-soft);
}

.records-table {
  min-width: 760px;
}

.records-pager {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 10px;
}

.record-site-link {
  color: var(--rose-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.record-delete-button {
  border: 1px solid rgba(161, 63, 57, 0.42);
  border-radius: 6px;
  padding: 7px 10px;
  background: transparent;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}

.record-delete-button:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.record-delete-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #eee7df;
}

@media (max-width: 960px) {
  .report-grid-operations {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid-operations .report-section:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .shell {
    padding-inline: 16px;
  }

  .header-context,
  .header-divider,
  .header-link span {
    display: none;
  }

  .header-link {
    width: 42px;
    padding: 0;
  }

  .state-shell {
    grid-template-columns: 1fr;
    gap: 36px;
    padding-block: 44px;
  }

  .state-copy h1,
  .state-shell-compact h1 {
    font-size: 38px;
  }

  .dashboard-shell {
    padding-block: 26px 54px;
  }

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

  .dashboard-heading h1 {
    font-size: 38px;
  }

  .heading-controls {
    width: 100%;
  }

  .range-control {
    min-width: 0;
    flex: 1 1 auto;
  }

  .range-control button {
    min-width: 0;
    flex: 1 1 0;
    padding-inline: 7px;
  }

  .refresh-button {
    width: 42px;
    flex: 0 0 42px;
    padding: 0;
  }

  .refresh-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

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

  .kpi-item,
  .kpi-item:first-child,
  .kpi-item:last-child {
    padding: 15px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .kpi-item:nth-child(2n) {
    border-right: 0;
  }

  .kpi-item:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .report-grid,
  .report-grid-primary,
  .report-grid-content,
  .report-grid-operations {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .report-grid-operations .report-section:last-child {
    grid-column: auto;
  }

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

  .section-meta {
    width: 100%;
    justify-content: space-between;
  }

  .traffic-chart {
    height: 170px;
  }

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

  .registry-section {
    padding-top: 38px;
  }

  .registry-heading {
    align-items: flex-start;
  }

  .records-form {
    grid-template-columns: 1fr auto;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .status-field select {
    min-width: 0;
  }

  .records-table {
    min-width: 0;
  }

  .records-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .records-table,
  .records-table tbody,
  .records-table tr,
  .records-table td {
    display: block;
    width: 100%;
  }

  .records-table tr {
    padding: 9px 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .records-table td,
  .records-table td:first-child,
  .records-table td:last-child {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(90px, 0.7fr) minmax(0, 1.3fr);
    gap: 12px;
    padding: 6px 0;
    border: 0;
  }

  .records-table td::before {
    content: attr(data-label);
    color: var(--ink-faint);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
  }

  .records-pager {
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .shell {
    padding-inline: 12px;
  }

  .brand {
    font-size: 24px;
  }

  .state-copy h1,
  .state-shell-compact h1,
  .dashboard-heading h1 {
    font-size: 34px;
  }

  .range-control button {
    font-size: 10px;
  }

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

  .search-field {
    grid-column: auto;
  }

  .filter-button {
    width: 100%;
  }
}

@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;
  }
}
