.portal-header { border-bottom: 1px solid var(--line); background: white; }
.portal-head { display: flex; align-items: center; gap: .7rem 1.5rem; flex-wrap: wrap; min-height: 5rem; padding-block: .65rem; }
.portal-head .brand > span { font-size: 2.35rem; }
.portal-head > span { color: var(--muted); font-weight: 650; font-size: .9rem; }
.portal-head nav { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; margin-left: auto; font-size: .875rem; }
.portal-head nav a { color: var(--accent); font-weight: 650; }
.portal-content { width: min(100% - 2rem, 1180px); padding-block: 1.65rem 2rem; }
.auth-card { width: min(100%, 27rem); margin: clamp(1rem, 7vh, 5rem) auto; padding: clamp(1rem, 4vw, 1.75rem); }
.auth-card > p { margin-top: .45rem; }
.form-grid { display: grid; gap: .8rem; margin-top: .95rem; }
.portal label { display: grid; gap: .28rem; font-size: .875rem; font-weight: 650; min-width: 0; }
.portal input, .portal select, .portal textarea {
  display: block; min-height: 2.55rem; width: 100%; padding: .48rem .62rem; border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); background: white; font: inherit; font-weight: 400;
}
.portal input[type=file] { padding-block: .52rem; }
.portal textarea { resize: vertical; }
.portal .subtle { margin-top: .24rem; }
.optional { color: var(--muted); font-weight: 400; }
.form-grid button { justify-self: start; }
.auth-card .form-grid button { width: 100%; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .45rem; margin-top: .7rem; color: var(--accent); font-size: .875rem; }
.auth-links a, .portal-tabs a { font-weight: 670; }
.form-message { margin-top: .4rem; font-size: .875rem; color: #245d3a; }
.form-message:empty { display: none; }
.form-message[data-error=true] { color: #942744; }
.portal-heading { display: flex; justify-content: space-between; align-items: end; gap: .55rem; margin-bottom: .85rem; }
.portal-heading h1 { font-size: clamp(1.55rem, 4vw, 2.15rem); }
.portal-heading p { font-size: .75rem; font-weight: 750; letter-spacing: .1em; }
.portal-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr); gap: .85rem; align-items: start; }
.history-columns { margin-top: .85rem; }
.portal-card { padding: 1rem; min-width: 0; }
.portal-card .section-heading { margin-bottom: .25rem; }
.portal-tabs { display: flex; gap: .5rem; margin-bottom: .85rem; }
.portal-tabs a { border-radius: 8px; padding: .55rem .75rem; background: white; border: 1px solid var(--line); font-size: .9rem; }
.portal-tabs [aria-current] { background: var(--lavender); color: var(--deep); border-color: #d6c1e8; }
.inline-form, .form-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: end; }
.inline-form { margin: .8rem 0 .3rem; }
.form-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-list { margin-top: .45rem; }
.list-entry { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .64rem 0; border-top: 1px solid var(--line); }
.list-entry > div { min-width: 0; overflow-wrap: anywhere; }
.list-entry h3 { font-size: .96rem; }
.brand-entry { grid-template-columns: minmax(0, 1fr) auto auto; }
.brand-entry label:has(input[type=checkbox]) { display: flex; align-items: center; gap: .25rem; }
.brand-entry input[type=checkbox] { width: 1rem; min-height: 1rem; accent-color: var(--accent); }
.portal-table { overflow-x: auto; margin-top: .6rem; }
.portal-table th, .portal-table td { padding: .55rem .4rem; }
.portal .filters input, .portal .filters select { min-height: 2.65rem; }
.portal .pagination { margin-bottom: .2rem; }
.movement-filter-panel summary { cursor: pointer; color: var(--accent); font-size: .875rem; font-weight: 650; }
.movement-filter-panel .filters { margin-top: .6rem; }
.movement-mobile-label { display: none; }
.movement-items { margin: 0; padding: 0; list-style: none; overflow-wrap: anywhere; }
.movement-items li + li { margin-top: .3rem; }
.movement-item {
  display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); align-items: center;
  gap: .65rem; width: 100%; padding: .2rem; border: 0; background: transparent;
  text-align: left; white-space: normal; overflow-wrap: anywhere;
}
.movement-item:hover { background: var(--ground); }
.movement-thumbnail { width: 100%; border: 1px solid var(--line); border-radius: 7px; }
.movement-thumbnail.photo-placeholder b { font-size: .8rem; }
.movement-item-name { display: block; line-height: 1.3; font-weight: 650; }
.movement-item .item-qty { display: block; margin-top: .16rem; }
#movement-product-title { margin-bottom: .45rem; overflow-wrap: anywhere; }
#movement-product-content .price { font-size: 1.2rem; }
@media (max-width: 820px) {
  .portal-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  #movement-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
  #movement-stats .stat { padding: .55rem .65rem; }
  #movement-stats strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
  .movement-filter-panel summary { padding-block: .55rem; }
  #movement-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .3rem; }
  #movement-filters .stretch { grid-column: 1 / -1; min-width: 0; }
  #movement-filters input, #movement-filters select { min-width: 0; font-size: 1rem; }
  #movement-filters button { min-height: 2.75rem; }

  .movement-list { border: 0; background: transparent; overflow: visible; }
  .movement-list > .empty { border: 1px solid var(--line); border-radius: var(--radius); background: white; }
  .movement-table, .movement-table tbody { display: block; }
  .movement-table tbody { display: grid; gap: .65rem; }
  .movement-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  .movement-table tbody > tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    grid-template-areas: "reference status" "date amount" "products products";
    align-items: start;
    gap: .55rem .75rem; padding: .8rem .85rem .9rem;
    border: 1px solid var(--line); border-radius: var(--radius); background: white;
  }
  .movement-table td { min-width: 0; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .movement-table .movement-reference { grid-area: reference; align-self: center; font-weight: 750; }
  .movement-table .movement-status { grid-area: status; justify-self: end; }
  .movement-table .movement-date { grid-area: date; font-variant-numeric: tabular-nums; }
  .movement-table .movement-amount { grid-area: amount; text-align: right; color: var(--deep); font-weight: 750; }
  .movement-table .movement-products { grid-area: products; padding-top: .55rem; border-top: 1px solid var(--line); }
  .movement-mobile-label { display: block; margin-bottom: .15rem; font-size: .875rem; font-weight: 650; color: var(--muted); }
  .movement-table .movement-items { font-size: .9375rem; line-height: 1.35; }
  .movement-table .movement-item { grid-template-columns: 3rem minmax(0, 1fr); gap: .6rem; }
  #movements-view .pagination { justify-content: center; }
  #movements-view .pagination button { min-height: 2.75rem; }
}
@media (max-width: 500px) {
  .portal-head nav { margin-left: 0; }
  .form-pair, .brand-entry { grid-template-columns: minmax(0, 1fr); }
  .portal-tabs { flex-wrap: wrap; }
}
