.status-card {
  position: relative;
  display: grid;
  min-height: 112px;
  grid-template-columns: 42px 1fr 18px;
  align-items: center;
  gap: 12px;
  padding: 17px;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.status-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 22px rgba(37, 60, 49, 0.08);
}

.status-card.is-active {
  border-color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--primary);
}

.status-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 7px;
}

.status-icon-all {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.status-icon-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-icon-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-icon-opened {
  color: var(--blue);
  background: var(--blue-soft);
}

.status-copy small,
.status-copy strong {
  display: block;
}

.status-copy small {
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.status-copy strong {
  font-size: 25px;
  line-height: 1.1;
}

.status-arrow {
  align-self: start;
  color: var(--border-strong);
}

.search-field {
  position: relative;
  display: block;
  width: min(330px, 32vw);
}

.search-field svg {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 11px;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.search-field input {
  padding-left: 36px;
}

.inventory-list {
  display: grid;
  gap: 9px;
}

.inventory-item {
  display: grid;
  min-height: 104px;
  grid-template-columns: 80px minmax(180px, 1.4fr) minmax(130px, 0.8fr) minmax(150px, 0.8fr) 106px 82px;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
}

.inventory-item.status-warning {
  border-left-color: #d49a16;
}

.inventory-item.status-danger,
.inventory-item.status-due {
  border-left-color: var(--danger);
}

.inventory-item.status-expired {
  border-left-color: #6d7070;
  background: #fafafa;
}

.item-photo {
  position: relative;
  display: grid;
  width: 80px;
  height: 80px;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  color: var(--text-muted);
  background: var(--surface-soft);
  cursor: pointer;
}

button.item-photo {
  padding: 0;
  border: 0;
  font: inherit;
}

button.item-photo:hover {
  background: var(--primary-soft);
}

button.item-photo:focus-visible {
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.18);
}

.item-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-photo svg {
  width: 27px;
  height: 27px;
}

.item-main {
  min-width: 0;
}

.item-main h3 {
  margin-bottom: 5px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta,
.item-submeta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.item-submeta {
  margin-top: 5px;
}

.item-meta span,
.item-submeta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.item-meta svg,
.item-submeta svg {
  width: 14px;
  height: 14px;
}

.category-chip,
.opened-chip {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.category-chip {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.opened-chip {
  color: var(--blue);
  background: var(--blue-soft);
}

.item-detail small,
.item-expiry small {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 11px;
}

.item-detail strong,
.item-expiry strong {
  display: block;
  font-size: 13px;
}

.item-expiry strong {
  font-size: 15px;
}

.item-expiry span {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
}

.expiry-normal {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.expiry-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.expiry-danger,
.expiry-due {
  color: var(--danger);
  background: var(--danger-soft);
}

.expiry-expired {
  color: #505657;
  background: #e9ebeb;
}

.expiry-unknown {
  color: var(--text-muted);
  background: #eef0ef;
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.item-actions .icon-button {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.item-actions .delete-button:hover {
  color: var(--danger);
  border-color: #e6b9bb;
  background: var(--danger-soft);
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  align-content: center;
  padding: 40px 20px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
}

.empty-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 13px;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  margin-bottom: 5px;
}

.empty-state p {
  margin-bottom: 17px;
  color: var(--text-muted);
}

.dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(880px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(20, 28, 24, 0.52);
  backdrop-filter: blur(2px);
}

.form-dialog {
  width: min(780px, calc(100% - 28px));
}

.form-dialog[open] {
  display: flex;
  flex-direction: column;
}

.form-dialog > form {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.form-dialog .dialog-header,
.form-dialog .dialog-footer {
  flex-shrink: 0;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
  background: var(--surface);
}

.dialog-header {
  border-bottom: 1px solid var(--border);
}

.dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 19px;
}

.dialog-kicker {
  margin-bottom: 1px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
}

.danger-text {
  color: var(--danger);
}

.dialog-body {
  max-height: calc(100vh - 175px);
  padding: 20px;
  overflow-y: auto;
}

.form-body {
  display: grid;
  min-height: 0;
  gap: 22px;
}

.compact-body {
  min-height: 100px;
}

.compact-body p {
  margin: 0;
  color: var(--text-muted);
}

.photo-field {
  display: grid;
  grid-template-columns: 126px 1fr;
  gap: 18px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.photo-preview {
  display: grid;
  width: 126px;
  height: 104px;
  place-items: center;
  align-content: center;
  gap: 6px;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  color: var(--text-muted);
  background: var(--surface);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview span {
  font-size: 11px;
}

.photo-copy h3 {
  margin-bottom: 2px;
  font-size: 14px;
}

.photo-copy p {
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 12px;
}

.photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.form-section {
  padding-top: 2px;
}

.form-section + .form-section {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.form-section-heading > span {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  border-radius: 6px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 10px;
  font-weight: 900;
}

.form-section-heading h3,
.form-section-heading p {
  margin: 0;
}

.form-section-heading h3 {
  font-size: 14px;
}

.form-section-heading p {
  color: var(--text-muted);
  font-size: 11px;
}

.inline-heading .switch {
  margin-left: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.field {
  display: block;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span,
.quantity-field > span,
.shelf-life-field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
}

.field > span b,
.quantity-field > span b,
.shelf-life-field > span b {
  color: var(--danger);
}

.quantity-field > div,
.shelf-life-field > div {
  display: grid;
  grid-template-columns: 1fr 92px;
}

.quantity-field #quantityInput,
.shelf-life-field input {
  border-radius: 6px 0 0 6px;
}

.quantity-field #unitInput,
.shelf-life-field select {
  border-left: 0;
  border-radius: 0 6px 6px 0;
}

.field-hint,
.field-error {
  display: block;
  min-height: 17px;
  margin-top: 3px;
  font-size: 11px;
}

.field-hint {
  color: var(--text-muted);
}

.field-error {
  color: var(--danger);
}

.calculation-preview {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 6px;
  color: var(--text-muted);
  background: var(--surface-soft);
  font-size: 12px;
}

.calculation-preview.has-result {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.calculation-preview.has-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: inherit;
}

.switch > span {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #c8ceca;
  transition: background-color 160ms ease;
}

.switch > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  content: "";
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::after {
  transform: translateX(16px);
}

.switch input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.2);
}

.switch b {
  font-size: 12px;
}

.opened-panel {
  display: grid;
  gap: 13px;
  margin-top: 3px;
}

.info-callout {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px;
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  color: #315a6d;
  background: var(--blue-soft);
}

.info-callout svg {
  flex: 0 0 17px;
  margin-top: 2px;
}

.info-callout p {
  margin: 0;
  font-size: 11px;
}

.action-list {
  display: grid;
  gap: 9px;
}

.action-list > button {
  display: grid;
  min-height: 78px;
  grid-template-columns: 50px 1fr 20px;
  align-items: center;
  gap: 13px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

.action-list > button:hover {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.action-list strong,
.action-list small {
  display: block;
}

.action-list small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.file-icon {
  display: grid;
  width: 50px;
  height: 42px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--text-muted);
  font-size: 9px;
  font-weight: 900;
}

.json-icon {
  background: var(--orange);
}

.csv-icon {
  background: var(--blue);
}

.xlsx-icon {
  background: var(--primary);
}

.file-drop {
  display: grid;
  min-height: 170px;
  place-items: center;
  align-content: center;
  gap: 5px;
  cursor: pointer;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.file-drop:hover {
  border-color: var(--primary);
}

.file-drop svg {
  width: 30px;
  height: 30px;
  margin-bottom: 4px;
  color: var(--primary);
}

.file-drop span {
  color: var(--text-muted);
  font-size: 11px;
}

.import-preview {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.import-preview strong,
.import-preview small {
  display: block;
}

.import-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-preview small {
  color: var(--text-muted);
}

.import-warning {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 6px;
  color: #803034;
  background: var(--danger-soft);
}

.import-warning svg {
  flex: 0 0 18px;
  margin-top: 2px;
}

.import-warning p {
  margin: 0;
  font-size: 11px;
}

.import-footer {
  flex-wrap: wrap;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  display: grid;
  width: min(360px, calc(100% - 40px));
  gap: 8px;
}

.toast {
  display: grid;
  grid-template-columns: 20px 1fr 20px;
  align-items: start;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
}

.toast-success > svg {
  color: var(--primary);
}

.toast-error > svg {
  color: var(--danger);
}

.toast p {
  margin: 0;
  font-size: 12px;
}

.toast button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
}

.toast button svg {
  width: 14px;
  height: 14px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
