:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f3f5f8;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f3f5f8; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }

.topbar {
  height: 70px;
  padding: 0 24px;
  background: #ffffff;
  border-bottom: 1px solid #dfe4ec;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: #182235; color: #fff;
  font-weight: 800; font-size: 13px; letter-spacing: .04em;
}
.eyebrow {
  font-size: 10px; font-weight: 800; letter-spacing: .14em;
  color: #758096; text-transform: uppercase;
}
h1 { font-size: 20px; line-height: 1.1; margin: 3px 0 0; }
h2 { font-size: 18px; margin: 3px 0 0; }
h3 { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 750; }
.status-pill.neutral { background: #eef1f5; color: #566177; }
.status-pill.ok { background: #e9f7ef; color: #19663b; }
.status-pill.error { background: #fceced; color: #a62d34; }

.layout { max-width: 1760px; margin: 0 auto; padding: 18px; }
.card {
  background: #fff;
  border: 1px solid #dde3ec;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,23,42,.025);
}
.login-card { max-width: 680px; margin: 9vh auto; padding: 24px; display: grid; gap: 22px; }
.muted { color: #667189; font-size: 13px; line-height: 1.55; margin: 8px 0 0; }
.login-form { display: grid; gap: 7px; }
.login-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 14px;
}
.sidebar { padding: 12px; align-self: start; position: sticky; top: 84px; }
.sidebar-title {
  font-size: 10px; letter-spacing: .12em; font-weight: 800;
  color: #7a8498; padding: 8px 9px 10px;
}
.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #49556b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-item.active { background: #eef2f8; color: #172033; }
.nav-item.locked { color: #9aa3b4; }
.nav-item.locked span {
  font-size: 9px; font-weight: 700;
  background: #f2f4f7; padding: 3px 5px; border-radius: 4px;
}
.sidebar-separator { border-top: 1px solid #e6eaf0; margin: 10px 7px; }
.sidebar-note { font-size: 11px; line-height: 1.4; color: #828da1; padding: 5px 9px; }

.main-column { min-width: 0; display: grid; gap: 12px; }

.input-strip { padding: 16px; }
.input-heading {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
}
.request-state { font-size: 12px; font-weight: 700; color: #687389; }
.price-form {
  display: grid;
  grid-template-columns: 170px 170px auto;
  gap: 12px;
  align-items: end;
}
.field { display: grid; gap: 5px; }
label { font-size: 11px; color: #59657a; font-weight: 800; }
input, select {
  border: 1px solid #cbd3df;
  border-radius: 8px;
  background: #fff;
  color: #182235;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus {
  border-color: #8ba0c1;
  box-shadow: 0 0 0 3px rgba(88,112,151,.10);
}
.field input {
  height: 40px;
  padding: 0 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.hint { font-size: 10px; color: #8a94a7; }
.primary {
  height: 40px;
  border: 1px solid #172033;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 0 17px;
  font-weight: 800;
}
.primary:hover { background: #222f47; }
.primary:disabled { opacity: .55; }
.ghost {
  border: 1px solid #d3dae5;
  background: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #556177;
}
.form-message {
  min-height: 18px;
  padding-top: 6px;
  color: #9c3439;
  font-size: 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
}
.summary-card {
  padding: 11px 13px;
  background: #fff;
  border: 1px solid #dde3ec;
  border-radius: 10px;
  display: grid;
  gap: 3px;
}
.summary-card span {
  font-size: 9px; letter-spacing: .09em;
  text-transform: uppercase; color: #8490a4; font-weight: 800;
}
.summary-card strong {
  font-size: 14px; color: #172033; font-variant-numeric: tabular-nums;
}

.market-shell { overflow: hidden; min-height: 560px; }
.market-toolbar {
  min-height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid #e1e6ed;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.toolbar-controls {
  display: grid;
  grid-template-columns: minmax(250px, 420px) 130px;
  gap: 8px;
}
.search { height: 38px; padding: 0 11px; }
select { height: 38px; padding: 0 9px; }

.family-toolbar {
  border-bottom: 1px solid #e4e8ef;
  background: #fafbfd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 12px;
}
.family-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 1px;
}
.family-tab {
  flex: 0 0 auto;
  border: 1px solid #d6dde7;
  background: #fff;
  color: #5e697d;
  border-radius: 999px;
  height: 32px;
  padding: 0 11px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.family-tab:hover { border-color: #bfc9d7; color: #27354c; }
.family-tab.active {
  border-color: #27354c;
  background: #27354c;
  color: #fff;
}
.family-tab:disabled { opacity: .6; }
.family-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(120,130,150,.12);
  font-size: 9px;
}
.family-tab.active .family-count { background: rgba(255,255,255,.18); }
.family-status {
  flex: 0 0 auto;
  display: grid;
  justify-items: end;
  gap: 1px;
}
.family-status span {
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8e98aa;
  font-weight: 800;
}
.family-status strong {
  font-size: 11px;
  color: #4e5a70;
}

.market-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 485px;
}
.category-rail {
  border-right: 1px solid #e1e6ed;
  background: #fbfcfd;
  padding: 8px;
  max-height: calc(100vh - 315px);
  min-height: 485px;
  overflow: auto;
}
.category-button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #566278;
  padding: 8px 9px;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
}
.category-button:hover { background: #f0f3f7; }
.category-button.active { background: #e8edf4; color: #182235; }
.category-name {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.category-meta {
  display: grid;
  justify-items: end;
  gap: 3px;
}
.category-count {
  min-width: 25px;
  height: 20px;
  border-radius: 999px;
  background: #eef1f5;
  display: grid;
  place-items: center;
  padding: 0 6px;
  font-size: 9px;
  color: #7a8497;
  font-variant-numeric: tabular-nums;
}
.category-period {
  font-size: 8px;
  color: #9aa3b3;
  font-weight: 800;
}
.empty-rail {
  padding: 18px 11px;
  color: #8a94a6;
  font-size: 11px;
  line-height: 1.5;
}

.market-content { min-width: 0; padding: 0; }
.empty-state {
  min-height: 440px;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
  color: #667188;
}
.empty-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: #eef2f7; display: grid; place-items: center;
  font-weight: 800; color: #58667d; margin-bottom: 10px;
}
.empty-state p { max-width: 520px; font-size: 12px; line-height: 1.55; }

.market-title {
  min-height: 68px;
  border-bottom: 1px solid #e5e9ef;
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.market-title-copy { min-width: 0; }
.market-title h3 {
  font-size: 15px;
  overflow-wrap: anywhere;
}
.market-title-sub {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.market-title-sub span {
  font-size: 9px;
  color: #778397;
  background: #f1f4f8;
  border-radius: 999px;
  padding: 3px 7px;
  font-weight: 750;
}
.market-title-count {
  flex: 0 0 auto;
  font-size: 11px;
  color: #68748a;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.no-results { padding: 30px 16px; color: #79859a; font-size: 12px; }

.selection-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.selection-table th {
  height: 36px;
  text-align: left;
  padding: 0 14px;
  border-bottom: 1px solid #e4e8ef;
  background: #fafbfd;
  color: #8993a5;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.selection-table th:nth-child(1) { width: auto; }
.selection-table th:nth-child(2),
.selection-table th:nth-child(3) { width: 155px; text-align: right; }
.selection-table td {
  height: 43px;
  padding: 7px 14px;
  border-bottom: 1px solid #edf0f4;
  font-size: 12px;
  color: #3e4a60;
}
.selection-table td:nth-child(2),
.selection-table td:nth-child(3) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}
.selection-table tr:hover td { background: #fafbfd; }
.selection-name { font-weight: 700; color: #263349 !important; overflow-wrap: anywhere; }
.selection-context {
  margin-left: 7px;
  display: inline-block;
  border-radius: 4px;
  background: #eff2f6;
  color: #8690a2;
  padding: 2px 5px;
  font-size: 8px;
  font-weight: 800;
  vertical-align: 1px;
}

@media (max-width: 1180px) {
  .market-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .selection-table th:nth-child(2),
  .selection-table th:nth-child(3) { width: 125px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
  }
  .sidebar-title, .sidebar-separator, .sidebar-note { display: none; }
  .nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .market-layout { grid-template-columns: 250px minmax(0, 1fr); }
  .category-rail { max-height: 520px; }
}

@media (max-width: 700px) {
  .topbar { height: 62px; padding: 0 12px; }
  .brand-mark { width: 34px; height: 34px; }
  h1 { font-size: 16px; }
  .eyebrow { font-size: 8px; }
  .layout { padding: 8px; }
  .login-card { margin: 4vh auto; padding: 16px; }
  .login-row { grid-template-columns: 1fr; }
  .price-form { grid-template-columns: 1fr 1fr; }
  .price-form .calculate { grid-column: 1 / -1; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .market-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .toolbar-controls { grid-template-columns: 1fr; }
  .family-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .family-status { display: none; }
  .market-layout { grid-template-columns: 1fr; }
  .category-rail {
    min-height: 0;
    max-height: 210px;
    border-right: 0;
    border-bottom: 1px solid #e1e6ed;
  }
  .market-title { min-height: 62px; }
  .selection-table th:nth-child(2),
  .selection-table td:nth-child(2) { display: none; }
  .selection-table th:nth-child(3) { width: 120px; }
  .selection-table td { padding-left: 10px; padding-right: 10px; }
}
