:root {
  color-scheme: light;
  --bg: #f6efe6;
  --bg-strong: #f0dfc8;
  --panel: rgba(255, 249, 242, 0.9);
  --panel-strong: #fff8f0;
  --line: rgba(116, 78, 48, 0.16);
  --text: #2c2118;
  --muted: #705b48;
  --accent: #d86232;
  --accent-strong: #9f3f1b;
  --accent-soft: rgba(216, 98, 50, 0.14);
  --info: #0e5a74;
  --warn: #a66d00;
  --good: #2f6f43;
  --danger: #9a3030;
  --shadow: 0 18px 42px rgba(77, 46, 18, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shell-width: 320px;
  --font-ui: "Leelawadee UI", "Noto Sans Thai", "Tahoma", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(216, 98, 50, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(14, 90, 116, 0.14), transparent 24%),
    linear-gradient(180deg, #fcf5ec 0%, #f5ede2 50%, #f1e6d9 100%);
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
  touch-action: manipulation;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.action-button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0.8rem 1rem;
}

.action-button:hover,
.action-button:focus-visible {
  background: var(--accent-strong);
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
}

.action-button--secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.config-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  gap: 14px;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.55);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.table-block {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.table-block h3 {
  margin: 0;
}

a {
  color: inherit;
}

.app-shell-loading,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

.shell {
  display: grid;
  grid-template-columns: var(--shell-width) 1fr;
  min-height: 100vh;
}

.shell__backdrop,
.shell__nav-mobile-head {
  display: none;
}

.shell__nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  padding: 24px;
  background: rgba(44, 33, 24, 0.95);
  color: #f7efe4;
}

.shell__nav::after {
  content: "";
  position: absolute;
  inset: auto 24px 18px;
  height: 84px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(216, 98, 50, 0.26), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.shell__brand {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.shell__eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.shell__brand h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
}

.shell__brand p,
.shell__hint,
.shell__scope {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
}

.shell__scope {
  font-size: 13px;
}

.shell__role-card,
.shell__nav-list,
.shell__safety {
  position: relative;
  z-index: 1;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
}

.shell__role-card {
  display: grid;
  gap: 12px;
}

.shell__label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

.shell__role-select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(14, 12, 11, 0.32);
  color: #fff6eb;
}

.shell__role-pills,
.chip-row,
.badge-row,
.stat-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  outline: none;
}

.nav-button.is-active {
  background: linear-gradient(135deg, rgba(216, 98, 50, 0.34), rgba(216, 98, 50, 0.14));
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(3px);
}

.nav-button__text {
  display: grid;
  gap: 3px;
}

.nav-button__title {
  font-weight: 700;
}

.nav-button__desc {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.2;
}

.pill {
  background: rgba(255, 255, 255, 0.08);
  color: #fff8ef;
}

.hero .pill {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.badge {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge--info {
  background: rgba(14, 90, 116, 0.12);
  color: var(--info);
}

.badge--warn {
  background: rgba(166, 109, 0, 0.12);
  color: var(--warn);
}

.badge--good {
  background: rgba(47, 111, 67, 0.13);
  color: var(--good);
}

.badge--danger {
  background: rgba(154, 48, 48, 0.14);
  color: var(--danger);
}

.badge--ghost {
  background: rgba(112, 91, 72, 0.12);
  color: var(--muted);
}

.shell__main {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar__menu {
  display: inline-flex;
  min-width: 48px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
}

.demo-bar {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border: 1px solid rgba(216, 98, 50, 0.24);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(255, 248, 240, 0.92), rgba(245, 233, 219, 0.92));
  box-shadow: var(--shadow);
}

.demo-bar strong {
  font-size: 15px;
}

.demo-bar__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

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

.section,
.panel,
.table-block {
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}

.hero,
.section,
.card,
.panel,
.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero,
.section,
.panel {
  padding: 24px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 14px;
  background:
    radial-gradient(circle at top right, rgba(216, 98, 50, 0.18), transparent 26%),
    linear-gradient(140deg, rgba(255, 251, 246, 0.96), rgba(243, 232, 219, 0.95));
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(216, 98, 50, 0.1);
}

.hero__title {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(30px, 3vw, 44px);
  line-height: 1.02;
}

.hero__summary,
.section__summary,
.card__meta,
.muted {
  color: var(--muted);
}

.hero__summary,
.section__summary {
  max-width: 72ch;
}

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

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

.card,
.kpi {
  padding: 18px;
}

.card h3,
.section h2,
.panel h2,
.kpi h3 {
  margin: 0 0 8px;
}

.card__meta,
.section__summary,
.tiny {
  font-size: 13px;
}

.section__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section__title-wrap {
  display: grid;
  gap: 6px;
}

.kpi__value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.kpi__label {
  font-size: 13px;
  color: var(--muted);
}

.progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(112, 91, 72, 0.14);
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f4aa5f);
}

.progress--good > span {
  background: linear-gradient(90deg, var(--good), #67a978);
}

.progress--info > span {
  background: linear-gradient(90deg, var(--info), #4a94aa);
}

.meter {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(112, 91, 72, 0.14);
  appearance: none;
}

.meter::-webkit-progress-bar {
  border-radius: 999px;
  background: rgba(112, 91, 72, 0.14);
}

.meter::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f4aa5f);
}

.meter::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f4aa5f);
}

.meter--good::-webkit-progress-value {
  background: linear-gradient(90deg, var(--good), #67a978);
}

.meter--good::-moz-progress-bar {
  background: linear-gradient(90deg, var(--good), #67a978);
}

.meter--info::-webkit-progress-value {
  background: linear-gradient(90deg, var(--info), #4a94aa);
}

.meter--info::-moz-progress-bar {
  background: linear-gradient(90deg, var(--info), #4a94aa);
}

.dashboard-toolbar {
  position: sticky;
  top: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 249, 242, 0.94);
  box-shadow: 0 12px 30px rgba(77, 46, 18, 0.11);
  backdrop-filter: blur(14px);
}

.dashboard-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 8px;
  flex: 1;
}

.dashboard-tab {
  display: grid;
  min-height: 64px;
  align-content: center;
  gap: 3px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.dashboard-tab span {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-tab:hover,
.dashboard-tab:focus-visible {
  border-color: var(--line);
  background: rgba(216, 98, 50, 0.07);
  outline: 3px solid var(--accent-soft);
}

.dashboard-tab.is-active {
  border-color: rgba(216, 98, 50, 0.24);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.dashboard-tab.is-active span {
  color: rgba(255, 255, 255, 0.82);
}

.dashboard-freshness {
  display: grid;
  min-width: 120px;
  gap: 2px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-freshness strong {
  color: var(--text);
  font-size: 14px;
}

.dashboard-view {
  display: grid;
  gap: 18px;
}

.dashboard-view .section {
  content-visibility: visible;
  contain-intrinsic-size: none;
}

#page-root > .section {
  content-visibility: visible;
  contain-intrinsic-size: none;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
}

.dashboard-kpis .kpi {
  min-height: 132px;
}

.dashboard-split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(240px, 0.45fr);
  gap: 18px;
}

.priority-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.priority-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
}

.priority-item--danger {
  border-left-color: var(--danger);
}

.priority-item--good {
  border-left-color: var(--good);
}

.priority-item__body {
  display: grid;
  gap: 5px;
}

.priority-item__owner {
  display: grid;
  min-width: 112px;
  gap: 2px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.priority-item__owner span {
  color: var(--muted);
  font-size: 11px;
}

.empty-panel {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
}

.attention-card {
  align-self: stretch;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #2c2118, #5a3924);
  color: #fff7ee;
}

.attention-card--collection {
  background: linear-gradient(160deg, #073d50, #0e5a74);
}

.attention-card__eyebrow {
  width: fit-content;
  margin-bottom: 8px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  text-transform: uppercase;
}

.attention-card p {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  line-height: 1.55;
}

.target-spotlight {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  overflow: hidden;
  border: 1px solid rgba(216, 98, 50, 0.22);
  border-radius: var(--radius-xl);
  background: linear-gradient(140deg, rgba(255, 250, 244, 0.98), rgba(244, 221, 199, 0.94));
  box-shadow: var(--shadow);
}

.target-spotlight--collection {
  border-color: rgba(14, 90, 116, 0.22);
  background: linear-gradient(140deg, rgba(245, 252, 253, 0.98), rgba(207, 228, 234, 0.95));
}

.target-spotlight__main,
.target-spotlight__aside {
  padding: 24px;
}

.target-spotlight__main {
  display: grid;
  gap: 16px;
}

.target-spotlight__main p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.target-spotlight__label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.target-spotlight__value {
  font-size: clamp(38px, 6vw, 66px);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 1;
}

.target-spotlight__value small {
  font-size: 0.34em;
  font-weight: 700;
  letter-spacing: normal;
}

.target-spotlight__aside {
  display: grid;
  align-content: center;
  gap: 0;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.38);
}

.target-spotlight__aside > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.target-spotlight__aside > div:last-child {
  border-bottom: 0;
}

.target-spotlight__aside span {
  color: var(--muted);
  font-size: 13px;
}

.text-good {
  color: var(--good);
}

.text-danger {
  color: var(--danger);
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.person-performance {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
}

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

.person-performance__head > div {
  display: grid;
  gap: 2px;
}

.person-performance__head span {
  color: var(--muted);
  font-size: 12px;
}

.person-performance__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.person-performance__stats span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(112, 91, 72, 0.07);
}

.person-performance__stats strong {
  color: var(--text);
}

.source-grid,
.ledger-rules {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.source-card,
.ledger-rules > div {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
}

.source-card--primary {
  border-color: rgba(216, 98, 50, 0.26);
  background: rgba(216, 98, 50, 0.09);
}

.source-card span,
.source-card small,
.ledger-rules p {
  color: var(--muted);
  font-size: 12px;
}

.source-card strong {
  font-size: 30px;
}

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

.ledger-rules__number {
  color: var(--accent);
  font-size: 30px;
  font-weight: 900;
}

.ledger-rules p {
  margin: 2px 0 0;
  line-height: 1.5;
}

.list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list__item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
}

.list__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

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

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(112, 91, 72, 0.14);
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(112, 91, 72, 0.08);
  font-size: 13px;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(216, 98, 50, 0.04);
}

.metric-stack {
  display: grid;
  gap: 8px;
}

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

.timeline {
  position: relative;
  display: grid;
  gap: 14px;
  padding-left: 16px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, rgba(216, 98, 50, 0.5), rgba(14, 90, 116, 0.14));
}

.timeline__item {
  position: relative;
  padding-left: 16px;
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(216, 98, 50, 0.12);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.route-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
}

.security-note {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(14, 90, 116, 0.18);
  background: rgba(14, 90, 116, 0.08);
  color: var(--info);
}

.footnote {
  color: var(--muted);
  font-size: 12px;
}

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

  .grid--3,
  .grid--2,
  .split,
  .target-spotlight {
    grid-template-columns: 1fr;
  }

  .target-spotlight__aside {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

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

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .shell__nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 360px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    z-index: 40;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.26);
  }

  .shell[data-nav-open="true"] .shell__nav {
    transform: translateX(0);
  }

  .shell__backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    border: 0;
    background: rgba(23, 15, 10, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .shell[data-nav-open="true"] .shell__backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .shell__nav-mobile-head {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
  }

  .shell__nav-close {
    display: grid;
    width: 48px;
    height: 48px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    color: #fff8ef;
    background: rgba(255, 255, 255, 0.08);
    font-size: 28px;
  }

  .shell__main {
    padding: 18px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    min-height: 64px;
    padding-top: env(safe-area-inset-top);
    background: rgba(252, 245, 236, 0.92);
    backdrop-filter: blur(12px);
  }

  .dashboard-toolbar {
    top: 72px;
  }

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

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .shell__main,
  .hero,
  .section,
  .panel {
    padding: 14px;
  }

  .shell__main {
    gap: 12px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .topbar {
    margin: -14px -14px 0;
    padding-right: 14px;
    padding-left: 14px;
  }

  .demo-bar {
    gap: 5px;
    padding: 14px;
  }

  .demo-bar__meta {
    display: grid;
    gap: 4px;
    font-size: 12px;
  }

  .hero {
    gap: 11px;
    border-radius: 22px;
  }

  .hero__title {
    font-size: clamp(28px, 9vw, 36px);
  }

  .hero__summary {
    line-height: 1.55;
  }

  .chip-row {
    display: grid;
  }

  .hero .pill {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .grid--4,
  .grid--3,
  .grid--2 {
    grid-template-columns: 1fr;
  }

  .dashboard-toolbar {
    top: 66px;
    display: grid;
    gap: 8px;
    padding: 8px;
  }

  .dashboard-tabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }

  .dashboard-tab {
    min-width: 154px;
    min-height: 58px;
    scroll-snap-align: start;
  }

  .dashboard-freshness {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    padding: 2px 6px;
  }

  .dashboard-view {
    gap: 12px;
  }

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

  .dashboard-kpis .kpi {
    min-height: 124px;
    padding: 14px;
    border-radius: 20px;
  }

  .dashboard-kpis .kpi__value {
    font-size: 28px;
  }

  .priority-item {
    grid-template-columns: 1fr;
  }

  .priority-item__owner {
    display: flex;
    min-width: 0;
    justify-content: space-between;
    padding-top: 9px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
    text-align: left;
  }

  .target-spotlight__main,
  .target-spotlight__aside {
    padding: 18px;
  }

  .target-spotlight__aside > div {
    min-height: 48px;
  }

  .target-spotlight__value {
    font-size: 42px;
  }

  .performance-grid,
  .source-grid,
  .ledger-rules {
    grid-template-columns: 1fr;
  }

  .hero__title {
    max-width: none;
  }

  .config-form {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .field {
    font-size: 14px;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .action-button {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

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

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 22px rgba(77, 46, 18, 0.07);
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    gap: 10px;
    padding: 11px 12px;
    overflow-wrap: anywhere;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
