/* Everyday work: clear action priority, readable stock and accessible controls. */
:root {
  --muted: #627261;
  --focus: #527a38;
  --shadow: 0 8px 28px #183b2b08;
}
.main {
  margin: 0 auto;
  padding-top: 30px;
}
.panel {
  box-shadow: var(--shadow);
}
button,
.button {
  min-height: 38px;
  font-size: 12px;
  font-weight: 500;
  transition:
    background-color 0.12s,
    border-color 0.12s;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.toolbar {
  padding: 14px 0;
  margin: 4px 0 18px;
  border-bottom: 1px solid var(--line);
}
.toolbar-actions {
  align-items: center;
  gap: 9px;
}
.toolbar-actions button {
  min-height: 42px;
}
.toolbar-actions:empty {
  display: none;
}
.toolbar > p {
  margin: 0;
  max-width: 48em;
}
.navigation-menu {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.navigation-menu > summary {
  display: none;
}
.sidebar nav button.active {
  box-shadow: inset 3px 0 var(--lime);
}
.stock-warning {
  color: #9b5d16 !important;
  background: #fff4e3;
  border-left: 3px solid #c98529;
  padding: 7px 9px;
  border-radius: 4px;
}
.line-stock-hint {
  display: block;
  margin-top: 6px;
  line-height: 1.75;
}
dialog {
  box-shadow: 0 24px 80px #10241730;
  scroll-padding-top: 75px;
}
.dialog-heading {
  position: sticky;
  top: -26px;
  z-index: 3;
  background: white;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.dialog-heading button {
  min-width: 44px;
  min-height: 44px;
  font-size: 27px;
  color: var(--muted);
}
dialog form > button[type="submit"],
dialog form > button.primary {
  min-height: 46px;
  font-size: 14px;
}
.expense-details {
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf8;
}
.expense-details > summary {
  padding: 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.expense-details > summary span {
  float: right;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}
.expense-details > .form-grid {
  padding: 0 14px 8px;
}
.expense-details[open] > summary {
  border-bottom: 1px solid var(--line);
}
.history-pager {
  flex-wrap: wrap;
  gap: 12px;
}
.history-pager > span {
  text-align: center;
  color: var(--muted);
}
.line-editor .line-search {
  max-width: none;
}
.line-editor select {
  max-width: 100%;
}
input,
select {
  min-height: 42px;
}
.check input {
  min-height: 0;
  accent-color: var(--green);
}
@media (max-width: 1000px) {
  .toolbar {
    align-items: stretch;
  }
  .toolbar-actions {
    justify-content: flex-start;
  }
}
@media (max-width: 720px) {
  .sidebar {
    padding: 14px 16px;
  }
  .sidebar .logo {
    font-size: 16px;
  }
  .sidebar .mark {
    width: 32px;
    height: 34px;
  }
  .navigation-menu {
    margin-top: 12px;
    overflow: visible;
  }
  .navigation-menu > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    background: #2c503b;
    padding: 10px 13px;
    border-radius: 7px;
    cursor: pointer;
    list-style: none;
  }
  .navigation-menu > summary::after {
    content: "⌄";
    font-size: 18px;
    margin-left: 12px;
  }
  .navigation-menu[open] > summary::after {
    content: "⌃";
  }
  .navigation-menu > summary small {
    margin-left: auto;
    color: #c8d8c5;
    font-size: 11px;
  }
  .navigation-menu > summary::-webkit-details-marker {
    display: none;
  }
  .sidebar nav {
    margin-top: 8px;
  }
  .sidebar-bottom {
    margin-top: 10px;
  }
  .sidebar-bottom button {
    min-height: 36px;
    padding: 6px 12px;
  }
  .main {
    padding: 22px 15px;
  }
  .toolbar {
    gap: 12px;
  }
  .toolbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolbar-actions > span button {
    width: 100%;
    min-height: 44px;
  }
  .toolbar > p {
    font-size: 12px;
  }
  .header-right {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  header h1 {
    font-size: 23px;
  }
  .panel-heading > div {
    flex-wrap: wrap;
  }
  .panel-heading button,
  .panel-heading .button {
    min-height: 42px;
  }
  .panel-heading h2 {
    line-height: 1.6;
  }
  .filters input {
    font-size: 14px;
  }
  .panel {
    border-radius: 12px;
  }
  #inventory-table,
  #inventory-table tr,
  #inventory-table td {
    display: block;
  }
  [data-section="inventory"] .table-wrap {
    overflow: visible;
  }
  [data-section="inventory"] thead {
    display: none;
  }
  #inventory-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 14px;
    padding: 17px 0;
    border-bottom: 1px solid var(--line);
  }
  #inventory-table tr:last-child {
    border-bottom: 0;
  }
  #inventory-table td {
    padding: 0;
    border: 0;
    min-width: 0;
    line-height: 1.75;
  }
  #inventory-table td:nth-child(1),
  #inventory-table td:nth-child(2),
  #inventory-table td:nth-child(3),
  #inventory-table td:nth-child(6) {
    grid-column: 1/-1;
  }
  #inventory-table td:nth-child(1) strong {
    font-size: 15px;
  }
  #inventory-table td:nth-child(1) small {
    font-size: 11px;
    overflow-wrap: anywhere;
  }
  #inventory-table td:nth-child(2) {
    color: var(--muted);
    font-size: 12px;
  }
  #inventory-table td:nth-child(3)::before,
  #inventory-table td:nth-child(4)::before,
  #inventory-table td:nth-child(5)::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--muted);
    display: block;
    margin-bottom: 3px;
  }
  #inventory-table td:nth-child(4),
  #inventory-table td:nth-child(5) {
    padding: 9px 11px;
    background: #f3f6ef;
    border-radius: 7px;
    font-size: 15px;
  }
  #inventory-table .pill {
    font-size: 13px;
  }
  #inventory-table td:nth-child(6) {
    display: flex;
    gap: 9px;
    margin-top: 4px;
  }
  #inventory-table td:nth-child(6) button {
    flex: 1;
    min-height: 44px;
    margin: 0;
    font-size: 12px;
  }
  .history-pager {
    padding-bottom: 0;
  }
  .history-pager button {
    min-height: 42px;
  }
  .history-pager > span {
    order: 3;
    flex-basis: 100%;
  }
  dialog,
  dialog.wide {
    max-width: 100vw;
    width: 100%;
    max-height: 94dvh;
    border-radius: 14px 14px 0 0;
    margin: auto 0 0;
    padding: 18px;
  }
  .dialog-heading {
    top: -18px;
  }
  .dialog-heading h2 {
    font-size: 18px;
  }
  .form-grid label {
    margin: 12px 0;
  }
  .line-editor {
    min-width: 0;
    display: block;
  }
  .line-editor thead {
    display: none;
  }
  .line-editor tbody {
    display: block;
  }
  .line-editor tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  .line-editor td {
    padding: 0;
    border: 0;
    min-width: 0;
  }
  .line-editor td:first-child {
    width: auto;
    grid-column: 1/-1;
  }
  .line-editor td:nth-child(2) {
    grid-column: 1/-1;
  }
  .line-editor input {
    width: 100%;
    min-height: 44px;
  }
  .line-editor td:nth-child(2)::before {
    content: "库位";
  }
  .line-editor td:nth-child(3)::before {
    content: "数量";
  }
  .line-editor td:nth-child(4)::before {
    content: "每件单价";
  }
  .line-editor td:nth-child(2)::before,
  .line-editor td:nth-child(3)::before,
  .line-editor td:nth-child(4)::before {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
  }
  .line-editor td:last-child {
    display: flex;
    justify-content: flex-end;
  }
  .line-editor .line-remove {
    min-width: 44px;
    min-height: 44px;
    font-size: 20px;
  }
  .expense-details > summary span {
    float: none;
    display: block;
    margin-top: 5px;
  }
  .document-total {
    line-height: 1.9;
  }
  .document-total strong {
    display: block;
    font-size: 20px;
    margin-left: 0;
  }
  .toast {
    max-width: calc(100vw - 24px);
    width: max-content;
    bottom: 18px;
    font-size: 12px;
  }
  .check {
    white-space: normal;
    line-height: 1.8;
  }
}
@media (prefers-reduced-motion: reduce) {
  button,
  .button {
    transition: none;
  }
}

#catalog-plan-dialog .table-wrap {
  max-height: 43vh;
  overflow: auto;
}
#catalog-plan-dialog .catalog-preview-footer {
  position: sticky;
  bottom: 0;
  background: inherit;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding-block: 0.7rem;
}
#catalog-plan-dialog .catalog-preview-footer .form-error {
  flex-basis: 100%;
  margin: 0;
}
#catalog-plan-dialog .catalog-preview-footer button {
  width: auto;
}
