/* ZIP product skin on Operate tokens.
   Typography/readability and form polish — no parallel theme. */

/* —— Readability: denser, heavier type (closer to Заявки console) —— */
body.op-app {
  font-size: 15px;
  line-height: 1.5;
  font-weight: var(--op-fw-medium);
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
}

:where(.op-app) :where(h1, h2, h3, h4) {
  letter-spacing: -0.01em;
  font-weight: var(--op-fw-semibold);
}

.op-page-title,
.op-login__card h1 {
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: var(--op-fw-semibold);
}

.op-lede,
.op-muted,
.op-hint,
.op-nav__item,
.op-table,
.task-justification,
.home-note-list {
  font-weight: var(--op-fw-medium);
}

.op-text-2-boost,
.op-kpi__label,
.op-nav__label,
.op-user__role,
.combo-meta,
.opt-meta {
  color: var(--op-text-2);
}

/* Light theme: cooler canvas + stronger secondary ink (Заявки-like contrast) */
:root,
:root[data-theme="light"] {
  --op-canvas: #e8eef5;
  --op-surface: #f7fafc;
  --op-surface-2: #eef3f8;
  --op-surface-hover: #e2eaf2;
  --op-border: #c9d5e3;
  --op-border-strong: #a9bacd;
  --op-border-input: #5f738c;
  --op-text: #0a1420;
  --op-text-2: #2a3b4f;
  --op-text-3: #45586e;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --op-canvas: #e8eef5;
    --op-surface: #f7fafc;
    --op-surface-2: #eef3f8;
    --op-surface-hover: #e2eaf2;
    --op-border: #c9d5e3;
    --op-border-strong: #a9bacd;
    --op-border-input: #5f738c;
    --op-text: #0a1420;
    --op-text-2: #2a3b4f;
    --op-text-3: #45586e;
  }
}

/* Dark: keep Operate dark, nudge body ink like Заявки */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --op-canvas: #060b12;
    --op-text: #e8eef5;
    --op-text-2: #b7c6d6;
    --op-text-3: #8fa3b8;
  }
}
:root[data-theme="dark"] {
  --op-canvas: #060b12;
  --op-text: #e8eef5;
  --op-text-2: #b7c6d6;
  --op-text-3: #8fa3b8;
}

/* —— Bare shell for login: full-bleed, no centering pad —— */
.op-main--bare {
  min-height: 100vh;
  padding: 0;
  display: block;
  background: var(--op-canvas);
}
.op-main--bare > .op-login {
  min-height: 100vh;
}

/* —— Forms: taller controls, clearer focus (login + inline) —— */
.op-login__card {
  width: min(420px, 100%);
  gap: var(--op-space-5);
  padding: var(--op-space-6);
  background: var(--op-surface);
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-md);
  box-shadow: var(--op-shadow-overlay);
}
.op-login__card .op-field {
  gap: 8px;
}
.op-login__card .op-label {
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}
.op-login__card .op-input {
  height: 44px;
  font-size: 1rem;
  font-weight: var(--op-fw-medium);
}
.op-login__actions {
  border-top: 0;
  padding-top: 0;
}
.op-login__submit {
  width: 100%;
  max-width: none;
  height: 44px;
  font-size: 1rem;
  font-weight: var(--op-fw-semibold);
}
.op-login__brand .op-login__product {
  margin-top: var(--op-space-6);
}
.op-demo-creds {
  margin-top: var(--op-space-2);
}
.op-demo-creds strong {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--op-text);
}
.op-demo-creds code {
  font-family: var(--op-font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--op-accent-text);
  background: var(--op-surface-2);
  border: 1px solid var(--op-border);
  padding: 0.1rem 0.35rem;
  border-radius: var(--op-radius-xs);
}
.op-demo-creds td:first-child {
  color: var(--op-text-2);
  padding-right: var(--op-space-4);
  white-space: nowrap;
}

.op-input,
.op-textarea,
.op-select select {
  font-size: 15px;
  font-weight: var(--op-fw-medium);
}
.op-input,
.op-select select {
  min-height: 40px;
  height: auto;
}

.op-kpi-grid-note {
  margin: 0;
}

/* Combo (поиск позиции / ОС) — поведение combo.js, стили на op-* */
.combo {
  position: relative;
  width: 100%;
}
.combo-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--op-space-3);
  min-height: 40px;
  padding: 0 var(--op-space-3);
  border: 1px solid var(--op-border-input);
  border-radius: var(--op-radius-sm);
  background: var(--op-surface);
  color: var(--op-text);
  font: inherit;
  font-weight: var(--op-fw-medium);
  text-align: left;
  cursor: pointer;
}
.combo-trigger:focus-visible {
  outline: 2px solid var(--op-accent);
  outline-offset: 2px;
}
.combo-value {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.combo-title {
  font-weight: var(--op-fw-semibold);
  color: var(--op-text);
}
.combo-meta {
  font-size: var(--op-fs-sm);
  color: var(--op-text-2);
}
.combo-chevron::before {
  content: "";
  display: block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--op-text-3);
  border-bottom: 2px solid var(--op-text-3);
  transform: rotate(45deg);
}
.combo-panel {
  display: none;
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: calc(100% + 4px);
  background: var(--op-surface);
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-sm);
  box-shadow: var(--op-shadow-overlay);
  max-height: 16rem;
  overflow: auto;
}
.combo.open .combo-panel { display: block; }
.combo-search {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--op-border);
  padding: var(--op-space-2) var(--op-space-3);
  background: var(--op-surface-2);
  color: var(--op-text);
  font: inherit;
  font-weight: var(--op-fw-medium);
}
.combo-list {
  list-style: none;
  margin: 0;
  padding: var(--op-space-1);
}
.combo-option {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--op-space-2) var(--op-space-3);
  border: 0;
  border-radius: var(--op-radius-xs);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.combo-option:hover,
.combo-option[aria-selected="true"] {
  background: var(--op-accent-soft);
}
.opt-title { font-weight: var(--op-fw-semibold); }
.opt-meta { font-size: var(--op-fs-sm); color: var(--op-text-2); }
.combo-empty {
  padding: var(--op-space-3);
  color: var(--op-text-2);
  font-size: var(--op-fs-sm);
}

.stock-form {
  display: inline-flex;
  align-items: center;
  gap: var(--op-space-2);
}
.stock-form input[type="number"] {
  width: 5.5rem;
  min-height: 36px;
  padding: 0 var(--op-space-2);
  border: 1px solid var(--op-border-input);
  border-radius: var(--op-radius-xs);
  background: var(--op-surface);
  color: var(--op-text);
  font: inherit;
  font-weight: var(--op-fw-medium);
  font-variant-numeric: tabular-nums;
}

/* Period filter: button shares baseline with date inputs (Заявки-style) */
.op-filterbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--op-space-2);
  margin-left: auto;
}
.op-filterbar__actions .op-field {
  flex: 0 0 auto;
  max-width: 11.5rem;
  margin: 0;
}
.op-filterbar__actions .op-btn {
  flex: none;
  height: var(--op-control-h);
}

/* Task status row: field + primary + danger on one baseline */
.task-actions {
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--op-space-2);
}
.eta-forward-form,
.inline-status-form {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: var(--op-space-2);
  margin: 0;
}
.eta-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  font-size: var(--op-fs-sm);
  font-weight: var(--op-fw-medium);
  color: var(--op-text-2);
  margin: 0;
}
.eta-field__label {
  line-height: 1.2;
}
.eta-field .op-input,
.eta-field input {
  width: 5.5rem;
  height: var(--op-control-h);
  min-height: var(--op-control-h);
  padding: 0 var(--op-space-2);
  border: 1px solid var(--op-border-input);
  border-radius: var(--op-radius-sm);
  background: var(--op-surface);
  color: var(--op-text);
  font: inherit;
  font-weight: var(--op-fw-medium);
}
.task-actions .op-btn {
  height: var(--op-control-h);
}

.op-meter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--op-space-3);
}
.op-meter-list__meta {
  display: flex;
  justify-content: space-between;
  gap: var(--op-space-3);
  margin-bottom: var(--op-space-1);
  font-size: var(--op-fs-sm);
  font-weight: var(--op-fw-medium);
}
.op-meter-list__n {
  font-variant-numeric: tabular-nums;
  color: var(--op-text-2);
}
.scroll-cap-6 {
  max-height: calc(6 * 3.1rem);
  overflow: auto;
}
.op-table tr.is-selected,
.op-meter-list li.is-selected {
  outline: 2px solid var(--op-accent);
  outline-offset: -2px;
  background: var(--op-accent-soft);
}
.op-bar-select {
  display: block;
  color: inherit;
  text-decoration: none;
}
.op-bar-select:hover .op-meter-list__meta {
  color: var(--op-link);
}
.code-snip {
  margin: 0;
  padding: var(--op-space-3);
  background: var(--op-surface-2);
  border: 1px solid var(--op-border);
  border-radius: var(--op-radius-sm);
  font-family: var(--op-font-mono);
  font-size: var(--op-fs-sm);
  overflow: auto;
}
.role-grid {
  display: grid;
  gap: var(--op-space-3);
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}
.role-grid li {
  display: flex;
  flex-direction: column;
  gap: var(--op-space-1);
  padding: var(--op-space-3);
  background: var(--op-surface-2);
  border-radius: var(--op-radius-sm);
  border: 1px solid var(--op-border);
}
.role-grid span { color: var(--op-text-2); font-size: var(--op-fs-sm); font-weight: var(--op-fw-medium); }
.home-note-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--op-text-2);
}
.home-note-list li + li { margin-top: var(--op-space-2); }
.task-justification {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--op-font-sans);
  font-size: var(--op-fs-md);
  line-height: 1.5;
  color: var(--op-text-2);
}
.analytics-grid {
  display: grid;
  gap: var(--op-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}
/* Users sits under site params in the left split column — compact, full column width */
.users-panel {
  margin: 0;
  min-width: 0;
}
.users-panel__body {
  gap: var(--op-space-3);
}
.users-create {
  max-width: none;
  width: 100%;
  gap: var(--op-space-3);
}
.users-create__actions {
  padding-top: var(--op-space-2);
  border-top: 0;
  margin: 0;
}
.users-table-wrap {
  width: 100%;
  max-width: none;
  margin: 0;
  overflow-x: auto;
}
.users-table {
  width: 100%;
  table-layout: fixed;
}
.users-table th,
.users-table td {
  vertical-align: middle;
}
.users-table th:nth-child(1),
.users-table td:nth-child(1) { width: 18%; }
.users-table th:nth-child(2),
.users-table td:nth-child(2) { width: 24%; }
.users-table th:nth-child(3),
.users-table td:nth-child(3) { width: 18%; }
.users-table__pwd {
  width: 22%;
}
.users-table__pwd-form {
  margin: 0;
  display: block;
  min-width: 0;
}
.users-table__pwd-input {
  width: 100%;
  max-width: none;
  height: var(--op-control-h-sm);
  min-height: var(--op-control-h-sm);
  padding: 0 var(--op-space-2);
  font-size: var(--op-fs-sm);
  font-weight: var(--op-fw-medium);
}
.users-table__actions {
  width: 18%;
  white-space: nowrap;
}
.users-table__btns {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--op-space-2);
}
.users-table__toggle {
  display: inline-flex;
  margin: 0;
}
.users-table__btns .op-btn {
  height: var(--op-control-h-sm);
  flex: 0 0 auto;
  white-space: nowrap;
}
.op-text-critical {
  color: var(--op-critical-fg);
  font-weight: var(--op-fw-semibold);
}
@media (max-width: 720px) {
  .users-table { table-layout: auto; }
  .users-table,
  .users-table thead,
  .users-table tbody,
  .users-table tr,
  .users-table th,
  .users-table td {
    display: block;
    width: 100%;
  }
  .users-table thead { display: none; }
  .users-table tr {
    padding: var(--op-space-3) 0;
    border-bottom: 1px solid var(--op-border);
  }
  .users-table td {
    padding: 4px 0;
    border: 0;
  }
  .users-table__pwd,
  .users-table__actions {
    width: 100%;
    min-width: 0;
  }
  .users-table__btns { justify-content: flex-start; }
}

/* Sidebar theme control: keep labels readable when icons-only is tight */
.op-sidebar__foot .op-segmented {
  width: 100%;
}
.op-sidebar__foot .op-switch {
  font-size: var(--op-fs-sm);
  font-weight: var(--op-fw-medium);
  color: var(--op-text-2);
}

/* Mobile stacked tables: Operate pairs cells as 1fr|auto — ZIP forms overflow.
   Use equal columns for short pairs; force full-width rows for dense risk cards. */
@media (max-width: 640px) {
  .op-app .op-table--stack tr {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--op-space-3) var(--op-space-3);
  }
  .op-app .op-table--stack td {
    min-width: 0;
  }
  .op-app .op-table--stack td[data-label]::before {
    margin-bottom: 2px;
  }
  .op-app .op-table--stack .op-mono {
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .op-app .op-table--stack .op-norm {
    flex-wrap: wrap;
    white-space: normal;
    max-width: 100%;
  }
  .op-app .op-table--stack .op-fresh {
    white-space: normal;
  }

  /* Risk-list cards: one field per row + clear card gaps */
  .op-app #risk-table.op-table--stack {
    background: transparent;
    border: 0;
  }
  .op-app #risk-table.op-table--stack tbody {
    display: flex;
    flex-direction: column;
    gap: var(--op-space-4);
  }
  .op-app #risk-table.op-table--stack tr {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--op-space-2);
    margin: 0;
    padding: var(--op-space-4);
    border: 1px solid var(--op-border);
    border-radius: var(--op-radius-md);
    background: var(--op-surface);
    border-bottom: 1px solid var(--op-border);
  }
  .op-app #risk-table.op-table--stack tbody tr:last-child {
    border-bottom: 1px solid var(--op-border);
  }
  .op-app #risk-table.op-table--stack td {
    grid-column: 1 / -1;
  }
  .op-app #risk-table.op-table--stack td[data-primary] {
    padding-bottom: var(--op-space-2);
    margin-bottom: var(--op-space-1);
    border-bottom: 1px solid var(--op-border);
  }
  .op-app #risk-table.op-table--stack td[data-primary] .op-cell__primary {
    font-size: var(--op-fs-xl);
    line-height: var(--op-lh-xl);
    font-weight: var(--op-fw-bold);
    letter-spacing: -0.01em;
    color: var(--op-text);
  }
  .op-app #risk-table.op-table--stack td[data-primary] .op-cell__secondary {
    margin-top: 4px;
    font-size: var(--op-fs-md);
    font-weight: var(--op-fw-semibold);
    color: var(--op-accent-text);
  }
  .op-app #risk-table.op-table--stack td[data-primary] .op-mono {
    font-size: inherit;
    font-weight: inherit;
  }
  .op-app #risk-table.op-table--stack td + td {
    margin-top: var(--op-space-2);
    padding-top: var(--op-space-2);
    border-top: 1px solid var(--op-border);
  }
  .op-app #risk-table.op-table--stack td[data-primary] + td {
    border-top: 0;
    margin-top: 0;
    padding-top: var(--op-space-2);
  }
  .op-app #risk-table.op-table--stack td.op-actions {
    border-top: 0;
    padding-top: var(--op-space-3);
    margin-top: var(--op-space-1);
  }
  .op-app #risk-table-wrap,
  .op-app .op-table-wrap:has(#risk-table) {
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .stock-form {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--op-space-2);
    width: 100%;
    max-width: 100%;
  }
  .stock-form input[type="number"],
  .stock-form .op-input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .stock-form .op-btn {
    flex: 0 0 auto;
  }
}
