:root {
  --bg: #eef2f0;
  --bg-accent: #d9e4dc;
  --ink: #1c2420;
  --muted: #5c6b63;
  --panel: #f7faf8;
  --line: #c5d2cb;
  --brand: #1f6b4a;
  --brand-ink: #103528;
  --danger: #8b2e2e;
  --high: #9a3412;
  --medium: #854d0e;
  --low: #3f6212;
  --shadow: 0 18px 40px rgba(28, 36, 32, 0.08);
  --radius: 18px;
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #f4fff8 0%, transparent 40%),
    linear-gradient(160deg, var(--bg), var(--bg-accent));
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}
.brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--brand-ink);
  text-decoration: none;
}
.topbar-nav { display: flex; gap: 14px; flex: 1; align-items: center; }
.nav-link {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--brand-ink); text-decoration: none; }
.nav-link.is-active {
  color: var(--brand-ink);
  font-weight: 600;
  border-bottom-color: var(--brand);
}
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.95rem; }
.content { display: grid; gap: 20px; }
.section-head, .filters, .form-card, .panel, .auth-card, .table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.section-head, .auth-card, .form-card, .panel { padding: 24px; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.section-head-compact {
  padding: 10px 16px;
  box-shadow: none;
}
.section-head-compact h1 {
  margin: 0 0 2px;
  font-size: 1.25rem;
}
.section-head-compact .lead {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}
h1, h2 { margin: 0 0 8px; letter-spacing: -0.02em; }
.lead, .meta, .hint, .empty { color: var(--muted); }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--brand);
  margin: 0 0 8px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  padding: 18px;
}
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 0.92rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
}
.checkbox input { width: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-ghost { background: transparent; }
.btn-danger {
  background: #fde2e2;
  border-color: #e8b4b4;
  color: var(--danger);
}
.btn-danger:hover { background: #f8caca; border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; }
.table td.no-row-nav { overflow: visible; position: relative; }
.table th, .table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.table tbody tr.clickable-row { cursor: pointer; }
.table tbody tr.clickable-row td {
  background: #f0f5f2;
  transition: background 0.15s ease;
}
.table tbody tr.clickable-row:hover td { background: #b8d4c3; }
.table th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: #e8eee9;
}
.status-new { background: #e0efff; }
.status-paid { background: #fff4d6; }
.status-arrived { background: #ddf7e6; }
/* Статусы счёта */
.inv-status-new { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.inv-status-production { background: #dbeafe; color: #1e3a8a; border-color: #93c5fd; }
.inv-status-goods { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.inv-status-ready_to_ship { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.inv-status-shipped { background: #dcfce7; color: #166534; border-color: #86efac; }
/* Статусы заявки */
.req-status-new { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.req-status-paid { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.req-status-arrived { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.status-form { margin: 0; }
.status-select {
  width: auto;
  min-width: 11rem;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 600;
}
.status-select option {
  color: var(--ink);
  background: #fff;
  font-weight: normal;
}
.meta-row { margin-top: 10px; }
.meta-row-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: end;
}
.inline-ship-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 0;
}
.inline-label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}
.inline-label input[type="date"] {
  width: auto;
  min-width: 10.5rem;
  padding: 6px 10px;
}
.inline-date-form { margin: 0; }
.inline-date-form input[type="date"] {
  width: auto;
  min-width: 9.5rem;
  padding: 6px 8px;
  font-size: 0.85rem;
}
.request-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 18px;
  align-items: start;
}
.panel-comments {
  padding: 16px;
}
.panel-comments h2 { font-size: 1.05rem; }
.field-list {
  margin: 0;
  display: grid;
  gap: 12px;
}
.field-list div {
  display: grid;
  gap: 2px;
}
.field-list dt {
  font-size: 0.82rem;
  color: var(--muted);
}
.field-list dd {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}
.mt { margin-top: 18px; }
.edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}
.inline-edit-grid {
  display: grid;
  grid-template-columns: 4rem 1.2fr 1.4fr auto;
  gap: 8px;
  flex: 1;
  align-items: center;
  min-width: 280px;
}
.inline-edit-grid.suppliers-grid {
  grid-template-columns: 1.3fr 1fr 1fr 1.2fr 1.4fr auto;
}
.priority-high { color: var(--high); background: #ffedd5; }
.priority-medium { color: var(--medium); background: #fef3c7; }
.priority-low { color: var(--low); background: #ecfccb; }
.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
.body-text { white-space: pre-wrap; line-height: 1.5; }
.comments { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.comments li {
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.92rem;
}
.comment-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.flash-error {
  background: #fde2e2;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 12px;
}
.flash-success {
  background: #ddf7e6;
  color: #166534;
  padding: 10px 12px;
  border-radius: 12px;
}
.flash {
  margin: 0;
}
.auth-card { max-width: 440px; margin: 8vh auto; }
@media (max-width: 800px) {
  .section-head, .topbar, .userbox { flex-direction: column; align-items: stretch; }
  .grid-2, .request-layout { grid-template-columns: 1fr; }
  .inline-edit-grid,
  .inline-edit-grid.suppliers-grid { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
