:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #102f55;
  background: #f4f7fb;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f7fb; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: #fff;
  border-bottom: 1px solid #dbe4ef;
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.brand span { display: grid; }
.brand strong { font-size: 17px; }
.brand small { color: #5d7088; }
.account { display: flex; align-items: center; gap: 14px; color: #5d7088; }
.account a { color: #154b8b; font-weight: 700; }

.shell { width: min(1220px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 24px; }
.hero h1 { margin: 2px 0 8px; font-size: clamp(30px, 4vw, 46px); line-height: 1.05; }
.hero p { margin: 0; color: #5d7088; }
.eyebrow { margin: 0 0 5px !important; color: #0086c9 !important; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.source-status { padding: 11px 15px; border: 1px solid #cfe0ef; border-radius: 999px; background: #fff; color: #385675; font-size: 14px; }
.source-status.ready { color: #08774a; border-color: #a9dec6; background: #eefaf4; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 20px; align-items: start; }
.panel { background: #fff; border: 1px solid #dbe4ef; border-radius: 22px; box-shadow: 0 16px 40px rgba(26, 59, 94, .07); }
.selection-panel, .selected-panel, .recent-panel { padding: 22px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field span { font-size: 13px; font-weight: 750; }
.field input { width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid #c8d6e5; border-radius: 12px; color: #102f55; background: #fff; }
.field input:focus { outline: 3px solid rgba(0, 134, 201, .16); border-color: #0086c9; }
.measures-card { margin: 2px 0 18px; padding: 14px 15px; border: 1px solid #cfe0ef; border-radius: 14px; background: #f7fbff; }
.measures-card.loading { opacity: .62; pointer-events: none; }
.source-card-title { display: grid; gap: 3px; margin-bottom: 9px; }
.source-card-title > strong { font-size: 15px; color: #102f55; }
.source-card-title > span { color: #5d7088; font-size: 12px; line-height: 1.4; }
.master-source-row { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid #dfeaf4; }
.master-source-row > div { display: grid; gap: 3px; }
.master-source-row strong { font-size: 13px; }
.master-source-row div > span { color: #5d7088; font-size: 12px; line-height: 1.4; }
.measures-age { flex: none; padding: 5px 9px; border-radius: 999px; background: #e8f7ef; color: #08774a; font-size: 11px; font-weight: 800; }
.measures-age.stale { background: #fff4de; color: #976000; }
.measures-age.old { background: #fdebed; color: #ad3041; }
.measures-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.measures-actions[hidden] { display: none; }
.measure-upload { cursor: pointer; }
.measure-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.measure-upload span { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 12px; border: 1px solid #9eb7d1; border-radius: 10px; background: #fff; color: #154b8b; font-size: 12px; font-weight: 800; }
.measure-upload input:focus-visible + span { outline: 3px solid rgba(0, 134, 201, .25); }
.master-message { flex-basis: 100%; color: #5d7088; font-size: 12px; }
.master-message:empty { display: none; }
.master-message.success { color: #08774a; }
.master-message.error { color: #ad3041; }
.bulk-import { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 18px; }
.upload-button { margin: 0; cursor: pointer; }
.upload-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-button span, .bulk-import > a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.upload-button span { background: #154b8b; color: #fff; }
.upload-button:hover span { background: #0e3d75; }
.upload-button input:focus-visible + span { outline: 3px solid rgba(0, 134, 201, .25); }
.bulk-import > a { border: 1px solid #b9cade; color: #154b8b; background: #fff; }
.import-status { flex: 1 1 100%; color: #5d7088; font-size: 12px; line-height: 1.4; }
.result-head, .selected-head, .recent-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.result-head { padding: 6px 2px 11px; color: #5d7088; font-size: 13px; }
.selected-head h2, .recent-head h2 { margin: 0; }
.selected-head > strong { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #154b8b; color: #fff; font-size: 20px; }

.product-results { display: grid; gap: 9px; max-height: 540px; overflow: auto; padding-right: 3px; }
.product-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid #dbe4ef; border-radius: 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.product-card:hover, .product-card.selected { border-color: #0086c9; background: #f2fbff; }
.product-card input { width: 20px; height: 20px; accent-color: #0086c9; }
.product-copy { min-width: 0; display: grid; gap: 3px; }
.product-copy strong { font-size: 14px; }
.product-copy span { color: #5d7088; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-copy small { color: #718298; }
.badge { padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #edf8f2; color: #08774a; }
.badge.warning { background: #fff4de; color: #976000; }

.selected-panel { position: sticky; top: 18px; }
.selected-products { display: grid; gap: 8px; max-height: 335px; overflow: auto; margin: 18px 0; }
.selected-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; background: #f5f8fc; border-radius: 11px; }
.selected-row div { min-width: 0; display: grid; gap: 2px; }
.selected-row strong { font-size: 13px; }
.selected-row span { font-size: 12px; color: #5d7088; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selected-row button { border: 0; background: transparent; color: #ad3041; cursor: pointer; font-size: 18px; }
.empty, .help { color: #718298; font-size: 13px; }
.help { line-height: 1.45; }

.primary, .secondary { min-height: 44px; padding: 10px 16px; border-radius: 12px; font-weight: 800; cursor: pointer; }
.primary { width: 100%; border: 0; background: #0b7c53; color: #fff; }
.primary:hover { background: #086744; }
.primary:disabled { opacity: .45; cursor: default; }
.secondary { border: 1px solid #c8d6e5; background: #fff; color: #154b8b; }
.status { min-height: 22px; margin-top: 12px; color: #5d7088; font-size: 13px; line-height: 1.4; }
.status.success { color: #08774a; }
.status.error { color: #ad3041; }

.recent-panel { margin-top: 20px; }
.draft-list { display: grid; gap: 9px; margin-top: 16px; }
.draft-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid #e0e7f0; border-radius: 12px; }
.draft-row strong, .draft-row span { display: block; }
.draft-row span { margin-top: 3px; color: #718298; font-size: 12px; }
.draft-status { font-size: 12px; font-weight: 800; color: #385675; }
.draft-actions { display: flex; gap: 7px; }
.draft-actions a, .draft-actions button { padding: 7px 10px; border: 1px solid #c8d6e5; border-radius: 9px; background: #fff; color: #154b8b; font-size: 12px; font-weight: 800; text-decoration: none; cursor: pointer; }

@media (max-width: 820px) {
  .account span { display: none; }
  .shell { width: min(100% - 20px, 680px); padding-top: 22px; }
  .hero { align-items: start; flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .selected-panel { position: static; }
  .product-results { max-height: 430px; }
  .draft-row { grid-template-columns: 1fr; }
  .bulk-import { display: grid; grid-template-columns: 1fr 1fr; }
  .upload-button span, .bulk-import > a { justify-content: center; text-align: center; }
  .import-status { grid-column: 1 / -1; }
}
