:root {
  --surface: #f9f9fb;
  --surface-lowest: #ffffff;
  --surface-low: #f3f3f5;
  --surface-mid: #eeeef0;
  --surface-high: #e8e8ea;
  --surface-variant: rgba(228, 189, 194, 0.20);
  --surface-glow: rgba(184, 0, 73, 0.06);
  --primary: #b80049;
  --primary-deep: rgba(184, 0, 73, 0.08);
  --secondary: #4c616c;
  --secondary-soft: rgba(76, 97, 108, 0.10);
  --text: #1a1c1d;
  --muted: #4c616c;
  --muted-dim: #8a9eaa;
  --good: #2e7d4a;
  --bad: #c0392b;
  --shadow: 0px 20px 40px rgba(184, 0, 73, 0.06);
  --ambient: 0 0 60px rgba(184, 0, 73, 0.04);
  --gold: #b80049;
  --gold-border: rgba(184, 0, 73, 0.10);
  --gold-glow: rgba(184, 0, 73, 0.05);
  --radius-sm: 6px;
  --radius-md: 12px;
  --font-headline: "Plus Jakarta Sans", sans-serif;
  --font-body: "Plus Jakarta Sans", sans-serif;
  --font-label: "Plus Jakarta Sans", sans-serif;
  /* Aliases usados em Analytics e modais (tema claro) */
  --border: rgba(26, 28, 29, 0.08);
  --text-dim: var(--muted-dim);
  --text-muted: var(--muted);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
}

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

button,
input,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  font-size: 20px;
  line-height: 1;
}

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

.app-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  background: rgba(249, 249, 251, 0.85);
  backdrop-filter: blur(12px);
  box-shadow: 0px 4px 24px rgba(184, 0, 73, 0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand,
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-title {
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-headline);
  font-style: italic;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-link {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-family: var(--font-headline);
  font-size: 11px;
  font-weight: 700;
  padding: 22px 0 16px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s;
}

.topbar-link:hover {
  color: var(--primary);
}

.topbar-link.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.topbar-link.is-muted {
  opacity: 0.66;
  cursor: default;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 280px;
  padding: 0 12px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--surface-high);
  color: var(--muted-dim);
  transition: box-shadow 0.2s, background 0.2s;
}

.search-shell:focus-within {
  box-shadow: 0 0 0 2px rgba(184, 0, 73, 0.15);
  background: var(--surface-lowest);
}

.topbar-search,
.filter-input,
.filter-select,
.purchase-form input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.topbar-search::placeholder {
  color: var(--muted-dim);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: var(--surface-high);
  color: var(--primary);
}

.icon-button-primary {
  background: linear-gradient(135deg, var(--primary), #e2165f);
  color: white;
  box-shadow: 0 0 20px rgba(184, 0, 73, 0.22);
}

.app-sidebar {
  padding: 22px 14px;
  background: var(--surface-low);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
}

.sidebar-brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: rgba(184, 0, 73, 0.08);
  color: var(--primary);
}

.sidebar-brand h1,
.sidebar-brand p,
.hero-panel h2,
.matrix-panel h3,
.alert-card h3,
.page-header h2 {
  margin: 0;
}

.sidebar-brand h1 {
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}

.sidebar-brand p {
  color: var(--muted-dim);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  font-family: var(--font-label);
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  flex: 1;
  align-content: start;
}

.sidebar-session {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
  color: var(--muted-dim);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-session-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.sidebar-session-line strong {
  color: var(--text);
  font-weight: 600;
}

.sidebar-session-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-label);
  color: var(--muted);
}

.sidebar-session-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.sidebar-session-link:hover {
  text-decoration: underline;
}

.sidebar-session-logout {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-high);
  color: var(--muted);
  font-size: 10px;
  font-family: var(--font-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.sidebar-session-logout:hover {
  color: var(--primary);
  border-color: rgba(184, 0, 73, 0.25);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  color: var(--muted);
  text-decoration: none;
  border: none;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.sidebar-link:hover {
  color: var(--primary);
  background: rgba(184, 0, 73, 0.06);
  transform: translateX(2px);
}

.sidebar-link.is-active {
  background: rgba(184, 0, 73, 0.08);
  color: var(--primary);
  box-shadow: inset 3px 0 0 var(--primary);
  font-weight: 600;
}

.sidebar-link.is-static {
  opacity: 0.85;
  cursor: default;
}

.sidebar-card,
.hero-panel,
.matrix-panel,
.alert-card,
.page-panel {
  position: relative;
  background: var(--surface-lowest);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-radius: var(--radius-md);
}

.sidebar-card {
  padding: 16px;
}

.sidebar-card-accent {
  margin-top: auto;
  background: rgba(184, 0, 73, 0.03);
}

.sidebar-card-label,
.section-kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sync-status,
.hero-copy,
.alert-copy,
.page-copy,
.feedback,
.empty-state {
  color: var(--muted);
}

.sync-status {
  margin: 0;
  line-height: 1.6;
  font-size: 13px;
}

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

.summary-card {
  padding: 12px 0;
  background: rgba(184, 0, 73, 0.04);
}

.summary-label,
.summary-meta,
.table-count,
.table-foot-stats,
.sub-value {
  font-family: var(--font-label);
}

.summary-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.summary-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.summary-meta {
  margin-top: 6px;
  color: var(--primary);
  font-size: 11px;
}

.app-main {
  position: relative;
  padding: 28px 28px 36px;
  overflow: hidden;
}

.app-main::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -180px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(184, 0, 73, 0.05), transparent 66%);
  pointer-events: none;
}

.hero-panel,
.page-panel {
  padding: 28px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  background: rgba(184, 0, 73, 0.02);
}

.breadcrumbs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted-dim);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.breadcrumbs .is-highlight {
  color: var(--primary);
}

.hero-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.hero-panel h2,
.page-header h2 {
  font-family: var(--font-headline);
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
}

.hero-copy,
.page-copy {
  max-width: 60ch;
  margin: 12px 0 0;
  line-height: 1.7;
}

.hero-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: rgba(184, 0, 73, 0.06);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-actions {
  display: grid;
  gap: 14px;
  align-content: start;
}

.filter-field,
.purchase-form label {
  display: grid;
  gap: 8px;
}

.filter-field span,
.purchase-form label {
  color: var(--primary);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.filter-input,
.filter-select,
.purchase-form input {
  min-height: 44px;
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  transition: border-color 0.2s;
}

.filter-input:focus,
.filter-select:focus,
.purchase-form input:focus,
.topbar-search:focus {
  border-color: rgba(184, 0, 73, 0.45);
  outline: none;
}

.filter-select option {
  background: var(--surface-lowest);
  color: var(--text);
}

.matrix-layout {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 304px;
  gap: 24px;
  align-items: start;
}

.matrix-panel {
  background: var(--surface-lowest);
}

.matrix-header,
.matrix-footer,
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.matrix-header {
  padding: 24px 24px 18px;
}

.matrix-header-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.class-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.matrix-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  background: var(--surface-high);
  border-radius: var(--radius-sm);
}

.toggle-chip,
.class-filter-chip,
.favorite-chip {
  min-height: 32px;
  padding: 0 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  transition: color 0.18s, background 0.18s;
}

.class-filter-chip {
  background: var(--surface-lowest);
  border: 1px solid rgba(0, 0, 0, 0.07);
}

.class-filter-chip:hover,
.class-filter-chip:focus-visible {
  color: var(--primary);
  background: rgba(184, 0, 73, 0.06);
  border-color: rgba(184, 0, 73, 0.15);
}

.toggle-chip.is-active,
.class-filter-chip.is-active,
.favorite-chip.is-active {
  background: rgba(184, 0, 73, 0.10);
  color: var(--primary);
  border-color: rgba(184, 0, 73, 0.20);
  font-weight: 700;
}

.favorite-chip {
  min-width: 100px;
}

.favorite-chip:hover,
.favorite-chip:focus-visible {
  color: var(--primary);
}

.favorite-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  margin: 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted-dim);
  transition: color 0.18s;
}

.favorite-button.is-active {
  color: var(--primary);
}

.favorite-button .material-symbols-outlined {
  font-size: 22px;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
}

.favorite-button.is-active .material-symbols-outlined {
  font-variation-settings: "FILL" 1, "wght" 600, "GRAD" 0, "opsz" 24;
}

.favorite-button:hover,
.favorite-button:focus-visible {
  color: var(--primary);
}

.matrix-table tbody tr.is-favorite {
  box-shadow: inset 3px 0 0 rgba(184, 0, 73, 0.9);
  background: rgba(184, 0, 73, 0.04) !important;
}

.matrix-table-wrap,
.table-wrap {
  overflow: auto;
  scrollbar-gutter: stable;
}

.matrix-table,
.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.matrix-table thead th,
.table-wrap th {
  padding: 12px 16px;
  background: var(--surface-low);
  color: var(--primary);
  font-family: var(--font-headline);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.matrix-table tbody tr,
.table-wrap tbody tr {
  background: var(--surface-lowest);
  transition: background 0.15s;
}

.matrix-table tbody tr:nth-child(even),
.table-wrap tbody tr:nth-child(even) {
  background: #fafafa;
}

.matrix-table td,
.table-wrap td {
  padding: 11px 16px;
  color: var(--muted);
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.matrix-table tbody tr:hover,
.table-wrap tbody tr:hover {
  background: rgba(184, 0, 73, 0.04) !important;
}

.matrix-table tbody tr:hover td {
  color: var(--text);
}

.col-flag {
  width: 52px;
}

.align-right {
  text-align: right;
}

.align-center {
  text-align: center;
}

.matrix-flag {
  color: var(--muted-dim);
}

.matrix-flag.is-featured {
  color: var(--primary);
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

.designation-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.item-icon,
.item-icon-link {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  border-radius: var(--radius-sm);
  background: var(--surface-low);
  color: var(--secondary);
  text-decoration: none;
  overflow: hidden;
}

.item-icon .material-symbols-outlined {
  font-size: 17px;
}

.item-icon img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
}

.item-icon-fallback {
  font-family: var(--font-label);
  font-size: 10px;
  font-weight: 700;
}

.designation-copy strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.designation-copy span {
  display: block;
  margin-top: 2px;
  color: var(--muted-dim);
  font-size: 10px;
  font-family: var(--font-label);
}

.designation-copy .item-class-tag {
  color: var(--secondary);
  letter-spacing: 0.04em;
}

.value-main {
  color: var(--text);
  font-family: var(--font-label);
  white-space: nowrap;
}

.value-profit {
  color: #2e7d4a;
  font-weight: 700;
}

.value-profit.is-negative {
  color: var(--bad);
}

.value-roi {
  display: grid;
  justify-items: end;
  gap: 2px;
}

.value-roi strong {
  color: var(--good);
  font-family: var(--font-label);
  font-size: 13px;
}

.value-roi.is-negative strong {
  color: var(--bad);
}

.value-capacity {
  font-family: var(--font-label);
  font-weight: 700;
  color: #7c3aed;
}

.sub-value {
  color: var(--muted-dim);
  font-size: 10px;
}

.trend-icon {
  color: var(--good);
}

.trend-icon.is-flat {
  color: var(--muted-dim);
}

.trend-icon.is-down {
  color: var(--bad);
}

.matrix-footer {
  padding: 12px 24px 14px;
  background: var(--surface-low);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.table-foot-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  color: var(--muted-dim);
  font-size: 11px;
}

.table-foot-stats strong {
  color: var(--good);
}

.table-count {
  margin: 0;
  color: var(--muted-dim);
  font-size: 11px;
  text-align: right;
}

.alert-card {
  padding: 20px;
  background: rgba(184, 0, 73, 0.03);
}

.alert-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.alert-card-head .material-symbols-outlined {
  color: var(--primary);
}

.alert-card h3 {
  font-size: 18px;
  color: var(--text);
}

.alert-copy {
  line-height: 1.65;
  margin: 12px 0 18px;
  font-size: 13px;
}

.alert-metrics {
  display: grid;
  gap: 10px;
}

.alert-metric {
  padding: 12px;
  background: var(--surface-low);
  border-radius: var(--radius-sm);
}

.alert-metric span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted-dim);
  font-family: var(--font-label);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.alert-metric strong {
  color: var(--text);
}

.page-layout {
  display: grid;
  gap: 24px;
}

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

.page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 24px;
}

.page-panel {
  padding: 24px;
}

.page-panel.is-full {
  grid-column: 1 / -1;
}

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

.notes-field,
.purchase-submit {
  grid-column: 1 / -1;
}

.action-button {
  min-height: 46px;
  padding: 0 22px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #e2165f);
  color: white;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  transition: box-shadow 0.2s, opacity 0.2s;
}

.action-button:hover {
  box-shadow: 0 0 20px rgba(184, 0, 73, 0.25);
  opacity: 0.92;
}

.feedback {
  margin: 14px 0 0;
  min-height: 20px;
}

.cost-summary {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-label);
  font-size: 12px;
}

.cost-summary strong {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-dim);
}

.empty-state {
  padding: 24px 16px;
}

.empty-state.align-center {
  text-align: center;
}

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.product-card {
  background: var(--surface-lowest);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.2s;
  box-shadow: 0px 4px 16px rgba(184, 0, 73, 0.05);
}

.product-card:hover {
  box-shadow: 0px 20px 40px rgba(184, 0, 73, 0.08);
}

.product-card.is-favorite {
  box-shadow: inset 3px 0 0 var(--primary), 0px 8px 20px rgba(184, 0, 73, 0.08);
}

.product-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.product-ingredients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.ingredient-badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-low);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.ingredient-badge.is-highlight {
  background: rgba(184, 0, 73, 0.08);
  color: var(--primary);
}

.product-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted-dim);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 28, 29, 0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 30;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-panel {
  background: var(--surface-lowest);
  border-radius: var(--radius-md);
  padding: 24px;
  width: min(640px, 100%);
  box-shadow: 0px 20px 40px rgba(184, 0, 73, 0.10);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}

.modal-summary {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-label);
  font-size: 12px;
  color: var(--muted-dim);
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1180px) {
  .hero-panel,
  .matrix-layout,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .alert-card {
    max-width: 420px;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .app-topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    height: auto;
  }

  .topbar-brand,
  .topbar-tools,
  .page-header,
  .matrix-header,
  .matrix-footer,
  .hero-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .app-sidebar {
    padding-top: 10px;
  }

  .search-shell {
    min-width: 0;
  }

  .app-main {
    padding: 18px;
  }

  .matrix-toggle {
    align-self: flex-start;
  }
}

@media (max-width: 680px) {
  .topbar-nav {
    display: none;
  }

  .purchase-form {
    grid-template-columns: 1fr;
  }

  .matrix-table thead {
    display: none;
  }

  .matrix-table,
  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table td {
    display: block;
    width: 100%;
  }

  .matrix-table tbody tr {
    padding: 14px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
    box-shadow: 0px 4px 12px rgba(184, 0, 73, 0.06);
  }

  .matrix-table td {
    padding: 8px 0;
    text-align: left;
  }

  .matrix-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted-dim);
    font-family: var(--font-label);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }

  .matrix-table td.col-flag-cell::before,
  .matrix-table td.designation-cell-wrap::before {
    display: none;
  }

  .designation-cell {
    min-width: 0;
  }

  .value-roi {
    justify-items: start;
  }
}

.app-main {
  padding: 16px 18px 20px;
}

.matrix-panel-dense {
  min-height: calc(100vh - 104px);
}

.matrix-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 18px 8px;
  align-items: end;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.filter-field-compact {
  min-width: 160px;
}

.filter-field-compact .filter-input,
.filter-field-compact .filter-select {
  min-height: 34px;
  padding-bottom: 4px;
}

.matrix-header {
  padding: 12px 18px 12px;
}

.matrix-header-main {
  gap: 8px;
}

.class-filter-chip,
.favorite-chip {
  min-height: 30px;
  padding: 0 12px;
  font-size: 10px;
}

.matrix-table thead th,
.table-wrap th {
  padding: 11px 14px;
}

.matrix-table td,
.table-wrap td {
  padding: 10px 14px;
  font-size: 13px;
}

.designation-cell {
  gap: 10px;
  min-width: 180px;
}

.item-icon,
.item-icon-link {
  width: 30px;
  height: 30px;
  flex-basis: 30px;
}

.item-icon img {
  width: 20px;
  height: 20px;
}

.designation-copy strong {
  font-size: 13px;
}

.designation-copy span {
  margin-top: 2px;
  font-size: 10px;
}

.matrix-footer-compact {
  padding: 10px 18px 12px;
  justify-content: flex-end;
}

.table-count {
  width: 100%;
  text-align: right;
}

@media (max-width: 960px) {
  .app-main {
    padding: 12px;
  }
}

/* ── Discount toggle button ─────────────────────────────────────────────── */
.discount-toggle-btn {
  width: 30px;
  height: 30px;
  padding: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.07);
  background: var(--surface-lowest);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.discount-toggle-btn:hover {
  border-color: rgba(184, 0, 73, 0.20);
  background: rgba(184, 0, 73, 0.06);
}

.discount-toggle-btn.is-active {
  background: rgba(184, 0, 73, 0.12);
  border-color: rgba(184, 0, 73, 0.35);
  box-shadow: 0 0 0 2px rgba(184, 0, 73, 0.12);
}

.discount-btn-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}

/* ── Farm card grid ─────────────────────────────────────────────────────── */
.farm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
  padding: 20px 18px 36px;
}

.farm-card {
  background: var(--surface-lowest);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: 0 4px 20px rgba(184, 0, 73, 0.06);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: box-shadow 0.2s, transform 0.2s;
}

.farm-card:hover {
  box-shadow: 0 8px 32px rgba(184, 0, 73, 0.10);
  transform: translateY(-1px);
}

.farm-card.is-favorited {
  box-shadow: inset 3px 0 0 var(--primary), 0 8px 24px rgba(184, 0, 73, 0.08);
}

.farm-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.farm-card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
}

.farm-card-delete {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--muted-dim);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.farm-card-delete:hover {
  color: var(--bad);
  background: rgba(192, 57, 43, 0.08);
}

.farm-card-delete .material-symbols-outlined {
  font-size: 18px;
}

.farm-kkh {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  background: rgba(46, 125, 74, 0.08);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  align-self: flex-start;
}

.farm-kkh-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--good);
  font-family: var(--font-headline);
  letter-spacing: -0.03em;
  line-height: 1;
}

.farm-kkh-unit {
  font-size: 11px;
  font-family: var(--font-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--good);
  opacity: 0.75;
}

.farm-card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.farm-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-wrap: wrap;
}

.farm-vote-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius-sm);
  background: var(--surface-low);
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.farm-vote-btn .material-symbols-outlined {
  font-size: 15px;
}

.farm-vote-btn:hover {
  border-color: rgba(184, 0, 73, 0.18);
  color: var(--primary);
  background: rgba(184, 0, 73, 0.05);
}

.farm-vote-btn.is-active-like {
  color: var(--good);
  background: rgba(46, 125, 74, 0.08);
  border-color: rgba(46, 125, 74, 0.20);
}

.farm-vote-btn.is-active-dislike {
  color: var(--bad);
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.20);
}

.farm-vote-btn.is-active-fav {
  color: var(--primary);
  background: rgba(184, 0, 73, 0.08);
  border-color: rgba(184, 0, 73, 0.22);
}

.farm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
  gap: 12px;
}

.farm-page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
}

.farm-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 16px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #e2165f);
  color: white;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  transition: box-shadow 0.2s, opacity 0.2s;
}

.farm-new-btn:hover {
  box-shadow: 0 0 16px rgba(184, 0, 73, 0.25);
  opacity: 0.92;
}

.farm-new-btn .material-symbols-outlined {
  font-size: 16px;
}

.farm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 28, 29, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 40;
}

.farm-modal-overlay.is-hidden { display: none; }

.farm-modal {
  background: var(--surface-lowest);
  border-radius: var(--radius-md);
  padding: 28px;
  width: min(520px, 100%);
  box-shadow: 0 20px 48px rgba(184, 0, 73, 0.12);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.farm-modal h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.farm-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.farm-form label {
  display: grid;
  gap: 6px;
  color: var(--primary);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.farm-form input,
.farm-form textarea {
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-low);
  transition: border-color 0.2s;
  outline: none;
}

.farm-form input:focus,
.farm-form textarea:focus {
  border-color: rgba(184, 0, 73, 0.45);
  background: var(--surface-lowest);
}

.farm-form textarea {
  resize: vertical;
  min-height: 80px;
}

.farm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.farm-btn-cancel {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.farm-btn-cancel:hover { background: var(--surface-low); }

.farm-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

/* ── Sidebar sync widget ──────────────────────────────────────────────────── */
.sidebar-brand.is-syncing #sidebarBrandIcon {
  animation: sidebarSpin 1.2s linear infinite;
}
@keyframes sidebarSpin { to { transform: rotate(-360deg); } }

.sidebar-sync-bar {
  width: 100%;
  height: 3px;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
  margin: 4px 0 3px;
  overflow: hidden;
}
.sidebar-sync-fill {
  height: 100%;
  width: 0%;
  background: var(--primary, #b80049);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.sidebar-sync-text {
  font-size: 10px;
  color: var(--muted-dim, #8a9eaa);
  font-family: var(--font-label, monospace);
  letter-spacing: 0.03em;
}
