* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0; background: #f8f7f4; color: #1d1d1f;
  line-height: 1.5;
}
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem; background: #fff; border-bottom: 1px solid #e5e5e0;
}
.topbar .brand { font-weight: 600; font-size: 1.2rem; text-decoration: none; color: inherit; }
.topbar .user { margin-left: auto; color: #555; }
.topbar .link, .topbar .inline { background: none; border: none; color: #1a6cd9; cursor: pointer; font: inherit; padding: 0; text-decoration: none; }
.topbar .inline { margin-left: 0.5rem; }
.container { max-width: 960px; margin: 2rem auto; padding: 0 1.25rem; }
h1, h2 { font-weight: 600; }
.muted { color: #6a6a70; }
.btn { display: inline-block; padding: 0.4rem 0.9rem; background: #1a6cd9; color: #fff; text-decoration: none; border-radius: 6px; }

table.projects { width: 100%; border-collapse: collapse; margin: 1rem 0; }
table.projects th, table.projects td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #e5e5e0; text-align: left; }
table.projects th { background: #f0eee8; font-weight: 600; }

.state { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 4px; font-size: 0.85rem; }
.state-empty, .state-uploaded { background: #ececec; color: #555; }
.state-parsed, .state-drafted, .state-ready_to_send { background: #ffe9b6; color: #6a4500; }
.state-sending, .state-collecting, .state-finalizing { background: #d9e7ff; color: #1a4790; }
.state-finalized { background: #d3f5dc; color: #1f6b3a; }
.state-parse_error, .state-finalize_error { background: #ffd6d6; color: #8a1a1a; }

dl.health { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 1.5rem; }
dl.health dt { font-weight: 600; color: #444; }

.foot { text-align: center; color: #999; padding: 2rem 0; font-size: 0.85rem; }
code { background: #ececec; padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.9em; }

.crumbs { margin: 0 0 0.5rem 0; }
.crumbs a { color: #6a6a70; text-decoration: none; }
.crumbs a:hover { color: #1a6cd9; }

.form { display: flex; flex-direction: column; gap: 1rem; max-width: 560px; margin: 1rem 0; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; }
.form label > span { font-weight: 500; }
.form label > span em { color: #c33; font-style: normal; }
.form input[type=text], .form textarea, .form input[type=file] {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d2d2cc;
  border-radius: 6px;
  background: #fff;
}
.form input[type=text]:focus, .form textarea:focus { outline: none; border-color: #1a6cd9; }
.form small { color: #6a6a70; }
.form .actions { display: flex; align-items: center; gap: 0.8rem; }
.form button.btn { border: none; cursor: pointer; }

.danger-zone { margin-top: 3rem; color: #8a1a1a; font-size: 1rem; }
.link.danger { color: #8a1a1a; }
.small { font-size: 0.85rem; }

/* Экран Разбор */
.counts { font-size: 1rem; margin: 0.5rem 0 1.5rem 0; }
.counts .state { margin-left: 0.4rem; }
.state-include   { background: #d3f5dc; color: #1f6b3a; }
.state-uncertain { background: #ffe9b6; color: #6a4500; }
.state-exclude   { background: #ececec; color: #6a6a70; }

.section-h { border-top: 1px solid #e5e5e0; padding-top: 1.5rem; margin-top: 2rem; font-size: 1.05rem; }
.section-h small { font-weight: normal; }

table.draft { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem 0; font-size: 0.95rem; }
table.draft th, table.draft td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #ececec; vertical-align: top; }
table.draft th { background: #f0eee8; font-weight: 600; text-align: left; }
table.draft tr.pos-include   { background: #f4fbf6; }
table.draft tr.pos-uncertain { background: #fffbef; }
table.draft tr.pos-exclude   { background: #f5f5f5; color: #999; }
table.draft .seq { color: #888; font-variant-numeric: tabular-nums; }
table.draft .qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.draft details summary { cursor: pointer; }
table.draft details summary::-webkit-details-marker { display: none; }
table.draft details[open] summary { font-weight: 600; }
table.draft .conf-high { color: #1f6b3a; margin-left: 0.3rem; }
table.draft .conf-medium { color: #6a4500; margin-left: 0.3rem; }
table.draft .conf-low { color: #8a1a1a; margin-left: 0.3rem; }
table.draft .src small { color: #6a6a70; font-size: 0.8rem; }

.status-btns { display: inline-flex; gap: 0.2rem; }
.status-btn {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font-size: 1.05rem; padding: 0.15rem 0.4rem; border-radius: 4px; opacity: 0.4;
}
.status-btn:hover { background: #fff; opacity: 0.85; }
.status-btn.active { opacity: 1; border-color: #d2d2cc; background: #fff; }

.inline-edit {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem;
  background: #fff; padding: 1rem; border-radius: 6px; border: 1px solid #d2d2cc; margin-top: 0.5rem;
}
.inline-edit label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; }
.inline-edit label.full { grid-column: 1 / -1; }
.inline-edit input, .inline-edit textarea, .inline-edit select {
  font: inherit; padding: 0.3rem 0.5rem; border: 1px solid #d2d2cc; border-radius: 4px; background: #fff;
}
.inline-edit .actions { grid-column: 1 / -1; }

.add-manual { max-width: 720px; }
.add-manual .row-2 { display: flex; gap: 0.5rem; }

.supplier-card {
  background: #fff; border: 1px solid #e5e5e0; border-radius: 6px;
  padding: 1rem 1.2rem; margin: 1rem 0;
}
.supplier-card h3 { margin: 0 0 0.5rem 0; }
.supplier-card details { margin: 0.5rem 0; }
.supplier-card details summary { cursor: pointer; color: #1a6cd9; }
.supplier-actions { margin-top: 0.5rem; }
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type="email"] {
  font: inherit; padding: 0.4rem 0.6rem; border: 1px solid #d2d2cc; border-radius: 4px;
}
