:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-2: #f7f3eb;
  --panel: #f7f3eb;
  --panel-2: #f1ede4;
  --accent: #d4a017;
  --accent-2: #f4c949;
  --text: #141414;
  --muted: #4f5456;
  --border: #dcd5c5;
  --shadow: 0 14px 32px rgba(20, 20, 20, 0.1);
  --pkg-guide: rgba(212, 160, 23, 0.22);
  --pkg-guide-2: rgba(212, 160, 23, 0.14);
  --pkg-indent-group: 18px;
  --pkg-indent-part: 18px;
  --pkg-tree-prefix: 60px;
  font-family: "Sora", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(244, 201, 73, 0.1) 0%, rgba(247, 243, 235, 0.92) 45%, #f4f1ea 70%),
    linear-gradient(135deg, #f7f3eb, #f4f1ea);
  color: var(--text);
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0 0 12px;
}

p {
  line-height: 1.6;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.app-shell.is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-self: start;
}

.topbar-center {
  justify-self: center;
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-view-title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  max-width: min(62vw, 680px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.brand-mark {
  display: none;
}

.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}

.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;
}

.user-email {
  font-size: 0.9rem;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 20px;
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(79, 84, 86, 0.28);
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 84, 86, 0.42);
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(220, 213, 197, 0.25);
  border-radius: 999px;
}


.nav-item {
  width: 100%;
  background: none;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-item.is-active {
  background: rgba(212, 160, 23, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

.nav-sheet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  flex: 1;
  min-height: 0;
}

.sheet-view.is-active {
  display: flex;
  flex-direction: column;
}

.detail-view.is-active {
  overflow: auto;
}

.quote-view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  overflow: hidden;
}

.package-admin-view.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.package-admin-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.package-admin-title-row .sheet-header-line {
  flex-wrap: wrap;
  white-space: normal;
}

.package-admin-title-row .sheet-subtitle {
  white-space: normal;
}

.package-admin-header-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.package-admin-header-actions .btn {
  white-space: nowrap;
}

.pkg-drag-add {
  cursor: grab;
}

.pkg-drag-add.is-dragging {
  cursor: grabbing;
  opacity: 0.9;
}

.pkg-drag-add.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.quote-view .panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.package-admin-grid {
  display: grid;
  grid-template-columns: 270px 5px minmax(260px, 1fr) 5px 340px;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.package-admin-grid .panel {
  margin-bottom: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Keep the 3-panel layout usable in the common "content column is narrower than viewport" case
   (sidebar + padding eat width). Prefer shrinking side panels before forcing a horizontal scrollbar. */
@media (max-width: 1280px) {
  .package-admin-grid {
    gap: 12px;
    grid-template-columns: 240px 5px minmax(240px, 1fr) 5px 300px;
  }
}

@media (max-width: 1180px) {
  .package-admin-grid {
    gap: 8px;
    grid-template-columns: 200px 4px minmax(220px, 1fr) 4px 240px;
  }
  .pkg-resize-handle {
    width: 4px;
  }
}

.package-search input[type="search"] {
  width: 100%;
}

.inline-field.package-search select {
  width: 100%;
}

.package-panel-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px;
}

.package-panel-actions > .btn {
  width: 100%;
  justify-content: center;
}

.package-panel-actions .panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.package-panel-actions .panel-actions .btn {
  width: 100%;
}

.package-filters {
  display: block;
  position: relative;
  margin: 6px 0 10px;
}

.package-category-filter {
  position: relative;
}

.package-category-filter .multi-select-menu {
  min-width: 100%;
}

.package-category-filter-count {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 4px;
}

.filter-btn {
  border: 1px solid rgba(220, 213, 197, 0.9);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  line-height: 1.1;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease, transform 0.12s ease, opacity 0.12s ease;
}

.filter-btn:hover {
  border-color: rgba(212, 160, 23, 0.45);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  transform: translateY(-1px);
}

.filter-btn.is-on {
  border-color: rgba(212, 160, 23, 0.55);
  background: rgba(212, 160, 23, 0.14);
  color: var(--text);
  font-weight: 600;
}

.filter-btn.is-off {
  opacity: 0.45;
}

.filter-btn.filter-btn-secondary {
  border-color: rgba(212, 160, 23, 0.25);
  background: rgba(244, 241, 234, 0.6);
  color: var(--text);
}

.category-picker {
  position: relative;
}

.quote-template-category-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quote-template-category-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.quote-template-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(220, 213, 197, 0.95);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.2;
  user-select: none;
  cursor: pointer;
}

.quote-template-category-chip input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: rgba(212, 160, 23, 0.95);
}

.multi-select-trigger {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 14px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.multi-select-trigger:hover {
  border-color: rgba(212, 160, 23, 0.45);
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  border: 1px solid rgba(220, 213, 197, 0.95);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  padding: 6px;
  max-height: 190px;
  overflow: auto;
}

.multi-select-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.2;
}

.multi-select-option:hover {
  background: rgba(212, 160, 23, 0.1);
}

.multi-select-option input[type="checkbox"] {
  appearance: auto;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: rgba(212, 160, 23, 0.95);
}

.multi-select-option input[type="checkbox"]:disabled {
  opacity: 0.4;
}

.pkg-category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin: 12px 0;
}

.pkg-category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px 88px;
  gap: 8px;
  align-items: center;
}

.pkg-category-row input[type="text"],
.pkg-category-add-row input[type="text"] {
  width: 100%;
}

.pkg-category-usage {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
  text-align: right;
}

.pkg-category-remove {
  width: 88px;
}

.pkg-category-remove[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.pkg-category-change-summary {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.84rem;
}

.pkg-category-change-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.pkg-category-change-summary ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.pkg-category-change-summary li + li {
  margin-top: 4px;
}

.pkg-category-change-summary li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.pkg-category-change-dismiss {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.pkg-category-change-dismiss:hover {
  color: var(--text);
  border-color: var(--accent);
}

.pkg-category-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.package-list,
.package-structure,
.parts-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 4px 0;
}

.package-structure {
  position: relative;
}

.pkg-drop-line {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  background: rgba(212, 160, 23, 0.85);
  pointer-events: none;
  display: none;
  z-index: 5;
}

.pkg-drop-line.is-visible {
  display: block;
}

.package-selected-path {
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.package-parts-help {
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.package-item {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.75);
  position: relative;
  padding-right: 66px;
  padding-bottom: 44px;
}

.package-item + .package-item {
  margin-top: 8px;
}

.package-item:hover {
  border-color: rgba(212, 160, 23, 0.35);
  transform: translateY(-1px);
}

.package-item.is-active {
  border-color: rgba(212, 160, 23, 0.65);
  box-shadow: 0 10px 20px rgba(20, 20, 20, 0.08);
}

.package-item-title {
  font-weight: 700;
  font-size: 0.92rem;
}

.package-item-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.package-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.tree-module {
  border: 1px solid rgba(212, 160, 23, 0.18);
  background: rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  padding: 12px;
}

.tree-module.is-selected {
  outline: 2px solid var(--pkg-guide);
  outline-offset: 4px;
}

.tree-module + .tree-module {
  margin-top: 12px;
}

.tree-reference {
  border-color: rgba(59, 130, 246, 0.25);
  background: #f8fbff;
}

.tree-reference-lock {
  cursor: default;
  color: #2563eb;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tree-reference-title {
  font-weight: 800;
  color: #1f2937;
}

.tree-reference-qty {
  width: 72px;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 9px;
}

.tree-reference-module {
  margin-left: var(--pkg-indent-group);
  padding: 10px 12px;
  border-left: 2px solid rgba(59, 130, 246, 0.32);
  border-top: 1px dashed rgba(59, 130, 246, 0.22);
}

.tree-reference-module-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: #374151;
}

.tree-reference-group {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.tree-module-header,
.tree-group-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.tree-module-header {
  margin-bottom: 10px;
}

.tree-module-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tree-module-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.tree-name-input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
}

.tree-group-name-input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 7px 10px;
  font-weight: 700;
  font-size: 0.85rem;
}

.tree-group {
  border-top: 1px dashed rgba(212, 160, 23, 0.25);
  margin-left: var(--pkg-indent-group);
  padding-left: 12px;
  border-left: 2px solid var(--pkg-guide-2);
  padding-top: 10px;
  margin-top: 10px;
}

.tree-group-title {
  font-weight: 700;
  font-size: 0.85rem;
}

.tree-group.is-selected {
  outline: 2px solid var(--pkg-guide);
  outline-offset: 4px;
  border-radius: 12px;
}

.tree-group-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.tree-parts {
  margin-top: 10px;
  /* Align part boxes with the start of the group name input (drag + collapse affordances). */
  margin-left: calc(var(--pkg-tree-prefix) - 10px);
  padding-left: 10px;
  border-left: 2px dotted var(--pkg-guide-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 18px;
}

.tree-part {
  display: grid;
  grid-template-columns: auto auto 1fr 88px auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(220, 213, 197, 0.9);
  border-radius: 12px;
  background: #ffffff;
}

.tree-part label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tree-part-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tree-part-sku {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-part-desc {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-part-qty {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
}

.tree-part-remove {
  border: 1px solid rgba(220, 213, 197, 0.9);
  background: rgba(244, 241, 234, 0.6);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  color: var(--muted);
}

.tree-part-remove:hover {
  border-color: rgba(212, 160, 23, 0.45);
  color: var(--text);
}

.parts-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(220, 213, 197, 0.9);
  background: rgba(255, 255, 255, 0.85);
  cursor: grab;
}

.parts-result:active {
  cursor: grabbing;
}

.parts-result + .parts-result {
  margin-top: 8px;
}

.parts-result-main {
  min-width: 0;
}

.parts-result-sku {
  font-size: 0.8rem;
  color: var(--muted);
}

.parts-result-desc {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.parts-result button {
  flex: none;
}

.parts-results-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 6px 2px 2px;
}

.parts-results-count {
  font-size: 0.8rem;
}

.parts-load-more {
  flex: 0 0 auto;
}

/* Drag handles */
.drag-handle {
  cursor: grab;
  opacity: 0.35;
  user-select: none;
  font-size: 0.85rem;
  padding: 0 2px;
  width: 18px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.drag-handle:hover {
  opacity: 0.75;
}
.drag-handle:active {
  cursor: grabbing;
}

/* Collapse toggle */
.collapse-toggle {
  cursor: pointer;
  user-select: none;
  font-size: 0.65rem;
  border: none;
  background: transparent;
  padding: 2px 4px;
  width: 18px;
  text-align: center;
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  display: inline-block;
}
.collapse-toggle:hover {
  opacity: 1;
}
.collapse-toggle.is-collapsed {
  transform: rotate(-90deg);
}

/* Delete buttons - structure tree */
.tree-delete-btn {
  border: 1px solid rgba(220, 213, 197, 0.9);
  background: rgba(244, 241, 234, 0.6);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 10px;
  opacity: 0.55;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.tree-module-header:hover .tree-delete-btn,
.tree-group-header:hover .tree-delete-btn {
  opacity: 1;
}
.tree-delete-btn:hover {
  opacity: 1 !important;
  background: rgba(200, 50, 50, 0.12);
  border-color: rgba(200, 50, 50, 0.25);
  color: #c33;
}

/* Delete buttons - package list */
.package-item-delete {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.12s;
  position: absolute;
  top: 8px;
  right: 8px;
}
.package-item:hover .package-item-delete {
  opacity: 0.9;
}
.package-item-delete:hover {
  opacity: 1 !important;
  background: rgba(200, 50, 50, 0.1);
  color: #c33;
}

.package-item-edit {
  border: 1px solid rgba(220, 213, 197, 0.9);
  background: rgba(244, 241, 234, 0.6);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 10px;
  opacity: 0.55;
  flex-shrink: 0;
  transition: opacity 0.12s, border-color 0.12s, background 0.12s, color 0.12s;
  position: absolute;
  right: 8px;
  bottom: 8px;
}

.package-item:hover .package-item-edit {
  opacity: 1;
}

.package-item-edit:hover {
  opacity: 1 !important;
  border-color: rgba(212, 160, 23, 0.45);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
}

@media (hover: none) {
  .tree-delete-btn {
    opacity: 0.8;
  }
  .package-item-edit {
    opacity: 0.85;
  }
  .package-item-delete {
    opacity: 0.7;
  }
}

/* Package name input (editable when selected) */
.package-item-name-input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 8px;
  padding: 3px 7px;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
  resize: vertical;
  min-height: 44px;
}

/* Drag over visual feedback */
.drag-over-above {
  box-shadow: inset 0 2px 0 rgba(212, 160, 23, 0.85) !important;
}
.drag-over-below {
  box-shadow: inset 0 -2px 0 rgba(212, 160, 23, 0.85) !important;
}

/* For module insertion/reorder, draw the line outside the module so it doesn't slice the background. */
.tree-module.drag-over-above {
  box-shadow: 0 -2px 0 rgba(212, 160, 23, 0.85) !important;
}
.tree-module.drag-over-below {
  box-shadow: 0 2px 0 rgba(212, 160, 23, 0.85) !important;
}
.is-dragging {
  opacity: 0.35;
}

/* Drop target feedback for library parts dropped into a group/module */
.drag-over-group {
  outline: 2px solid rgba(212, 160, 23, 0.65);
  outline-offset: 3px;
}

.tree-group-header.drag-over-group,
.tree-module-header.drag-over-group,
.tree-parts.drag-over-group {
  background: rgba(212, 160, 23, 0.1);
  border-radius: 10px;
}

.tree-parts.drag-over-group {
  min-height: 26px;
}

.tree-module.drag-over-denied {
  outline: 2px dashed rgba(158, 163, 173, 0.95);
  outline-offset: 3px;
  background: rgba(139, 145, 160, 0.08);
  cursor: not-allowed !important;
}

.tree-module-header.drag-over-denied {
  background: rgba(158, 163, 173, 0.16);
  border-radius: 10px;
  color: rgba(63, 70, 82, 0.9);
  cursor: not-allowed !important;
}

/* Expand drop zones during active drag so the last row/group is reachable */
.quote-rows.quote-drag-active {
  padding-bottom: 88px;
}
.quote-rows.quote-drag-active .quote-module {
  padding-bottom: 56px;
}
.quote-rows.quote-drag-active .quote-group {
  padding-bottom: 44px;
}

/* Collapsed module hides its groups */
.tree-module.is-collapsed .tree-group {
  display: none;
}

/* Collapsed group hides its parts */
.tree-group.is-collapsed .tree-parts {
  display: none;
}

/* Module header collapsed summary */
.tree-module-summary {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 2px;
}

/* Resize handles between panels */
.pkg-resize-handle {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  border-radius: 3px;
  transition: background 0.15s;
}
.pkg-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  left: -10px;
  width: 25px;
  height: 100%;
}
.pkg-resize-handle:hover,
.pkg-resize-handle.is-resizing {
  background: rgba(212, 160, 23, 0.35);
}

@media (max-width: 1080px) {
  .package-admin-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .pkg-resize-handle {
    display: none;
  }
}

.lead {
  font-size: 1.05rem;
  color: var(--muted);
}

.home-hero {
  margin-top: 2px;
}

.home-eyebrow {
  margin: 0 0 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.home-title {
  margin: 0 0 10px;
  font-size: 1.45rem;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.callout {
  margin-top: 28px;
  background: rgba(244, 201, 73, 0.15);
  border: 1px solid rgba(212, 160, 23, 0.2);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.about-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.about-list li + li {
  margin-top: 6px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-sm {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
}

.btn-primary {
  background: var(--accent);
  color: #1a1400;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-2);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(246, 196, 60, 0.45);
  color: var(--accent);
}

.btn-danger {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.45);
  color: rgb(180, 35, 24);
}

.btn-danger:hover {
  background: rgba(180, 35, 24, 0.14);
  border-color: rgba(180, 35, 24, 0.65);
}

.view-header {
  margin-bottom: 0;
}

.sheet-view .view-header {
  margin-bottom: 0;
}

.panel-meta.quote-meta {
  position: relative;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  min-height: 0;
  margin-bottom: 12px;
}

#view-quote-builder #quote-status:empty,
#view-quote-builder #quote-toast:empty,
#view-quote-builder #quote-removed:empty {
  display: none;
}

#view-quote-customers #quote-customer-status:empty {
  display: none;
}

#view-quote-builder #quote-toast.is-toast {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 25;
  max-width: min(420px, 92%);
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.quote-navbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
}

.quote-navbar-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
  row-gap: 10px;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  -ms-overflow-style: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
}

.quote-navbar-row-actions {
  align-items: center;
}

.quote-navbar-row::-webkit-scrollbar {
  height: 10px;
}

.quote-navbar-row::-webkit-scrollbar-thumb {
  background: rgba(20, 20, 20, 0.22);
  border-radius: 999px;
}

.quote-navbar-row::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}

.quote-navbar .inline-field {
  margin: 0;
}

.quote-customer-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.quote-customer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-customer-toolbar input[type="search"] {
  width: 320px;
  min-width: 200px;
}

.quote-customer-table-wrap {
  max-height: 560px;
}

.quote-customer-table {
  table-layout: fixed;
  min-width: 760px;
}

.quote-customer-table th,
.quote-customer-table td {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-customer-table tbody td {
  vertical-align: middle;
  padding: 8px 12px;
}

.quote-customer-table tbody td input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-size: 0.9rem;
  margin: -4px 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.quote-customer-table tbody td input:focus {
  background: #fff;
  outline: 2px solid rgba(246, 196, 60, 0.35);
}

.quote-customer-table-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
}

.quote-customer-table-actions .btn {
  min-width: 88px;
  text-align: center;
}

.quote-customer-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.quote-customer-status-pill.is-active {
  color: #0f5f36;
  background: rgba(28, 153, 88, 0.14);
  border: 1px solid rgba(28, 153, 88, 0.28);
}

.quote-customer-status-pill.is-inactive {
  color: #8a3b22;
  background: rgba(208, 92, 43, 0.12);
  border: 1px solid rgba(208, 92, 43, 0.25);
}

.quote-nav-item input,
.quote-nav-item select {
  min-width: 110px;
}

.quote-nav-item.quote-nav-customer-quick input {
  width: 320px;
  min-width: 320px;
}

.quote-nav-customer select {
  min-width: 260px;
}

.quote-nav-saved-quote select {
  width: 300px;
  min-width: 300px;
}

.quote-nav-number input {
  width: 170px;
  min-width: 170px;
  text-transform: uppercase;
  background: #e8e3d7;
  border-color: #c7beaa;
  color: #6f6960;
  cursor: text;
  box-shadow: none;
}

.quote-nav-number input[readonly]:focus {
  outline: 2px solid rgba(246, 196, 60, 0.22);
}

.quote-nav-description input {
  width: 240px;
  min-width: 240px;
}

.quote-nav-date input {
  min-width: 150px;
}

.quote-nav-currency select {
  min-width: 96px;
}

.quote-saved-quote-wrap {
  display: inline-flex;
  align-items: flex-end;
  gap: 6px;
}

.quote-delete-btn {
  min-width: 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
}

.quote-navbar-controls .btn-sm {
  white-space: nowrap;
}

.quote-add-menu {
  position: relative;
}

.quote-add-menu summary {
  list-style: none;
  user-select: none;
}

.quote-add-menu summary::-webkit-details-marker {
  display: none;
}

.quote-add-menu[open] .quote-add-menu-pop {
  display: flex;
}

.quote-add-menu-pop {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}

.quote-add-menu-pop .btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

@media (max-width: 900px) {
  .quote-navbar {
    overflow-x: visible;
  }
}

.sheet-header-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
  overflow: hidden;
}

.sheet-title {
  margin: 0;
  font-size: 1.4rem;
}

.sheet-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-subtitle:not(:empty)::before {
  content: "— ";
}

.tab-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.tab {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.tab.is-active {
  background: var(--accent);
  color: #1a1400;
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 20px;
  min-width: 0;
}

.sheet-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel-elevated {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-color: rgba(212, 160, 23, 0.25);
  box-shadow: 0 16px 34px rgba(20, 20, 20, 0.12);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.detail-section {
  grid-column: 1 / -1;
  border: 1px solid rgba(220, 213, 197, 0.9);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.detail-section.is-editable-section {
  border-color: rgba(212, 160, 23, 0.35);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(244, 241, 234, 0.72));
}

.detail-section-title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.detail-section-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.detail-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-field {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

.detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-badge {
  flex: 0 0 auto;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.detail-badge.is-editable {
  background: rgba(212, 160, 23, 0.16);
  border-color: rgba(212, 160, 23, 0.35);
  color: rgba(20, 20, 20, 0.92);
}

.detail-badge.is-locked {
  background: rgba(220, 213, 197, 0.35);
  border-color: rgba(220, 213, 197, 0.85);
  color: rgba(79, 84, 86, 0.9);
}

.detail-field.is-locked {
  background: rgba(247, 243, 235, 0.65);
  border-style: dashed;
  border-color: rgba(220, 213, 197, 0.95);
}

.detail-field.is-editable {
  border-color: rgba(212, 160, 23, 0.55);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.12);
}

.detail-value {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

[data-calc-tooltip="1"] {
  cursor: help;
}

.detail-value.detail-value-preview {
  color: #785a12;
  font-weight: 600;
}

.detail-input,
.detail-select,
.detail-textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
}

.detail-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.detail-input.field-error,
.detail-select.field-error,
.detail-textarea.field-error {
  border-color: rgba(240, 106, 106, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 106, 106, 0.4);
}

.field-error {
  border-color: rgba(240, 106, 106, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 106, 106, 0.4);
}

.duplicate-attribute-error {
  border-color: rgba(240, 106, 106, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 106, 106, 0.4);
}

.field-warning {
  border-color: rgba(246, 196, 60, 0.85);
  box-shadow: 0 0 0 1px rgba(246, 196, 60, 0.35);
}

.detail-error-message {
  margin-top: 6px;
  font-size: 0.72rem;
  color: rgba(240, 170, 170, 0.95);
}

.form-error-message {
  margin-top: 6px;
  font-size: 0.75rem;
  color: rgba(240, 170, 170, 0.95);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(680px, 92vw);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(20, 20, 20, 0.18);
}

.modal-card h3 {
  margin: 0 0 10px;
  color: var(--text);
}

.modal-choice {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(216, 209, 198, 0.9);
  border-radius: 12px;
  background: rgba(247, 243, 235, 0.9);
  color: var(--text);
  font-size: 0.92rem;
}

.modal-choice span {
  flex: 1;
}

.modal-choice input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
}

.modal-field {
  margin-top: 12px;
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 0.92rem;
}

.modal-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.modal-card.pkg-import-card {
  width: min(980px, 94vw);
  max-height: 86vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.pkg-import-module-list {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f7f3eb;
  padding: 10px;
  overflow: auto;
  flex: 1;
  min-height: 180px;
  scrollbar-gutter: stable both-edges;
}

.pkg-import-module {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 10px;
  border-radius: 12px;
}

.pkg-import-module:hover {
  background: rgba(235, 230, 219, 0.9);
}

.pkg-import-expand {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(210, 204, 192, 0.9);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.pkg-import-expand.is-collapsed {
  transform: rotate(-90deg);
}

.pkg-import-module-main {
  flex: 1;
  min-width: 0;
}

.pkg-import-module-title {
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.pkg-import-module-meta {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--muted);
}

.pkg-import-groups {
  margin: 8px 0 0 64px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pkg-import-group {
  border: 1px solid rgba(216, 209, 198, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  padding: 8px 10px;
}

.pkg-import-group summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--text);
  list-style: none;
}

.pkg-import-group summary::-webkit-details-marker {
  display: none;
}

.pkg-import-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pkg-import-group-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pkg-import-group-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.pkg-import-parts {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pkg-import-part {
  display: grid;
  grid-template-columns: 110px 1fr 60px;
  gap: 10px;
  align-items: start;
  font-size: 0.86rem;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(247, 243, 235, 0.9);
}

.pkg-import-part-sku {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pkg-import-part-desc {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pkg-import-part-qty {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.modal-subtitle {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--text);
}

.modal-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 0.9rem;
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.section-header {
  margin-bottom: 14px;
}

.section-header h3 {
  margin: 0 0 6px;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-meta-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.inline-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.inline-field span {
  font-weight: 600;
}

.inline-field input,
.inline-field select {
  width: 150px;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
}

.status-strong {
  font-weight: 600;
  color: var(--text);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-grid-span {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
}

#add-sku-form input[name="code"][readonly] {
  background: rgba(220, 213, 197, 0.28);
  border-color: rgba(220, 213, 197, 0.95);
  color: rgba(79, 84, 86, 0.82);
  cursor: not-allowed;
}

#add-sku-form input[name="code"].is-loading {
  cursor: progress;
  background: linear-gradient(
    90deg,
    rgba(220, 213, 197, 0.28),
    rgba(212, 160, 23, 0.14),
    rgba(220, 213, 197, 0.28)
  );
  background-size: 220% 100%;
  animation: addSkuCodeShimmer 1.1s ease-in-out infinite;
}

@keyframes addSkuCodeShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

option {
  background: #ffffff;
  color: var(--text);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

textarea.pkg-template-name {
  min-height: 54px;
  resize: vertical;
}

.chat-history {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  padding: 12px;
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.chat-line {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 8px;
}

.chat-line strong {
  color: var(--accent);
}

.chat-empty {
  font-size: 0.9rem;
  color: var(--muted);
}

.chat-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.chat-input-field {
  flex: 1;
  min-width: 240px;
}

.chat-input-field span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.panel-results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-results-header h4 {
  margin: 0;
}

.panel-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.quote-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: visible;
  padding: 12px;
}

.quote-empty-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 32px 24px;
  border: 2px dashed rgba(139, 145, 160, 0.35);
  border-radius: 14px;
  background: rgba(244, 241, 234, 0.65);
  text-align: center;
}

.quote-table {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
}

.quote-scroll {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  /* Let the browser decide when the horizontal scrollbar should appear. */
  display: flex;
  flex-direction: column;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
}

.quote-scroll-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
  /* Prevent the inner content from shrinking below its intrinsic grid width,
     so the outer container owns the horizontal scroll bar. */
  min-width: max-content;
  scrollbar-gutter: stable both-edges;
}

.quote-header {
  display: grid;
  grid-template-columns: 48px minmax(200px, 1.3fr) minmax(110px, 0.8fr) minmax(200px, 1.45fr) 84px 140px 140px 40px;
  gap: 12px;
  align-items: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 12px;
  background: linear-gradient(135deg, rgba(244, 241, 234, 0.96), rgba(241, 237, 228, 0.98));
  border-bottom: 1px solid var(--border);
}

.quote-table:not(.is-excel-view) .quote-header {
  display: none;
}

.quote-row {
  display: grid;
  grid-template-columns: 48px minmax(200px, 1.3fr) minmax(110px, 0.8fr) minmax(200px, 1.45fr) 84px 140px 140px 40px;
  gap: 12px;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.quote-table.is-excel-view .quote-header {
  grid-template-columns: calc(48px + var(--quote-excel-indent-check)) minmax(170px, 1.9fr) minmax(88px, 0.75fr) 84px 140px 140px 40px;
  gap: 8px;
  padding: 10px 12px;
}

.quote-table.is-excel-view .quote-header > :nth-child(2) {
  display: none;
}

.quote-table.is-excel-view .quote-header > :nth-child(5),
.quote-table.is-excel-view .quote-header > :nth-child(6),
.quote-table.is-excel-view .quote-header > :nth-child(7) {
  /* In List view we still keep these columns aligned, but don't show headers. */
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.quote-table.is-excel-view .quote-header > :nth-child(1),
.quote-table.is-excel-view .quote-header > :nth-child(3),
.quote-table.is-excel-view .quote-header > :nth-child(4) {
  /* Hide # / Description / SKU labels in List view while preserving column alignment. */
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.quote-excel-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: rgba(244, 241, 234, 0.55);
}

.quote-excel-section-title {
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}
.quote-excel-section-title:hover {
  text-decoration: underline;
}

.quote-excel-reorder-handle {
  border: none;
  background: transparent;
  color: inherit;
}

.quote-excel-row-handle {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  cursor: grab;
}
.quote-excel-row-handle:active {
  cursor: grabbing;
}

.quote-excel-section.quote-excel-module {
  font-weight: 700;
  color: var(--text);
  background: rgba(244, 241, 234, 0.85);
}

.quote-excel-section.quote-excel-group {
  font-weight: 600;
}

.quote-rows.is-excel-view,
.quote-table.is-excel-view {
  /* Visual hierarchy in List view */
  --quote-excel-indent-group: 16px;
  --quote-excel-indent-part: 6px;
  /* Align line checkboxes with the group include checkbox.
     Group checkbox starts at (header padding-left 12px + group indent + collapse-toggle 18px + gap 8px);
     rows have 6px left padding. */
  --quote-excel-indent-check: calc(12px + var(--quote-excel-indent-group) + 18px + 8px + 14px + 8px - 6px);
}

.quote-rows.is-excel-view .quote-excel-section.quote-excel-group {
  padding-left: calc(12px + var(--quote-excel-indent-group));
}

.quote-excel-section.is-excluded {
  opacity: 0.6;
}

.quote-rows.is-excel-view {
  padding: 0;
  gap: 0;
}

.quote-rows.is-excel-view.quote-drag-active {
  padding-bottom: 64px;
}

.quote-rows.is-excel-view .quote-row {
  grid-template-columns: calc(48px + var(--quote-excel-indent-check)) minmax(170px, 1.9fr) minmax(88px, 0.75fr) 84px 140px 140px 40px;
  padding: 4px 6px;
  gap: 8px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.quote-rows.is-excel-view .quote-note-row {
  margin-left: 0;
  background: rgba(255, 241, 191, 0.5);
}

.quote-rows.is-excel-view .quote-index {
  padding-left: var(--quote-excel-indent-check);
}

.quote-rows.is-excel-view .quote-row:first-child {
  border-top: 1px solid var(--border);
}

.quote-rows.is-excel-view .quote-text {
  font-size: 0.85rem;
}

.quote-rows.is-excel-view .quote-excel-part-input {
  width: 100%;
  font-size: 0.85rem;
  padding: 2px 6px;
  /* Slightly offset the Part field to visually separate it from the row index/checkbox column. */
  margin-left: var(--quote-excel-indent-part);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
}
.quote-rows.is-excel-view .quote-excel-name-input {
  margin-left: 0;
}

.quote-rows.is-excel-view .quote-excel-part-input::placeholder {
  color: rgba(40, 40, 40, 0.55);
}

.quote-rows.is-excel-view .quote-excel-part-input:focus {
  outline: none;
  border-color: rgba(212, 160, 23, 0.55);
  background: rgba(255, 255, 255, 0.92);
}

.quote-part-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 0.85rem;
}
.quote-part-input:focus {
  outline: none;
  border-color: rgba(212, 160, 23, 0.55);
  background: rgba(255, 255, 255, 0.92);
}

.quote-custom-row .quote-part-sku-input:disabled,
.quote-custom-row .quote-excel-sku-input:disabled {
  border-color: rgba(139, 118, 83, 0.28);
  background: linear-gradient(135deg, rgba(232, 226, 214, 0.9), rgba(243, 239, 231, 0.96));
  color: rgba(93, 79, 57, 0.62);
  cursor: not-allowed;
  opacity: 1;
}
.quote-part-fields {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(150px, 0.8fr);
  gap: 12px;
  align-items: end;
  min-width: 0;
}
.quote-part-suggestion-wrap {
  position: relative;
  width: 100%;
}
.quote-part-suggestions {
  position: absolute;
  left: 0;
  right: auto;
  top: calc(100% + 4px);
  z-index: 25;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  /* Wider than the input so suggestions are readable. */
  width: max(100%, 520px);
  max-width: 720px;
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.quote-part-suggestions[hidden] {
  display: none;
}
.quote-part-suggestions:empty {
  display: none;
}
.quote-part-suggestion {
  border: 1px solid rgba(26, 26, 26, 0.08);
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  text-align: left;
  padding: 7px 9px;
  font: inherit;
  cursor: pointer;
  display: grid;
  grid-template-areas: "desc sku meta";
  grid-template-columns: minmax(0, 1fr) minmax(110px, 170px) auto;
  align-items: center;
  gap: 8px;
}
.quote-part-suggestion:hover,
.quote-part-suggestion:focus-visible {
  border-color: rgba(212, 160, 23, 0.55);
  background: rgba(212, 160, 23, 0.06);
  outline: none;
}

.quote-part-suggestion-sku {
  grid-area: sku;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-part-suggestion-description {
  grid-area: desc;
  font-size: 0.74rem;
  line-height: 1.2;
  color: var(--muted);
  min-width: 0;
  /* Allow a bit more of the name to show without making items too tall. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
}

.quote-part-suggestion-meta {
  grid-area: meta;
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0.85;
}

.quote-part-suggestion-empty {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 8px 10px;
  text-align: center;
}

.quote-rows.is-excel-view .quote-remove {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.quote-group-header.drag-over-group {
  background: rgba(212, 160, 23, 0.08);
  border-radius: 12px;
}

.quote-module-header.drag-over-group {
  background: rgba(212, 160, 23, 0.08);
}

.quote-module {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quote-module-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(244, 241, 234, 0.8), rgba(241, 237, 228, 0.9));
}

.quote-module-title {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  flex: 1 1 auto;
  min-width: 0;
}
.quote-module-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.quote-module-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.quote-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: 14px;
}

.quote-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(244, 201, 73, 0.12);
}

.quote-group.is-selected .quote-group-header {
  border-color: rgba(212, 160, 23, 0.7);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.16);
}

.quote-group-title {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  text-align: left;
  flex: 1 1 auto;
  min-width: 0;
}

.quote-group-title:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.quote-group-meta {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.quote-section-counts {
  flex: 0 0 180px;
  text-align: right;
  font-weight: 500;
}

.quote-section-subtotal {
  flex: 0 0 120px;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.quote-part-row {
  margin-left: 28px;
}

.quote-part-row.is-excluded {
  opacity: 0.55;
}

.quote-note-row {
  margin-left: 28px;
  border-color: #d7b14d;
  background: linear-gradient(135deg, #fff8d9, #fff3c2);
}

.quote-note-row.is-excluded {
  opacity: 0.55;
}

.quote-note-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #d7b14d;
  border-radius: 10px;
  background: #fffdf0;
  padding: 8px 10px;
}

.quote-note-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.quote-note-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: #9c5d00;
  color: #fff8e4;
}

.quote-note-subtitle {
  font-size: 0.73rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7b4f11;
  font-weight: 700;
}

.quote-note-textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  border: 1px solid #c89f3a;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: #3a2a10;
  background: #fffef7;
}

.quote-note-textarea:focus {
  outline: none;
  border-color: #9c5d00;
  box-shadow: 0 0 0 3px rgba(156, 93, 0, 0.16);
}

.quote-removed {
  display: flex;
  align-items: center;
}

.quote-removed.is-hidden {
  display: none;
}

.quote-restore-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-restore-item {
  flex: 1;
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.quote-restore-forget {
  flex: none;
  width: 34px;
  padding-left: 0;
  padding-right: 0;
  opacity: 0.7;
}
.quote-restore-forget:hover {
  opacity: 1;
}

.quote-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}

.quote-field input {
  width: 100%;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
}

.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;
}

.quote-field-compact input {
  width: 100%;
}

.quote-index {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
}

.quote-include {
  display: inline-flex;
  align-items: center;
}

.quote-include input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.quote-index-text {
  min-width: 1.5ch;
}

.quote-edit-row-handle {
  cursor: grab;
  user-select: none;
}
.quote-edit-row-handle:active {
  cursor: grabbing;
}

.quote-remove {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  line-height: 1;
  font-size: 1.1rem;
}

#quote-add-row {
  cursor: grab;
}

#quote-add-note {
  cursor: grab;
}

#view-quote-builder .quote-add-menu-pop .btn:disabled,
#view-quote-builder .quote-add-menu-pop .btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  color: var(--muted);
}

#quote-add-row.is-dragging {
  cursor: grabbing;
}

#quote-add-note.is-dragging {
  cursor: grabbing;
}

.quote-value {
  font-size: 0.95rem;
  color: var(--text);
  align-self: center;
}

.quote-value[data-unit-id] {
  cursor: text;
}

.quote-value.is-manual-unit {
  font-weight: 700;
  color: #c33;
}

.quote-value.is-editing {
  padding: 0;
}

.quote-unit-edit-input {
  width: 100%;
  min-width: 120px;
  font-size: 0.85rem;
  padding: 4px 6px;
  border: 1px solid var(--accent);
  border-radius: 6px;
}

.quote-text {
  font-size: 0.9rem;
  color: var(--text);
}

.quote-sku {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quote-description {
  white-space: normal;
  word-break: break-word;
}

.quote-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.quote-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.quote-export-options {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.quote-export-option {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.quote-export-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
}

.quote-export-financial-field {
  gap: 8px;
}

.quote-export-financial-first {
  margin-left: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.quote-export-financial-field input {
  width: 96px;
  min-width: 96px;
}

.quote-export-financial-field.is-disabled {
  opacity: 0.68;
}

.quote-export-financial-field input:disabled {
  background: #e8e3d7;
  border-color: #c7beaa;
  color: #6f6960;
  cursor: not-allowed;
}

.quote-footer-total {
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  justify-content: flex-end;
}

.quote-footer-field {
  min-width: 120px;
}

.quote-footer-field input {
  width: 110px;
  min-width: 110px;
}

.quote-footer-total-label {
  margin-left: 8px;
}

.status-text {
  font-size: 0.85rem;
  color: var(--muted);
}

.status-text.is-error {
  color: #f2a65a;
}

.filter-panel {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #ffffff;
}

.filter-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.filter-panel[open] {
  max-height: min(35vh, 300px);
  overflow: auto;
  scrollbar-gutter: stable both-edges;
}

.column-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.column-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.column-panel-title::before {
  content: "›";
  display: inline-block;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 0.16s ease;
}

.column-panel[open] > .column-panel-title::before {
  transform: rotate(90deg);
}

.column-panel summary {
  cursor: pointer;
  list-style: none;
}

.column-panel summary::-webkit-details-marker {
  display: none;
}

.column-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 14px;
}

.column-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text);
}

.column-toggle input {
  accent-color: var(--accent);
}

.column-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.filter-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.filter-grid label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sheet-table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  max-width: 100%;
  flex: 1;
  min-height: 0;
  scrollbar-gutter: stable both-edges;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  background: #f4f1ea;
  color: var(--text);
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.sheet-table th,
.sheet-table td {
  min-width: 180px;
  max-width: 420px;
  white-space: normal;
  word-break: break-word;
}

.sheet-table th[data-column="sku"],
.sheet-table td[data-column="sku"] {
  white-space: nowrap;
}

.sheet-table .sticky-col {
  position: sticky;
  background: #f7f3eb !important;
  z-index: 2;
  box-shadow: 2px 0 0 rgba(228, 224, 214, 0.8);
}

.sheet-table thead .sticky-col {
  background: #f4f1ea !important;
  z-index: 4;
}

.sheet-table tbody td.sticky-col {
  background: #f7f3eb !important;
}

.sheet-table tbody tr:nth-child(even) td.sticky-col {
  background: #f1ede4 !important;
}

.sheet-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: top;
  background: #f7f3eb;
}

.sheet-table tbody tr:nth-child(even) td {
  background: #f1ede4;
}

.sheet-table input {
  width: 100%;
  background: #ffffff;
  border: 1px solid rgba(228, 224, 214, 0.8);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 0.85rem;
}

.sheet-textarea {
  width: 100%;
  min-height: 42px;
  background: #ffffff;
  border: 1px solid rgba(228, 224, 214, 0.8);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 0.85rem;
  resize: vertical;
  white-space: pre-wrap;
  line-height: 1.4;
}

.sheet-table input:focus {
  outline: 2px solid rgba(246, 196, 60, 0.35);
}

.sheet-textarea:focus {
  outline: 2px solid rgba(246, 196, 60, 0.35);
}

.sheet-table input.is-saving {
  opacity: 0.6;
}

.sheet-table .cell-muted {
  color: var(--muted);
}

.sku-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.sku-link:hover {
  color: var(--accent-2);
}

.sheet-pagination {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.login-screen {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(244, 201, 73, 0.22), rgba(255, 255, 255, 0.96)),
    #f9f7f2;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.login-page .login-screen {
  display: flex;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  width: min(420px, 90vw);
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 12px;
  border-radius: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.login-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(17, 24, 39, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-loading-text {
  display: block;
}

.google-button {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  min-height: 68px;
}

.muted {
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-shell {
  animation: rise-in 0.6s ease-out;
}

.sidebar {
  animation: rise-in 0.6s ease-out;
  animation-delay: 0.1s;
  animation-fill-mode: both;
}

.content {
  animation: rise-in 0.6s ease-out;
  animation-delay: 0.18s;
  animation-fill-mode: both;
}

.login-card {
  animation: rise-in 0.5s ease-out;
}

.admin-users-view.is-active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Prevent the "mystery" horizontal scrollbar; only allow vertical scrolling for the view. */
  overflow-x: hidden;
  overflow-y: auto;
}

.admin-users-table {
  /* Override base .sheet-table sizing to avoid an excessively wide admin grid. */
  min-width: 0;
  table-layout: fixed;
}

.admin-users-table th,
.admin-users-table td {
  min-width: 0;
  max-width: none;
}

.admin-users-table th:first-child,
.admin-users-table td:first-child {
  white-space: nowrap;
}

.admin-users-table th:nth-child(1),
.admin-users-table td:nth-child(1) {
  width: clamp(160px, 26%, 320px);
}

.admin-users-table th:nth-child(2),
.admin-users-table td:nth-child(2),
.admin-users-table th:nth-child(3),
.admin-users-table td:nth-child(3),
.admin-users-table th:nth-child(4),
.admin-users-table td:nth-child(4),
.admin-users-table th:nth-child(5),
.admin-users-table td:nth-child(5),
.admin-users-table th:nth-child(6),
.admin-users-table td:nth-child(6),
.admin-users-table th:nth-child(7),
.admin-users-table td:nth-child(7),
.admin-users-table th:nth-child(8),
.admin-users-table td:nth-child(8) {
  width: clamp(48px, 6%, 70px);
  text-align: center;
}

.admin-users-table th:nth-child(9),
.admin-users-table td:nth-child(9) {
  width: clamp(140px, 22%, 260px);
}

.admin-users-table th:nth-child(10),
.admin-users-table td:nth-child(10) {
  width: 80px;
  text-align: center;
}

.admin-users-table tbody td {
  padding: 6px 10px;
  vertical-align: middle;
}

.admin-users-table tbody tr:hover td {
  background: #ebe6db;
}

.admin-users-table tbody tr:hover td.sticky-col {
  background: #e5dfd1 !important;
}

.admin-user-email {
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-flag {
  vertical-align: middle;
}

.admin-user-action {
  vertical-align: middle;
}

.admin-user-action-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.admin-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}

.admin-action-save:hover {
  background: rgba(46, 125, 50, 0.10);
  border-color: rgba(46, 125, 50, 0.35);
  color: #2e7d32;
}

.admin-action-delete:hover {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.35);
  color: rgb(180, 35, 24);
}

.admin-save-toast {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #2e7d32;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  animation: admin-save-pop 1.2s ease forwards;
}

@keyframes admin-save-pop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(4px) scale(0.85); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-4px) scale(1); }
  70%  { opacity: 1; transform: translateX(-50%) translateY(-4px) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(0.9); }
}

.admin-user-ts {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.admin-user-updated-by {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-users-view .sheet-table-wrap {
  /* Avoid the "always visible" scroll gutter look on Windows; only show scrollbars when needed. */
  scrollbar-gutter: auto;
  /* Admin Users table is designed to fit within the panel; avoid horizontal scrollbars from rounding. */
  overflow-x: hidden;
}

.admin-user-flags {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .admin-user-flags {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 600px) {
  .admin-user-flags {
    grid-template-columns: 1fr;
  }
}

.admin-user-flag-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(20, 20, 20, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.35);
}

.admin-user-flag-field > span:first-child {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-user-flag-field > .admin-flag {
  margin-top: 2px;
}

.admin-flag {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 26px;
  cursor: pointer;
  user-select: none;
}

.admin-flag input[type="checkbox"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.admin-flag-ui {
  pointer-events: none;
  position: relative;
  width: 42px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(20, 20, 20, 0.18);
  box-shadow: inset 0 1px 2px rgba(20, 20, 20, 0.08);
  transition: background 140ms ease, border-color 140ms ease;
}

.admin-flag-ui::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(20, 20, 20, 0.22);
  transition: transform 140ms ease;
}

.admin-flag input[type="checkbox"]:checked + .admin-flag-ui {
  background: rgba(212, 160, 23, 0.6);
  border-color: rgba(212, 160, 23, 0.9);
}

.admin-flag input[type="checkbox"]:checked + .admin-flag-ui::after {
  transform: translateX(20px);
}

.admin-flag input[type="checkbox"]:focus-visible + .admin-flag-ui {
  outline: 2px solid rgba(246, 196, 60, 0.45);
  outline-offset: 2px;
}

.spot-pricing-shell {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 20px;
}

.spot-pricing-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.spot-pricing-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.spot-pricing-panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.spot-pricing-panel-head .muted {
  margin: 0;
}

.spot-pricing-grid {
  display: grid;
  gap: 14px;
}

.spot-pricing-input-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.spot-pricing-results-grid {
  grid-template-columns: 1fr;
}

.spot-pricing-result-value {
  font-size: 1rem;
  font-weight: 600;
  color: #5d4512;
}

.spot-pricing-total-card {
  grid-column: 1 / -1;
  border-color: rgba(212, 160, 23, 0.55);
  box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.08);
  background: linear-gradient(135deg, rgba(255, 250, 238, 0.96), rgba(248, 242, 226, 0.9));
}

.spot-pricing-total-card .spot-pricing-result-value {
  font-size: 1.25rem;
  color: #3b2a08;
}

.spot-pricing-rate-note {
  font-size: 0.82rem;
  text-align: left;
  max-width: 320px;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
  }

  .sidebar {
    padding: 14px;
  }

  .content,
  .quote-view.is-active,
  .quote-table,
  .quote-scroll {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .content {
    padding: 20px;
  }

  .content,
  .quote-view.is-active {
    overflow: hidden;
  }

  .quote-scroll {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 12px 16px;
    gap: 12px;
  }

  .topbar-view-title {
    font-size: 1rem;
    max-width: 60vw;
  }

  body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
    overflow: visible;
  }

  .sidebar {
    /* Keep the full nav reachable even if the Sheets list grows large. */
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    height: auto;
    max-height: 40dvh;
    overflow: auto;
  }


  .content {
    overflow: visible;
  }

  .spot-pricing-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .spot-pricing-panel-head {
    flex-direction: column;
  }

  .spot-pricing-rate-note {
    max-width: none;
    text-align: left;
  }
}
