:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --teal: #0f766e;
  --teal-soft: #ccfbf1;
  --screen: #f6f7f9;
  --danger: #e11d48;
  --danger-soft: #ffe4e6;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --card: #ffffff;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, "Segoe UI", system-ui, sans-serif;
  background: var(--screen);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
/* Hide raw Vue templates (e.g. invite overlay) until the app mounts. */
[v-cloak] { display: none !important; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.5rem;
  background: var(--screen);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand i { color: var(--teal); }
.brand small {
  display: block;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0;
}
.brand-copy { display: flex; flex-direction: column; gap: 0.1rem; }
.page {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem 3rem;
  display: grid;
  gap: 1rem;
}
.shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 64px);
  align-items: start;
}
.shell .page {
  max-width: none;
  margin: 1.5rem 1.5rem 1.5rem 0;
  width: 100%;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: stretch;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.75rem;
  min-height: calc(100vh - 64px);
}
.sidebar nav { display: grid; gap: 0.35rem; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.35s var(--ease), color 0.35s var(--ease), transform 0.35s var(--ease);
}
.nav-item i { color: var(--muted); }
.nav-item:hover {
  color: var(--ink);
  transform: translateX(3px);
}
.nav-item.active {
  background: var(--teal-soft);
  color: var(--ink);
}
.nav-item.active i { color: var(--teal); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  animation: rise 0.55s var(--ease) both;
}
.card:nth-child(2) { animation-delay: 0.06s; }
.login { max-width: 420px; margin: 3rem auto; width: 100%; }
.login .btn { margin-top: 0.75rem; width: 100%; }
.board { display: grid; gap: 0.65rem; }
.order-cards { display: none; }
.hit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--screen);
}
.hit-title { font-weight: 800; font-size: 14px; }
table.orders tbody tr.order-row { cursor: pointer; }
table.orders tbody tr.order-row.open td { background: #f8fafc; }
table.orders tbody tr.expand-row:hover td { background: transparent; }
table.orders tbody tr.expand-row td { padding: 0 0.4rem 0.9rem; animation: none; }
.expander { width: 2rem; color: var(--muted); }
.nested {
  width: 100%;
  background: var(--screen);
  border-radius: 12px;
  overflow: auto;
}
.nested th, .nested td { border-bottom: 0; padding: 0.5rem 0.7rem; }
.nested thead th { font-size: 0.75rem; }
.order-summary { margin: 0.75rem 0 0.5rem; font-weight: 600; }
h1, h2 {
  margin: 0 0 1rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem; margin-bottom: 1rem; }
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; }
input, select {
  font: inherit;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  outline: none;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
input:focus, select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-soft);
}
input:disabled, select:disabled {
  background: var(--screen);
  color: var(--muted);
}
label.field-missing { color: var(--danger); }
input.input-missing {
  border-color: var(--danger);
  background: var(--danger-soft);
}
input.input-missing:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}
.lookup {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}
.lookup label { flex: 1; }
.muted-left { color: var(--muted); text-align: left; margin: 0 0 1rem; }
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
  margin: 0 0 1rem;
}
.facts div { margin: 0; }
.facts dt { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.facts dd { margin: 0.15rem 0 0; }
.hints {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 0.1rem);
  z-index: 20;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: 220px;
  overflow: auto;
}
.hints li {
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-weight: 500;
}
.hints li:hover { background: var(--screen); }
.hint-msg { color: var(--muted); font-weight: 500; }
.btn {
  background: var(--ink);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 0.95rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  transition: transform 0.25s var(--ease), filter 0.25s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.tiny { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.row.end { justify-content: flex-end; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
  text-align: left;
  padding: 0.55rem 0.4rem;
  color: var(--muted);
  font-weight: 600;
}
td {
  text-align: left;
  padding: 0.7rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
tbody tr {
  animation: rise 0.5s var(--ease) both;
}
tbody tr:nth-child(1) { animation-delay: 0.04s; }
tbody tr:nth-child(2) { animation-delay: 0.08s; }
tbody tr:nth-child(3) { animation-delay: 0.12s; }
tbody tr:nth-child(4) { animation-delay: 0.16s; }
tbody tr:nth-child(5) { animation-delay: 0.2s; }
tbody tr:nth-child(n+6) { animation-delay: 0.24s; }
tbody tr:hover td { background: #f8fafc; }
td .btn + .btn { margin-left: 0.35rem; }
.muted { color: var(--muted); text-align: center; }
.price {
  color: var(--teal);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.banner { border-radius: 12px; padding: 0.7rem 0.9rem; }
.banner.error { background: var(--danger-soft); color: var(--danger); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.banner:not(.error):not(.ok) { background: #eef2ff; color: #3730a3; }
.muted-inline { color: var(--muted); font-weight: 500; }
.catalog-progress {
  display: flex;
  align-items: center;
}
.catalog-progress .live { margin: 0; }
.catalog-actions {
  justify-content: flex-start;
  border-top: 0;
  padding-top: 0.25rem;
}
.tag { border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.8rem; font-weight: 800; background: var(--line); }
.tag.pending { background: #fef3c7; color: #92400e; }
.tag.sent { background: #dcfce7; color: #166534; }
.tag.open { background: var(--teal-soft); color: var(--teal); }
.tag.waiting { background: #e5e7eb; color: #374151; }
.tag.processing { background: #dbeafe; color: #1e40af; }
.tag.failed { background: var(--danger-soft); color: var(--danger); }
.btn.icon {
  padding: 0.35rem 0.45rem;
  min-width: 2rem;
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
}
.btn.icon:hover:not(:disabled) {
  color: var(--teal);
  background: var(--teal-soft);
  transform: none;
}
.col-edit { width: 2.6rem; text-align: right; }
.dropzone {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  border: 2px dashed var(--line);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  margin: 0 0 1rem;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  position: relative;
}
.dropzone strong { color: var(--ink); }
.dropzone .pi { color: var(--teal); font-size: 1.2rem; }
.dropzone.drag { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); }
.dropzone.busy { opacity: 0.7; pointer-events: none; }
.dropzone-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.order-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 0.75rem 1rem;
  margin: 0 0 0.85rem;
}
.order-search { min-width: 0; }
.order-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0 0 1rem;
}
.order-filters .tag {
  font: inherit;
  cursor: pointer;
  border: 0;
}
.order-filters .tag.active.pending { background: #fef3c7; color: #92400e; }
.order-filters .tag.active.sent { background: #dcfce7; color: #166534; }
.order-filters .tag.active.waiting { background: #e5e7eb; color: #374151; }
.order-filters .tag.active.processing { background: #dbeafe; color: #1e40af; }
.order-filters .tag.active.failed { background: var(--danger-soft); color: var(--danger); }
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.th-sort.active { color: var(--ink); }
.th-sort i { font-size: 0.75rem; }
.order-edit-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.order-edit-title { flex: 1; min-width: 0; }
.order-edit-title h1 { margin: 0 0 0.25rem; }
.order-edit-nav { display: flex; gap: 0.25rem; }
.order-edit-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.order-edit-split.no-pdf { grid-template-columns: 1fr; }
.order-pdf {
  background: var(--screen);
  border-radius: 12px;
  min-height: 480px;
  overflow: hidden;
}
.order-pdf iframe,
.order-pdf img {
  width: 100%;
  height: 70vh;
  min-height: 480px;
  border: 0;
  background: #fff;
}
.order-form h2 { font-size: 1.05rem; margin: 0.5rem 0 0.75rem; }
.edit-lines input { width: 100%; padding: 0.4rem 0.5rem; }
.edit-lines .pos,
.nested .pos {
  width: 2.6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 700;
}
.edit-lines .input-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.line-warn { display: block; color: var(--danger); font-weight: 600; margin-top: 0.2rem; }
.actions.wrap { flex-wrap: wrap; }
.audit-block { margin-top: 1.5rem; }
.audit-table { font-size: 0.85rem; }
.audit-system { color: var(--muted); }
.audit-system td { font-style: italic; }
.lines { max-width: 280px; color: var(--muted); font-size: 0.85rem; }
.qwm-no { display: block; margin-top: 0.15rem; color: var(--muted); font-weight: 500; }
.live {
  font-size: 0.8rem;
  color: var(--teal);
  font-weight: 700;
}
.live::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.4rem;
  border-radius: 50%;
  background: #10b981;
  vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  animation: pulse 2.2s ease-out infinite;
}
.remaining {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.overlay-enter-active,
.overlay-leave-active {
  transition: opacity 0.45s var(--ease);
}
.overlay-enter-from,
.overlay-leave-to { opacity: 0; }
.overlay-enter-active .sheet {
  animation: sheetUp 0.6s var(--ease) both;
}
.dialog { max-width: 460px; width: 100%; }
.sheet {
  background: var(--card);
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 18px;
  padding: 1.25rem 1.25rem 1rem;
  position: relative;
}
.sheet h2 { margin: 0 2.5rem 1rem 0; }
.close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
}
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheetUp {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 10px transparent; }
}
@media (max-width: 720px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: max(0.7rem, env(safe-area-inset-top)) 1rem 0.7rem;
    gap: 0.75rem;
  }
  .brand { min-width: 0; }
  .brand-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 52vw;
  }
  .page { margin: 0 auto; padding: 0.85rem 0.85rem 5.5rem; gap: 0.85rem; }
  .shell { grid-template-columns: 1fr; min-height: 0; }
  .shell .page { margin: 0; width: 100%; }
  .sidebar {
    position: static;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.75rem;
  }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem; }
  .nav-item {
    justify-content: center;
    min-height: 44px;
    padding: 0.65rem 0.5rem;
  }
  .nav-item:hover { transform: none; }
  .card { padding: 1rem; }
  h1, h2 { font-size: 1.2rem; }
  .lookup { flex-direction: column; align-items: stretch; }
  .order-toolbar { grid-template-columns: 1fr 1fr; }
  .lookup .btn { width: 100%; min-height: 44px; }
  .row { flex-wrap: wrap; align-items: center; }
  .hit {
    flex-direction: column;
    align-items: stretch;
  }
  .hit .btn { width: 100%; min-height: 44px; }
  table.orders { display: none; }
  .order-cards { display: grid; gap: 0.65rem; }
  .order-card {
    background: var(--screen);
    border-radius: 16px;
    overflow: hidden;
  }
  .order-card-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "chevron main tag" "chevron main price";
    gap: 0.15rem 0.65rem;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 0.85rem;
    cursor: pointer;
  }
  .order-card-head .pi { grid-area: chevron; color: var(--muted); align-self: center; }
  .order-card-main { grid-area: main; display: grid; gap: 0.15rem; min-width: 0; }
  .order-card-main strong { font-size: 0.95rem; }
  .order-card-head .tag { grid-area: tag; justify-self: end; align-self: start; }
  .order-card-head .price { grid-area: price; justify-self: end; }
  .order-card-body { padding: 0 0.85rem 0.85rem; display: grid; gap: 0.75rem; }
  .order-card-body .btn { width: 100%; min-height: 44px; }
  .order-card-tools { padding: 0 0.85rem 0.65rem; display: flex; justify-content: flex-end; }
  .order-card-tools .btn.icon { min-height: 44px; min-width: 44px; }
  .order-edit-head { flex-wrap: wrap; }
  .order-edit-split { grid-template-columns: 1fr; }
  .order-pdf iframe, .order-pdf img { height: 50vh; min-height: 280px; }
  .btn.icon { min-height: 44px; min-width: 44px; }
  .facts { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .overlay {
    padding: 0;
    align-items: end;
    place-items: end stretch;
  }
  .sheet {
    width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 20px 20px 0 0;
    padding: 1.15rem 1rem calc(1rem + env(safe-area-inset-bottom));
  }
  .actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .actions .btn { width: 100%; min-height: 44px; }
  .btn { min-height: 44px; }
  .btn.tiny { min-height: 44px; }
  input, select { font-size: 16px; }
}

@media (max-width: 420px) {
  .brand small { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .nav-item:hover,
  .btn:hover,
  .btn:active { transform: none; }
}
