:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4d;
  --text: #e6edf3;
  --muted: #8b9cb3;
  --accent: #3d9ee5;
  --warn: #e5a93d;
  --danger: #e57373;
  --soon: #4a5568;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.layout {
  display: block;
  min-height: 100vh;
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: .5rem;
  }
  .main { margin-left: 0; }
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.75rem 0 1rem;
  margin-bottom: 1rem;
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0;
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  overflow-y: auto;
}
.sidebar h1 {
  font-size: 0.95rem;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.sidebar-toggle {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 7px;
  background: var(--border);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
}
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 1.8rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 7px;
  background: rgba(61,158,229,0.12);
  color: var(--accent);
}
.nav-icon svg {
  width: 1.12rem;
  height: 1.12rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav a:hover { background: rgba(61,158,229,0.08); color: var(--accent); }
.nav a.active { border-left-color: var(--accent); background: rgba(61,158,229,0.06); }
.nav a.soon {
  color: var(--soon);
  cursor: not-allowed;
  pointer-events: none;
}
.main { margin-left: 220px; padding: 1.25rem 1.75rem 2.5rem; max-width: 960px; }
.main.main-wide {
  width: calc(100vw - 220px - 3.5rem);
  max-width: none;
}
html.sidebar-collapsed .sidebar {
  width: 72px;
}
html.sidebar-collapsed .sidebar-head {
  justify-content: center;
  padding: 0;
}
html.sidebar-collapsed .sidebar h1,
html.sidebar-collapsed .nav-label {
  display: none;
}
html.sidebar-collapsed .nav a {
  justify-content: center;
  padding: 0.55rem 0;
}
html.sidebar-collapsed .nav-icon {
  flex-basis: 2rem;
  width: 2rem;
  height: 2rem;
}
html.sidebar-collapsed .main {
  margin-left: 72px;
}
html.sidebar-collapsed .main.main-wide {
  width: calc(100vw - 72px - 3.5rem);
}
@media (max-width: 760px) {
  html.sidebar-collapsed .sidebar {
    width: auto;
  }
  html.sidebar-collapsed .main {
    margin-left: 0;
  }
  html.sidebar-collapsed .main.main-wide {
    width: auto;
  }
}
h2 {
  font-size: 1.35rem;
  margin: 0 0 0.65rem;
  font-weight: 600;
}
h3 { font-size: 1.05rem; color: var(--muted); margin: 1.5rem 0 0.5rem; font-weight: 600; }
p.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }
p.hint.err { color: var(--danger); }
.is-hidden { display: none !important; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.analytics-collapsible > summary,
.analytics-settings > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
.analytics-collapsible > summary {
  font-size: 1.05rem;
}
.analytics-settings {
  margin-bottom: 0.85rem;
}
.analytics-settings > summary {
  font-size: 0.92rem;
  margin-bottom: 0.65rem;
}
.analytics-collapsible:not([open]) {
  padding-bottom: 1.1rem;
}
.analytics-collapsible[open] > summary {
  margin-bottom: 0.85rem;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: 0.82rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.85rem; }
.row > div { flex: 1 1 160px; }
.chk { display: flex; align-items: center; gap: 0.45rem; margin: 0.5rem 0; }
.chk label { margin: 0; color: var(--text); }
button, .btn, .button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
button.secondary, .button.secondary { background: var(--border); color: var(--text); }
button:hover, .button:hover { filter: brightness(1.08); }
.msg { padding: 0.65rem 0.85rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.92rem; }
.msg.ok { background: rgba(80,180,120,0.15); border: 1px solid rgba(80,180,120,0.35); }
.msg.err { background: rgba(229,115,115,0.12); border: 1px solid rgba(229,115,115,0.35); color: var(--danger); }
pre.log {
  background: var(--bg);
  padding: 0.85rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  max-height: 320px;
  overflow-y: auto;
}
.badge { font-size: 0.72rem; padding: 0.2rem 0.45rem; border-radius: 4px; background: var(--border); color: var(--muted); }
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 0.5rem;
}
.tool-tile {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  color: var(--soon);
  font-size: 0.82rem;
}

.invite-bodies-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.65rem;
}

.invite-mail {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15,20,25,0.45);
  overflow: hidden;
}

.invite-mail-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 0.85rem;
  font-size: 0.93rem;
  color: var(--text);
  user-select: none;
  transition: background 0.15s ease;
}
.invite-mail-summary:hover {
  background: rgba(61,158,229,0.06);
}
.invite-mail-summary:focus {
  outline: none;
}
.invite-mail-summary:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 6px;
}

.invite-mail-summary::-webkit-details-marker,
.invite-mail-summary::marker {
  display: none;
}

.invite-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.18s ease;
}
.invite-chevron::before {
  content: "";
  border-style: solid;
  border-width: 0.28em 0 0.28em 0.42em;
  border-color: transparent transparent transparent var(--accent);
  transform: translateX(2px);
}
.invite-mail[open] .invite-chevron {
  transform: rotate(90deg);
}

.invite-summary-text {
  flex: 1 1 auto;
  min-width: 0;
}
.invite-summary-date {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}
.invite-summary-dash { color: var(--muted); }
.invite-summary-theme {
  font-weight: 500;
  word-break: break-word;
}
.invite-summary-id {
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.invite-mail-inner {
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
}

.invite-mail-inner .hint {
  margin: 0.65rem 0 0;
}

.lot-items-h {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
  font-weight: 600;
}
.lot-items-pre { max-height: 400px; margin-top: 0.35rem; }
.invite-body {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.48;
  max-height: 280px;
  overflow: auto;
}
.invite-body-msg { margin-top: 0.75rem; }

.eis-subtitle {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 1rem 0 0.35rem;
  font-weight: 600;
}
.eis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.5rem 0 0;
}
.eis-table th,
.eis-table td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.55rem;
  text-align: left;
  vertical-align: top;
}
.eis-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(0,0,0,0.15);
}
.eis-table tr.eis-new-row td {
  background: rgba(229, 169, 61, 0.18);
}
.eis-table tr.eis-new-row:hover td {
  background: rgba(229, 169, 61, 0.25);
}
.eis-table code { font-size: 0.82rem; word-break: break-all; }

.eis-rss-compare-table {
  table-layout: fixed;
}
.eis-rss-compare-table .rss-col-purchase { width: 13%; }
.eis-rss-compare-table .rss-col-date { width: 11%; }
.eis-rss-compare-table .rss-col-lag { width: 10%; }
.eis-rss-compare-table .rss-col-stage { width: 13%; }
.eis-rss-compare-table .rss-col-customer { width: 42%; }
.eis-rss-compare-table .rss-col-price { width: 10%; }
.eis-rss-compare-table td,
.eis-rss-compare-table th {
  overflow-wrap: anywhere;
}
.eis-rss-compare-table td:last-child,
.eis-rss-compare-table th:last-child {
  text-align: right;
}

.shelf-table form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.shelf-position-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.85rem;
  background: rgba(15,20,25,0.35);
}
.shelf-position-box h4 {
  margin: 0 0 0.4rem;
  color: var(--text);
}

.offer-matching-table td,
.offer-matching-table th {
  overflow-wrap: anywhere;
}
.offer-matching-table {
  table-layout: fixed;
  min-width: 980px;
}
.offer-matching-table th[data-offer-col] {
  position: relative;
  padding-right: 0.95rem;
}
.offer-col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}
.offer-col-resizer::after {
  content: "";
  position: absolute;
  top: 25%;
  right: 3px;
  width: 1px;
  height: 50%;
  background: rgba(255,255,255,0.25);
}
.offer-column-resizing {
  cursor: col-resize !important;
  user-select: none !important;
}
.offer-columns-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  margin: 0.75rem 0;
  background: rgba(0,0,0,0.12);
}
.offer-columns-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}
.offer-columns-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  margin: 0.65rem 0;
}
.offer-columns-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.86rem;
}
.offer-filter-form {
  margin: 0.85rem 0;
}
.offer-filter-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.offer-filter-row input {
  max-width: 320px;
}
.offer-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.7rem 0;
}
.offer-pagination-bottom {
  margin-top: 0.85rem;
}
.offer-pagination-actions {
  display: inline-flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.button.disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.offer-matching-table .offer-customer-cell {
  font-size: 0.78rem;
  line-height: 1.35;
}
.offer-matching-table .offer-open-modal {
  min-width: 2.25rem;
  padding: 0.45rem 0.55rem;
  font-size: 1rem;
}
.offer-create-preoffer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.45rem 0.55rem;
  margin-left: 0.25rem;
  box-sizing: border-box;
}
.offer-matching-table form {
  display: inline-flex;
  margin: 0;
}
.offer-matching-table form button {
  min-width: 2.25rem;
  padding: 0.45rem 0.55rem;
  font-size: 1rem;
}
.offer-matching-table tr.offer-pass-row td {
  background: rgba(40, 120, 40, 0.08);
}
.offer-matching-table tr.offer-fail-row td {
  background: rgba(180, 50, 50, 0.06);
}
.offer-recommendation {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  margin: 0.45rem 0 0.8rem;
}
.offer-recommendation.offer-ok {
  background: rgba(40, 120, 40, 0.12);
}
.offer-recommendation.offer-bad {
  background: rgba(180, 50, 50, 0.1);
}
.offer-rts-link {
  display: inline-block;
  margin-top: 0.45rem;
}
.offer-compare-table tr.offer-compare-match td {
  background: rgba(40, 120, 40, 0.14);
}
.offer-compare-table tr.offer-compare-missing td,
.offer-compare-table tr.offer-compare-mismatch td,
.offer-compare-table tr.offer-compare-no_offer td {
  background: rgba(180, 50, 50, 0.12);
}
.offer-compare-table-wrap {
  overflow: visible;
  margin-top: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.offer-compare-table-wrap .offer-compare-table {
  margin: 0;
}
.offer-compare-table-wrap .offer-compare-table thead th {
  position: static;
}
.eis-modal #offer-modal-body {
  overflow: visible;
  display: block;
}
.offer-alternatives {
  margin-top: 0.85rem;
}
.offer-alternatives h4 {
  margin: 0 0 0.35rem;
}

.preoffer-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 0.75rem;
}
.preoffer-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.preoffer-form label > span {
  color: var(--muted);
  font-size: 0.86rem;
}
.preoffer-form input,
.preoffer-form textarea {
  width: 100%;
  box-sizing: border-box;
}
.preoffer-form .preoffer-enabled {
  flex-direction: row;
  align-items: center;
}
.preoffer-form .preoffer-characteristics,
.preoffer-form .eis-submit-row {
  grid-column: 1 / -1;
}
.preoffers-table td,
.preoffers-table th {
  overflow-wrap: anywhere;
}
.preoffer-disabled-row {
  opacity: 0.68;
}

.eis-table th.eis-sortable-th {
  cursor: pointer;
  user-select: none;
}
.eis-table th.eis-sortable-th:hover {
  filter: brightness(1.08);
}
.eis-sort-ind {
  font-size: 0.75rem;
  opacity: 0.85;
}

.eis-submit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
}
.eis-submit-row-follow {
  margin-top: 0.45rem;
  padding-left: 0;
}
.eis-submit-row button {
  white-space: nowrap;
}
.eis-inline-form {
  display: inline;
  margin: 0;
}
.eis-inline-form button {
  margin: 0;
}
.eis-cron-countdown {
  min-height: 1.25rem;
  margin-left: 0.15rem;
}

.eis-ktru-compare-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}
.eis-ktru-compare-link:hover { filter: brightness(1.08); }

.eis-modal {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.eis-modal[hidden] {
  display: none !important;
}
.eis-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 22, 0.58);
}
.eis-modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  max-height: min(90vh, 880px);
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
  padding: 0.85rem 1rem 1rem;
}
.eis-modal-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -0.2rem 0 0.15rem;
}
.eis-modal-close {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eis-modal-close:hover { filter: brightness(1.12); background: rgba(255,255,255,0.06); }

.eis-modal-heading {
  margin: 0 2.25rem 0.45rem 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
}

.eis-modal-position {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  line-height: 1.42;
}

.eis-modal-customer-block {
  width: 100%;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.62rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

.eis-modal-customer-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.015em;
  margin-bottom: 0.38rem;
  line-height: 1.3;
}

.eis-modal-customer-org {
  font-size: 0.87rem;
  line-height: 1.42;
  white-space: pre-wrap;
  word-break: break-word;
}
.offer-modal-delivery-block {
  flex: 0 0 auto;
  margin-top: -0.2rem;
}

.eis-modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.45rem 1rem;
  margin: 0 0 0.65rem;
  font-size: 0.87rem;
}
.eis-modal-meta dt {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}
.eis-modal-meta dd {
  margin: 0.1rem 0 0;
  word-break: break-word;
}
.eis-modal-meta > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  background: rgba(0,0,0,0.12);
}

.eis-modal-table-wrap {
  flex: 1;
  overflow: auto;
  margin-top: 0.35rem;
  padding-right: 0.08rem;
}
.eis-modal .eis-cmp-table {
  margin-top: 0;
}
.eis-cmp-table td {
  vertical-align: top;
  word-break: break-word;
}
.eis-cmp-tr.eis-cmp-match td {
  background: rgba(40, 120, 40, 0.12);
}
.eis-cmp-tr.eis-cmp-mismatch td {
  background: rgba(180, 50, 50, 0.1);
}
.eis-cmp-tr.eis-cmp-neutral td {
  background: rgba(120, 120, 120, 0.07);
}
