:root {
  --bg: #eef1f6;
  --bg-accent: linear-gradient(135deg, #eef2ff 0%, #f0fdf4 50%, #fefce8 100%);
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #dbe1ea;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #059669;
  --warning: #d97706;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* Shared form language. Keep every native field visually consistent, including
   fields created dynamically in dialogs and settings sections. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]),
select,
textarea {
  max-width: 100%;
  border: 1px solid #cfd9e3;
  border-radius: 11px;
  background-color: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.035);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]) {
  min-height: 42px;
  padding: .62rem .78rem;
}

select {
  min-height: 42px;
  padding: .62rem 2.35rem .62rem .78rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  cursor: pointer;
}

textarea {
  padding: .72rem .8rem;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):hover,
select:hover,
textarea:hover {
  border-color: #aebdc9;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):focus,
select:focus,
textarea:focus {
  border-color: #7c73e8;
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .13);
}

input::placeholder,
textarea::placeholder { color: #929eab; opacity: 1; }

input:disabled,
select:disabled,
textarea:disabled { background-color: #f3f6f8; color: #7b8794; cursor: not-allowed; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image: var(--bg-accent);
  background-attachment: fixed;
  color: var(--text);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.subtitle { margin: 0; color: var(--muted); font-size: 0.95rem; }

.status-bar {
  min-width: 240px;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, #eef2ff, #f0f9ff);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #3730a3;
  box-shadow: var(--shadow-sm);
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  padding: 1rem 2rem 0;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.6);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  font-weight: 600;
  color: var(--primary);
  box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.04);
}

main {
  margin: 0 2rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

.panel { display: none; padding: 1.5rem 1.75rem; }
.panel.active { display: block; }

.panel-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.panel-head p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  line-height: 1.5;
}

.panel-head p:last-child { margin-bottom: 1rem; }

/* Settings collapsible blocks */
.settings-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--surface-muted);
  overflow: hidden;
}

.settings-block[open] {
  box-shadow: var(--shadow-sm);
}

.settings-block-title {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1.15rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  list-style: none;
  user-select: none;
}

.settings-block-title::-webkit-details-marker { display: none; }

.settings-block-title::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s;
}

.settings-block:not([open]) .settings-block-title::after {
  transform: rotate(-90deg);
}

.settings-block-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  font-size: 1rem;
}

.settings-hint,
.settings-block-hint {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}

.settings-block-body {
  padding: 0 1.15rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.env-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  background: var(--surface-muted);
}

.env-group-title {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  list-style: none;
}

.env-group-title::-webkit-details-marker { display: none; }

.env-group-body { padding: 0 1rem 0.75rem; }

.env-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.env-row label { font-size: 0.88rem; word-break: break-word; color: var(--text); }

.env-row input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.env-row input:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.mode-row, .period-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.periodic { margin-bottom: 1rem; }
.periodic.hidden { display: none; }

.lookback-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted, #64748b);
}

.lookback-label input {
  max-width: 6rem;
}

.period-row input, .period-row select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}

.stock-source-card {
  margin-bottom: 1rem;
}

.stock-source-card .btn {
  margin-top: 0.75rem;
}

.stock-source-card .btn-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0;
  border: none;
  background: none;
  color: #1d4ed8;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.92rem;
}

.text-link {
  padding: 0;
  border: none;
  background: none;
  color: #1d4ed8;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
}

.text-link:hover {
  color: #1e40af;
}

.stock-load-status {
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.4;
  min-height: 2rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
}

.stock-load-status.running {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.stock-load-status.ok {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.stock-load-status.error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-grid-narrow {
  max-width: 720px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.card-wb { border-top: 3px solid #a855f7; }
.card-bitrix { border-top: 3px solid #0ea5e9; }
.card-onec { border-top: 3px solid #f59e0b; }
.card-accent { border-top: 3px solid var(--primary); background: linear-gradient(180deg, #fafaff, #fff); }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  border-color: #94a3b8;
  background: var(--surface-muted);
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #4f46e5);
}

.btn.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.btn.is-loading {
  position: relative;
}

.btn.is-loading::after {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  margin-left: 0.45rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: middle;
  animation: btn-spin 0.75s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.actions { margin-top: 1rem; }

.message {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 0.85rem;
  min-height: 2.5rem;
  line-height: 1.45;
}

.description-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  min-height: 520px;
}

.section-tree-wrap, .products-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  background: linear-gradient(180deg, #fafbfc, #fff);
  box-shadow: var(--shadow-sm);
}

.aside-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.aside-head h3 { margin: 0; font-size: 0.95rem; }

.section-tree, .section-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.section-tree ul { padding-left: 0.85rem; border-left: 2px solid #e2e8f0; }

.section-tree button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
}

.section-tree button:hover { background: #e2e8f0; }

.section-tree button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.products-list {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 1rem;
}

.product-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #eef2f6;
  transition: background 0.12s;
}

.product-row:hover { background: #fafbfc; }

.coupons-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.journal-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 1100px;
}

.journal-block {
  margin-top: 0;
}

.journal-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.journal-updated-at {
  font-size: 0.88rem;
  color: var(--muted);
}

.journal-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.journal-table th,
.journal-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.journal-table th {
  background: var(--surface-muted);
  font-weight: 600;
  color: var(--muted);
}

.journal-table tr:last-child td {
  border-bottom: none;
}

.journal-table-events td:nth-child(4),
.journal-table-events td:nth-child(5) {
  font-size: 0.84rem;
  color: #334155;
}

.journal-stat-ok {
  color: #047857;
}

.journal-stat-error {
  color: #b91c1c;
}

.journal-stat-muted {
  color: var(--muted);
}

.misc-layout {
  display: grid;
  gap: 1rem;
  max-width: 920px;
}

.misc-card {
  padding: 1.25rem;
}

.misc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  margin-top: 1rem;
}

.misc-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.misc-toolbar input[type="text"] {
  min-width: 220px;
}

.misc-group {
  margin-top: 0;
}

.active-products-table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.active-products-table-wrap.hidden {
  display: none;
}

.active-products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.active-products-table th,
.active-products-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.active-products-table th {
  background: var(--surface-muted);
  font-weight: 600;
  color: var(--muted);
}

.active-products-table tr:last-child td {
  border-bottom: none;
}

.active-products-action-activate {
  color: #047857;
}

.active-products-action-deactivate {
  color: #b45309;
}

.active-products-remove {
  padding: 0;
  border: none;
  background: none;
  color: #b91c1c;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}

.coupons-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.coupons-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-muted, #64748b);
}

.coupon-status.status-active {
  color: #15803d;
}

.coupon-status.status-used {
  color: #1d4ed8;
}

.coupon-status.status-deactivated {
  color: #b91c1c;
}

.prices-table:not(.coupons-table):not(.hits-table) .product-row,
.stocks-table .product-row,
.data-header:not(.coupons-header):not(.hits-header) {
  grid-template-columns: 24px 1fr 120px;
  align-items: center;
}

.coupons-table .data-header,
.coupons-table .coupon-row {
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1.2fr;
  align-items: start;
}

.hits-table .data-header,
.hits-table .hit-row {
  grid-template-columns: 28px minmax(180px, 1.6fr) 120px 90px 90px 110px;
  align-items: center;
}

.hits-table.hits-table-no-date .data-header,
.hits-table.hits-table-no-date .hit-row {
  grid-template-columns: 28px minmax(180px, 1.6fr) 120px 90px 90px;
}

.hits-sort-btn {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.hits-sort-btn:hover {
  color: var(--primary);
}

.hits-sort-btn .sort-mark {
  margin-left: 0.2rem;
  font-size: 0.75rem;
  opacity: 0.85;
}

.hits-toolbar {
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
}

.hits-list-head {
  margin-top: 0.5rem;
}

.hits-list-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hit-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.hit-source {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #334155;
}

.hit-source-wb {
  background: #fce7f3;
  color: #9d174d;
}

.hit-source-bitrix {
  background: #dbeafe;
  color: #1d4ed8;
}

.hit-check-wrap {
  display: flex;
  justify-content: center;
}

.promos-layout {
  padding: 0 0.25rem 1rem;
}

.data-header,
.prices-header {
  display: grid;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: linear-gradient(180deg, #f1f5f9, #e2e8f0);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.price-input,
.qty-input {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}

.price-input:focus,
.qty-input:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.toolbar,
.prices-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toolbar-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar input[type="number"],
.toolbar select,
.prices-toolbar input[type="number"],
.prices-toolbar select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--surface);
}

.prices-toolbar-primary {
  align-items: center;
}

.prices-toolbar-formula {
  align-items: flex-start;
}

.price-formula-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.price-formula-field select,
.price-formula-field input[type="number"] {
  min-width: 7rem;
}

.price-preset-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.price-preset-editor.hidden {
  display: none;
}

.price-preset-settings-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.price-preset-settings-row .text-link {
  margin-top: 1.35rem;
}

#apply-price-preset-all {
  margin-top: 0.75rem;
}

.product-row:last-child { border-bottom: none; }
.product-name { font-weight: 600; font-size: 0.95rem; }
.product-meta { color: var(--muted); font-size: 0.85rem; }

.product-group {
  border-bottom: 1px solid #eef2f6;
}

.product-group:last-child { border-bottom: none; }

.stocks-table .product-group-head {
  display: grid;
  grid-template-columns: 24px 1fr 120px;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f6;
}

.group-title {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.group-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted);
  padding: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.group-toggle:hover { background: #e2e8f0; }

.group-qty-spacer {
  display: block;
}

.offer-row {
  padding-left: 2.5rem;
  background: #fff;
}

.offer-row.empty-offers {
  display: block;
  padding: 0.55rem 0.75rem 0.55rem 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.stocks-header {
  grid-template-columns: 24px 1fr 120px;
}

.stocks-table .offer-row {
  grid-template-columns: 24px 1fr 120px;
}

.sync-banner {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #eef2ff, #f0fdf4);
}

.sync-banner p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.sync-banner strong {
  font-size: 1rem;
}

.description-editor textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  resize: vertical;
  background: var(--surface);
}

.description-editor label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.check-all { font-size: 0.9rem; color: var(--muted); }

.hidden { display: none !important; }

.cache-info {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: 0.9rem;
  line-height: 1.45;
}

.cache-info.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

code {
  font-size: 0.88em;
  padding: 0.1em 0.35em;
  background: #f1f5f9;
  border-radius: 4px;
}

@media (max-width: 900px) {
  .description-layout { grid-template-columns: 1fr; }
  .env-row { grid-template-columns: 1fr; }
  .tabs, main, .header {
    margin-left: 0;
    margin-right: 0;
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .header { flex-direction: column; }
  .status-bar { width: 100%; min-width: 0; }
}

.unmatched-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: min(1200px, 96vw);
  width: 96vw;
}

.unmatched-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.unmatched-dialog-inner {
  padding: 1rem 1.25rem 1.25rem;
  margin: 0;
}

.unmatched-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.unmatched-dialog-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.unmatched-dialog-toolbar.hidden,
.unmatched-dialog-progress.hidden {
  display: none;
}

.unmatched-select-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #334155;
}

.unmatched-dialog-progress {
  margin-bottom: 0.6rem;
}

.unmatched-progress-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.unmatched-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.2s ease;
}

.unmatched-progress-text {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: #475569;
}

.unmatched-table-wrap {
  max-height: 60vh;
  overflow: auto;
}

.unmatched-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  line-height: 1.25;
}

.unmatched-table th,
.unmatched-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.3rem 0.35rem;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.unmatched-table th.col-check,
.unmatched-table td.col-check {
  width: 2rem;
  text-align: center;
  white-space: nowrap;
}

.unmatched-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.unmatched-actions {
  white-space: nowrap;
  width: 1%;
}

.unmatched-actions .btn {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}

.unmatched-actions .btn + .btn {
  margin-left: 0.25rem;
}

.unmatched-load {
  border-color: #86efac;
  background: #ecfdf5;
  color: #047857;
}

.unmatched-load:hover {
  border-color: #4ade80;
  background: #d1fae5;
}

.unmatched-load:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.btn-danger:hover {
  border-color: #fca5a5;
  background: #fee2e2;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alerts-bell-wrap {
  position: relative;
}

.alerts-bell {
  position: relative;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.alerts-bell-icon { width: 21px; height: 21px; fill: none; stroke: #334155; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.alerts-bell-count {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  line-height: 1.1rem;
  text-align: center;
}

.alerts-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  width: min(360px, 90vw);
  max-height: 360px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 40;
}

.alerts-dropdown-head {
  padding: 0.6rem 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.alerts-dropdown-head button { border: 0; background: transparent; color: #4f46e5; font: inherit; font-size: .76rem; cursor: pointer; }

.alerts-dropdown-list {
  padding: 0.4rem;
}

.alerts-item {
  position: relative;
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.78rem;
}
.alerts-item-read { position: absolute; top: .45rem; right: .45rem; width: 25px; height: 25px; border: 0; border-radius: 50%; background: #edf3f1; color: #42675a; cursor: pointer; }
.alerts-item-read:hover { background: #dcebe5; }
.alerts-item strong { padding-right: 30px; }

.alerts-item p {
  margin: 0.2rem 0 0;
  color: #64748b;
}

.alerts-empty {
  margin: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.smart-stocks-toolbar {
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.smart-stocks-toolbar-channels {
  margin-bottom: 0.5rem;
}

.smart-threshold-input {
  width: 4.5rem;
}

.smart-stocks-toolbar .inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.smart-manual-target {
  width: 4.5rem;
  max-width: 100%;
  text-align: right;
}

.smart-stocks-panel-head {
  margin-bottom: 0.75rem;
}

.smart-stocks-head-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.smart-stocks-panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
}

.smart-stocks-meta {
  margin: 0 !important;
  margin-left: auto !important;
  padding: 0;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: right;
  max-width: min(100%, 38rem);
  font-weight: 400;
}

.help-q {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.help-q:hover,
.help-q[aria-expanded="true"] {
  border-color: var(--primary, #6366f1);
  color: var(--primary, #6366f1);
  background: #eef2ff;
}

.help-popover {
  margin-top: 0.65rem;
  max-width: 42rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.smart-stocks-toolbar-secondary {
  margin-top: -0.25rem;
  justify-content: space-between;
  width: 100%;
}

.smart-stocks-toolbar-left,
.smart-stocks-toolbar-right {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  flex: 0 0 auto;
}

.smart-stocks-toolbar-right {
  margin-left: auto;
}

.smart-stocks-toolbar .inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.smart-period-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
}

.smart-fbo-warehouses-link {
  margin-left: 0.75rem;
  white-space: nowrap;
}

.smart-fbo-warehouses-summary {
  color: #64748b;
  font-size: 0.9rem;
}

.fbo-warehouses-dialog {
  max-width: min(640px, 96vw);
  width: min(640px, 96vw);
}

.fbo-warehouses-list {
  max-height: min(60vh, 520px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.25rem 0;
}

.fbo-warehouse-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.fbo-warehouse-row:hover {
  background: #f8fafc;
}

.fbo-warehouse-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fbo-warehouse-qty {
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

.smart-period-inline input[type="number"] {
  width: 4.5rem;
}

.smart-group-row td {
  background: #f1f5f9;
  border-top: 1px solid #cbd5e1;
}

.smart-group-row td:first-child {
  font-size: 0.95rem;
}

.smart-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.smart-group-chevron {
  display: inline-block;
  width: 0.85rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.smart-group-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
}

.smart-row.smart-child-row td:first-child {
  padding-left: 1.5rem;
}

.smart-stocks-table .num {
  text-align: right;
  white-space: nowrap;
}

.smart-stocks-table .col-enable {
  text-align: center;
  width: 3rem;
}

.smart-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
}

.smart-toggle.is-on {
  color: #059669;
}

.smart-toggle.is-off {
  color: #94a3b8;
}

.smart-row.has-alert {
  background: #fff7ed;
}

.smart-row.needs-update td:nth-child(7) {
  font-weight: 700;
  color: #b45309;
}

#smart-subjects-tree button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.marking-safety {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  background: #eff6ff;
  color: #1e3a8a;
}

.marking-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.marking-sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 12px 0; }
.marking-source { border: 1px solid #e0e5ee; border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; background: #fafbfc; }
.marking-source.is-ready { border-color: #87c99a; background: #f2fbf4; }
.marking-source span { font-size: 13px; font-weight: 600; }
.marking-source small { color: #657083; }
.marking-table th[data-marking-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.marking-table th[data-marking-sort]::after { content: " ↕"; color: #9aa3b2; font-size: 11px; }
.marking-table th.sort-asc::after { content: " ↑"; color: #4f46e5; }
.marking-table th.sort-desc::after { content: " ↓"; color: #4f46e5; }
.marking-table th[data-marking-sort] { position: relative; padding-right: 2.2rem; }
.marking-column-filter-button { position: absolute; top: 50%; right: .38rem; width: 1.65rem; height: 1.65rem; transform: translateY(-50%); display: grid; place-items: center; border: 1px solid transparent; border-radius: 50%; background: transparent; color: #718096; cursor: pointer; line-height: 1; transition: .15s ease; }
.marking-column-filter-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.marking-column-filter-button:hover { border-color: #a5b4fc; background: #eef2ff; color: #4338ca; box-shadow: 0 2px 8px #312e8120; }
.marking-table th.filter-active .marking-column-filter-button { border-color: #6366f1; background: #6366f1; color: #fff; }
.marking-column-filter-popover { position: fixed; z-index: 10020; width: min(330px, calc(100vw - 24px)); max-height: min(520px, calc(100vh - 24px)); padding: 14px; border: 1px solid #dfe5ee; border-radius: 16px; background: #fff; box-shadow: 0 20px 60px #1e293b38; display: grid; gap: 11px; }
.marking-column-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #172033; }
.marking-column-filter-close { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #eef2f1; color: #394943; cursor: pointer; font-size: 20px; }
.marking-column-filter-search { width: 100%; min-width: 0!important; padding: .65rem .8rem; border: 1px solid #d6dfe7; border-radius: 10px; font: inherit; }
.marking-column-filter-links { display: flex; gap: 14px; }
.marking-column-filter-links button { padding: 0; border: 0; background: transparent; color: #4f46e5; cursor: pointer; font: inherit; font-size: .82rem; }
.marking-column-filter-values { min-height: 44px; max-height: 270px; overflow: auto; display: grid; gap: 5px; padding: 3px; }
.marking-column-filter-values label { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 9px; cursor: pointer; }
.marking-column-filter-values label:hover { background: #f1f5f9; }
.marking-column-filter-values input, .marking-row-select, #marking-select-all { appearance: none; width: 22px; height: 22px; flex: 0 0 22px; border: 1.5px solid #9aa7b5; border-radius: 7px; background: #fff; display: inline-grid; place-content: center; cursor: pointer; transition: .14s ease; }
.marking-column-filter-values input::before, .marking-row-select::before, #marking-select-all::before { content: ""; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform .12s ease; }
.marking-column-filter-values input:checked, .marking-row-select:checked, #marking-select-all:checked { border-color: #5b5ce2; background: #5b5ce2; box-shadow: 0 2px 7px #4f46e533; }
.marking-column-filter-values input:checked::before, .marking-row-select:checked::before, #marking-select-all:checked::before { transform: rotate(-45deg) scale(1); }
#marking-select-all:indeterminate { border-color: #5b5ce2; background: #5b5ce2; }
#marking-select-all:indeterminate::before { width: 10px; height: 0; border-left: 0; border-bottom: 2px solid #fff; transform: none; margin: 0; }
.marking-column-filter-values input:focus-visible, .marking-row-select:focus-visible, #marking-select-all:focus-visible { outline: 3px solid #c7d2fe; outline-offset: 2px; }
.marking-column-filter-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; border-top: 1px solid #edf0f4; }
.marking-table .marking-code-col, .marking-table td.marking-code-cell { width: 150px; max-width: 150px; }
.marking-code { display: block; max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marking-dialog { max-width: 520px; width: calc(100% - 32px); padding: 24px; border: 0; border-radius: 18px; color: var(--text); box-shadow: 0 24px 72px #13251f40; }
.marking-dialog::backdrop { background: #15231f7a; backdrop-filter: blur(2px); }
.marking-dialog form { display: grid; gap: 14px; }
.marking-dialog h3 { margin: 0; font-size: 1.3rem; letter-spacing: -.015em; }
.marking-dialog p { margin: 0; color: var(--muted); line-height: 1.45; }
.marking-dialog label { display: grid; gap: 7px; font-size: .92rem; font-weight: 600; }
.marking-dialog input:not([type="radio"]):not([type="checkbox"]), .marking-dialog select { width: 100%; min-height: 46px; }
.marking-dialog textarea { width: 100%; min-height: 190px; resize: vertical; font-family: Consolas, "Courier New", monospace; line-height: 1.45; }
.marking-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.marking-dialog-actions .btn { min-height: 42px; padding-inline: 18px; }
.crpt-certificate-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crpt-certificate-row select { flex: 1 1 520px; min-width: 260px; }

.marking-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.marking-card span { color: var(--muted); font-size: 0.82rem; }
.marking-card strong { font-size: 1.45rem; }
.marking-card.warning { border-color: #fed7aa; background: #fff7ed; }
.marking-card.info { border-color: #bbf7d0; background: #f0fdf4; }

.marking-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.marking-toolbar label { display: inline-flex; align-items: center; gap: 0.4rem; }
.marking-toolbar input[type="number"] { width: 5rem; }
.marking-toolbar input[type="search"] { min-width: 18rem; }

.marking-filter-bar { display: flex; justify-content: center; margin: .8rem 0 1rem; }
.marking-command-bar { position: relative; display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; padding: .8rem .9rem; margin-bottom: .55rem; border: 1px solid #dfe7e4; border-radius: 15px; background: linear-gradient(180deg,#fff,#f8fbfa); box-shadow: 0 3px 14px #173f3210; }
.marking-period-control { display: inline-flex; align-items: center; gap: .45rem; color: #5f6f69; font-size: .88rem; font-weight: 600; white-space: nowrap; }
.marking-number-stepper { display: inline-grid; grid-template-columns: 32px 54px 32px; align-items: stretch; height: 38px; border: 1px solid #d5dfdc; border-radius: 11px; overflow: hidden; background: #fff; box-shadow: inset 0 1px 2px #0f172a0a; }
.marking-pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin: .65rem 0 0; padding: .7rem .85rem; border: 1px solid #dfe6e3; border-radius: 13px; background: #f8fbfa; color: #53645e; font-size: .84rem; }
.marking-page-buttons { display: flex; align-items: center; justify-content: center; gap: .45rem; }
.marking-page-buttons .btn { min-width: 36px; height: 36px; padding: 0 .65rem; border-radius: 10px; font-size: 1.05rem; }
#marking-page-label { min-width: 135px; text-align: center; color: #34463f; font-weight: 600; }
.marking-page-size { justify-self: end; display: flex; align-items: center; gap: .55rem; }
.marking-page-size select { min-width: 82px; height: 36px; padding: 0 30px 0 11px; border: 1px solid #cedbd6; border-radius: 10px; background: #fff; color: #34463f; font: inherit; }
@media (max-width: 760px) { .marking-pagination { grid-template-columns: 1fr; } .marking-page-range, .marking-page-size { justify-self: center; } }
.marking-number-stepper button { border: 0; background: #f2f6f4; color: #35584b; cursor: pointer; font: inherit; font-size: 19px; }
.marking-number-stepper button:hover { background: #e5efea; }
.marking-number-stepper input { width: 54px!important; min-width: 0; padding: 0 3px; border: 0; border-left: 1px solid #e0e7e4; border-right: 1px solid #e0e7e4; border-radius: 0; background: #fff; text-align: center; font: inherit; font-weight: 650; -moz-appearance: textfield; }
.marking-number-stepper input::-webkit-inner-spin-button, .marking-number-stepper input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.marking-number-stepper input:focus { outline: 0; box-shadow: inset 0 0 0 2px #a5b4fc; }
.marking-operations-menu { position: relative; }
.marking-operations-menu summary { list-style: none; display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; user-select: none; }
.marking-operations-menu summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
.marking-operations-menu[open] summary svg { transform: rotate(180deg); }
.marking-operations-menu summary::-webkit-details-marker { display: none; }
.marking-operations-menu[open] summary { border-color: #a5b4fc; box-shadow: 0 0 0 3px #6366f11a; }
.marking-operations-menu-list { position: absolute; z-index: 40; top: calc(100% + 8px); left: 0; min-width: 255px; padding: 7px; border: 1px solid #dde5e2; border-radius: 13px; background: #fff; box-shadow: 0 16px 42px #172b2440; display: grid; gap: 3px; }
.marking-operations-menu-list button { padding: .72rem .8rem; border: 0; border-radius: 9px; background: transparent; color: #263b34; text-align: left; cursor: pointer; font: inherit; }
.marking-operations-menu-list button:hover { background: #eef5f2; color: #234f3f; }
.marking-selected-count { margin-left: auto; padding: .48rem .72rem; border-radius: 999px; background: #eef2ff; color: #4338ca; font-size: .86rem; font-weight: 650; white-space: nowrap; }
.marking-table-tools { display: flex; justify-content: flex-end; align-items: center; gap: .55rem; margin: .25rem 0 .55rem; }
.marking-table-left-actions { display: inline-flex; align-items: center; gap: .55rem; margin-right: auto; }
.marking-export-codes-button, .marking-print-codes-button { min-height: 42px; border-radius: 12px; white-space: nowrap; }
.marking-search-wrap { position: relative; display: block; width: min(370px,100%); }
.marking-search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #718096; font-size: 20px; pointer-events: none; }
.marking-search-wrap input { width: 100%; min-width: 0; height: 42px; padding: .65rem 2.3rem .65rem 2.45rem; border: 1px solid #d5dfdc; border-radius: 999px; background: #fff; color: var(--text); font: inherit; box-shadow: inset 0 1px 2px #0f172a0a; }
.marking-search-wrap input:focus { outline: none; border-color: #8baea0; box-shadow: 0 0 0 3px #5f978324; }
.marking-bulk-filter-button { display: inline-flex; align-items: center; gap: .45rem; min-height: 42px; border-radius: 12px; white-space: nowrap; }
.marking-bulk-filter-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.marking-bulk-filter-button.active { border-color: #818cf8; background: #eef2ff; color: #4338ca; box-shadow: 0 0 0 3px #6366f114; }
.marking-bulk-filter-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #5548df; color: #fff; font-size: .75rem; font-weight: 700; }
.marking-bulk-filter-count[hidden] { display: none; }
.marking-bulk-filter-dialog { max-width: 620px; }
.marking-bulk-filter-actions { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; }
.marking-columns-menu { position: relative; }
.marking-columns-menu > summary { list-style: none; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border-radius: 50%; cursor: pointer; }
.marking-columns-menu > summary::-webkit-details-marker { display: none; }
.marking-columns-menu > summary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.marking-columns-menu[open] > summary { border-color: #a5b4fc; box-shadow: 0 0 0 3px #6366f11a; }
.marking-columns-popover { position: absolute; z-index: 45; top: calc(100% + 8px); right: 0; display: grid; gap: .7rem; width: 270px; max-height: min(520px,70vh); overflow: auto; padding: .9rem; border: 1px solid #dce5e2; border-radius: 14px; background: #fff; box-shadow: 0 18px 48px #172b2438; }
#marking-column-options { display: grid; gap: .2rem; }
#marking-column-options label { display: flex; align-items: center; gap: .65rem; min-height: 36px; padding: .35rem .45rem; border-radius: 8px; cursor: pointer; }
#marking-column-options label:hover { background: #f1f6f4; }
#marking-column-options input { width: 18px; height: 18px; accent-color: #5548df; }
#marking-columns-show-all { border: 0; border-radius: 9px; padding: .58rem .7rem; background: #eef2ff; color: #4338ca; cursor: pointer; font: inherit; font-weight: 600; }
.marking-column-hidden { display: none !important; }
#marking-message:empty { display: none; }
#marking-message:not(:empty) { margin: .55rem 0; }

.marking-filter-wrap {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.marking-filter-label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}

.marking-filter-group {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f1f5f9;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.marking-filter {
  min-height: 34px;
  padding: 0.42rem 0.75rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.marking-filter:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.marking-filter:active { transform: translateY(1px); }
.marking-filter:focus-visible { outline: 2px solid #818cf8; outline-offset: 2px; }
.marking-filter.active { color: #3730a3; background: #fff; box-shadow: 0 2px 7px rgba(15, 23, 42, 0.12); }
.marking-filter.withdraw.active { color: #9a3412; background: #fff7ed; }
.marking-filter.reintroduce.active { color: #166534; background: #f0fdf4; }
.marking-filter.none.active { color: #475569; background: #fff; }

.marking-table-wrap { overflow: auto; max-height: calc(100vh - 360px); }
.marking-table { min-width: 1580px; }
.marking-table td { vertical-align: top; }
.marking-table td small { display: block; margin-top: 0.2rem; color: var(--muted); }
.marking-code { display: block; max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marking-action { display: inline-block; padding: 0.2rem 0.45rem; border-radius: 999px; white-space: nowrap; font-size: 0.78rem; font-weight: 600; }
.marking-action-withdraw { color: #9a3412; background: #ffedd5; }
.marking-action-reintroduce { color: #166534; background: #dcfce7; }
.marking-table tr.marking-row-due-soon > td { background: #fff7ed; }
.marking-table tr.marking-row-overdue > td { background: #fef2f2; }
.marking-table tr.marking-row-due-soon:hover > td { background: #ffedd5; }
.marking-table tr.marking-row-overdue:hover > td { background: #fee2e2; }
.marking-history-toggle { display: block; margin-top: .3rem; padding: 0; border: 0; background: transparent; color: #4f46e5; cursor: pointer; font-size: .75rem; }
.marking-history-row > td { background: #f8fafc !important; padding: .75rem 1rem !important; }
.marking-history { display: grid; gap: .55rem; }
.marking-history-cycle { display: flex; flex-wrap: wrap; gap: .35rem 1rem; align-items: baseline; padding-bottom: .45rem; border-bottom: 1px solid var(--border); }
.marking-history-cycle:last-child { border-bottom: 0; padding-bottom: 0; }
.marking-history-cycle span { color: #475569; font-size: .82rem; }
.marking-recovery-dialog { width: min(760px, calc(100vw - 32px)); max-width: 760px; }
.marking-recovery-results { display: grid; gap: 12px; max-height: min(62vh, 620px); overflow: auto; padding: 2px; }
.marking-recovery-item { border: 1px solid #dfe5ee; border-radius: 16px; padding: 14px 16px; background: #fff; }
.marking-recovery-item header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.marking-recovery-item header span { color: #66758b; font-size: 13px; }
.marking-recovery-item > small { display: block; margin-top: 5px; color: #66758b; }
.marking-recovery-item ol { margin: 12px 0 0; padding-left: 24px; display: grid; gap: 9px; }
.marking-recovery-item li { padding-left: 4px; }
.marking-recovery-item li strong, .marking-recovery-item li span { display: block; }
.marking-recovery-item li span { margin-top: 2px; color: #66758b; font-size: 13px; line-height: 1.35; }
.marking-recovery-item .recovery-last_resort { color: #9a5b00; }
.marking-row-actions-head, .marking-row-actions { width: 52px; min-width: 52px; text-align: center; }
.marking-row-remove { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid #e3e8ef; border-radius: 11px; background: #fff; color: #7b8798; cursor: pointer; transition: .16s ease; }
.marking-row-remove svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.marking-row-remove:hover { color: #c2414b; border-color: #f2c8cc; background: #fff5f5; transform: translateY(-1px); }
.marking-row-remove:focus-visible { outline: 3px solid #6657ff33; outline-offset: 2px; }
.crpt-operation-settings { display: grid; grid-template-columns: minmax(320px, 1fr) 180px auto; gap: .75rem; align-items: end; margin-top: 1rem; }
.crpt-operation-settings label { display: grid; gap: .35rem; color: var(--muted); font-size: .86rem; }
@media (max-width: 900px) { .crpt-operation-settings { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .marking-summary { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .marking-filter-wrap { width: 100%; align-items: flex-start; flex-direction: column; }
  .marking-filter-group { max-width: 100%; overflow-x: auto; }
  .marking-filter-bar { justify-content: flex-start; }
  .marking-command-bar { align-items: stretch; }
  .marking-command-bar > .btn, .marking-operations-menu, .marking-operations-menu summary { width: 100%; justify-content: center; }
  .marking-selected-count { margin-left: 0; text-align: center; }
  .marking-search-wrap { width: 100%; }
}

/* Production map */
.production-map-toolbar {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}
.production-map-toolbar label { display: flex; flex-direction: column; gap: .4rem; color: var(--muted); font-size: .82rem; font-weight: 600; }
.production-map-toolbar input, .production-map-toolbar select { min-width: 220px; padding: .62rem .75rem; border: 1px solid var(--border); border-radius: 9px; background: #fff; font: inherit; color: var(--text); }
.production-map-toolbar input:focus, .production-map-toolbar select:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.production-map-toolbar .production-map-mode-control { margin-left: auto; }
.production-map-mode-control select { appearance: none; min-width: 210px; padding: 11px 42px 11px 15px; border-color: #b8cdc4; border-radius: 10px; background-color: #f1f6f3; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23234943' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; color: #234943; font-weight: 600; cursor: pointer; }
.production-map-mode-control select:focus { border-color: #5f9783; box-shadow: 0 0 0 3px rgba(70,125,105,.16); }
.production-map-legend { display: flex; gap: .65rem; flex-wrap: wrap; margin: .75rem 0; font-size: .8rem; }
.production-map-legend span { padding: .42rem .68rem; border-radius: 8px; }
.production-map-green { background: #e0eee5; color: #29543c; }
.production-map-orange { background: #f5e9d5; color: #76551f; }
.production-map-red { background: #f1dfdd; color: #7b3d38; }
.production-map-unknown { background: #e5e9eb; color: #4b5a63; }
.production-map-legend .green { background: #e0eee5; color: #29543c; }
.production-map-legend .orange { background: #f5e9d5; color: #76551f; }
.production-map-legend .red { background: #f1dfdd; color: #7b3d38; }
.production-map-legend .unknown { background: #e5e9eb; color: #4b5a63; }
.production-map-status { min-height: 1.3rem; color: var(--muted); }
.production-map-crumbs { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin: .8rem 0 1rem; }
.production-map-crumbs button { border: 1px solid var(--border); border-radius: 9px; padding: .45rem .7rem; background: #fff; color: #334155; cursor: pointer; font: inherit; }
.production-map-crumbs button:not(:last-child)::after { content: " ›"; color: #94a3b8; }
.production-map-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0,1fr)); gap: 1rem; }
.production-map-tile { position: relative; min-height: 190px; padding: 68px 1.25rem 1.25rem; border: 1px solid #c7d6d0; border-radius: 18px; text-align: left; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.production-map-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(15,23,42,.1); }
.production-map-tile strong { display: block; font-size: clamp(17px,2vw,25px); overflow-wrap: anywhere; }
.production-map-tile.worker strong { font-size: 18px; line-height: 1.4; hyphens: auto; }
.production-map-tile small { display: block; margin-top: .9rem; line-height: 1.5; }
.production-map-count { position: absolute; top: 15px; right: 16px; max-width: calc(100% - 32px); padding: 5px 10px; border: 1px solid #994347; border-radius: 10px; background: #a94d50; color: #fff; font-size: 20px; font-weight: 650; overflow-wrap: anywhere; }
.production-map-green .production-map-count { background: #38694d; border-color: #305d43; }
.production-map-orange .production-map-count { background: #b45b18; border-color: #9c4e13; color: #fff; }
.production-map-red .production-map-count { background: #a94d50; border-color: #994347; }
.production-map-unknown .production-map-count { background: #536772; border-color: #485c67; }
.production-map-dim { background: #edf0ef !important; color: #8a9592 !important; opacity: .55; }
.production-map-dim .production-map-count { background: #62736d; border-color: #586861; }
.production-map-table-wrap { overflow: auto; }
.production-map-table { width: 100%; min-width: 900px; }
.production-map-table tr.production-map-green td { background: #e0eee5; }
.production-map-table tr.production-map-orange td { background: #f5e9d5; }
.production-map-table tr.production-map-red td { background: #f1dfdd; }
.production-map-table tr.production-map-unknown td { background: #e5e9eb; }
.production-map-table tr.production-map-dim td { background: #edf0ef !important; color: #8a9592; }
.forecast-refresh { display: inline-flex; align-items: center; gap: .55rem; min-height: 42px; padding: .62rem 1rem; border-radius: 11px; white-space: nowrap; }
.forecast-refresh svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.forecast-refresh:disabled svg { animation: forecast-refresh-spin .9s linear infinite; }
@keyframes forecast-refresh-spin { to { transform: rotate(360deg); } }
.production-map-column-toolbar { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.production-map-column-toolbar details { position: relative; }
.production-map-column-toolbar summary { width: fit-content; margin-left: auto; padding: 5px 12px; border-radius: 8px; background: #e6eeed; color: #234943; cursor: pointer; font-size: 25px; list-style: none; }
.production-map-column-toolbar summary::-webkit-details-marker { display: none; }
#production-map-column-options { position: absolute; z-index: 10; right: 0; display: grid; gap: .5rem; min-width: 230px; padding: .8rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
#production-map-column-options label { display: flex; gap: .45rem; align-items: center; white-space: nowrap; }
@media (max-width: 700px) {
  .production-map-toolbar { align-items: stretch; }
  .production-map-toolbar label, .production-map-toolbar input, .production-map-toolbar select { width: 100%; min-width: 0; }
  .production-map-toolbar .production-map-mode-control { margin-left: 0; flex-basis: 100%; }
  .production-map-tile { min-height: 170px; padding: 62px 1rem 1rem; }
  .production-map-count { font-size: 19px; }
}
.login-screen{position:fixed;inset:0;z-index:10000;background:linear-gradient(135deg,#f5f7ff,#edf8f3);display:grid;place-items:center;padding:20px}.login-screen.hidden{display:none}.login-card{width:min(380px,100%);background:#fff;border:1px solid #dfe5ea;border-radius:18px;box-shadow:0 20px 60px #25315a22;padding:28px;display:grid;gap:16px}.login-card h2{margin:0}.login-card label{display:grid;gap:6px}.users-head{display:flex;align-items:center;justify-content:space-between;gap:20px}.users-list{display:grid;gap:12px;margin-top:18px}.user-row{display:grid;grid-template-columns:minmax(190px,1.4fr) minmax(200px,2fr) auto;gap:18px;align-items:center;padding:18px 20px;border:1px solid #dce5e2;border-radius:15px;background:linear-gradient(180deg,#fff,#fbfdfc);box-shadow:0 3px 14px #173f3210}.user-row.disabled{background:#f5f6f6;color:#77817e}.user-name{font-size:16px;font-weight:700}.user-role{display:block;color:#71807b;font-size:13px;margin-top:4px}.user-access{font-size:13px;color:#53645e}.user-actions{display:flex;gap:9px;align-items:center}.user-status{border:0;border-radius:999px;padding:8px 12px;font-weight:650;cursor:pointer;background:#e2f2e8;color:#27613e}.user-status.off{background:#ecefef;color:#67716e}.user-status:disabled{cursor:not-allowed;opacity:.55}.user-dialog{width:min(680px,calc(100% - 32px));border:0;border-radius:20px;padding:0;box-shadow:0 24px 80px #142b2445}.user-dialog::backdrop{background:#15231f80;backdrop-filter:blur(2px)}.user-dialog form{padding:24px}.user-dialog-head{display:flex;justify-content:space-between;gap:18px;align-items:start}.user-dialog-head h3{margin:0;font-size:22px}.user-dialog-head p{margin:6px 0 18px;color:#71807b}.dialog-close{border:0;background:#edf1f0;border-radius:50%;width:36px;height:36px;font-size:24px;cursor:pointer}.users-form{display:grid;grid-template-columns:1fr 1fr;gap:14px}.users-form label{display:grid;gap:7px}.checkbox-line{display:flex!important;align-items:center;gap:8px}.user-switches{display:flex;gap:24px;margin:20px 0}#user-permissions{display:flex;flex-wrap:wrap;gap:14px;border:1px solid #dfe5ea;border-radius:12px;margin:16px 0;padding:16px}#user-permissions label{display:flex;gap:6px;align-items:center}.user-dialog-actions{display:grid;grid-template-columns:auto 1fr auto auto;gap:10px;align-items:center;margin-top:20px}.btn.danger{background:#fff0f0;border-color:#efb8b8;color:#a42222}@media(max-width:700px){.users-head{align-items:stretch;flex-direction:column}.user-row{grid-template-columns:1fr}.user-actions{justify-content:flex-start}.users-form{grid-template-columns:1fr}.user-dialog-actions{grid-template-columns:1fr 1fr}.user-dialog-actions span{display:none}}
.login-card input,.user-dialog input:not([type]),.user-dialog input[type="text"],.user-dialog input[type="password"]{box-sizing:border-box;width:100%;height:46px;padding:0 14px;border:1px solid #cfdad6;border-radius:11px;background:#fbfdfc;color:#17231f;font:inherit;outline:none;transition:border-color .16s,box-shadow .16s,background .16s}.login-card input:hover,.user-dialog input:not([type]):hover,.user-dialog input[type="text"]:hover,.user-dialog input[type="password"]:hover{border-color:#aabbb5;background:#fff}.login-card input:focus,.user-dialog input:not([type]):focus,.user-dialog input[type="text"]:focus,.user-dialog input[type="password"]:focus{border-color:#6658e8;background:#fff;box-shadow:0 0 0 4px #6658e817}.login-card .btn.primary{width:100%;min-height:46px;border-radius:11px;font-size:16px}.login-card .message:empty,.user-dialog .message:empty{display:none}.login-card .message:not(:empty),.user-dialog .message:not(:empty){display:block;min-height:0;margin:0;padding:11px 13px;border-radius:10px;background:#fff4f4;white-space:pre-wrap}.user-dialog-actions .btn{min-height:42px;border-radius:10px;padding-inline:18px}
