:root {
  color-scheme: light;
  --bg-canvas: oklch(0.95 0.02 85);
  --bg-sidebar: oklch(0.26 0.03 55);
  --bg-main: oklch(0.975 0.01 85);
  --bg-panel: oklch(0.99 0.007 85);
  --bg-panel-soft: oklch(0.95 0.012 80);
  --bg-accent: oklch(0.64 0.11 55);
  --bg-accent-strong: oklch(0.54 0.12 45);
  --text-strong: oklch(0.22 0.02 60);
  --text-muted: oklch(0.48 0.015 62);
  --text-inverse: oklch(0.95 0.01 85);
  --line-soft: oklch(0.86 0.01 78);
  --line-strong: oklch(0.76 0.03 70);
  --danger: oklch(0.62 0.17 28);
  --success: oklch(0.62 0.12 145);
  --shadow-panel: 0 1px 3px rgba(58, 42, 26, 0.08), 0 18px 34px rgba(72, 50, 24, 0.08);
  --shadow-button: 0 8px 18px rgba(122, 81, 35, 0.18);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-canvas);
  color: var(--text-strong);
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

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

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background:
    linear-gradient(145deg, rgba(171, 137, 90, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), transparent 24%),
    var(--bg-canvas);
}

.sidebar {
  padding: 28px 22px;
  background:
    linear-gradient(180deg, rgba(255, 244, 220, 0.06), transparent 20%),
    var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(221, 176, 96, 0.95), rgba(149, 103, 41, 0.9));
  color: #2a1b0f;
  font-family: var(--font-display);
  font-size: 1.8rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 12px 22px rgba(0, 0, 0, 0.2);
}

.brand h1,
.section-head h3,
#viewTitle {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.022em;
  margin: 0;
  text-wrap: balance;
}

.brand h1 {
  font-size: 1.9rem;
}

.eyebrow,
.section-kicker,
.panel-label {
  margin: 0 0 6px;
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar .eyebrow,
.sidebar .panel-label,
.sidebar .panel-copy {
  color: rgba(249, 242, 231, 0.72);
}

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

.nav-item,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-md);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), background-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-item {
  padding: 14px 16px;
  background: transparent;
  color: rgba(249, 242, 231, 0.8);
  text-align: left;
}

.nav-item.is-active {
  background: rgba(255, 247, 235, 0.12);
  color: #fff6ea;
  box-shadow: inset 0 0 0 1px rgba(255, 240, 218, 0.08);
}

.sidebar-panel {
  margin-top: auto;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 247, 235, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.panel-copy {
  margin: 0;
  line-height: 1.65;
  text-wrap: pretty;
}

.main {
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

#viewTitle {
  font-size: clamp(2rem, 3vw, 2.7rem);
  color: var(--text-strong);
}

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

.secondary-button,
.ghost-button,
.primary-button {
  padding: 0 18px;
  font-weight: 700;
}

.secondary-button {
  background: var(--bg-panel);
  color: var(--text-strong);
  box-shadow: var(--shadow-panel);
}

.ghost-button {
  background: transparent;
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.primary-button {
  background: var(--bg-accent);
  color: #fff8f0;
  box-shadow: var(--shadow-button);
}

.view-shell {
  display: grid;
}

.view {
  display: grid;
  gap: 20px;
  animation: section-enter 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.metrics-grid,
.two-column,
.split-layout {
  display: grid;
  gap: 20px;
}

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

.two-column {
  grid-template-columns: 1.15fr 1fr;
}

.split-layout {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.paper-panel {
  padding: 22px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), transparent 18%),
    var(--bg-panel);
  box-shadow: var(--shadow-panel);
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top right, rgba(188, 138, 67, 0.2), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.76), transparent 18%),
    var(--bg-panel);
  box-shadow: var(--shadow-panel);
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 22px 0 auto;
  width: 86px;
  height: 86px;
  background: radial-gradient(circle, rgba(199, 152, 91, 0.22), transparent 72%);
  pointer-events: none;
}

.metric-label {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.metric-value,
.money,
.qty {
  font-variant-numeric: tabular-nums;
}

.metric-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 2vw, 2.4rem);
  letter-spacing: -0.022em;
}

.metric-note {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

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

.compact-input,
.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--bg-panel-soft);
  padding: 12px 14px;
  color: var(--text-strong);
  box-shadow: inset 0 0 0 1px rgba(112, 92, 65, 0.08);
}

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

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

.stack-form span {
  color: var(--text-muted);
  font-size: 0.92rem;
}

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

.table-shell,
.list-shell {
  overflow: hidden;
  border-radius: 18px;
  background: rgba(248, 241, 229, 0.65);
  box-shadow: inset 0 0 0 1px rgba(118, 95, 66, 0.08);
}

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

thead th {
  text-align: left;
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody td {
  padding: 15px 16px;
  border-top: 1px solid rgba(118, 95, 66, 0.08);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.52);
}

.status-chip,
.type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 0.84rem;
  font-weight: 700;
}

.status-chip.ok {
  color: oklch(0.34 0.05 140);
  background: rgba(105, 166, 92, 0.14);
}

.status-chip.warn {
  color: #8f3e23;
  background: rgba(176, 102, 56, 0.16);
}

.type-chip.in {
  color: #215c38;
  background: rgba(103, 173, 117, 0.16);
}

.type-chip.out {
  color: #8a3828;
  background: rgba(184, 83, 62, 0.18);
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.list-row + .list-row {
  border-top: 1px solid rgba(118, 95, 66, 0.08);
}

.item-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.item-meta,
.empty-state,
.toast {
  color: var(--text-muted);
}

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

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(42, 28, 15, 0.92);
  color: #f9f2e7;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

:focus-visible {
  outline: 3px solid rgba(191, 133, 64, 0.42);
  outline-offset: 2px;
}

@media (hover: hover) {
  .nav-item:hover,
  .secondary-button:hover,
  .ghost-button:hover {
    transform: translateY(-1px);
  }

  .primary-button:hover {
    transform: translateY(-1px);
    background: var(--bg-accent-strong);
  }
}

.nav-item:active,
.secondary-button:active,
.ghost-button:active,
.primary-button:active {
  transform: scale(0.96);
}

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

@media (max-width: 1100px) {
  .metrics-grid,
  .two-column,
  .split-layout {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    gap: 18px;
  }

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

  .main {
    padding: 18px;
  }

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

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

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

  .paper-panel,
  .metric-card {
    padding: 18px;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  tbody tr {
    padding: 8px 0;
  }

  tbody td {
    border-top: 0;
    padding: 8px 0;
  }

  tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
  }
}

@keyframes section-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}
