:root {
  --bg: #f4efe6;
  --ink: #1f1a17;
  --muted: #796b5d;
  --panel: #fffaf2;
  --accent: #183d33;
  --gold: #c7943b;
  --danger: #b84848;
  --line: #e7dccb;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: radial-gradient(circle at top left, #f8d7a7, transparent 28%), var(--bg);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
}
.sidebar {
  min-height: 100vh;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #17382f;
  color: white;
}
.brand-block {
  display: grid;
  gap: 10px;
  justify-items: start;
}
.brand-logo {
  width: 150px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.eyebrow { margin: 0 0 8px; color: var(--gold); font-weight: 700; }
h1, h2, h3 { margin: 0; }
nav { display: grid; gap: 10px; margin-top: 34px; }
button, input, select, textarea { font: inherit; }
.nav-btn, .ghost, .primary {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
}
.nav-btn { text-align: right; background: rgba(255,255,255,.08); color: white; }
.nav-btn.active { background: var(--gold); color: #1d1407; font-weight: 700; }
.ghost { background: #f7efe3; color: var(--ink); }
.primary { background: var(--accent); color: white; font-weight: 700; }
.main { padding: 30px; overflow: auto; }
.hidden { display: none !important; }
.login-card, .card {
  background: rgba(255,250,242,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 60px rgba(54, 34, 14, .12);
}
.login-card {
  max-width: 520px;
  margin: 8vh auto;
  padding: 28px;
  display: grid;
  gap: 12px;
}
.login-logo {
  width: 180px;
  justify-self: center;
  margin-bottom: 4px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
.badge { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.card { padding: 20px; margin-bottom: 16px; }
.card strong { display: block; margin-top: 8px; font-size: 34px; }
.split { display: grid; grid-template-columns: minmax(280px, 390px) 1fr; gap: 18px; align-items: start; }
.form-card { display: grid; gap: 12px; position: sticky; top: 24px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: white;
}
textarea { min-height: 86px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
.field-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.field-label input,
.field-label select {
  color: var(--ink);
  font-weight: 400;
}
.price-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf8;
  padding: 14px;
}
.price-panel strong {
  display: block;
  margin: 0 0 4px;
  font-size: 15px;
}
.price-panel small {
  color: var(--muted);
}
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.price-field input {
  background: #fff;
}
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.filter-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.operation-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 12px;
  align-items: end;
  margin: 14px 0 10px;
}
.filter-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 12px;
}
.filter-btn.active {
  border-color: var(--gold);
  background: #fff7e7;
  color: #1d1407;
  font-weight: 700;
}
.list { display: grid; gap: 10px; margin-top: 14px; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.row-actions { display: flex; gap: 8px; align-items: center; }
.mini-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.mini-btn.danger {
  border-color: #efcaca;
  color: var(--danger);
}
.catalog-stack { display: grid; gap: 18px; }
.catalog-tree {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.tree-node {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  padding: 13px;
}
.tree-node.line {
  border-color: #ddcaa9;
  background: #fffaf2;
}
.tree-node.product {
  margin-right: 28px;
}
.tree-node.variant {
  margin-right: 56px;
  background: #fffdf8;
}
.tree-main {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  cursor: pointer;
}
.tree-main strong {
  display: block;
  font-size: 18px;
}
.tree-main small {
  display: block;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 3px;
}
.tree-toggle,
.tree-dot {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7efe3;
  color: var(--accent);
  font-weight: 800;
}
.tree-dot {
  width: 12px;
  height: 12px;
  background: var(--gold);
  border: 0;
}
.tree-children {
  display: grid;
  gap: 8px;
}
.tree-empty {
  margin: 2px 0 2px 42px;
}
.details-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf8;
  margin-top: 14px;
  padding: 14px;
}
.details-box h4 { margin: 0 0 8px; }
.details-section-title { margin-top: 18px !important; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.details-grid span { color: var(--muted); }
.history-current {
  border: 1px solid var(--gold);
  border-radius: 14px;
  background: #fff7e7;
  margin: 12px 0;
  padding: 12px;
  font-weight: 700;
}
.history-current.ok {
  border-color: #bed9ca;
  background: #effaf3;
  color: #1d6b44;
}
.history-list { display: grid; gap: 10px; margin-top: 12px; }
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px;
}
.history-side { text-align: right; display: grid; gap: 4px; }
.muted { color: var(--muted); }
.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}
.followup-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  min-width: 900px;
  font-size: 13px;
}
.compact-table { min-width: 640px; }
.followup-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  padding: 0 9px;
}
.followup-table td {
  background: white;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
  line-height: 1.35;
}
.followup-table td:first-child {
  border-right: 1px solid var(--line);
  border-radius: 0 14px 14px 0;
}
.followup-table td:last-child {
  border-left: 1px solid var(--line);
  border-radius: 14px 0 0 14px;
}
.status-pill {
  display: inline-flex;
  border-radius: 999px;
  background: #effaf3;
  color: #1d6b44;
  padding: 6px 10px;
  font-weight: 700;
}
.status-pill.warn {
  background: #fff7e7;
  color: #8a5a12;
}
.print-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.due { color: var(--danger); }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #fff7e7; }
.status-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}
.status-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.status-form input,
.status-form select {
  font-size: 13px;
  padding: 10px;
}
.followup-summary { margin-top: 8px; }
.row small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.6; }
.qty { font-size: 24px; font-weight: 800; color: var(--accent); }
.low { color: var(--danger); }
.message, .message-box { color: var(--danger); }
.message-box {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff0f0;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; }
  .split, .stats { grid-template-columns: 1fr; }
  .operation-search { grid-template-columns: 1fr; }
  .status-form { grid-template-columns: 1fr; }
  .form-card { position: static; }
}
@media print {
  body.printing-operation {
    display: block;
    background: white;
  }
  body.printing-operation .sidebar,
  body.printing-operation .topbar,
  body.printing-operation #messageBox,
  body.printing-operation #viewRoot > .card > .section-head,
  body.printing-operation #operationsMarketFilters,
  body.printing-operation .operation-search,
  body.printing-operation #viewRoot > .card > .table-wrap,
  body.printing-operation .print-hidden {
    display: none !important;
  }
  body.printing-operation .main,
  body.printing-operation #appPanel,
  body.printing-operation #viewRoot,
  body.printing-operation #operationDetails {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }
  body.printing-operation .table-wrap {
    overflow: visible;
  }
  body.printing-operation table {
    min-width: 0 !important;
    width: 100%;
  }
}
