/* ── Inventory movement tracking ─────────────────────────────────────────── */

.movements-overview { margin-bottom: 12px; }

.movements-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 0;
}

.movements-kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 0;
}

.movements-kpi--warn {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

.movements-kpi-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.movements-kpi--warn .movements-kpi-value { color: #ef4444; }

.movements-kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 0;
  line-height: 1.25;
}

.movements-filters-card {
  margin-bottom: 16px;
  border: 1px solid var(--border, #2d3344);
  border-radius: 10px;
  background: var(--surface, #161b22);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  overflow: visible;
  position: relative;
  z-index: 50;
}

.movements-filters-card > .card-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.movements-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 0;
}

.movements-filters-title {
  margin: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #8b949e);
  line-height: 1.2;
}

/* Filter searchable selects */
.movements-filter-form .filter-select-wrapper {
  position: relative;
  min-width: 160px;
  max-width: 220px;
  flex: 0 1 200px;
}

.movements-filter-form .filter-select-wrapper--item {
  min-width: 200px;
  max-width: 280px;
  flex: 0 1 260px;
}

.filter-select-wrapper.is-open {
  z-index: 10001;
}

.filter-select-wrapper .user-select-dropdown.is-fixed-open {
  z-index: 10000;
}

.filter-select-wrapper .user-select-control {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, #161b22);
  cursor: text;
}

.filter-select-wrapper .user-select-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}

.filter-select-wrapper .user-select-search {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}

.filter-select-wrapper .user-select-clear {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 12px;
}

.filter-select-wrapper .user-select-arrow {
  color: var(--text-muted);
  font-size: 12px;
  pointer-events: none;
}

.filter-select-wrapper .user-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface, #161b22);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-height: 260px;
  overflow: hidden;
}

.filter-select-wrapper .user-select-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface, #161b22);
}

.filter-select-wrapper .user-select-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  background: var(--surface, #161b22);
}

.filter-select-wrapper .user-select-option:hover,
.filter-select-wrapper .user-select-option.keyboard-focus {
  background: var(--surface-2, #1c2128);
}

.filter-select-wrapper .user-select-option.selected {
  background: rgba(88, 166, 255, 0.15);
  font-weight: 600;
}

.filter-select-wrapper .user-select-no-results {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface, #161b22);
}

/* Icon picker (movement types form) */
.icon-picker-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.icon-picker-preview-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 10px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-width: 480px;
}

.icon-picker-btn {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
}

.icon-picker-btn:hover {
  border-color: var(--accent);
  transform: scale(1.08);
}

.icon-picker-btn.is-selected {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.12);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.movements-stats-card { margin-bottom: 16px; }

.movements-page-toolbar {
  margin-bottom: 16px;
}

.movements-page-toolbar .toolbar-row-2 {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.movements-page-toolbar .toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.movements-timeline-card {
  position: relative;
  z-index: 1;
}

.movements-filter-form {
  width: 100%;
  min-width: 0;
  overflow: visible;
  margin: 0;
  padding: 0;
}

.movements-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.movements-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.movements-empty-text {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}

.movement-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 160px;
  padding: 8px 4px 0;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.movement-bar-col {
  flex: 1;
  min-width: 72px;
  max-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 150px;
}

.movement-bar-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.movement-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--border);
  border-radius: 6px 6px 0 0;
  overflow: hidden;
  min-height: 20px;
}

.movement-bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  transition: height 0.4s ease;
  min-height: 6px;
}

.movement-bar-fill--receipt { background: #10b981; }
.movement-bar-fill--transfer { background: #58a6ff; }
.movement-bar-fill--issue { background: #8b5cf6; }
.movement-bar-fill--return { background: #06b6d4; }
.movement-bar-fill--write_off { background: #ef4444; }
.movement-bar-fill--repair_send { background: #f59e0b; }
.movement-bar-fill--repair_return { background: #22c55e; }

.movement-bar-label { font-size: 18px; line-height: 1; }
.movement-bar-sublabel {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  max-width: 80px;
}

.filter-date {
  max-width: 150px;
}

/* Movement type form — field picker */
.movement-fields-picker {
  margin-top: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #161b22);
}

.movement-fields-picker-header {
  margin-bottom: 16px;
}

.movement-fields-picker-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.movement-fields-picker-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.movement-fields-picker-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.movement-fields-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.movement-field-toggle input { display: none; }

.movement-field-toggle-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  height: 100%;
  min-height: 88px;
}

.movement-field-toggle input:checked + .movement-field-toggle-card {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.12);
}

.movement-field-toggle-card:hover {
  border-color: var(--accent);
}

.movement-field-toggle-icon {
  font-size: 20px;
  line-height: 1;
}

.movement-field-toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.movement-field-toggle-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.movement-fields-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.movement-field-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.25);
  color: var(--text);
}

.movement-fields-picker-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Timeline */
.movement-timeline {
  position: relative;
  padding-left: 4px;
}

.movement-timeline-item {
  display: flex;
  gap: 10px;
  padding-bottom: 8px;
  position: relative;
}

.movement-timeline-item.has-connector-below::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--border));
  border-radius: 1px;
}

.movement-timeline-item.is-cancelled {
  opacity: 0.55;
}

.movement-timeline-marker {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface, #161b22);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  margin-top: 6px;
}

.movement-timeline-icon { font-size: 15px; line-height: 1; }

.movement-timeline-content {
  flex: 1;
  min-width: 0;
  background: var(--surface, #161b22);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.movement-timeline-content:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.movement-compact-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(0, 2fr) auto;
  align-items: center;
  gap: 10px 14px;
  width: 100%;
}

.movement-compact-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.movement-item-inline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}

.movement-item-inline a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-inv-num {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  flex-shrink: 0;
}

.movement-compact-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.movement-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text);
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.15);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.movement-chip-icon {
  flex-shrink: 0;
  font-size: 11px;
}

.movement-chip--muted {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.movement-compact-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.movement-timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.movement-flow-arrow {
  color: var(--accent);
  margin: 0 2px;
  font-weight: 600;
  flex-shrink: 0;
}

.movement-due-date.is-overdue {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  font-weight: 600;
}

.movement-timeline-notes {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-timeline--compact .movement-timeline-item {
  padding-bottom: 6px;
}

.movement-timeline--compact .movement-timeline-content {
  padding: 7px 10px;
}

.movements-empty {
  text-align: center;
  padding: 48px 24px;
}

.movements-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* Form */
.movement-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.movement-type-option input { display: none; }

.movement-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: center;
}

.movement-type-option input:checked + .movement-type-card {
  border-color: var(--accent);
  background: rgba(88,166,255,0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(88,166,255,0.15);
}

.movement-type-card-icon { font-size: 24px; }
.movement-type-card-label { font-size: 12px; font-weight: 600; }

/* Detail page */
.movement-detail-page .movement-detail-toolbar.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.movement-detail-page .movement-detail-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  margin-right: auto;
  width: auto;
  flex: 0 0 auto;
}

.movement-detail-page .movement-detail-toolbar-actions > .btn,
.movement-detail-page .movement-detail-toolbar-actions > .inline-form {
  flex: 0 0 auto;
}

.movement-detail-page .movement-detail-toolbar-actions .inline-form {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}

.movement-detail-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(88,166,255,0.12), rgba(88,166,255,0.04));
  border: 1px solid var(--border);
}

.movement-detail-hero-icon { font-size: 48px; }

.movement-detail-hero-title {
  margin: 8px 0 4px;
  font-size: 1.4rem;
}

.movement-detail-hero-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.movement-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.movement-participants-flow {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.movement-participant {
  text-align: center;
  flex: 1;
  min-width: 120px;
}

.movement-participant-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.movement-participant-name {
  font-size: 15px;
  font-weight: 600;
}

.movement-participant-arrow {
  font-size: 24px;
  color: var(--accent);
  font-weight: 300;
}

.badge-lg { font-size: 13px; padding: 4px 12px; }
.badge-primary { background: rgba(139,92,246,0.15); color: #8b5cf6; }

/* Flow graph */
.movement-flow-graph-scroll {
  overflow-x: auto;
  padding: 8px 4px 16px;
  -webkit-overflow-scrolling: touch;
}

.movement-flow-graph {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: min-content;
  padding: 8px 0;
}

.movement-flow-node {
  flex-shrink: 0;
  width: 180px;
  padding: 16px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--card-bg);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.movement-flow-node:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.movement-flow-node--success { border-color: #10b981; background: rgba(16,185,129,0.06); }
.movement-flow-node--info { border-color: #58a6ff; background: rgba(88,166,255,0.06); }
.movement-flow-node--primary { border-color: #8b5cf6; background: rgba(139,92,246,0.06); }
.movement-flow-node--warning { border-color: #f59e0b; background: rgba(245,158,11,0.06); }
.movement-flow-node--danger { border-color: #ef4444; background: rgba(239,68,68,0.06); }

.movement-flow-node-icon { font-size: 28px; margin-bottom: 6px; }
.movement-flow-node-label { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.movement-flow-node-date { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; }
.movement-flow-node-detail { font-size: 11px; color: var(--text-muted); line-height: 1.4; margin-bottom: 4px; }
.movement-flow-node-link { font-size: 11px; color: var(--accent); text-decoration: none; }
.movement-flow-node-link:hover { text-decoration: underline; }

.movement-flow-edge {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 40px;
  position: relative;
}

.movement-flow-edge-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--accent), var(--border));
}

.movement-flow-edge-arrow {
  color: var(--accent);
  font-size: 10px;
  margin-left: -4px;
}

.movement-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.movement-graph-stat {
  text-align: center;
  padding: 12px 24px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.movement-graph-stat-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.movement-graph-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.item-movements-card { margin-bottom: 16px; }

@media (max-width: 900px) {
  .movements-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .movement-compact-grid {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "primary actions"
      "meta meta";
  }

  .movement-compact-primary { grid-area: primary; }
  .movement-compact-meta { grid-area: meta; }
  .movement-compact-actions { grid-area: actions; }
}

@media (max-width: 768px) {
  .movement-detail-hero { flex-direction: column; text-align: center; }
  .movement-type-grid { grid-template-columns: repeat(2, 1fr); }
  .movement-flow-node { width: 150px; }
  .movements-filter-form .filter-select,
  .movements-filter-form .filter-date { max-width: 100%; flex: 1 1 100%; }
  .movements-page-toolbar .toolbar-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .movement-compact-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "primary"
      "meta"
      "actions";
  }

  .movement-compact-actions {
    justify-content: space-between;
    width: 100%;
  }

  .movement-chip {
    white-space: normal;
  }
}
