:root {
  --purple: #0081c3;
  --purple-dark: #006699;
  --purple-light: #c5e4f5;
  --purple-wash: #f2f7fb;
  --green: #75bb32;
  --green-dark: #4f8a1c;
  --green-light: #ecf9d8;
  --aqua: #0081c3;
  --orange: #FFA500;
  --ink: #424242;
  --ink-2: #424242;
  --muted: #666666;
  --muted-2: #999999;
  --line: #E7E7E7;
  --line-2: #E7E7E7;
  --canvas: #f2f7fb;
  --paper: #FFFFFF;
  --chip: #F9F9F9;
  --gold: #FFA500;
  --error: #FB5058;
  --sidebar: 220px;
  --bar: 73px;
  --font: Outfit, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--canvas);
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.app-bar {
  height: var(--bar);
  padding: 0 24px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
  background: #0081c3;
  color: #fff;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; min-width: 140px; }
.brand-logo { height: 40px; width: auto; display: block; }

.search-pill {
  justify-self: center;
  max-width: 460px;
  width: 100%;
  background: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  color: #999;
  font-size: 15px;
  text-align: left;
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 0;
  background: var(--canvas);
}
.powered {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  height: 36px;
  padding: 0 20px;
  background: #006ea8;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.powered img {
  height: 14px;
  width: auto;
  display: block;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}
.side {
  border-right: 1px solid var(--line-2);
  padding: 16px 12px;
  background: var(--paper);
}
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  margin-bottom: 2px;
}
.side-link:hover { background: var(--canvas); }
.side-link.active {
  background: var(--purple-wash);
  color: var(--purple);
  font-weight: 700;
}
.side-link.active .ico { color: var(--gold); }
.side-link.hidden { display: none; }
.ico { width: 18px; color: var(--muted-2); text-align: center; }

.side-note {
  margin: 28px 8px 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.side-note strong { display: block; color: var(--ink); margin-bottom: 4px; font-size: 11px; }

.content {
  background: var(--canvas);
  padding: 24px 32px 48px;
  min-width: 0;
}
.page-title { margin: 0 0 4px; font-size: 28px; font-weight: 500; color: var(--ink); line-height: 1.15; }
.page-sub { margin: 0 0 20px; color: var(--muted); }

button, .btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  min-height: 36px;
  padding: 8px 16px;
  border: 0;
}
.btn.primary, button.primary {
  background: #0081c3;
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}
.btn.primary:hover, button.primary:hover { background: #006699; }
.btn.secondary, button.secondary {
  background: var(--paper);
  color: var(--purple);
  border: 1px solid var(--purple);
}
.btn.ghost {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--error); color: #fff; }
.btn:disabled, button:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { min-height: 28px; padding: 4px 10px; font-size: 13px; }

.banner {
  background: var(--purple-wash);
  color: var(--purple-dark);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.quote-list { padding: 0; }
.quote-row {
  display: grid;
  grid-template-columns: 148px minmax(140px, 1.1fr) auto minmax(180px, 1.4fr) auto;
  gap: 12px 16px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
}
.quote-row:last-child { border-bottom: 0; }
.quote-row:hover { background: var(--canvas); }
.quote-row.expired { background: #f3f3f3; color: #9a9a9a; }
.quote-row.expired strong,
.quote-row.expired .muted,
.quote-row.expired .quote-k { color: #9a9a9a; }
.quote-row.expired .chip { background: #eee; color: #9a9a9a; border-color: #e0e0e0; }
.quote-row.expired .quote-open-btn { background: #bdbdbd; }
.quote-row.expired:hover { background: #ececec; }
.quote-until strong { font-weight: 700; }
.quote-id { display: flex; align-items: center; }
.quote-open-btn { justify-self: end; white-space: nowrap; text-align: center; }
.quote-who { min-width: 0; }
.quote-k { display: none; }

.grid-2 { display: grid; grid-template-columns: 1.45fr .75fr; gap: 16px; }
.price-layout { align-items: start; }
.price-shared {
  display: grid;
  grid-template-columns: repeat(4, minmax(8.5rem, 1fr));
  gap: 10px;
  margin: 8px 0 14px;
}
.price-shared label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
}
.price-cap {
  display: block;
  min-height: 2.5em;
  line-height: 1.25;
  white-space: nowrap;
}
.price-shared input { margin-top: 4px; width: 100%; }
.price-sheet input { min-height: 32px; width: 88px; }
.price-sheet td, .price-sheet th { white-space: nowrap; }
.price-example {
  background: var(--purple-wash);
  border-radius: 12px;
  padding: 14px 16px;
  position: sticky;
  top: 88px;
}
.price-example h3 { margin: 0 0 4px; font-size: 16px; }
.price-total { margin: 14px 0 0; font-size: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 700; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--canvas); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
  background: #FFF2DA;
  color: #9a6200;
  border: 1px solid #FFE0A3;
}
.chip.done { background: #ecf9d8; color: #4f8a1c; border-color: #d4efb0; }
.chip.wait { background: var(--chip); color: var(--muted); border-color: var(--line); }
.chip.status { background: var(--purple-wash); color: var(--purple); border-color: var(--purple-light); }

.wizard { list-style: none; margin: 0; padding: 0; }
.wizard li { position: relative; }
.wizard li:not(.last)::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: -4px;
  width: 2px;
  background: #d5e3ec;
}
.wizard-step {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 6px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.wizard-step:hover { background: var(--canvas); }
.wizard-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: #e7eef3;
  color: #666;
  position: relative;
  z-index: 1;
}
.wizard-step.done .wizard-num { background: #75bb32; color: #fff; }
.wizard-step.open .wizard-num { background: #ffa500; color: #fff; }
.wizard-step.here { background: var(--purple-wash); font-weight: 700; }
.wizard-step.here .wizard-num { background: #0081c3; color: #fff; box-shadow: 0 0 0 3px #c5e4f5; }
.muted { color: var(--muted); }
.right { text-align: right; }

.task { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.task h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }

label { display: block; font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
input[type="text"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
  font: inherit;
  padding: 8px 10px;
  min-height: 40px;
  border: 1px solid #8f8f8f;
  border-radius: 8px;
  background: #fff;
  width: 100%;
  color: var(--ink);
}
input[type="text"], input[type="number"] {
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #0081c3;
  box-shadow: 0 0 0 2px rgba(0, 129, 195, 0.22);
}
input:disabled, select:disabled, textarea:disabled {
  background: #eef3f7;
  color: #666;
  border-color: #c8c8c8;
  cursor: not-allowed;
  opacity: 1;
  box-shadow: none;
}
textarea { min-height: 72px; resize: vertical; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.confirm-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.confirm-row .field { margin: 0; }
.select-bar {
  position: sticky;
  top: 73px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}
.select-bar .field { margin: 0; flex: 1 1 220px; max-width: 360px; }
.select-bar .btn { flex: 1 1 260px; }
.catalog-search { position: relative; flex: 1 1 100%; }
.catalog-search input { padding-right: 42px; }
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #666;
  font-size: 22px;
  line-height: 1;
}
.search-clear:hover { background: var(--canvas); color: var(--ink); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.step-bar { justify-content: flex-end; }
.step-bar .row-actions { margin: 0; width: 100%; justify-content: flex-end; }
.step-bar .btn { flex: 0 1 auto; }

.audit { font-size: 13px; color: var(--muted); margin: 0; padding-left: 18px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.split .card { margin: 0; background: var(--purple-wash); }
.warn {
  background: #F9D6E0;
  border: 1px solid #FFB5C8;
  padding: 10px 12px;
  border-radius: 8px;
}
.empty { padding: 36px 20px; text-align: center; }
.empty h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.empty p { margin: 0; color: var(--muted); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.catalog-card {
  background: #fff;
  border: 1px solid transparent;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.catalog-card[hidden], #catalog-empty[hidden] { display: none; }
.catalog-card:hover { box-shadow: 0 6px 18px rgba(0, 129, 195, 0.16); }
.catalog-card.selected {
  border: 2px solid #0081c3;
  box-shadow: 0 0 0 3px #c5e4f5;
}
.catalog-photo {
  position: relative;
  aspect-ratio: 1 / 1;
  height: auto;
  background: #f3f1ee;
  overflow: hidden;
}
.select-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  background: #0081c3;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  padding: 5px 8px;
  border-radius: 8px;
}
.catalog-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.catalog-body { padding: 10px 12px 12px; }
.catalog-title { font-size: 15px; font-weight: 600; color: #424242; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catalog-accent { font-size: 13px; color: #0081c3; }
.catalog-muted { font-size: 12px; color: var(--ink-2); }
.catalog-small { font-size: 11px; color: var(--muted-2); }

.spec {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.spec i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); display: block; }
.spec .k { font-size: 12px; color: var(--muted); }
.spec .v { font-size: 12px; font-weight: 700; }

.buy-bar { display: grid; grid-template-columns: auto 1fr; align-items: center; margin-top: 10px; gap: 12px; }
.buy-btn {
  width: 28px; height: 28px; min-height: 28px; min-width: 28px;
  padding: 0; border-radius: 6px;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink-2); font-size: 16px;
}
.buy-qty { min-width: 28px; text-align: center; font-weight: 700; }
.price { font-size: 18px; font-weight: 700; text-align: right; }

@media (max-width: 980px) {
  .app-bar {
    height: auto;
    padding: 10px 12px;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .brand { min-width: 0; }
  .brand-logo { height: 32px; }
  .search-pill { display: none; }

  .shell { grid-template-columns: 1fr; }
  .side {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-2);
    padding: 8px 10px;
  }
  .side-link {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
    min-height: 40px;
  }
  .side-note { display: none; }
  .side .btn.ghost {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 40px;
  }

  .content { padding: 16px 12px 32px; }
  .page-title { font-size: 22px; }
  .select-bar { top: 56px; }
  .select-bar .field { max-width: none; }
  .select-bar .btn { flex-basis: 100%; }
  .grid-2, .split { grid-template-columns: 1fr; }
  .price-shared { grid-template-columns: 1fr 1fr; }
  .price-example { position: static; }
  .task { grid-template-columns: 1fr; }
  .price-layout > div:first-child { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .price-sheet { min-width: 640px; }
  .quote-row {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    align-items: start;
    padding: 14px 12px;
  }
  .quote-id { grid-column: 1 / -1; }
  .quote-who { grid-column: 1 / -1; }
  .quote-row > div:nth-child(3) { grid-column: 1 / -1; }
  .quote-open { grid-column: 1 / -1; }
  .quote-open-btn { grid-column: 1 / -1; width: 100%; justify-self: stretch; display: block; }
  .quote-k {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
  }
  .chips { gap: 6px; }
  input, select, textarea { font-size: 16px; }
}

@media (max-width: 520px) {
  .catalog-grid { grid-template-columns: 1fr; }
  .catalog-card { flex-direction: row; align-items: stretch; }
  .catalog-photo {
    width: 112px;
    flex: 0 0 112px;
    aspect-ratio: auto;
    min-height: 112px;
  }
  .catalog-photo img { height: 100%; }
  .select-badge { top: 6px; left: 6px; font-size: 11px; padding: 3px 6px; }
  .catalog-body { flex: 1; min-width: 0; padding: 8px 10px 10px; }
  .price-shared { grid-template-columns: 1fr; }
}
