@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800;900&family=Saira:wght@700;800;900&display=swap");

:root {
  --brand-red: #e60015;
  --brand-navy: #142a3e;
  --brand-yellow: #ffc012;
  --bg: #f8f8f8;
  --fg: #171717;
  --white: #ffffff;
  --border-light: #ececec;
  --border-mid: #dcdfe2;
  --text-muted: #666666;
  --content-max-width: 1500px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 15px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Inter Fallback", sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

main {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 100px 80px;
}

@media (max-width: 1024px) {
  body {
    background: var(--white);
  }

  main {
    padding: 0 35px 60px;
  }
}

.app-shell {
  min-height: 100vh;
}

.header-main {
  background: var(--white);
  border-bottom: 1px solid var(--border-light);
  padding: 20px 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

@media (min-width: 1025px) {
  .header-main {
    height: 127px;
  }
}

@media (max-width: 1024px) {
  .header-main {
    padding: 20px 35px;
  }
  .nav-links {
    flex-wrap: wrap;
  }
  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

.brand-title {
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.5px;
  color: var(--brand-navy);
}

.brand-logo {
  height: 48px;
  width: auto;
}

.brand-logo.large {
  height: 64px;
}

.nav-links {
  display: flex;
  gap: 12px;
  font-family: "Saira", sans-serif;
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-link {
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  transition: color 200ms ease, background 200ms ease;
}

.nav-link.active,
.nav-link:hover {
  background: var(--brand-red);
  color: var(--white);
}

.user-pill {
  background: var(--border-light);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  font-family: "Saira", sans-serif;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 18px;
  padding: 10px 25px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: opacity 200ms ease, background 200ms ease;
}

.btn-primary {
  background: var(--brand-red);
  color: var(--white);
}

.btn-secondary {
  background: var(--brand-yellow);
  color: var(--white);
}

.btn-tertiary {
  background: var(--brand-navy);
  color: var(--white);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--brand-navy);
  color: var(--brand-navy);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 27px;
}

@media (min-width: 1025px) {
  .card {
    padding: 40px;
  }
}

.page-title {
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 44px;
  margin: 0 0 16px;
}

@media (min-width: 1025px) {
  .page-title {
    font-size: 55px;
  }
}

.section-title {
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 32px;
  margin: 0 0 16px;
}

.muted {
  color: var(--text-muted);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 16px;
  font-weight: 500;
}

.input {
  padding: 17px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  font-family: "Inter", sans-serif;
  font-size: 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

.table th {
  text-align: left;
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-size: 14px;
  color: var(--brand-navy);
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-light);
}

.sortable-button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}

.sort-indicator {
  font-size: 12px;
  color: var(--brand-red);
}

.empty-state {
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--white);
}

.login-shell {
  max-width: 420px;
  margin: 80px auto;
  padding: 40px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.article-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 4px;
}

.article-search-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 16px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  transition: background 150ms ease;
}

.article-search-item:last-child {
  border-bottom: none;
}

.article-search-item:hover {
  background: var(--bg);
}

.article-search-item-name {
  font-weight: 500;
  color: var(--fg);
}

.article-search-selected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.article-search-selected-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.article-search-selected-name {
  font-weight: 500;
}

.info-box {
  background: linear-gradient(135deg, #f0f4f8 0%, #e8eef4 100%);
  border: 1px solid var(--border-mid);
  border-left: 4px solid var(--brand-navy);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.info-box h4 {
  margin: 0 0 8px;
  font-family: "Saira", sans-serif;
  font-size: 14px;
  text-transform: uppercase;
  color: var(--brand-navy);
}

.info-box p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.info-box ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.detail-header-left {
  flex: 1;
}

.override-section {
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 8px;
}

.override-section h4 {
  margin: 0 0 12px;
  font-family: "Saira", sans-serif;
  font-size: 16px;
  text-transform: uppercase;
  color: var(--brand-navy);
}

.override-section p {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.checkbox-cell {
  width: 40px;
  text-align: center;
}

.checkbox-cell input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand-red);
}

.selection-bar {
  position: sticky;
  bottom: 20px;
  background: var(--brand-navy);
  color: var(--white);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  margin-top: 20px;
}

.selection-actions {
  display: flex;
  gap: 12px;
}

.selection-bar-info {
  font-family: "Saira", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.selection-bar .btn {
  background: var(--white);
  color: var(--brand-navy);
}

.selection-bar .btn:hover {
  background: var(--brand-yellow);
}

.table tr.selected {
  background: rgba(230, 0, 21, 0.05);
}

.table tr:hover {
  background: var(--bg);
}

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

.result-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--white);
  transition: box-shadow 200ms ease;
}

.result-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.result-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}

.result-title {
  font-family: "Saira", sans-serif;
  font-weight: 800;
  font-size: 20px;
  text-transform: uppercase;
  color: var(--brand-navy);
  line-height: 1.3;
}

.result-meta {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}

.result-meta::before {
  content: "";
  display: none;
}

.source-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-item {
  padding: 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 200ms ease;
}

.source-item:hover {
  border-color: var(--border-mid);
}

.source-item > div:first-child {
  font-weight: 600;
  font-size: 15px;
}

.source-item > div:first-child strong {
  color: var(--brand-navy);
  font-weight: 700;
}

.source-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.error {
  color: var(--brand-red);
  font-size: 14px;
}

.success {
  color: #0f766e;
  font-size: 14px;
}

.modal::backdrop {
  background: rgba(20, 42, 62, 0.4);
}

.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  padding: 24px;
  width: min(600px, 92vw);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

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

.modal-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mini-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--bg);
}

.mini-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px solid var(--border-light);
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-grid {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  font-family: "Saira", sans-serif;
  text-transform: uppercase;
  font-size: 18px;
  margin: 16px 0 8px;
  color: var(--brand-navy);
}

.match-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--border-light);
  color: var(--brand-navy);
  margin: 6px 0;
}

.match-manual {
  background: rgba(230, 0, 21, 0.12);
  color: var(--brand-red);
}

.match-ean14,
.match-distriboissons {
  background: rgba(255, 192, 18, 0.2);
  color: #8a5d00;
}

.match-exact,
.match-fuzzy {
  background: rgba(20, 42, 62, 0.12);
  color: var(--brand-navy);
}

.match-singleton {
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
}

@media (max-width: 720px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

#search-input {
  flex: 1 1 300px;
  min-width: 0;
}

.toolbar .input {
  min-width: 0;
}

.toolbar .input[type="number"] {
  width: 140px;
}

.toolbar select.input {
  width: 180px;
}

.toolbar .input[name="source_system"] {
  width: 220px;
}
