/* Compact dashboard density and alignment pass. Loaded last intentionally. */

.field-error:empty,
.range-inline-warning:empty {
  display: none;
}

.primary-fields,
.stat-filter-row {
  align-items: start;
}

.stat-filter-row .form-row > label,
.stat-filter-row .field-label-row {
  box-sizing: border-box;
  min-height: 20px;
  margin-bottom: 5px;
}

.stat-filter-row .remove-stat-btn {
  align-self: start;
  margin-top: 25px;
}

/* The gem itself is the toggle; its red/monochrome state carries the visual
   status while aria-pressed and the accessible label carry the semantics. */
.gem-fallback-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  justify-content: center;
  padding: 3px !important;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

@media (min-width: 520px) {
  .stat-filter-row,
  .stat-filter-row.is-empty-socket {
    grid-template-columns:
      260px
      56px
      50px
      56px
      40px;
    gap: 7px;
    justify-content: start;
  }

  .stat-select-field,
  .stat-filter-row.is-empty-socket .stat-select-field,
  .stat-min-field,
  .gem-fallback-field,
  .gem-min-field,
  .remove-stat-btn,
  .stat-filter-row.is-empty-socket .remove-stat-btn {
    grid-column: auto;
    grid-row: auto;
  }

  .stat-helper {
    grid-column: 1 / -1;
  }
}

@media (max-width: 519px) {
  .stat-filter-row,
  .stat-filter-row.is-empty-socket {
    grid-template-columns: minmax(0, 1fr) 56px 50px 56px 40px;
    gap: 7px;
  }

  .stat-select-field,
  .stat-filter-row.is-empty-socket .stat-select-field {
    grid-column: 1 / 5;
    grid-row: 1;
  }

  .remove-stat-btn,
  .stat-filter-row.is-empty-socket .remove-stat-btn {
    grid-column: 5;
    grid-row: 1;
  }

  .stat-min-field,
  .gem-fallback-field,
  .gem-min-field {
    grid-column: auto;
  }

  .stat-helper {
    grid-column: 1 / -1;
  }
}

.gem-fallback-toggle:hover,
.gem-fallback-toggle:focus-visible {
  border-color: rgba(239, 212, 151, 0.72);
  background: rgba(197, 160, 89, 0.07);
  box-shadow: 0 0 0 1px rgba(197, 160, 89, 0.12);
}

.gem-fallback-toggle .gem-fallback-state {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.gem-fallback-toggle.is-selected .gem-fallback-icon {
  filter: saturate(1.25) drop-shadow(0 0 6px rgba(222, 42, 42, 0.52));
}

.gem-fallback-toggle.is-selected .gem-fallback-silhouette {
  filter: drop-shadow(0 0 5px rgba(210, 35, 35, 0.42));
}

.ruby-fallback-svg .ruby-facet--edge { fill: #741019; }
.ruby-fallback-svg .ruby-facet--top { fill: #ee3346; }
.ruby-fallback-svg .ruby-facet--left { fill: #b51628; }
.ruby-fallback-svg .ruby-facet--right { fill: #8f1020; }
.ruby-fallback-svg .ruby-facet--center { fill: #d71c32; }
.ruby-fallback-svg .ruby-facet--shine { fill: #ff9aa4; }

.gem-fallback-toggle.is-off .ruby-fallback-svg,
.gem-fallback-toggle.is-unavailable .ruby-fallback-svg {
  filter: grayscale(1) contrast(1.08) brightness(0.72);
  opacity: 0.76;
}

.gem-fallback-toggle.is-off .gem-fallback-icon {
  filter: grayscale(1) contrast(1.08) brightness(0.82);
  opacity: 0.82;
}

.stat-filter-row .attribute-combobox__input,
.stat-filter-row .stat-min,
.stat-filter-row .gem-min,
.stat-filter-row .remove-stat-btn {
  box-sizing: border-box;
  height: 40px;
  min-height: 40px;
}

.stat-filter-row .form-row > label,
.stat-filter-row .field-label-row > label {
  font-size: 0.66rem;
  letter-spacing: 0.045em;
}

.gem-fallback-field {
  align-items: center;
}

.gem-fallback-field .field-label-row {
  justify-content: center;
}

@media (min-width: 768px) {
  .alert-form {
    gap: 12px;
    margin-bottom: 22px;
    padding: 18px 18px 18px 24px;
  }

  .alert-form > .panel-heading {
    padding-bottom: 9px;
  }

  .form-stage {
    padding: 10px;
  }

  .stage-heading {
    margin-bottom: 8px;
    padding-bottom: 7px;
  }

  .primary-fields {
    gap: 10px;
    padding: 11px;
  }

  input[type="text"],
  input[type="number"],
  select,
  .rarity-picker__trigger,
  .stat-filter-row input,
  .gem-fallback-toggle,
  .remove-stat-btn {
    min-height: 40px;
    height: 40px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .rarity-picker__trigger {
    box-sizing: border-box;
    height: 40px !important;
    min-height: 40px !important;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .attribute-combobox__toggle {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .stats-container {
    gap: 6px;
    padding: 10px;
  }

  .stat-filter-row {
    grid-template-columns:
      260px
      56px
      50px
      56px
      40px;
    gap: 7px;
    justify-content: start;
    padding: 8px;
  }

  .gem-fallback-field {
    align-items: flex-start;
  }

  .watch-state,
  .alert-status-row {
    min-height: 0;
    padding: 7px 10px;
  }

  .form-actions {
    min-height: 40px;
  }

  .alert-card {
    height: 100% !important;
    gap: 7px;
    padding: 12px 12px 11px 17px;
  }

  #alerts-container,
  .alerts-grid {
    align-items: stretch;
    grid-auto-rows: 1fr;
  }

  .alert-card .card-header {
    min-height: 38px;
    padding-left: 44px;
  }

  .alert-item-icon {
    width: 35px;
    height: 35px;
  }

  .alert-summary {
    gap: 6px;
  }

  .alert-card .card-actions {
    gap: 5px;
    margin-top: auto;
    padding-top: 7px;
  }

  .alert-card button {
    min-height: 34px;
    padding: 6px 8px;
  }
}

/* Emergency readability patch: give Natural and Gem Min enough horizontal room
   for signed and decimal values without forcing a value after the user clears it. */
@media (min-width: 520px) {
  .stat-filter-row,
  .stat-filter-row.is-empty-socket,
  .stat-filter-row {
    grid-template-columns:
      260px
      88px
      50px
      88px
      40px;
  }
}

.stat-filter-row .stat-min,
.stat-filter-row .gem-min {
  min-width: 88px;
  padding-inline: 12px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.stat-filter-row .stat-min::-webkit-inner-spin-button,
.stat-filter-row .stat-min::-webkit-outer-spin-button,
.stat-filter-row .gem-min::-webkit-inner-spin-button,
.stat-filter-row .gem-min::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

@media (max-width: 519px) {
  .stat-filter-row .stat-min,
  .stat-filter-row .gem-min {
    min-width: 76px;
  }
}

/* Uniform alert-builder stages. Choose Item and Add Attribute now share the
   same header treatment and body surface. */
.alert-form .form-stage,
.alert-form .stats-section {
  overflow: visible;
  padding: 0;
  border: 1px solid rgba(197, 160, 89, 0.18);
  background: rgba(13, 11, 10, 0.52);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.45);
}

.alert-form .stage-heading,
.alert-form .stats-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid rgba(197, 160, 89, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), rgba(0, 0, 0, 0.08)),
    rgba(10, 9, 8, 0.52);
}

.alert-form .stats-heading {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.alert-form .item-stage-heading {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.alert-form .item-selection-clear {
  align-self: center;
  min-width: 64px;
  margin-left: 12px;
}

#alert-item[readonly] {
  cursor: default;
  caret-color: transparent;
}

.item-selection-locked .dmw-item-picker-toggle {
  display: none;
}

.alert-form .stage-heading .stage-number,
.alert-form .stats-heading .stage-number {
  align-self: center;
}

.alert-form .primary-fields,
.alert-form .stats-container {
  margin: 0;
  padding: 11px;
  background: rgba(0, 0, 0, 0.14);
  box-shadow: none;
}

/* Keep the row compact while leaving enough room for the rarity icon and label. */
@media (min-width: 821px) {
  .alert-form .primary-fields {
    grid-template-columns: minmax(260px, 32.5%) 170px minmax(160px, 22%);
    justify-content: start;
  }

  .alert-form .rarity-picker__trigger {
    justify-content: flex-start;
    gap: 10px;
    padding-right: 30px;
    padding-left: 13px;
  }

  .alert-form .rarity-picker__menu {
    min-width: 170px;
  }
}

@media (max-width: 520px) {
  .alert-form .item-stage-heading {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .alert-form .item-selection-clear {
    grid-column: 2;
    justify-self: start;
    margin-left: 0;
  }
}

/* Alerts are enabled by default; status remains available to application logic
   and saved-card controls, but is no longer shown in the creation form. */
.alert-form .alert-status-row {
  display: none !important;
}
