:root {
  color-scheme: light;
  --bg: #f5f1ea;
  --surface: #fffdf9;
  --line: #ded5c8;
  --ink: #211d18;
  --muted: #74695d;
  --accent: #286f63;
  --accent-strong: #1f5a50;
  --danger: #b95845;
  --soft: #eee7dc;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #f9f5ee;
}

.brand h1,
.panel h2,
.panel h3,
.module-header h2 {
  margin: 0;
}

.brand p,
.module-header span,
.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel + .panel,
.brand + .panel,
.panel + .nav {
  margin-top: 14px;
}

.section-label {
  margin: 18px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 14px;
}

.panel-title-row,
.module-header,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.module-header {
  margin-bottom: 14px;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.subnav button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
}

.subnav button.active {
  border-color: var(--accent);
  background: #e6f0ed;
  color: var(--accent-strong);
  font-weight: 700;
}

.accounting-page {
  grid-column: 1 / -1;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.grid.compact {
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

label.inline-check {
  display: flex;
  align-items: center;
  color: var(--ink);
}

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

.radio-row label.inline-check {
  margin-top: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 111, 99, 0.12);
}

.primary-btn,
.ghost-btn,
.nav button {
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 10px 12px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn,
.nav button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.link-btn {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: underline;
}

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

.nav button {
  text-align: left;
}

.nav button.active {
  border-color: var(--accent);
  background: #e9f3f0;
  color: var(--accent-strong);
}

.hidden {
  display: none !important;
}

.result-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.result-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  text-align: left;
}

.result-item strong {
  display: block;
  margin-bottom: 4px;
}

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

.product-preview {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 88px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbf8f2;
}

.product-preview:empty {
  display: none;
}

.product-preview img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  margin-top: 10px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft);
  font-weight: 700;
}

.summary,
.user-card {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.7;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

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

.empty-state {
  max-width: 520px;
  margin: 12vh auto;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 30px rgba(33, 29, 24, 0.24);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 980px) {
  .app-shell,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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