:root {
  --ink: var(--color-ink);
  --ink-soft: var(--color-muted);
  --canvas: var(--color-page);
  --panel: var(--color-panel);
  --line: var(--color-line);
  --navy: var(--azul);
  --primary: var(--vermelho);
  --primary-hover: var(--brand-red-dark);
  --accent: var(--azul);
  --accent-soft: var(--color-blue-soft);
  --orange: var(--vermelho);
  --danger: #b91c28;
  --shadow: var(--shadow-soft);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--glass-page-background);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--azul);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  position: sticky;
  top: 0;
  flex-direction: column;
  min-height: 100vh;
  padding: 32px 24px;
  overflow: hidden;
  color: #fff;
  background: var(--navy);
}

.sidebar::after {
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 210px;
  height: 210px;
  content: "";
  border: 28px solid rgba(8, 79, 152, 0.24);
  border-radius: 50%;
}

.brand,
.workspace-header,
.filter-row,
.results-heading,
.pagination,
.dialog-header,
.dialog-footer,
.footer-actions,
.check-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--vermelho);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--azul);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: rgba(255, 255, 255, 0.58);
}

.brand h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.sidebar-copy {
  max-width: 180px;
  margin: 46px 0 24px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.93rem;
  line-height: 1.55;
}

.summary-stack {
  display: grid;
  gap: 10px;
}

.summary-card {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 90px;
  padding: 16px;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.055);
}

.summary-card.accent {
  color: #fff;
  border-color: var(--vermelho);
  background: var(--vermelho);
}

.summary-label {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.76rem;
  font-weight: 700;
}

.summary-card.accent .summary-label {
  color: rgba(255, 255, 255, 0.85);
}

.summary-card strong {
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.sidebar-note {
  z-index: 1;
  display: flex;
  gap: 9px;
  margin-top: auto;
  color: rgba(255, 255, 255, 0.57);
  font-size: 0.77rem;
  line-height: 1.45;
}

.note-dot {
  width: 8px;
  height: 8px;
  flex: none;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--vermelho);
}

.workspace {
  width: min(100%, 1600px);
  padding: 42px clamp(22px, 4vw, 64px) 56px;
}

.workspace-header {
  gap: 28px;
  justify-content: space-between;
  margin-bottom: 30px;
}

.workspace-header h2 {
  max-width: 650px;
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.7rem, 2.5vw, 2.5rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.close-button {
  min-height: 42px;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-button {
  display: inline-flex;
  gap: 9px;
  padding: 0 17px;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 750;
  border-radius: var(--radius-sm);
  background: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 12px rgba(242, 30, 38, .12);
}

.primary-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-button span {
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 0;
}

.ghost-button,
.icon-button,
.close-button {
  color: var(--ink-soft);
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--glass-surface-strong);
  box-shadow: var(--glass-highlight);
}

.ghost-button {
  padding: 0 14px;
}

.ghost-button:hover,
.icon-button:hover,
.close-button:hover {
  color: var(--brand-blue-dark);
  border-color: var(--glass-selected-line);
  background: var(--glass-selected);
}

.filter-panel {
  padding: 16px;
  margin-bottom: 37px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--glass-surface);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.search-field {
  display: flex;
  height: 54px;
  gap: 12px;
  padding: 0 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
}

.search-field:focus-within {
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(8, 79, 152, 0.1);
}

.search-icon {
  color: var(--azul);
  font-size: 1.6rem;
  line-height: 1;
  transform: rotate(-20deg);
}

.search-field input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  border: 0;
  outline: 0;
}

.search-field input::placeholder {
  color: var(--color-muted);
}

.filter-row {
  gap: 12px;
  padding-top: 15px;
}

.filter-row label {
  display: grid;
  min-width: 145px;
  gap: 6px;
}

.filter-row label span,
.form-fields label > span {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

select,
.filter-row select,
.form-fields input,
.form-fields textarea,
.form-fields select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.filter-row select {
  font-size: 0.9rem;
}

.filter-row .ghost-button {
  margin-left: auto;
  align-self: end;
}

.catalogue-section {
  min-height: 450px;
}

.results-heading {
  justify-content: space-between;
  margin-bottom: 18px;
}

.results-heading h3 {
  margin: 0;
  color: var(--navy);
  font-size: 1.25rem;
  letter-spacing: -0.035em;
}

.pagination {
  gap: 9px;
}

.pagination span {
  min-width: 86px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.icon-button {
  display: grid;
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.05rem;
  place-items: center;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(205px, 1fr));
  gap: 16px;
}

.product-card {
  position: relative;
  display: flex;
  min-height: 304px;
  overflow: hidden;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  background: var(--glass-surface-strong);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}

.product-card:hover {
  z-index: 1;
  border-color: var(--glass-selected-line);
  box-shadow: var(--glass-highlight), 0 12px 26px rgba(49, 84, 122, .1);
  transform: translateY(-2px);
}

.product-image {
  display: grid;
  height: 169px;
  place-items: center;
  border-bottom: 1px solid var(--color-line);
  background:
    linear-gradient(135deg, var(--color-blue-soft), #fff),
    var(--color-surface);
}

.product-image img {
  width: 100%;
  height: 100%;
  padding: 12px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.image-placeholder {
  display: grid;
  width: 50px;
  height: 50px;
  color: var(--color-muted);
  font-size: 1.5rem;
  place-items: center;
  border: 1px solid var(--color-line);
  border-radius: 50%;
}

.product-card-content {
  display: flex;
  gap: 8px;
  padding: 14px 14px 15px;
  flex: 1;
  flex-direction: column;
}

.product-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}

.badge {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 7px;
  overflow: hidden;
  color: var(--brand-blue-dark);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 5px;
  background: var(--color-blue-soft);
}

.badge.inactive {
  color: #9a5344;
  background: #fff0e8;
}

.favorite-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px var(--color-red-soft);
}

.product-card h4 {
  display: -webkit-box;
  min-height: 39px;
  margin: 0;
  overflow: hidden;
  color: var(--navy);
  font-size: 0.96rem;
  letter-spacing: -0.02em;
  line-height: 1.24;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.product-subtitle {
  display: -webkit-box;
  min-height: 17px;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.79rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.product-footer {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: auto;
  color: var(--color-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.product-footer span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  max-width: 430px;
  padding: 56px 25px;
  margin: 40px auto;
  text-align: center;
  place-items: center;
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
}

.empty-symbol {
  display: grid;
  width: 54px;
  height: 54px;
  margin-bottom: 13px;
  color: var(--azul);
  font-size: 1.7rem;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state h3 {
  color: var(--navy);
  font-size: 1.05rem;
}

.empty-state p {
  margin: 8px 0 18px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.product-dialog {
  width: min(1050px, calc(100vw - 32px));
  max-height: min(850px, calc(100vh - 32px));
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg);
  background: var(--glass-surface-strong);
  box-shadow: var(--glass-highlight), 0 24px 64px rgba(49, 84, 122, .16);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.product-dialog::backdrop {
  background: rgba(44, 68, 96, .3);
}

.product-form {
  display: flex;
  min-height: min(720px, calc(100vh - 32px));
  flex-direction: column;
}

.dialog-header {
  padding: 23px 26px 20px;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.35rem;
  letter-spacing: -0.045em;
}

.close-button {
  display: grid;
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  place-items: center;
}

.form-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  overflow: auto;
}

.image-panel {
  padding: 25px 22px;
  border-right: 1px solid var(--line);
  background: var(--color-surface);
}

.image-preview {
  display: grid;
  aspect-ratio: 1 / 1.1;
  overflow: hidden;
  color: var(--color-muted);
  text-align: center;
  place-items: center;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: #fff;
}

.image-preview img {
  width: 100%;
  height: 100%;
  padding: 13px;
  object-fit: contain;
}

.image-preview span {
  display: block;
  font-size: 2rem;
}

.image-preview p {
  margin: -40px 0 0;
  font-size: 0.78rem;
}

.image-caption {
  margin: 12px 2px 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.45;
}

.form-fields {
  padding: 24px 27px 28px;
}

.field-grid {
  display: grid;
  gap: 15px;
}

.field-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-fields label {
  display: grid;
  gap: 6px;
}

.form-fields label.full-span {
  grid-column: 1 / -1;
}

.form-fields label > span b {
  color: var(--danger);
}

.form-fields textarea {
  min-height: 76px;
  padding: 10px;
  resize: vertical;
}

.form-fields input:focus,
.form-fields textarea:focus,
.form-fields select:focus {
  border-color: var(--azul);
}

.form-fields small {
  color: var(--color-muted);
  font-size: 0.72rem;
}

code {
  padding: 1px 4px;
  color: var(--brand-blue-dark);
  border-radius: 4px;
  background: var(--color-blue-soft);
}

.check-row {
  gap: 20px;
  padding-top: 18px;
}

.check-field {
  display: inline-flex !important;
  gap: 8px !important;
  align-items: center;
  color: var(--ink) !important;
  font-size: 0.85rem;
  font-weight: 700;
}

.check-field input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--azul);
}

.dialog-footer {
  min-height: 76px;
  padding: 15px 26px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  background: var(--color-surface);
}

.footer-actions {
  gap: 10px;
  margin-left: auto;
}

.danger-button {
  padding: 0 13px;
  color: var(--danger);
  font-weight: 750;
  border: 1px solid rgba(201, 73, 66, 0.27);
  border-radius: var(--radius-sm);
  background: #fff7f6;
}

.danger-button:hover {
  border-color: rgba(185, 28, 40, .4);
  background: #ffe8ea;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 16px;
  color: var(--brand-blue-dark);
  font-size: 0.87rem;
  font-weight: 700;
  line-height: 1.35;
  border: 1px solid var(--glass-selected-line);
  border-radius: var(--radius-md);
  background: #eef6ff;
  box-shadow: var(--glass-highlight), var(--glass-shadow);
}

.toast.error {
  color: var(--danger);
  border-color: #efb9bf;
  background: #fff2f3;
}

.skeleton {
  min-height: 304px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(110deg, #e1eaf5 8%, #f5f8fc 18%, #e1eaf5 33%);
  background-size: 200% 100%;
  animation: loading 1.25s linear infinite;
}

@keyframes loading {
  to {
    background-position-x: -200%;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: 0;
    padding: 20px 24px;
  }

  .sidebar::after,
  .sidebar-copy,
  .sidebar-note {
    display: none;
  }

  .summary-stack {
    display: flex;
    gap: 8px;
    margin: 18px 0 0 auto;
  }

  .summary-card {
    min-width: 110px;
    min-height: 68px;
    padding: 11px;
  }

  .brand {
    float: left;
  }
}

@media (max-width: 700px) {
  .workspace {
    padding: 28px 16px 40px;
  }

  .workspace-header {
    align-items: flex-end;
    margin-bottom: 22px;
  }

  .workspace-header h2 {
    font-size: 1.72rem;
  }

  .workspace-header .primary-button {
    min-width: 46px;
    padding: 0 13px;
    font-size: 0;
  }

  .workspace-header .primary-button span {
    font-size: 1.5rem;
  }

  .filter-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-row label {
    min-width: 0;
  }

  .filter-row .ghost-button {
    grid-column: 1 / -1;
    margin-left: 0;
  }

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

  .product-card {
    min-height: 270px;
    border-radius: var(--radius-md);
  }

  .product-image {
    height: 135px;
  }

  .product-card-content {
    padding: 11px;
  }

  .product-card h4 {
    font-size: 0.85rem;
  }

  .form-layout {
    display: block;
  }

  .image-panel {
    display: flex;
    gap: 14px;
    padding: 15px 20px;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .image-preview {
    width: 86px;
    height: 86px;
    flex: none;
  }

  .image-caption {
    margin: 0;
  }

  .form-fields {
    padding: 20px;
  }

  .field-grid.two-columns {
    grid-template-columns: 1fr;
  }

  .form-fields label.full-span {
    grid-column: auto;
  }

  .dialog-footer {
    gap: 14px;
    padding: 15px 20px;
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .footer-actions {
    width: 100%;
    margin: 0;
  }

  .footer-actions button,
  .danger-button {
    flex: 1;
  }
}

@media (max-width: 540px) {
  .sidebar {
    padding: 17px 16px;
  }

  .summary-stack {
    display: none;
  }

  .workspace-header {
    gap: 14px;
  }

  .pagination span {
    display: none;
  }

  .product-grid {
    grid-template-columns: 1fr 1fr;
  }

  .check-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
