:root {
  --ink: #17231e;
  --muted: #6f7d76;
  --line: #e3e9e5;
  --surface: #ffffff;
  --background: #f4f7f5;
  --green: #176b4d;
  --green-dark: #10533b;
  --green-pale: #e8f3ed;
  --orange: #d86f35;
  --red: #b73f45;
  --shadow: 0 22px 65px rgba(25, 50, 39, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -10%, rgba(48, 143, 103, .12), transparent 28rem),
    var(--background);
  font-family: "DM Sans", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  padding: 0 max(28px, calc((100vw - 1480px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(221, 229, 224, .85);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: white; background: var(--green);
  font: 800 19px "Manrope", sans-serif;
  box-shadow: 0 8px 20px rgba(23, 107, 77, .22);
}
.brand strong, .brand span { display: block; }
.brand strong { font: 800 16px "Manrope", sans-serif; letter-spacing: -.3px; }
.brand span { font-size: 11px; color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }
.button-ghost { color: var(--muted); background: transparent; }
.button-ghost:hover { color: var(--red); background: #fff3f3; }

main { width: min(1480px, calc(100% - 56px)); margin: 0 auto 60px; }
.hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 32px; padding: 58px 0 32px;
}
.eyebrow {
  margin: 0 0 10px; color: var(--green); font-size: 12px;
  font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase;
}
h1, h2, h3 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: clamp(34px, 4vw, 52px); line-height: 1.05; letter-spacing: -2.1px; }
.hero > div > p:last-child { margin: 14px 0 0; color: var(--muted); font-size: 16px; }
.formula-card {
  min-width: 230px; padding: 18px 22px;
  background: var(--ink); color: white; border-radius: 18px;
  box-shadow: 0 15px 35px rgba(23, 35, 30, .14);
}
.formula-card span, .formula-card small { display: block; color: #b8c4be; }
.formula-card span { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; }
.formula-card strong { display: block; font: 800 29px "Manrope"; margin: 4px 0 2px; }
.formula-card small { font-size: 11px; }
.hero-actions { display: flex; align-items: stretch; gap: 12px; }
.hero-actions > .button { min-width: 145px; }
.representative-name {
  display: block; max-width: 210px; overflow: hidden;
  text-overflow: ellipsis; color: #425048;
}

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stats article, .unclassified-stat {
  background: rgba(255, 255, 255, .72); border: 1px solid var(--line);
  border-radius: 16px; padding: 17px 20px;
}
.stats span, .unclassified-stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.stats strong, .unclassified-stat strong { font: 700 22px "Manrope", sans-serif; }
.unclassified-stat { text-align: left; color: var(--ink); }
.unclassified-stat small { display: block; margin-top: 4px; color: var(--green); font-size: 9px; font-weight: 700; }
.unclassified-stat:hover { border-color: #b7d9c7; background: var(--green-pale); }

.workspace {
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
  background: var(--surface); box-shadow: 0 8px 35px rgba(26, 48, 38, .05);
}
.toolbar {
  padding: 18px; display: flex; justify-content: space-between; gap: 18px;
  border-bottom: 1px solid var(--line);
}
.search-field {
  width: min(480px, 48%); display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 11px; padding: 0 13px;
  background: #fafcfb;
}
.search-field span { font-size: 22px; color: var(--muted); transform: rotate(-15deg); }
.search-field input {
  width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: var(--ink);
}
.filter-group { display: flex; align-items: flex-end; gap: 10px; }
.filter-group label { color: var(--muted); font-size: 11px; font-weight: 600; }
select, input {
  border: 1px solid var(--line); outline: 0; color: var(--ink);
  background: white; border-radius: 10px;
}
.filter-group select { display: block; min-width: 190px; height: 42px; padding: 0 11px; margin-top: 4px; }
.custom-range { display: flex; align-items: center; gap: 6px; }
.custom-range input { width: 75px; height: 42px; padding: 0 10px; }
.custom-range span { color: var(--muted); }

.table-wrap { overflow: auto; min-height: 500px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; white-space: nowrap; }
th {
  padding: 13px 14px; color: var(--muted); background: #fafcfb;
  border-bottom: 1px solid var(--line); text-align: left; font-weight: 600;
  position: sticky; top: 0; z-index: 2;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--green); }
th.active-sort::after { content: " ↓"; color: var(--green); }
th.active-sort.asc::after { content: " ↑"; }
td { padding: 13px 14px; border-bottom: 1px solid #eef2ef; }
tbody tr.product-row { cursor: pointer; transition: background .15s ease; }
tbody tr.product-row:hover { background: #f5faf7; }
tbody tr:last-child td { border-bottom: 0; }
.product-cell strong { display: block; max-width: 255px; overflow: hidden; text-overflow: ellipsis; }
.product-cell span { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.price { font-weight: 600; }
.muted-value { color: #a5afa9; }
.supplier-name { display: block; max-width: 165px; overflow: hidden; text-overflow: ellipsis; }
.positive { color: var(--green); font-weight: 700; }
.negative { color: var(--red); font-weight: 700; }
.loading, .empty { padding: 80px 20px; text-align: center; color: var(--muted); }

.pagination {
  min-height: 62px; padding: 12px 18px; display: flex; align-items: center;
  justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
.pagination > div { display: flex; align-items: center; gap: 12px; }
.page-button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: white; color: var(--ink);
}
.page-button:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.page-button:disabled { opacity: .35; cursor: default; }

.button {
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.button-primary { color: white; background: var(--green); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--ink); border-color: var(--line); background: white; }
.button-secondary:hover { border-color: #b9c9c0; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; padding: 28px;
  background: rgba(12, 25, 19, .52); backdrop-filter: blur(7px);
  display: grid; place-items: center;
}
.modal {
  width: min(900px, 100%); max-height: calc(100vh - 56px); overflow-y: auto;
  padding: 32px; position: relative; background: white; border-radius: 22px; box-shadow: var(--shadow);
}
.modal-settings { width: min(650px, 100%); }
.close-button {
  position: absolute; top: 18px; right: 18px; width: 35px; height: 35px;
  border: 0; border-radius: 50%; background: var(--background); color: var(--muted); font-size: 23px;
}
.modal-heading { padding-right: 40px; }
.modal-heading h2 { margin: 0; font-size: 27px; letter-spacing: -.8px; }
.modal-heading > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.detail-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 24px 0 30px; }
.detail-metrics div { background: var(--background); border-radius: 12px; padding: 13px; }
.detail-metrics span, .detail-metrics strong { display: block; }
.detail-metrics span { color: var(--muted); font-size: 10px; min-height: 27px; }
.detail-metrics strong { font: 700 15px "Manrope", sans-serif; margin-top: 4px; }
.modal-section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding-top: 22px; border-top: 1px solid var(--line);
}
.modal-section-title h3 { margin: 0; font-size: 17px; }
.modal-section-title p { color: var(--muted); margin: 4px 0 0; font-size: 11px; }
.supplier-form {
  display: grid; grid-template-columns: 2fr 1fr .7fr; gap: 10px;
  margin: 18px 0; padding: 16px; border: 1px solid #cfe3d8;
  background: #f5faf7; border-radius: 14px;
}
.supplier-form h4 { grid-column: 1 / -1; margin: 0 0 3px; font: 700 14px "Manrope", sans-serif; }
.supplier-form input, .supplier-form select { min-width: 0; height: 41px; padding: 0 11px; }
.supplier-form input[name="address"], .supplier-form input[name="whatsapp_group"] { grid-column: span 2; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.supplier-list { display: grid; gap: 9px; margin-top: 16px; }
.supplier-card {
  display: grid; grid-template-columns: 1.3fr 2fr 1fr auto; align-items: center; gap: 16px;
  border: 1px solid var(--line); border-radius: 13px; padding: 14px;
}
.supplier-card.cheapest { border-color: #b7d9c7; box-shadow: inset 3px 0 var(--green); }
.supplier-card strong, .supplier-card span { display: block; }
.supplier-card span { color: var(--muted); font-size: 11px; margin-top: 3px; white-space: normal; }
.supplier-price { text-align: right; font: 700 16px "Manrope", sans-serif; }
.cheapest-tag { color: var(--green) !important; text-transform: uppercase; font-size: 9px !important; font-weight: 700; }
.supplier-actions { display: flex; align-items: center; gap: 3px; }
.edit-supplier, .delete-supplier {
  width: 30px; height: 30px; border: 0; border-radius: 8px;
  background: transparent; color: #8f9c95; font-size: 16px;
}
.edit-supplier:hover { color: var(--green); background: var(--green-pale); }
.delete-supplier:hover { color: var(--red); }
.no-suppliers { padding: 28px; border: 1px dashed #ced8d2; border-radius: 13px; text-align: center; color: var(--muted); }

.modal-label { width: min(1040px, 100%); }
.modal-small { width: min(480px, 100%); }
.label-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 25px; }
.label-editor-head h2 { margin: 0; font-size: 28px; }
.label-editor-head > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.danger-button { color: var(--red); border-color: #f0d2d5; background: #fff7f7; }
.danger-button:hover { color: white; background: var(--red); }
.label-properties {
  margin: 24px 0 0; padding: 16px; display: grid;
  grid-template-columns: 1fr 2fr auto; align-items: end; gap: 12px;
  border: 1px solid var(--line); border-radius: 14px; background: #fafcfb;
}
.label-properties label, .simple-form label {
  color: var(--muted); font-size: 10px; font-weight: 700;
}
.label-properties input, .label-properties select, .simple-form input {
  display: block; width: 100%; height: 42px; margin-top: 5px; padding: 0 11px;
}
.label-tabs { display: flex; gap: 3px; margin-top: 26px; border-bottom: 1px solid var(--line); }
.label-tabs button {
  padding: 12px 16px; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); background: transparent; font-size: 12px; font-weight: 700;
}
.label-tabs button.active { color: var(--green); border-bottom-color: var(--green); }
.label-tabs span {
  margin-left: 4px; padding: 2px 6px; border-radius: 10px;
  color: inherit; background: var(--background); font-size: 9px;
}
.tab-panel { padding-top: 20px; }
.member-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.member-toolbar h3 { margin: 0; font-size: 16px; }
.member-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.product-picker {
  margin-top: 15px; padding: 15px; border: 1px solid #cfe3d8;
  border-radius: 14px; background: #f5faf7;
}
.product-picker .search-field { width: 100%; background: white; }
.search-results { max-height: 290px; overflow-y: auto; margin-top: 10px; }
.search-results > p { margin: 18px 0; color: var(--muted); text-align: center; font-size: 11px; }
.search-result {
  padding: 10px 7px; display: flex; align-items: center; justify-content: space-between; gap: 15px;
  border-bottom: 1px solid #e1ebe5;
}
.search-result:last-child { border-bottom: 0; }
.search-result strong, .search-result span { display: block; }
.search-result strong { font-size: 12px; }
.search-result span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.member-list { display: grid; gap: 7px; margin-top: 15px; }
.member-card {
  padding: 12px 14px; display: grid; grid-template-columns: minmax(240px, 1fr) auto auto;
  align-items: center; gap: 20px; border: 1px solid var(--line); border-radius: 12px;
}
.member-card.representative { border-color: #b7d9c7; box-shadow: inset 3px 0 var(--green); }
.member-card strong, .member-card span { display: block; }
.member-card strong { font-size: 12px; }
.member-card > div:first-child span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.member-prices { display: flex; gap: 15px; font-size: 11px; font-variant-numeric: tabular-nums; }
.member-card > button {
  border: 0; color: var(--red); background: transparent; font-size: 10px; font-weight: 700;
}
.member-card > button:hover { text-decoration: underline; }
.simple-form { margin-top: 24px; }
.simple-form .form-actions { margin-top: 18px; }
.modal-unclassified { width: min(980px, 100%); }
.unclassified-toolbar {
  margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.unclassified-toolbar .search-field { width: min(580px, 75%); }
.select-page { color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.select-page input { vertical-align: -2px; }
.unclassified-list {
  height: min(390px, 42vh); overflow-y: auto; margin-top: 14px;
  border: 1px solid var(--line); border-radius: 13px;
}
.unclassified-item {
  padding: 11px 14px; display: grid; grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center; gap: 13px; border-bottom: 1px solid #edf1ee;
}
.unclassified-item:last-child { border-bottom: 0; }
.unclassified-item > input { width: 17px; height: 17px; }
.unclassified-item strong, .unclassified-item span { display: block; }
.unclassified-item strong { font-size: 12px; }
.unclassified-item span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.unclassified-item .member-prices { color: var(--ink); font-size: 11px; }
.unclassified-pagination {
  padding: 10px 2px; display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 11px;
}
.unclassified-pagination > div { display: flex; align-items: center; gap: 10px; }
.assignment-panel {
  padding: 15px; display: grid; grid-template-columns: auto 1fr auto 1fr auto;
  align-items: end; gap: 12px; border: 1px solid #cfe3d8;
  border-radius: 14px; background: #f5faf7;
}
.assignment-panel label { color: var(--muted); font-size: 10px; font-weight: 700; }
.assignment-panel select, .assignment-panel input {
  display: block; width: 100%; height: 41px; margin-top: 5px; padding: 0 10px;
}
.selection-summary {
  min-width: 74px; height: 41px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 9px; background: white;
}
.selection-summary strong { font: 700 17px "Manrope", sans-serif; }
.selection-summary span { color: var(--muted); font-size: 8px; }
.assignment-or { padding-bottom: 12px; color: var(--muted); font-size: 10px; }

.settings-list { margin-top: 22px; display: grid; gap: 4px; }
.setting-row {
  display: grid; grid-template-columns: 1fr 130px; align-items: center; gap: 18px;
  padding: 13px 0; border-bottom: 1px solid #edf1ee;
}
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { font-size: 13px; }
.setting-row small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.setting-input { position: relative; }
.setting-input input { width: 100%; height: 40px; padding: 0 42px 0 11px; text-align: right; }
.setting-input span { position: absolute; right: 10px; top: 12px; font-size: 11px; color: var(--muted); pointer-events: none; }
.settings-summary {
  margin: 18px 0; padding: 14px; display: flex; justify-content: space-between;
  background: var(--green-pale); color: var(--green-dark); border-radius: 11px; font-size: 13px;
}

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 100;
  padding: 13px 18px; color: white; background: var(--ink); border-radius: 11px;
  box-shadow: var(--shadow); font-size: 12px;
}
.toast.error { background: var(--red); }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    radial-gradient(circle at 8% 85%, rgba(54, 146, 106, .15), transparent 25rem),
    #edf3ef;
}
.login-shell {
  width: min(1040px, 100%);
  min-height: 650px;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(390px, .9fr) 1.1fr;
  overflow: hidden;
  border: 1px solid rgba(213, 224, 217, .9);
  border-radius: 28px;
  background: white;
  box-shadow: 0 28px 80px rgba(24, 52, 39, .14);
}
.login-panel {
  padding: 44px 54px 34px;
  display: flex;
  flex-direction: column;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font: 800 17px "Manrope", sans-serif; }
.login-brand span { margin-top: 1px; color: var(--muted); font-size: 11px; }
.login-copy { margin-top: auto; padding-top: 65px; }
.login-copy h1 { font-size: 37px; letter-spacing: -1.6px; }
.login-copy > p:last-child {
  max-width: 350px; margin: 13px 0 0;
  color: var(--muted); font-size: 14px; line-height: 1.55;
}
.login-form { display: grid; gap: 17px; margin-top: 32px; }
.login-form label { color: #45534c; font-size: 12px; font-weight: 700; }
.login-form label > input, .password-field {
  width: 100%; height: 48px; margin-top: 7px;
}
.login-form input {
  width: 100%; height: 100%; padding: 0 14px;
  background: #fafcfb; border-color: #dbe4df;
}
.login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.password-field { position: relative; }
.password-field input { padding-right: 76px; }
.password-field button {
  position: absolute; right: 7px; top: 7px; height: 34px;
  padding: 0 9px; border: 0; border-radius: 7px;
  color: var(--green); background: transparent; font-size: 10px; font-weight: 700;
}
.password-field button:hover { background: var(--green-pale); }
.login-submit { width: 100%; min-height: 48px; margin-top: 4px; font-size: 13px; }
.login-error {
  padding: 11px 13px; color: #932f35; background: #fff1f2;
  border: 1px solid #f5d2d5; border-radius: 9px; font-size: 12px;
}
.login-footer { margin: auto 0 0; padding-top: 34px; color: #98a39d; font-size: 10px; }
.login-visual {
  position: relative; overflow: hidden;
  display: grid; place-items: center;
  background:
    linear-gradient(145deg, rgba(255,255,255,.04), transparent 45%),
    var(--ink);
}
.login-visual::before {
  content: ""; position: absolute; width: 390px; height: 390px;
  border-radius: 50%; background: rgba(47, 139, 99, .2); filter: blur(3px);
}
.visual-orbit {
  position: absolute; border: 1px solid rgba(166, 215, 191, .15);
  border-radius: 50%;
}
.orbit-one { width: 470px; height: 470px; }
.orbit-two { width: 610px; height: 610px; }
.visual-card {
  width: min(360px, 75%); padding: 30px; position: relative; z-index: 1;
  border: 1px solid rgba(255,255,255,.12); border-radius: 20px;
  color: white; background: rgba(255,255,255,.07); backdrop-filter: blur(8px);
}
.visual-card span { color: #9fcbb8; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; }
.visual-card strong { display: block; margin-top: 12px; font: 700 24px/1.35 "Manrope", sans-serif; }
.visual-bars { height: 90px; margin-top: 35px; display: flex; align-items: flex-end; gap: 9px; }
.visual-bars i {
  flex: 1; display: block; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(to top, #247653, #63b28f);
}
.visual-bars i:nth-child(1) { height: 32%; }
.visual-bars i:nth-child(2) { height: 55%; }
.visual-bars i:nth-child(3) { height: 45%; }
.visual-bars i:nth-child(4) { height: 76%; }
.visual-bars i:nth-child(5) { height: 100%; }

@media (max-width: 900px) {
  main { width: min(100% - 28px, 1480px); }
  .topbar { padding: 0 18px; }
  .hero { padding-top: 38px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .filter-group { justify-content: space-between; }
  .detail-metrics { grid-template-columns: repeat(2, 1fr); }
  .supplier-card { grid-template-columns: 1fr 1fr; }
  .hero-actions { flex-direction: column; }
  .label-properties { grid-template-columns: 1fr; }
  .member-card { grid-template-columns: 1fr auto; }
  .member-prices { grid-column: 1; grid-row: 2; }
  .assignment-panel { grid-template-columns: 1fr 1fr; }
  .selection-summary, .assignment-or { display: none; }
  .login-shell { grid-template-columns: 1fr; width: min(500px, 100%); }
  .login-visual { display: none; }
}

@media (max-width: 560px) {
  .hero { align-items: stretch; flex-direction: column; }
  .formula-card { min-width: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats article { padding: 14px; }
  .modal-backdrop { padding: 0; }
  .modal { max-height: 100vh; min-height: 100vh; border-radius: 0; padding: 25px 18px; }
  .supplier-form { grid-template-columns: 1fr; }
  .supplier-form input[name="address"], .supplier-form input[name="whatsapp_group"] { grid-column: auto; }
  .setting-row { grid-template-columns: 1fr 110px; }
  .unclassified-toolbar { align-items: stretch; flex-direction: column; }
  .unclassified-toolbar .search-field { width: 100%; }
  .unclassified-item { grid-template-columns: auto 1fr; }
  .unclassified-item .member-prices { grid-column: 2; }
  .assignment-panel { grid-template-columns: 1fr; }
  .login-page { padding: 0; background: white; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .login-panel { padding: 34px 24px 25px; }
  .login-copy { padding-top: 70px; }
}
