:root {
  --accent: #d70714;
  --accent-hover: #b80612;
  --sidebar: #111111;
  --sidebar-2: #1a1a1a;
  --bg: #eef1f6;
  --panel: #ffffff;
  --border: #e3e7ef;
  --text: #1f2937;
  --muted: #6b7280;
  --red-soft: #fef3f2;
  --green-soft: #ecfdf3;
  --font: "Segoe UI", Inter, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
  align-items: start;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  padding: 14px 10px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  z-index: 45;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
  flex-shrink: 0;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.brand strong { display: block; font-size: 14px; letter-spacing: 0.02em; }
.brand small { color: #9aa3b5; font-size: 11px; }

.nav { flex: 1; min-height: 0; overflow-y: auto; }
.nav-group {
  margin: 10px 0 4px;
  padding: 0 12px;
  color: #8b93a7;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7dce8;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  margin: 2px 0;
}
.nav a .ico { width: 18px; text-align: center; opacity: 0.85; font-size: 13px; }
.nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav a.active {
  background: rgba(215, 7, 20, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.content { padding: 18px 22px 28px; min-width: 0; }

.user-box {
  flex-shrink: 0;
  padding: 14px 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { color: #9aa3b5; font-size: 12px; margin-top: 2px; }
.logout-btn { width: 100%; margin-top: 8px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.login-wrap { width: min(400px, 92vw); }
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 16px;
}
.breadcrumbs { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.breadcrumbs span { color: var(--text); }
.breadcrumbs a { color: var(--muted); }
h1 { margin: 0; font-size: 22px; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flash {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--green-soft);
  color: #027a48;
  border: 1px solid #abefc6;
}
.flash.ok { background: var(--green-soft); color: #027a48; border: 1px solid #abefc6; }
.flash.err, .flash.error {
  background: var(--red-soft);
  color: #b42318;
  border: 1px solid #fecdca;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 1;
}
.search { min-width: 240px; flex: 0 1 360px; }
.search input { width: 100%; height: 34px; }
.toolbar select, .toolbar input[type="search"] {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-width: 180px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
}
.panel + .panel { margin-top: 14px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: #fafbfe;
}
.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.panel-head-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.muted, .note, .meta { color: var(--muted); font-size: 13px; }
.note { margin: 0.4rem 0 1rem; }

.selection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #fecdca;
  white-space: nowrap;
}
.selection-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.selection-actions[hidden],
.selection-badge[hidden] { display: none !important; }
.bulk-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0;
}
.bulk-inline select,
.bulk-inline input {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 32px;
}
.bulk-inline button { margin-top: 0; }

.table-wrap { overflow-x: auto; overflow-y: visible; }
table { width: 100%; border-collapse: collapse; }
.catalog-table th,
.catalog-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.catalog-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #f8fafc;
  white-space: nowrap;
}
.catalog-row:hover td { background: #fafafa; }
.catalog-row.is-selected td { background: #fef3f2; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}
.th-sort:hover { color: var(--accent); text-decoration: none; }
.th-sort-icon {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  line-height: 1;
  font-weight: 800;
  opacity: 0.4;
  margin-left: 2px;
}
.th-sort-icon::before { content: "A"; color: #2563eb; }
.th-sort-icon::after { content: "Z"; color: #dc2626; }
.th-sort.is-active { color: var(--accent); }
.th-sort.is-active .th-sort-icon { opacity: 1; }
.th-sort.is-active.order-asc .th-sort-icon::after { opacity: 0.28; }
.th-sort.is-active.order-desc .th-sort-icon::before { opacity: 0.28; }

.col-check { width: 44px; text-align: center; }
.col-actions { width: 56px; }
.col-product { min-width: 180px; }
.products-table .col-product .th-sort { margin-left: 44px; }

.product-cell { display: flex; align-items: flex-start; gap: 8px; }
.product-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  color: #64748b;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.product-thumb-placeholder { font-size: 14px; }
.product-main { min-width: 0; }
.product-name-link {
  display: inline;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
a.product-name-link:hover { color: var(--accent); text-decoration: underline; }
.product-name-secondary {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.25;
}
.kit-cell {
  white-space: normal;
  max-width: 16rem;
  font-size: 12px;
  color: var(--muted);
}

.check-menu {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  position: relative;
}
.check-menu details { position: relative; }
.check-menu summary {
  list-style: none;
  cursor: pointer;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") center/8px no-repeat;
}
.check-menu summary::-webkit-details-marker { display: none; }
.check-menu-panel {
  position: absolute;
  top: 22px;
  left: 0;
  z-index: 20;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15,23,42,0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.check-menu-panel button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  margin: 0;
}
.check-menu-panel button:hover { background: #f1f5f9; color: var(--text); }

.col-picker-cell {
  width: 44px;
  min-width: 44px;
  padding: 4px 6px;
  text-align: right;
}
.col-picker-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #64748b;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
}
.col-picker-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--red-soft);
}
.col-picker-btn svg { display: block; }
.col-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
}
.col-picker-overlay[hidden] { display: none; }
.col-picker-modal {
  width: min(420px, 100%);
  max-height: min(72vh, 640px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.col-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.col-picker-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.col-picker-close {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  margin: 0;
  padding: 0;
}
.col-picker-close:hover { background: #f1f5f9; color: var(--text); }
.col-picker-list { overflow: auto; padding: 0 0 8px; }
.col-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 500;
  cursor: pointer;
}
.col-picker-row:hover { background: var(--red-soft); }

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: #475569;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin: 0;
  font-size: 13px;
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--red-soft);
  text-decoration: none;
}

.btn, button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 7px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border-radius: 8px;
}
[hidden] { display: none !important; }
.btn:hover, button:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: #f8fafc; color: var(--text); }
.btn.small { padding: 6px 10px; font-size: 12px; margin: 0; }
button.danger { background: #444; }
.form button, .form .btn { margin-top: 0.6rem; }

.btn-split { display: inline-flex; align-items: stretch; }
.btn-split > .btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin: 0;
}
.btn-split-menu { position: relative; display: flex; align-items: stretch; }
.btn-split-menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 7px 10px;
  border-radius: 0 8px 8px 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-left: 1px solid rgba(255,255,255,0.25);
}
.btn-split-menu > summary::-webkit-details-marker { display: none; }
.btn-split-menu[open] > summary { background: var(--accent-hover); }
.btn-split-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 20;
  overflow: hidden;
}
.btn-split-dropdown a {
  display: block;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.btn-split-dropdown a:hover { background: #f8fafc; text-decoration: none; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.pager a, .pager strong {
  min-width: 28px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 6px;
}
.pager strong { background: var(--accent); color: #fff; }

.empty, .empty-inline {
  background: var(--panel);
  padding: 1.4rem 1.2rem;
  margin: 0;
  color: var(--muted);
}
.empty { border: 1px solid var(--border); border-radius: 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin: 0.7rem 0;
  max-width: 52rem;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
}
.field-ro {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.field-ro-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.field-ro-value { font-weight: 600; }
.form label { display: block; margin: 0.6rem 0; font-weight: 600; }
.form input, .form select, .form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.inline { display: inline-block; margin-right: 0.5rem; }
.tight label { font-weight: 500; }
.list { list-style: none; padding: 0; margin: 0; }
.item-title { font-weight: 700; color: inherit; text-decoration: none; }
.item-title:hover { color: var(--accent); }

.stamp {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}
.stamp.nohours, .stamp.stale { background: #fef3c7; color: #92400e; }
.stamp.soon { background: #ffedd5; color: #9a3412; }
.stamp.due { background: var(--accent); color: #fff; }
.stamp.order { background: #111; color: #fff; }
.stamp.ok { background: #dcfce7; color: #166534; }

ul.kit { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.kit-rows { border: 1px solid var(--border); padding: 0.6rem 0.8rem 0.2rem; margin: 0.8rem 0; border-radius: 8px; }
.kit-row {
  display: grid;
  grid-template-columns: 1fr 1fr 5.5rem;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.crumb { margin: 0 0 0.4rem; }
.crumb a { color: var(--muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
  }
}
