:root {
  --wl-teal: #113c3d;
  --wl-teal-dark: #0a2829;
  --wl-orange: #f3752b;
  --wl-bg: #f5f8f6;
  --wl-surface: #ffffff;
  --wl-text: #1b1d1d;
  --wl-muted: #6a6a6a;
  --wl-border: #d8ddda;
  --wl-success: #1a7a4c;
  --wl-error: #c0392b;
  --wl-focus: #2563eb;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--wl-text);
  background: var(--wl-bg);
}

.wrap {
  width: min(1200px, 100% - 2rem);
  margin-inline: auto;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid var(--wl-border);
  box-shadow: 0 1px 8px rgba(17, 60, 61, 0.06);
  padding: 0.85rem 0;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.site-logo {
  display: block;
  width: auto;
  height: 34px;
  max-width: min(160px, 45vw);
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--wl-teal);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  font-size: 0.875rem;
  color: var(--wl-muted);
}

.main {
  padding: 1.25rem 0 2.5rem;
}

.panel {
  background: var(--wl-surface);
  border: 1px solid var(--wl-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(17, 60, 61, 0.06);
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--wl-border);
  background: #fafcfb;
}

.meta-line {
  margin: 0;
  font-size: 0.875rem;
  color: var(--wl-muted);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 16rem;
  justify-content: flex-end;
}

.search-input {
  width: min(18rem, 100%);
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--wl-border);
  border-radius: 8px;
  font: inherit;
}

.save-status {
  min-width: 5.5rem;
  font-size: 0.8rem;
  color: var(--wl-muted);
  text-align: right;
}

.save-status.is-saving { color: var(--wl-muted); }
.save-status.is-saved { color: var(--wl-success); }
.save-status.is-error { color: var(--wl-error); }

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 14rem);
}

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  line-height: 1.25;
}

.sheet th,
.sheet td {
  border-right: 1px solid var(--wl-border);
  border-bottom: 1px solid var(--wl-border);
  padding: 0;
  vertical-align: middle;
}

.sheet th:last-child,
.sheet td:last-child {
  border-right: 0;
}

.sheet th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef3f0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--wl-muted);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.col-code { width: 5.5rem; }
.col-buy,
.col-blanks,
.col-designed {
  width: 7.25rem;
}

.price-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0.2rem 0.45rem 0.12rem;
  min-height: 2rem;
  font-size: 0.84rem;
  line-height: 1.2;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.price-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.1rem;
  min-width: 0;
  color: var(--wl-text);
}

.price-stack--range .price-row {
  justify-content: flex-end;
}

.price-prefix {
  flex: 0 0 auto;
  color: inherit;
  font: inherit;
}

.buy-value,
.price-input {
  flex: 0 0 4.65rem;
  width: 4.65rem;
  min-width: 0;
  color: inherit;
  font: inherit;
  text-align: right;
}

.buy-value--range {
  flex: 1 1 auto;
  width: auto;
  text-align: right;
  white-space: normal;
}

.margin-slot {
  align-self: flex-end;
  width: 4.65rem;
  min-height: 0.95rem;
  padding: 0;
  text-align: right;
  line-height: 1.1;
}

.price-stack--range .margin-slot {
  width: 100%;
}

.sheet td.readonly.col-buy,
.sheet td.price-cell {
  padding: 0;
  vertical-align: middle;
  background: #fff;
}

.sheet td.readonly.col-buy {
  background: #f6f8f7;
}

.margin {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.margin-base,
.margin-na {
  color: var(--wl-muted);
  font-weight: 500;
}

.margin-profit {
  color: #1a4fd6;
}

.margin-flat {
  color: var(--wl-muted);
}

.margin-loss {
  color: #b45309;
}

.sheet td.price-cell.cell-loss,
.sheet td.price-cell .price-stack.line-loss:not(:focus-within) {
  background: #fef08a;
}

.price-stack:focus-within {
  box-shadow: inset 0 0 0 2px var(--wl-focus);
  background: #fff;
}

.price-input {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.price-input:focus {
  box-shadow: none;
  background: transparent;
}

.sheet th.col-buy,
.sheet th.col-blanks,
.sheet th.col-designed {
  text-align: right;
  padding-right: 0.45rem;
}

.wrap {
  width: min(1280px, 100% - 2rem);
  margin-inline: auto;
}

.sheet td.readonly {
  padding: 0.28rem 0.5rem;
  background: #fff;
}

.sheet td.readonly code {
  font-size: 0.8rem;
}

.sheet tr:hover td.readonly {
  background: #fbfdfc;
}

.sheet tr.is-active td.price-cell {
  background: #eef6ff;
}

.sheet tr.is-active td.price-cell .price-stack:focus-within {
  background: #fff;
}

.price-input.is-dirty {
  background: #fffbeb;
}

.price-input.is-saving {
  color: var(--wl-muted);
}

.price-input.is-saved {
  background: #ecfdf3;
}

.price-input.is-error {
  background: #fef2f2;
  box-shadow: inset 0 0 0 2px var(--wl-error);
}

.loading-cell {
  padding: 2rem 1rem !important;
  text-align: center;
  color: var(--wl-muted);
}

.loading-cell--error {
  color: var(--wl-error);
}

.hint {
  margin: 0;
  padding: 0.85rem 1rem 1rem;
  font-size: 0.82rem;
  color: var(--wl-muted);
  border-top: 1px solid var(--wl-border);
}

.hint kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--wl-border);
  border-radius: 4px;
  background: #fff;
  font-size: 0.78rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 0;
}

.btn-primary {
  background: var(--wl-orange);
  color: #fff;
}

.btn-primary:hover { filter: brightness(0.96); }

.btn-ghost {
  background: transparent;
  color: var(--wl-teal);
  border: 1px solid var(--wl-border);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(24rem, 100%);
  background: #fff;
  border: 1px solid var(--wl-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(17, 60, 61, 0.08);
  padding: 2rem 1.75rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo {
  display: inline-block;
  max-width: 100%;
  height: auto;
}

.login-subtitle {
  margin: 0.75rem 0 0;
  color: var(--wl-muted);
  font-size: 0.95rem;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.login-form input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--wl-border);
  border-radius: 8px;
  font: inherit;
}

.form-error {
  margin: 0;
  color: var(--wl-error);
  font-size: 0.875rem;
}

@media (max-width: 720px) {
  .toolbar-right {
    width: 100%;
    justify-content: stretch;
  }

  .search-input {
    flex: 1;
    width: 100%;
  }

  .sheet-wrap {
    max-height: calc(100vh - 16rem);
  }
}
