:root {
  --bg: #f4f6f8;
  --card: #fff;
  --text: #18212f;
  --muted: #667085;
  --border: #dfe4ea;
  --accent: #1f6feb;
  --danger: #b42318;
  --success: #067647;
  --warning: #b54708;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
.topbar { position: sticky; top: 0; z-index: 10; background: #101828; color: #fff; display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 12px 20px; }
.brand { font-weight: 700; color: #fff; }
.nav { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.nav a { color: #d0d5dd; }
.nav .active { color: #fff; }
.container { max-width: 1180px; margin: 0 auto; padding: 22px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #344054; }
input, select, button, textarea { font: inherit; }
input, select, textarea { width: 100%; border: 1px solid #cfd6df; border-radius: 8px; padding: 10px 11px; background: #fff; }
button, .btn { border: 0; border-radius: 8px; padding: 10px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #eef2f6; color: #344054; }
.btn-danger { background: #fee4e2; color: var(--danger); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 11px 9px; text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-new { background: #eff8ff; color: #175cd3; }
.badge-in_work { background: #fff7ed; color: var(--warning); }
.badge-closed { background: #ecfdf3; color: var(--success); }
.muted { color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: grid; grid-template-columns: 1.2fr repeat(3, 1fr) auto; gap: 8px; align-items: end; }
.login { max-width: 420px; margin: 9vh auto 0; }
.error { background: #fef3f2; color: #b42318; border: 1px solid #fecdca; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.material-row { display: grid; grid-template-columns: 120px 1fr 100px 130px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.material-list { max-height: 54vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; }
.material-row input { text-align: right; }
.summary { display: flex; gap: 20px; flex-wrap: wrap; }
.summary > div { min-width: 160px; }
.summary strong { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.h1 { font-size: 24px; margin: 0 0 16px; }
.h2 { font-size: 18px; margin: 0 0 12px; }
.notice { padding: 10px 12px; border-radius: 8px; background: #f2f4f7; color: #475467; }
.shortage { font-weight: 700; color: var(--danger); }
.ok { font-weight: 700; color: var(--success); }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form > div { flex: 1 1 170px; }
.right { text-align: right; }
@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .grid-2, .grid-3, .filters { grid-template-columns: 1fr; }
  .material-row { grid-template-columns: 72px 1fr 70px 90px; font-size: 13px; }
  .container { padding: 14px 10px 36px; }
  .card { padding: 14px; border-radius: 10px; }
  .h1 { font-size: 21px; }
  .btn { width: 100%; }
  .toolbar .btn { width: auto; }
}
.import-card { border-left: 4px solid var(--accent); }
.import-summary > div { min-width: 220px; }
.error-list { margin: 0; padding-left: 22px; color: var(--danger); }
.error-list li { margin: 6px 0; }
code { background: #f2f4f7; border-radius: 5px; padding: 2px 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* CRM 0.2 — request workflow */
.grid-span-2 { grid-column: 1 / -1; }
.request-title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.request-header-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 20px; }
.request-header-grid > div { min-width: 0; }
.request-header-grid strong { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.request-header-grid span { display: block; font-weight: 600; }
.request-comment { white-space: pre-wrap; line-height: 1.5; }
.priority { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.priority-urgent { background: #fff1f0; color: #b42318; border: 1px solid #fecdca; }
.urgent-text { color: var(--danger); }
.badge-awaiting_stock { background: #f2f4f7; color: #344054; }
.badge-awaiting_purchase { background: #fffaeb; color: #b54708; }
.badge-ordered_supplier { background: #f4f3ff; color: #5925dc; }
.badge-ready_shipment { background: #ecfdf3; color: #067647; }
.badge-shipped { background: #e0f2fe; color: #026aa2; }
.success-notice { background: #ecfdf3; color: #067647; }
.action-row { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.workflow-actions { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.timeline { position: relative; }
.timeline-item { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 10px; padding-bottom: 18px; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 13px; bottom: -2px; width: 2px; background: #e4e7ec; }
.timeline-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); margin-top: 3px; z-index: 1; box-shadow: 0 0 0 3px #eff8ff; }
.timeline-meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
@media (max-width: 900px) {
  .request-header-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .grid-span-2 { grid-column: auto; }
  .request-header-grid { grid-template-columns: 1fr; }
  .workflow-actions .btn { width: 100%; }
}
