:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --line: #dde3ea;
  --line-strong: #cfd7e0;
  --text: #121b31;
  --muted: #7f8a9a;
  --subtle: #aab3bf;
  --orange: #e77b18;
  --orange-soft: #fff2e4;
  --orange-line: #f8c28b;
  --blue: #376ed8;
  --blue-soft: #eaf2ff;
  --green: #19a06b;
  --green-soft: #eaf8f1;
  --red: #d94a3a;
  --red-soft: #fff0ed;
  --shadow: 0 18px 45px rgba(34, 48, 73, 0.1);
  --tiny-shadow: 0 6px 18px rgba(34, 48, 73, 0.06);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

:where(button, a, input, select):focus-visible {
  outline: 3px solid rgba(55, 110, 216, 0.28);
  outline-offset: 2px;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-sprite symbol path,
button svg path,
.icon-btn svg path,
.rail-item svg path,
.search-box svg path,
.check-list svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  min-height: 100vh;
  padding: 12px;
  gap: 12px;
}

.rail {
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  flex-direction: column;
  padding: 12px 10px;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ff4c3a, #c9191c);
  box-shadow: 0 10px 20px rgba(224, 61, 39, 0.22);
  display: grid;
  place-items: center;
  margin-bottom: 22px;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.36);
  transform: rotate(45deg);
}

.brand-mark::before {
  width: 16px;
  height: 16px;
  top: 6px;
  left: 8px;
  clip-path: polygon(0 0, 100% 0, 55% 100%);
}

.brand-mark::after {
  width: 14px;
  height: 14px;
  right: 6px;
  bottom: 7px;
  clip-path: polygon(45% 0, 100% 100%, 0 100%);
}

.brand-mark span {
  width: 10px;
  height: 10px;
  left: 9px;
  bottom: 8px;
  opacity: 0.62;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.rail-item {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #9ca6b3;
  background: transparent;
  display: grid;
  place-items: center;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.rail-item svg {
  width: 19px;
  height: 19px;
}

.rail-item:hover {
  color: var(--orange);
  background: var(--orange-soft);
}

.rail-item.active {
  color: #fff;
  background: linear-gradient(135deg, #f4922d, #e77713);
  box-shadow: 0 12px 24px rgba(239, 134, 31, 0.25);
}

.workspace {
  min-width: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(165px, 190px) minmax(240px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box {
  width: 100%;
  max-width: 520px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--subtle);
  border: 1px solid transparent;
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 0 12px;
}

.search-box svg {
  width: 18px;
  height: 18px;
}

.search-box input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: 0;
  color: var(--text);
  min-width: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.top-actions select {
  height: 38px;
  border: 1px solid var(--line);
  color: #536071;
  background: #fff;
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
}

.multi-select {
  position: relative;
  flex: 0 0 auto;
  min-width: 154px;
}

.multi-select-trigger {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #536071;
  background: #fff;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.multi-select-trigger:hover,
.multi-select.open .multi-select-trigger {
  color: var(--orange);
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.select-caret {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.18s ease;
}

.multi-select.open .select-caret {
  transform: translateY(2px) rotate(225deg);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: none;
  width: 180px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--tiny-shadow);
  padding: 8px;
}

.multi-select.open .multi-select-menu {
  display: grid;
}

.multi-select-option {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 7px;
  color: #425166;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.multi-select-option:hover {
  background: var(--surface-soft);
}

.multi-select-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--orange);
}

.multi-select-all {
  color: var(--orange);
}

.multi-select-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.param-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #536071;
  padding: 0 12px;
  font-size: 13px;
}

.context-chip {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: #536071;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.inline-select {
  min-width: 92px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #425166;
  background: #fff;
  padding: 0 8px;
  outline: 0;
}

.inline-select:disabled {
  color: var(--muted);
  background: #f0f3f7;
}

.icon-btn,
.full-btn,
.text-btn,
.chip,
.segmented button,
.tab-strip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  color: #536071;
  background: #fff;
  border: 1px solid var(--line);
  padding: 0 13px;
  white-space: nowrap;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-btn span,
.full-btn span,
.chip span {
  white-space: nowrap;
}

a.icon-btn,
a.rail-item,
a.brand-mark {
  text-decoration: none;
}

.icon-btn svg,
.full-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn:hover,
.full-btn:hover,
.chip:hover,
.segmented button:hover,
.tab-strip button:hover {
  border-color: var(--orange-line);
  color: var(--orange);
  background: var(--orange-soft);
}

.icon-btn:disabled,
.full-btn:disabled,
.chip:disabled,
.segmented button:disabled,
.tab-strip button:disabled {
  cursor: not-allowed;
  color: #9aa5b3;
  border-color: var(--line);
  background: #f2f5f8;
  box-shadow: none;
  transform: none;
}

.primary-action {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #f2942f, #e2740c);
  box-shadow: 0 10px 24px rgba(239, 134, 31, 0.22);
}

.primary-action:hover {
  color: #fff;
  background: linear-gradient(135deg, #f19a3a, #dc6d08);
}

.attention-pulse {
  animation: attentionPulse 0.8s ease-in-out 3;
}

@keyframes attentionPulse {
  0%,
  100% {
    box-shadow: 0 10px 24px rgba(239, 134, 31, 0.22);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(239, 134, 31, 0.18), 0 14px 30px rgba(239, 134, 31, 0.3);
  }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 124px;
  max-width: 180px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #ff9c39, #d96b05);
  font-weight: 750;
}

.avatar.square {
  border-radius: 8px;
  background: linear-gradient(135deg, #4e8ee9, #24a7b8);
}

.user-chip strong,
.user-chip small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip strong {
  font-size: 12px;
  font-weight: 760;
}

.user-chip small {
  color: var(--muted);
  font-size: 11px;
}

.view {
  display: none;
  padding: 20px 4px 28px;
}

.view.active {
  display: block;
}

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 16px;
}

.page-title p {
  margin: 0 0 6px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 760;
}

.page-title h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #9a610c;
  background: #fff5e8;
  border: 1px solid #f6cf9f;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 720;
  white-space: nowrap;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
}

.status-pill.ok {
  color: #18754f;
  background: var(--green-soft);
  border-color: #b9e4d0;
}

.status-pill.ok span {
  background: var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card,
.panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.metric-card {
  min-height: 100px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card small,
.panel-head p,
.muted,
.detail-head p,
.timeline small {
  color: var(--muted);
}

.metric-card small {
  font-weight: 650;
}

.metric-card strong {
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: 0;
}

.metric-line {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.metric-line.positive {
  color: var(--green);
}

.metric-line.warning {
  color: #b86b00;
}

.metric-line.danger,
.danger-text {
  color: var(--red);
}

.alert-card {
  background: linear-gradient(135deg, #fff, #fff4ef);
  border-color: #ffd3c8;
}

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

.panel {
  padding: 16px;
  min-width: 0;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: 1 / -1;
}

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

.panel-head.compact {
  align-items: center;
  margin-bottom: 14px;
}

.panel-head h2,
.detail-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.mode-switch-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mode-switch-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mode-segment {
  flex: 0 0 auto;
}

.is-cumulative-mode .mode-switch-panel {
  background: #fffaf3;
}

.panel-head p,
.detail-head p {
  margin: 5px 0 0;
  font-size: 12px;
}

.segmented,
.tab-strip {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.tab-strip {
  max-width: 100%;
  overflow-x: auto;
}

.segmented button,
.tab-strip button {
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0 10px;
  font-size: 12px;
  box-shadow: none;
  white-space: nowrap;
}

.segmented button.active,
.tab-strip button.active,
.chip.active {
  color: #fff;
  background: var(--orange);
  border-color: var(--orange);
}

.chart-wrap {
  min-height: 258px;
}

.chart-wrap svg {
  width: 100%;
  height: 258px;
}

.chart-area {
  fill: url(#orangeFill);
}

.chart-line {
  fill: none;
  stroke: #ec8220;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cumulative-grid line {
  stroke: #e8edf2;
  stroke-width: 1;
}

.cumulative-line {
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cumulative-legend text {
  fill: #697586;
  font-size: 12px;
  font-weight: 700;
}

.bars rect {
  fill: #f7a351;
  opacity: 0.82;
  rx: 2;
}

.chart-labels {
  fill: #9ba5b2;
  font-size: 13px;
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

.chart-stats b {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.score-badge {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--orange-soft);
  color: #bd6508;
  font-weight: 780;
}

.health-meter {
  margin: 24px 0 18px;
}

.meter-track {
  height: 9px;
  border-radius: 999px;
  background: #e8edf2;
  overflow: hidden;
}

.meter-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f9b051, #ec7921);
}

.meter-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  margin-top: 8px;
}

.risk-list {
  display: grid;
  gap: 10px;
}

.risk-list div,
.detail-list div,
.timeline-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.risk-list div {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 10px 12px;
}

.risk-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.risk-dot.danger {
  background: var(--red);
}

.risk-dot.ok {
  background: var(--green);
}

.risk-dot.warn {
  background: var(--orange);
}

.risk-list strong {
  flex: 1;
}

.risk-list em {
  color: var(--muted);
  font-style: normal;
}

.donut-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 10px 0 18px;
}

.donut {
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 55%, transparent 56%),
    conic-gradient(var(--orange) calc(var(--value) * 1%), #e7edf3 0);
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-copy strong {
  display: block;
  font-size: 26px;
}

.donut-copy small {
  color: var(--muted);
  font-weight: 650;
}

.mini-bars {
  display: grid;
  gap: 8px;
}

.mini-bars label {
  display: flex;
  justify-content: space-between;
  color: #596577;
  font-size: 12px;
  font-weight: 700;
}

.mini-bars div {
  height: 7px;
  border-radius: 999px;
  background: #e9eef3;
  overflow: hidden;
}

.mini-bars div span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35b9cd, #f28a23);
}

.table-shell {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #bdc6d1 transparent;
}

.table-shell.tall {
  max-height: calc(100vh - 250px);
  min-height: 0;
  overflow: auto;
}

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

.overview-orders-table {
  min-width: 780px;
}

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

.payments-table {
  min-width: 980px;
}

.wallets-table {
  min-width: 1000px;
}

.ledger-table {
  min-width: 1280px;
}

.col-id {
  width: 104px;
}

.col-product {
  width: 220px;
  white-space: normal;
}

.col-subject,
.col-supplier {
  width: 150px;
  white-space: normal;
}

.col-date {
  width: 132px;
}

.col-status,
.col-lock,
.col-type {
  width: 104px;
}

.col-currency,
.col-rate,
.col-quantity {
  width: 76px;
}

.col-money {
  width: 126px;
}

.col-reference {
  width: 170px;
  white-space: normal;
}

.col-voucher,
.col-action {
  width: 92px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  color: #7b8796;
  font-size: 12px;
  font-weight: 760;
  background: #fafbfd;
}

td {
  color: #2d384b;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th[data-sticky="start"],
td[data-sticky="start"] {
  position: sticky;
  left: 0;
}

th[data-sticky="end"],
td[data-sticky="end"] {
  position: sticky;
  right: 0;
}

th[data-sticky] {
  z-index: 5;
}

td[data-sticky] {
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line), -1px 0 0 var(--line);
}

tbody tr:hover td[data-sticky],
tbody tr.selected td[data-sticky] {
  background: #fff8f0;
}

.table-shell.is-overflowing:not(.at-scroll-end) {
  box-shadow: inset -18px 0 16px -18px rgba(37, 49, 68, 0.7);
}

.table-scroll-hint {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 6px auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-soft);
  color: #687486;
  font-size: 13px;
  font-weight: 800;
}

.table-scroll-hint[hidden] {
  display: none;
}

.data-date {
  display: grid;
  gap: 3px;
  line-height: 1.25;
}

.cell-primary {
  display: block;
}

.mobile-cell-meta {
  display: none;
}

.mobile-only {
  display: none;
}

.data-date time,
.detail-list time {
  font-variant-numeric: tabular-nums;
}

.data-date small {
  color: var(--muted);
  font-size: 11px;
}

.missing-data {
  color: #a75b0a;
  font-size: 12px;
  font-weight: 750;
}

.data-date .missing-data,
.detail-list .missing-data {
  color: #a75b0a;
}

tbody tr:hover,
tbody tr.selected {
  background: #fff8f0;
}

tbody tr[tabindex] {
  cursor: pointer;
}

tbody tr[tabindex]:focus-visible {
  outline: 3px solid rgba(55, 110, 216, 0.28);
  outline-offset: -3px;
}

.empty-cell,
.empty-panel {
  color: var(--muted);
  text-align: center;
}

.empty-panel {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 18px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge.orange {
  color: #a75b0a;
  background: var(--orange-soft);
}

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

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

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

.badge.neutral {
  color: #697586;
  background: #eef2f6;
}

.text-btn {
  min-height: 30px;
  padding: 0 10px;
  color: var(--orange);
  background: var(--orange-soft);
  border-color: transparent;
}

.table-action-btn {
  min-width: 52px;
}

.table-action-btn:disabled {
  color: #98a2b3;
  background: #eef2f6;
  cursor: not-allowed;
}

.split-layout {
  display: block;
  min-width: 0;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.chip {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.chip.action-chip {
  color: var(--orange);
  background: var(--orange-soft);
  border-color: transparent;
}

.detail-panel {
  padding: 0;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  visibility: hidden;
  pointer-events: none;
}

.detail-drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.detail-drawer-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: rgba(18, 27, 49, 0.24);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.detail-drawer.open .detail-drawer-scrim {
  opacity: 1;
}

.detail-drawer .detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, calc(100vw - 28px));
  height: 100%;
  border-width: 0 0 0 1px;
  border-radius: 8px 0 0 8px;
  box-shadow: -18px 0 48px rgba(24, 35, 54, 0.16);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.detail-drawer.open .detail-panel {
  transform: translateX(0);
}

.detail-drawer-toolbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 16px;
}

.detail-content {
  padding: 18px;
}

.detail-drawer-open {
  overflow: hidden;
}

.detail-note {
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.5;
}

.detail-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.detail-list {
  display: grid;
  gap: 10px;
}

.detail-list div {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.detail-list span {
  color: var(--muted);
}

.detail-subhead {
  margin: 18px 0 10px;
  color: #657184;
  font-size: 12px;
  font-weight: 780;
}

.detail-subhead:first-of-type {
  margin-top: 0;
}

.detail-list strong,
.detail-value {
  min-width: 0;
  max-width: 175px;
  text-align: right;
  overflow-wrap: anywhere;
  white-space: normal;
}

.detail-long-text {
  margin: 0;
  padding: 11px 0;
  color: #2d384b;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.pending-cell {
  color: var(--red);
  font-weight: 760;
}

.action-stack {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.full-btn {
  width: 100%;
  min-height: 42px;
}

.big-number {
  font-size: 30px;
  font-weight: 780;
  margin: 10px 0 22px;
}

.payment-pool-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(420px, 2fr);
  grid-template-rows: auto 1fr;
  align-items: center;
  column-gap: 28px;
}

.payment-pool-panel .panel-head {
  grid-column: 1;
  grid-row: 1;
  margin-bottom: 4px;
}

.payment-pool-panel .big-number {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
}

.payment-pool-panel .mini-bars {
  grid-column: 2;
  grid-row: 1 / span 2;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
}

.payment-pool-panel .mini-bars label:nth-of-type(1),
.payment-pool-panel .mini-bars > div:nth-of-type(1) {
  grid-column: 1;
}

.payment-pool-panel .mini-bars label:nth-of-type(2),
.payment-pool-panel .mini-bars > div:nth-of-type(2) {
  grid-column: 2;
}

.payment-pool-panel .mini-bars label:nth-of-type(3),
.payment-pool-panel .mini-bars > div:nth-of-type(3) {
  grid-column: 3;
}

.payment-pool-panel .mini-bars label {
  grid-row: 1;
}

.payment-pool-panel .mini-bars > div {
  grid-row: 2;
  align-self: start;
}

.flow-board {
  display: grid;
  grid-template-columns: 1fr 64px 1fr 64px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 240px;
}

.allocation-detail {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.allocation-cumulative-head,
.allocation-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.allocation-cumulative-head h2,
.allocation-detail-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.allocation-cumulative-head p,
.allocation-detail-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.cumulative-allocation-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

.history-pool-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.history-pool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.history-pool-row span {
  color: #5d6878;
  font-weight: 760;
}

.history-pool-row strong {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.history-pool-row em {
  min-width: 54px;
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.history-pool-row.total {
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.history-pool-row.total strong {
  color: var(--orange);
}

.cumulative-detail-shell table {
  min-width: 980px;
}

.strong-num {
  color: var(--orange);
  font-weight: 820;
}

.flow-column {
  display: grid;
  gap: 12px;
}

.flow-column h2 {
  margin: 0;
  font-size: 16px;
}

.flow-card {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flow-card.strong {
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.flow-card b {
  font-variant-numeric: tabular-nums;
}

.muted-card {
  background: var(--surface-soft);
}

.flow-arrow {
  height: 2px;
  background: linear-gradient(90deg, var(--orange), #4bb7c9);
  position: relative;
}

.flow-arrow::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-right: 2px solid #4bb7c9;
  border-top: 2px solid #4bb7c9;
  transform: translateY(-50%) rotate(45deg);
}

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

.check-list div {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 0 12px;
  color: #344054;
  font-weight: 700;
}

.check-list div b {
  margin-left: auto;
  color: var(--green);
  font-size: 12px;
}

.check-list svg {
  width: 18px;
  height: 18px;
  color: var(--green);
}

.check-list .blocked {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffd3ca;
}

.check-list .blocked svg {
  color: var(--red);
}

.check-list .blocked b {
  color: var(--red);
}

.timeline {
  display: grid;
  gap: 20px;
  padding: 10px 2px;
}

.timeline-item {
  position: relative;
  align-items: flex-start;
}

.timeline-item > span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #c7d0da;
  background: #fff;
  margin-top: 3px;
  flex: 0 0 auto;
}

.timeline-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 22px;
  width: 2px;
  height: 34px;
  background: var(--line);
}

.timeline-item.done > span {
  background: var(--green);
  border-color: var(--green);
}

.timeline-item.current > span {
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 0 5px var(--orange-soft);
}

.timeline-item strong,
.timeline-item small {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(22, 32, 49, 0.28);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(30, 44, 65, 0.2);
  overflow: hidden;
}

.rollback-modal {
  width: min(560px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  padding: 18px;
}

.modal-body p {
  margin: 0 0 16px;
  color: #4a5568;
}

.modal-actions {
  display: grid;
  gap: 10px;
}

.modal-detail-list {
  margin-bottom: 16px;
}

.help-content {
  display: grid;
  gap: 14px;
}

.help-content section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.help-content h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 14px;
}

.help-content p {
  margin: 0;
  color: #536071;
  font-size: 13px;
}

.manual-modal {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
}

.manual-modal .modal-head {
  background: rgba(255, 255, 255, 0.96);
}

.manual-modal .modal-body {
  max-height: calc(100vh - 116px);
  overflow: auto;
}

.manual-content {
  display: grid;
  gap: 16px;
}

.manual-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.manual-section h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 16px;
}

.manual-section p {
  margin: 0;
  color: #4e5a6b;
  font-size: 13px;
}

.manual-callout {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  border-left: 3px solid var(--orange);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
}

.manual-callout strong,
.manual-grid strong,
.manual-rules strong,
.manual-steps strong {
  color: var(--text);
}

.manual-callout span,
.manual-grid span,
.manual-rules span,
.manual-steps span {
  color: #536071;
  font-size: 13px;
}

.manual-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: manual-step;
}

.manual-steps li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 4px;
  align-items: start;
  counter-increment: manual-step;
}

.manual-steps li::before {
  content: counter(manual-step);
  grid-column: 1;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  background: var(--orange);
  font-size: 12px;
  font-weight: 800;
}

.manual-steps li strong,
.manual-steps li span {
  display: block;
  grid-column: 2;
  min-width: 0;
}

.manual-steps li strong {
  grid-row: 1;
}

.manual-steps li span {
  grid-row: 2;
  line-height: 1.55;
}

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

.manual-grid div,
.manual-rules div {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.manual-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.manual-status span {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-radius: 999px;
  color: #9a610c;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  font-size: 12px;
  font-weight: 800;
}

.manual-status i {
  position: relative;
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: var(--orange-line);
}

.manual-status i::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--orange-line);
  border-top: 2px solid var(--orange-line);
  transform: translateY(-50%) rotate(45deg);
}

.manual-faq {
  display: grid;
  gap: 8px;
}

.manual-faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.manual-faq summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 760;
}

.manual-faq p {
  margin-top: 8px;
}

.form-modal {
  width: min(560px, calc(100vw - 32px));
}

.modal.form-modal.manual-modal {
  width: min(920px, calc(100vw - 32px));
}

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

.form-field {
  display: grid;
  gap: 6px;
}

.form-field span {
  color: #5d6878;
  font-size: 12px;
  font-weight: 750;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  padding: 0 11px;
  outline: 0;
}

.form-field textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.5;
  padding-top: 10px;
  font-family: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--orange-line);
  box-shadow: 0 0 0 3px rgba(239, 134, 31, 0.12);
}

.voucher-cell {
  min-width: 72px;
}

.voucher-trigger {
  display: inline-grid;
  grid-template-columns: 32px 12px;
  align-items: center;
  gap: 4px;
  width: 56px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  text-align: left;
}

.voucher-trigger:hover {
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.voucher-trigger img,
.voucher-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.voucher-trigger img {
  display: block;
  object-fit: cover;
}

.voucher-placeholder {
  display: grid;
  place-items: center;
  color: var(--orange);
  background: var(--orange-soft);
  font-size: 20px;
}

.voucher-count {
  display: block;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.voucher-modal {
  width: min(720px, calc(100vw - 32px));
}

.voucher-modal .modal-head > div {
  min-width: 0;
}

.voucher-modal .modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.voucher-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: min(52vh, 520px);
  overflow: auto;
}

.voucher-preview {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-soft);
}

.voucher-preview:hover {
  border-color: var(--orange-line);
}

.voucher-preview img {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  background: #fff;
  object-fit: contain;
}

.voucher-preview span {
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.voucher-preview small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.voucher-empty {
  grid-column: 1 / -1;
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.voucher-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  margin-top: 16px;
}

.voucher-upload-row input {
  min-width: 0;
  height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.voucher-help {
  margin: 8px 0 0 !important;
  color: var(--muted) !important;
  font-size: 12px;
}

@media (max-width: 560px) {
  .voucher-upload-row {
    grid-template-columns: 1fr;
  }
}

.rollback-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.rollback-summary-grid div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.rollback-summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rollback-summary-grid strong {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rollback-impact {
  margin-bottom: 14px;
  padding: 12px;
  color: #7a3b00;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  border-radius: 8px;
  line-height: 1.6;
}

.rollback-reason {
  margin-bottom: 14px;
}

.form-actions {
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  margin-top: 4px;
}

.settings-modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
}

.settings-modal .modal-head {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.96);
}

.settings-modal .modal-head p {
  margin: 4px 0 0;
  color: #697588;
  font-size: 12px;
  font-weight: 650;
}

.settings-modal .modal-body {
  max-height: calc(100vh - 118px);
  overflow: auto;
}

.settings-loading,
.settings-error-state {
  display: grid;
  gap: 8px;
  color: #536071;
  font-size: 14px;
}

.settings-error-state strong {
  color: var(--text);
}

.system-view {
  display: block;
}

.system-layout {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 18px;
}

.system-subnav {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.system-subnav button {
  min-height: 42px;
  border-radius: 8px;
  color: #536071;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  font-weight: 760;
}

.system-subnav button:hover {
  color: var(--orange);
  background: var(--orange-soft);
}

.system-subnav button.active {
  color: #fff;
  background: var(--orange);
}

.system-content {
  min-width: 0;
}

.system-tab {
  display: none;
}

.system-tab.active {
  display: block;
}

.system-panel {
  min-height: 0;
}

.system-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.system-filters select,
.permission-role-head select,
#permissionRoleSelect {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #536071;
  background: #fff;
  padding: 0 12px;
}

.system-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.system-table th,
.system-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.system-table th {
  color: #697586;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 780;
}

.system-table tr:last-child td {
  border-bottom: 0;
}

.tag-line,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.row-actions button {
  min-height: 28px;
  border-radius: 7px;
  color: #536071;
  background: #fff;
  border: 1px solid var(--line);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 730;
}

.row-actions button:hover {
  color: var(--orange);
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.row-actions button:disabled {
  cursor: not-allowed;
  color: #9aa5b3;
  background: #f2f5f8;
  border-color: var(--line);
}

.row-actions .danger-link {
  color: var(--red);
}

.mini-tag {
  display: inline-flex;
  margin-left: 8px;
  min-height: 20px;
  align-items: center;
  border-radius: 999px;
  background: #eef2f6;
  color: #697586;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 760;
}

.system-card-list {
  display: none;
}

.system-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.system-card strong {
  display: block;
}

.system-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
}

.permission-editor {
  display: grid;
  gap: 14px;
}

.permission-role-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.permission-role-head strong,
.permission-role-head span {
  display: block;
}

.permission-role-head span {
  color: var(--muted);
  margin-top: 3px;
}

.permission-form {
  display: grid;
  gap: 14px;
}

.permission-group {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-group legend {
  padding: 0 6px;
  color: var(--text);
  font-weight: 800;
}

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

.permission-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px 10px;
  color: #536071;
  font-weight: 710;
}

.permission-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--orange);
}

.permission-check.sensitive {
  background: #fffaf3;
  border-color: #f7d8b2;
}

.permission-check.locked {
  color: #9aa5b3;
  background: #f2f5f8;
  border-color: var(--line);
}

.permission-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: center;
}

.permission-actions p,
.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.system-modal {
  width: min(680px, calc(100vw - 32px));
}

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

.system-form .form-field-wide,
.system-form .form-section,
.system-form .form-note,
.system-form .modal-actions {
  grid-column: 1 / -1;
}

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.system-note {
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--orange-line);
  border-radius: 8px;
  background: var(--orange-soft);
  color: #845019;
  font-size: 12px;
  font-weight: 720;
}

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

.menu-config-group {
  display: grid;
  gap: 8px;
}

.menu-config-group h3 {
  margin: 0;
  color: #536071;
  font-size: 13px;
}

.menu-config-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.menu-config-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(150px, 1fr) minmax(150px, 1fr) 96px 116px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

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

.menu-config-head {
  color: #697586;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 780;
}

.menu-config-row label,
.log-filter-grid label {
  display: grid;
  gap: 5px;
  color: #697586;
  font-size: 12px;
  font-weight: 740;
}

.menu-config-row input,
.menu-config-row select,
.log-filter-grid input,
.log-filter-grid select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  min-width: 0;
}

.technical-id strong,
.technical-id small {
  display: block;
}

.technical-id strong {
  color: var(--text);
  font-size: 13px;
}

.technical-id small {
  margin-top: 3px;
  color: var(--muted);
  word-break: break-word;
}

.menu-switch {
  margin: 0;
  min-height: 38px;
  background: var(--surface-soft);
}

.log-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}

.log-filter-actions {
  display: flex;
  gap: 8px;
  grid-column: span 2;
}

.log-table {
  min-width: 980px;
}

.log-table tbody tr {
  cursor: pointer;
}

.log-table tbody tr:hover {
  background: #fffaf3;
}

.log-table button,
.log-card button,
.log-pagination button {
  min-height: 28px;
  border-radius: 7px;
  color: #536071;
  background: #fff;
  border: 1px solid var(--line);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 730;
}

.log-table button:hover,
.log-card button:hover,
.log-pagination button:hover {
  color: var(--orange);
  border-color: var(--orange-line);
  background: var(--orange-soft);
}

.log-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.log-pagination div {
  display: flex;
  gap: 8px;
}

.log-pagination button:disabled {
  cursor: not-allowed;
  color: #9aa5b3;
  background: #f2f5f8;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(18, 27, 49, 0.26);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.log-drawer {
  width: min(560px, 100vw);
  height: 100%;
  background: #fff;
  box-shadow: -18px 0 42px rgba(34, 48, 73, 0.14);
  display: flex;
  flex-direction: column;
}

.log-drawer-body {
  overflow: auto;
  padding: 18px;
  display: grid;
  gap: 16px;
}

.log-detail-section {
  display: grid;
  gap: 10px;
}

.log-detail-section h3 {
  margin: 0;
  font-size: 14px;
}

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

.log-detail-grid div,
.log-summary-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.log-detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.log-detail-grid dd {
  margin: 5px 0 0;
  color: var(--text);
  font-weight: 760;
  word-break: break-word;
}

.log-summary-block {
  display: grid;
  gap: 8px;
}

.log-summary-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #536071;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.form-section {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.switch-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: #536071;
  font-weight: 740;
}

.switch-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 13px;
}

.settings-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.settings-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-section-title span,
.settings-muted {
  color: #697588;
  font-size: 12px;
  font-weight: 650;
}

.settings-section-title strong {
  color: var(--text);
}

.settings-muted {
  margin: 0;
  line-height: 1.55;
}

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

.settings-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.settings-field span {
  color: #4d596a;
  font-size: 12px;
  font-weight: 800;
}

.settings-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  padding: 0 11px;
  outline: 0;
}

.settings-field input:focus {
  border-color: var(--orange-line);
  box-shadow: 0 0 0 3px rgba(239, 134, 31, 0.12);
}

.settings-field small {
  min-height: 16px;
  color: #7a8494;
  font-size: 11px;
}

.settings-field em {
  min-height: 16px;
  color: #c24224;
  font-size: 11px;
  font-style: normal;
  font-weight: 720;
}

.settings-field.has-error input {
  border-color: #e06b4d;
  box-shadow: 0 0 0 3px rgba(224, 107, 77, 0.12);
}

.settings-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: #697588;
  background: #fff;
  padding: 14px;
  font-size: 13px;
}

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

.settings-impact-grid div {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.settings-impact-grid span,
.settings-impact-grid small {
  color: #697588;
  font-size: 11px;
  font-weight: 700;
}

.settings-impact-grid strong {
  color: var(--text);
  font-size: 24px;
}

.settings-impact-note,
.settings-risk {
  display: grid;
  gap: 6px;
  border-radius: 8px;
  line-height: 1.55;
  font-size: 12px;
}

.settings-impact-note {
  border: 1px solid var(--line);
  color: #536071;
  background: #fff;
  padding: 10px 12px;
}

.settings-impact-note strong {
  color: #5f6b7a;
}

.settings-impact-note.is-blocking {
  border-color: rgba(207, 80, 45, 0.28);
  background: rgba(230, 105, 64, 0.08);
}

.settings-impact-note.is-blocking strong {
  color: #ad3f1f;
}

.settings-risk {
  border: 1px solid var(--orange-line);
  color: #7a521b;
  background: var(--orange-soft);
  padding: 12px 13px;
}

.settings-risk strong,
.settings-risk b {
  color: #89520e;
}

.settings-error {
  min-height: 18px;
  color: #c24224;
  font-size: 12px;
  font-weight: 760;
}

.settings-actions,
.choice-actions {
  grid-template-columns: 1fr 1fr;
}

.settings-actions {
  position: sticky;
  bottom: -18px;
  z-index: 2;
  margin: 0 -18px -18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 18px 18px;
  backdrop-filter: blur(8px);
}

.choice-modal {
  width: min(460px, calc(100vw - 32px));
}

.agent-ledger-page .brand-mark {
  text-decoration: none;
}

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

.currency-balance-chart {
  display: grid;
  gap: 22px;
  padding: 24px 4px 18px;
}

.currency-row {
  display: grid;
  grid-template-columns: 58px minmax(160px, 1fr) minmax(150px, auto);
  align-items: center;
  gap: 14px;
}

.currency-row > span {
  color: #4c596b;
  font-weight: 800;
}

.currency-row strong {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.balance-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.balance-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #31b67a, #86d9b5);
}

.balance-track i.small {
  background: linear-gradient(90deg, #52bfd0, #9be3ef);
}

.balance-track.negative i {
  margin-left: auto;
  background: linear-gradient(90deg, #f4a15b, #dd5946);
}

.ledger-type-stack {
  display: grid;
  gap: 10px;
}

.ledger-type-stack div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.ledger-type-stack span {
  color: #526071;
  font-weight: 700;
}

.ledger-type-stack b {
  color: var(--text);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

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

.wallet-card {
  min-height: 136px;
  border: 1px solid #cdebdc;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #f0fbf6);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.wallet-card.negative {
  border-color: #ffd1c8;
  background: linear-gradient(135deg, #ffffff, #fff0ed);
}

.wallet-card span {
  color: #5b687a;
  font-weight: 750;
}

.wallet-card strong {
  font-size: 21px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.wallet-card small {
  color: var(--muted);
  font-weight: 650;
}

.wallet-balance-hero {
  min-height: 126px;
  border: 1px solid #cdebdc;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7fffb, #ffffff);
  padding: 16px;
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.wallet-balance-hero.negative {
  border-color: #ffd1c8;
  background: linear-gradient(135deg, #fff6f3, #ffffff);
}

.wallet-balance-hero small {
  color: var(--muted);
  font-weight: 700;
}

.wallet-balance-hero strong {
  font-size: 28px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.wallet-balance-hero span {
  color: #647084;
}

.amount-positive {
  color: var(--green);
  font-weight: 760;
}

.amount-negative {
  color: var(--red);
  font-weight: 760;
}

.agent-card {
  min-height: 210px;
}

.supplier-catalog-page .workspace {
  min-height: calc(100vh - 24px);
}

@media (max-width: 1500px) {
  .supplier-catalog-page .topbar {
    grid-template-columns: minmax(165px, 190px) minmax(240px, 1fr);
  }

  .supplier-catalog-page .top-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

.catalog-title {
  align-items: center;
}

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

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.catalog-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.product-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  background: #f1f4f7;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.product-media img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.product-placeholder {
  display: none;
  place-items: center;
  gap: 8px;
  color: #8592a3;
  text-align: center;
}

.product-placeholder span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #f2942f, #e2740c);
  font-size: 22px;
  font-weight: 780;
}

.product-placeholder small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.product-media.image-missing .product-placeholder {
  display: grid;
}

.catalog-card-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.catalog-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.supplier-tag {
  color: #7a8493;
  font-size: 11px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-card h2 {
  min-height: 38px;
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.catalog-meta {
  display: grid;
  gap: 6px;
  margin: 0;
}

.catalog-meta div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.catalog-meta dt,
.catalog-meta dd {
  margin: 0;
}

.catalog-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.catalog-meta dd {
  color: #283448;
  font-size: 12px;
  font-weight: 760;
  text-align: right;
  overflow-wrap: anywhere;
}

.catalog-meta-highlight dt,
.catalog-meta-highlight dd {
  color: var(--red);
}

.catalog-meta-highlight dd {
  font-weight: 820;
}

.catalog-card .badge {
  min-height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

.catalog-empty {
  margin-top: 16px;
}

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

.archive-summary-grid > div {
  display: grid;
  gap: 4px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.archive-summary-grid span,
.archive-summary-grid small {
  color: var(--muted);
}

.archive-summary-grid strong {
  font-size: 26px;
  line-height: 1.1;
}

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

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }
}

@media (max-width: 1180px) {
  th[data-priority="tertiary"],
  td[data-priority="tertiary"] {
    display: none;
  }

  .overview-orders-table {
    min-width: 680px;
  }

  .orders-table {
    min-width: 820px;
  }

  .payments-table,
  .wallets-table {
    min-width: 760px;
  }

  .ledger-table {
    min-width: 980px;
  }
}

@media (max-width: 820px) {
  th[data-priority="secondary"],
  td[data-priority="secondary"] {
    display: none;
  }

  .overview-orders-table,
  .orders-table {
    min-width: 680px;
  }

  .payments-table,
  .wallets-table,
  .ledger-table {
    min-width: 720px;
  }
}

@media (max-width: 700px) {
  th[data-priority="secondary"],
  td[data-priority="secondary"] {
    display: none;
  }

  .overview-orders-table,
  .orders-table {
    min-width: 620px;
  }

  .payments-table {
    min-width: 100%;
    table-layout: fixed;
  }

  .wallets-table {
    min-width: 100%;
    table-layout: fixed;
  }

  .ledger-table {
    min-width: 100%;
    table-layout: fixed;
  }

  th[data-mobile-hide],
  td[data-mobile-hide] {
    display: none;
  }

  .mobile-cell-meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.35;
    white-space: normal;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline;
  }

  .orders-table {
    min-width: 100%;
    table-layout: fixed;
  }

  .overview-orders-table {
    min-width: 100%;
    table-layout: fixed;
  }

  .overview-orders-table .col-id {
    width: auto;
  }

  .overview-orders-table .col-money[data-sticky="end"] {
    width: 104px;
  }

  .orders-table .col-id {
    width: 86px;
  }

  .orders-table .col-product {
    width: auto;
  }

  .orders-table .col-status {
    width: 88px;
  }

  .orders-table .col-money[data-sticky="end"] {
    width: 94px;
  }

  .orders-table .col-action {
    width: 70px;
  }

  .wallets-table .col-subject {
    width: auto;
  }

  .wallets-table .col-money:not([data-priority]) {
    width: 132px;
  }

  .payments-table .col-subject {
    width: auto;
  }

  .payments-table .col-money:not([data-priority]) {
    width: 112px;
  }

  .payments-table .col-voucher {
    width: 70px;
  }

  .ledger-table .col-date {
    width: auto;
  }

  .ledger-table .col-money:not([data-priority]) {
    width: 112px;
  }

  .ledger-table .col-voucher {
    width: 70px;
  }

  .allocation-table,
  .cumulative-detail-shell .cumulative-allocation-table {
    min-width: 100%;
    table-layout: fixed;
  }

  .allocation-table .col-id,
  .cumulative-allocation-table .col-id {
    width: auto;
  }

  .allocation-table .col-money {
    width: 104px;
  }

  .cumulative-allocation-table .col-money {
    width: 118px;
  }
}

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

  .currency-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .currency-row strong {
    text-align: left;
  }

  .wallet-strip {
    grid-template-columns: 1fr;
  }

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

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }

  .archive-summary-grid {
    grid-template-columns: 1fr;
  }

  .table-shell.tall {
    min-height: 0;
    max-height: none;
  }

  .manual-grid,
  .manual-rules {
    grid-template-columns: 1fr;
  }

  .manual-steps li {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .manual-status i {
    display: none;
  }

  .settings-modal {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
  }

  .settings-modal .modal-body {
    max-height: calc(100vh - 108px);
  }

  .settings-field-grid,
  .settings-impact-grid,
  .settings-actions,
  .choice-actions {
    grid-template-columns: 1fr;
  }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120%);
  opacity: 0;
  background: #15213a;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 16px 38px rgba(21, 33, 58, 0.22);
  padding: 12px 16px;
  font-weight: 720;
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 30;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.login-page {
  min-height: 100vh;
  background: #f4f5f7;
}

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

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(21, 33, 58, 0.12);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  margin: 0;
}

.login-brand p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-brand h1 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

.login-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-error {
  min-height: 22px;
  margin: 4px 0 12px;
  color: #d74b2a;
  font-size: 13px;
  font-weight: 700;
}

.module-switcher {
  width: 100%;
  min-width: 0;
}

.module-picker {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.module-picker span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
}

.module-picker select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #425166;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 760;
}

[hidden] {
  display: none !important;
}

.no-access-card {
  text-align: left;
}

@media (max-width: 1260px) {
  .topbar {
    grid-template-columns: minmax(165px, 190px) minmax(240px, 1fr);
  }

  .top-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .span-4,
  .span-5,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }

  .split-layout {
    display: block;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: 100%;
    max-width: 100vw;
    grid-template-columns: minmax(0, 1fr);
    padding: 8px;
    gap: 8px;
  }

  .rail {
    position: static;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 10px;
  }

  .workspace {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .brand-mark {
    margin: 0;
  }

  .rail-nav {
    flex-direction: row;
    justify-content: flex-start;
    min-width: 0;
    overflow-x: auto;
    padding: 2px;
    scrollbar-width: thin;
  }

  .rail-item {
    flex: 0 0 42px;
  }

  .rail-item.active {
    width: auto;
    grid-template-columns: 18px auto;
    gap: 7px;
    padding: 0 11px;
  }

  .rail-item.active::after {
    content: attr(aria-label);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
  }

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

  .module-switcher,
  .search-box,
  .top-actions {
    grid-column: 1;
    width: 100%;
    max-width: none;
  }

  .page-title,
  .mode-switch-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .mode-switch-panel {
    padding: 12px 16px;
  }

  .search-box {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    padding: 0;
  }

  .top-actions > * {
    width: 100%;
    min-width: 0;
  }

  .top-actions .context-chip,
  .top-actions .multi-select {
    grid-column: 1 / -1;
  }

  .multi-select-menu,
  .supplier-catalog-page .multi-select-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .user-chip {
    min-width: 0;
    max-width: none;
    border-left: 0;
    padding-left: 0;
  }

  .view {
    padding: 16px 0 24px;
  }

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

  .payment-pool-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .payment-pool-panel .panel-head,
  .payment-pool-panel .big-number,
  .payment-pool-panel .mini-bars {
    grid-column: 1;
    grid-row: auto;
  }

  .payment-pool-panel .big-number {
    margin: 2px 0 16px;
  }

  .detail-drawer .detail-panel {
    width: min(420px, 100vw);
    border-radius: 0;
  }

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

  .flow-board {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    width: 2px;
    height: 38px;
    justify-self: center;
    background: linear-gradient(180deg, var(--orange), #4bb7c9);
  }

  .flow-arrow::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -1px;
    transform: translateX(-50%) rotate(135deg);
  }
}

@media (max-width: 820px) {
  .system-layout {
    grid-template-columns: 1fr;
  }

  .system-subnav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px;
  }

  .system-subnav button {
    flex: 0 0 auto;
    min-height: 36px;
    text-align: center;
    padding: 0 12px;
  }

  .system-table-wrap {
    display: none;
  }

  .system-card-list {
    display: grid;
    gap: 10px;
  }

  .permission-grid,
  .check-grid,
  .system-form {
    grid-template-columns: 1fr;
  }

  .permission-actions {
    grid-template-columns: 1fr;
  }

  .menu-config-head {
    display: none;
  }

  .menu-config-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .log-filter-actions {
    grid-column: 1 / -1;
  }

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

@media (max-width: 480px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace {
    border-radius: 8px;
  }

  .topbar {
    gap: 10px;
    padding: 12px;
  }

  .module-switcher,
  .top-actions {
    width: 100%;
  }

  .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    overflow: visible;
    padding: 0;
  }

  .top-actions select,
  .top-actions .icon-btn,
  .top-actions .user-chip,
  .top-actions .multi-select {
    width: 100%;
    min-width: 0;
  }

  .top-actions .icon-btn,
  .top-actions select,
  .top-actions .user-chip,
  .top-actions .multi-select-trigger {
    min-height: 36px;
  }

  .top-actions .param-chip,
  .top-actions .context-chip,
  .top-actions .multi-select {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .icon-btn span,
  .full-btn span {
    min-width: 0;
  }

  .view {
    padding: 12px;
  }

  .page-title h1 {
    font-size: 26px;
  }

  .metric-card strong {
    font-size: 23px;
  }

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

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

  .panel {
    padding: 14px;
  }

  table {
    min-width: 100%;
  }

  .cumulative-detail-shell table {
    min-width: 1220px;
  }

  .cumulative-allocation-grid {
    grid-template-columns: 1fr;
  }

  .allocation-cumulative-head,
  .allocation-detail-head {
    flex-direction: column;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .chart-wrap,
  .chart-wrap svg {
    min-height: 240px;
    height: 240px;
  }

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

  .settings-modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .settings-modal .modal-body {
    max-height: calc(100vh - 102px);
  }

  .system-subnav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
  }

  .system-subnav button {
    flex: 0 0 auto;
  }

  .panel-actions,
  .log-filter-actions,
  .log-pagination {
    align-items: stretch;
    flex-direction: column;
  }

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

  .log-filter-grid label:nth-of-type(1),
  .log-filter-grid label:nth-of-type(2) {
    order: 1;
  }

  .log-filter-actions {
    order: 2;
  }

  .log-filter-grid label:nth-of-type(n + 3) {
    order: 3;
  }

  .log-drawer {
    width: 100vw;
  }
}

@media (min-width: 600px) and (max-width: 820px) {
  .top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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