:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf5;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2563c7;
  --accent-secondary: #7c3aed;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-self: start;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark.has-logo {
  background: var(--surface-2);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.nav-group:last-child {
  margin-bottom: 0;
}

.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0.35rem 0.85rem 0.35rem;
  opacity: 0.9;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--muted);
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: #fff; }

.main { padding: 1.5rem 2rem; overflow: auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.topbar h1 { font-size: 1.5rem; font-weight: 600; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.quick-jump {
  min-width: 9.5rem;
}

.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;
}

.tenant-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  min-width: 220px;
}

.view { display: none; }
.view.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.stat-card .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; margin-top: 0.35rem; }

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.panel h2 { font-size: 0.95rem; margin-bottom: 1rem; color: var(--muted); }
.panel-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel-header-row h2 { margin-bottom: 0; }

.list { list-style: none; }
.list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}
.list li:last-child { border-bottom: none; }
.list.mono li { font-family: ui-monospace, monospace; font-size: 0.8rem; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.toolbar { margin-bottom: 1rem; }
.toolbar select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font: inherit;
}

/* Products toolbar — modern search + filters */
.products-toolbar {
  gap: 0.75rem 1rem;
}

.products-toolbar .btn.primary {
  margin-top: 0;
  flex-shrink: 0;
}

.search-field {
  position: relative;
  flex: 1 1 16rem;
  min-width: 12rem;
  max-width: 28rem;
}

.search-field__icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

.search-field__input {
  width: 100%;
  height: 2.625rem;
  padding: 0 2.5rem 0 2.625rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-field__input::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.search-field__input:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--muted));
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-2));
}

.search-field__input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent),
    inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.search-field:focus-within .search-field__icon {
  color: var(--accent);
}

.search-field__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 1.125rem;
  width: 1.125rem;
  margin-right: 0.125rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9cb3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M18 6L6 18M6 6l12 12'/%3E%3C/svg%3E") center / contain no-repeat;
  cursor: pointer;
  opacity: 0.75;
}

.search-field__input::-webkit-search-cancel-button:hover {
  opacity: 1;
}

.products-toolbar__select {
  height: 2.625rem;
  min-width: 10.5rem;
  padding: 0 2rem 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b9cb3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.products-toolbar__select:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--muted));
}

.products-toolbar__select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  background: var(--surface-2);
  color: var(--accent);
}

.btn {
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  cursor: pointer;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dim); }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  max-width: 360px;
}

.toast.show { opacity: 1; transform: translateY(0); }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #1a2a44 0%, var(--bg) 55%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-card input,
.login-card select,
.login-card textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font: inherit;
}

.login-brand { margin-bottom: 0.5rem; }

.login-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.35rem 0 0;
  line-height: 1.35;
}

.error-text { color: #f87171; font-size: 0.85rem; }

.user-label { display: block; color: var(--accent); margin-top: 4px; }

.logout-btn { margin-top: auto; }

.btn.block { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

.quote-builder { display: flex; flex-direction: column; gap: 1rem; }

.quote-builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  gap: 1.25rem;
  align-items: start;
}

.quote-builder-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.quote-builder-aside {
  position: sticky;
  top: 1rem;
}

.quote-builder-aside .btn.block {
  margin-top: 1.25rem;
}

.aside-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -0.25rem 0 1rem;
  line-height: 1.4;
}

.quote-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  list-style: none;
  margin: 0 0 1rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--muted);
}

.quote-steps li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.quote-steps li.done {
  color: var(--success);
}

.quote-steps li.active {
  color: var(--accent);
  font-weight: 600;
}

/* OrderMation-style quote builder */
.quote-om {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quote-om-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.quote-om-toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
}

.quote-om-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 1.25rem;
  margin-left: auto;
}

.quote-om-totals {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.quote-om-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.quote-om-buttons .btn {
  margin-top: 0;
  white-space: nowrap;
}

.quote-om-totals strong {
  color: var(--text);
  margin-left: 0.35rem;
}

.quote-om-section {
  margin: 0;
}

.quote-om-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}

.quote-header-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.quote-header-panels {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 1280px) {
  .quote-header-panels {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}

@media (max-width: 640px) {
  .quote-header-panels {
    grid-template-columns: 1fr;
  }
}

.quote-header-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.quote-header-panel-notes {
  width: 100%;
}

.quote-panel-title {
  margin: 0;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 1px solid var(--border);
}

.quote-panel-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem;
  flex: 1;
}

.quote-field-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 0.85rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px dashed color-mix(in srgb, var(--border) 80%, transparent);
}

.quote-field-group:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.quote-group-title {
  margin: 0 0 0.15rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.quote-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 900px) {
  .quote-notes-grid {
    grid-template-columns: 1fr;
  }
}

.quote-header-panel label,
.quote-product-entry label,
.quote-product-row label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.quote-header-panel input,
.quote-header-panel select,
.quote-header-panel textarea,
.quote-product-entry input,
.quote-product-entry select,
.quote-product-entry textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
}

.quote-header-panel input:focus,
.quote-header-panel select:focus,
.quote-header-panel textarea:focus,
.quote-product-entry input:focus,
.quote-product-entry select:focus {
  outline: none;
  border-color: var(--accent);
}

.quote-header-panel textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.line-notes-field .line-notes-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.45;
  max-height: 12rem;
  overflow: auto;
}

.line-notes-field .line-notes-preview.hidden {
  display: none;
}

.line-notes-preview p {
  margin: 0 0 0.5rem;
}

.line-notes-preview p:last-child {
  margin-bottom: 0;
}

.line-notes-preview ul,
.line-notes-preview ol {
  margin: 0.35rem 0 0.5rem 1.25rem;
  padding: 0;
}

.line-notes-preview li {
  margin: 0.15rem 0;
}

.line-notes-preview strong,
.line-notes-preview b {
  font-weight: 600;
}

.line-notes-preview h1,
.line-notes-preview h2,
.line-notes-preview h3,
.line-notes-preview h4 {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.line-notes-field textarea.hidden {
  display: none;
}

.quote-summary-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.quote-summary-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.quote-summary-view,
.quote-pdf-preview,
#quoteDetailBody.quote-pdf-preview-host,
#poDetailBody.quote-pdf-preview-host {
  background: color-mix(in srgb, var(--border) 35%, var(--bg));
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.45;
  min-height: 28rem;
  height: min(70vh, 36rem);
  overflow: hidden;
}

.quote-summary-view > .muted,
.quote-pdf-preview > .muted,
#quoteDetailBody.quote-pdf-preview-host > .muted,
#poDetailBody.quote-pdf-preview-host > .muted {
  padding: 0.75rem 0.85rem;
  margin: 0;
}

.pdf-viewer-frame {
  width: 100%;
  height: 100%;
  min-height: 28rem;
  border: 0;
  display: block;
  background: var(--bg);
}

.quote-summary-view section + section {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.quote-summary-view h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.quote-summary-view dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(7rem, 34%) 1fr;
  gap: 0.2rem 0.65rem;
}

.quote-summary-view dt {
  margin: 0;
  color: var(--muted);
}

.quote-summary-view dd {
  margin: 0;
  word-break: break-word;
}

.quote-summary-view .summary-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.quote-summary-view .summary-lines li {
  padding: 0.45rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.quote-summary-view .summary-lines li:last-child {
  border-bottom: none;
}

.quote-summary-view .summary-line-title {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.quote-summary-view .summary-muted {
  color: var(--muted);
  font-size: 0.78rem;
}

.field-required input,
.field-required select,
.field-required textarea {
  background: color-mix(in srgb, #f5e6a8 18%, var(--bg));
}

.field-warn input {
  background: color-mix(in srgb, #f0c9a0 22%, var(--bg));
}

.field-readonly,
.field-readonly:focus {
  background: color-mix(in srgb, var(--muted) 8%, var(--bg));
  color: var(--muted);
  cursor: default;
}

.address-stack {
  gap: 0 !important;
}

.address-stack label {
  margin: 0;
}

.address-stack input {
  border-radius: 0;
  margin-top: 0;
}

.address-stack label:first-of-type input {
  border-radius: 6px 6px 0 0;
}

.address-stack label:last-of-type input {
  border-radius: 0 0 6px 6px;
}

.address-stack label + label input {
  border-top: none;
}

.address-stack .field-narrow {
  max-width: 9.5rem;
  margin-top: 0.35rem;
}

.address-stack .field-narrow input {
  border-radius: 6px;
  border-top: 1px solid var(--border);
}

.form-grid-pair {
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.input-with-actions {
  display: flex;
  gap: 0.35rem;
  align-items: stretch;
}

.input-with-actions select,
.input-with-actions input {
  flex: 1;
  min-width: 0;
}

.btn-icon {
  flex: 0 0 2rem;
  width: 2rem;
  height: auto;
  min-height: 2.1rem;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg));
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.btn-icon:hover {
  background: color-mix(in srgb, var(--accent) 28%, var(--bg));
}

.btn-icon:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quote-check-row,
.quote-check-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.quote-check-row {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.quote-header-panel .checkbox-label {
  font-size: 0.8rem;
  color: var(--text);
}

.quote-field-group-checks {
  padding-top: 0.25rem;
}

.quote-om-section .panel {
  padding: 1.25rem;
}

.quote-product-entry {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-inset {
  background: color-mix(in srgb, var(--bg) 60%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.quote-product-meta {
  max-width: 20rem;
  margin-bottom: 0.25rem;
}

.quote-product-row {
  grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.5rem;
}

.quote-lines-table-wrap {
  margin-top: 0.5rem;
}

.quote-lines-table {
  width: 100%;
  font-size: 0.82rem;
}

.quote-lines-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

.quote-lines-table td,
.quote-lines-table th {
  padding: 0.5rem 0.6rem;
}

.quote-lines-table .btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.quote-line-actions {
  white-space: nowrap;
}

.quote-line-actions .btn-sm + .btn-sm {
  margin-left: 0.25rem;
}

.quote-lines-table tr.quote-line-editing {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.quote-lines-table .input-compact {
  width: 100%;
  min-width: 4rem;
  max-width: 11rem;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.quote-lines-table tr.quote-line-editing td {
  vertical-align: middle;
}

.quote-lines-table .qb-row-product.input-compact {
  max-width: 14rem;
}

.quote-line-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.attention-panel {
  margin-bottom: 1.5rem;
}

.attention-panel-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.attention-list {
  list-style: none;
}

.attention-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.attention-list li:last-child {
  border-bottom: none;
}

.attention-list .btn {
  margin-top: 0;
}

.attention-calm {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.25rem 0;
}

.view-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  max-width: 48rem;
  line-height: 1.45;
}

.view-hint code {
  font-size: 0.8em;
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-grid-stack {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.form-grid label,
.quote-builder > label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.quote-builder textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.form-grid .span-full {
  grid-column: 1 / -1;
}

textarea {
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.panel label:has(textarea) {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.qb-lines { display: flex; flex-direction: column; gap: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.qb-line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.line-total { margin-top: 0.75rem; font-size: 0.9rem; color: var(--muted); }

.file-label input[type="file"] { margin-top: 0.35rem; }
.file-name { display: block; color: var(--success); font-size: 0.8rem; margin-top: 0.25rem; }

.qb-summary .summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.qb-summary .summary-row.total {
  font-size: 1.1rem;
  border-bottom: none;
  margin-top: 0.5rem;
}

.qb-summary h2 {
  margin-bottom: 0.35rem;
}

.artwork-form { display: flex; flex-direction: column; gap: 0.75rem; }

.artwork-list a { color: var(--accent); text-decoration: none; }
.artwork-list small { display: block; color: var(--muted); }

.artwork-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

input[type="date"].date-picker-only,
input[type="datetime-local"].date-picker-only,
input[type="month"].date-picker-only,
input[type="week"].date-picker-only {
  cursor: pointer;
  caret-color: transparent;
  position: relative;
}

input[type="date"].date-picker-only::-webkit-calendar-picker-indicator,
input[type="datetime-local"].date-picker-only::-webkit-calendar-picker-indicator,
input[type="month"].date-picker-only::-webkit-calendar-picker-indicator,
input[type="week"].date-picker-only::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.quote-preview-heading {
  flex: 1 0 100%;
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.quote-image-preview-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.35rem 0 0.75rem;
}

.quote-setup-grid {
  display: grid;
  gap: 1.25rem;
  margin: 1rem 0;
}

.quote-setup-grid .admin-widget-group h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.quote-image-preview-panel.hidden {
  display: none;
}

.quote-preview-item {
  position: relative;
  margin: 0;
  max-width: 140px;
}

.quote-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  min-width: 1.75rem;
  padding: 0.1rem 0.35rem;
  line-height: 1.2;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.quote-preview-thumb {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quote-preview-file {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
}

.quote-preview-item figcaption {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  line-height: 1.3;
  word-break: break-word;
}

.quote-preview-item figcaption a {
  color: var(--accent);
  text-decoration: none;
}

.quote-preview-item figcaption small {
  display: block;
  color: var(--muted);
}

.variant-list-item {
  margin-bottom: 0.75rem;
}

.variant-image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.variant-list-thumb {
  width: 72px;
  height: 72px;
}

.product-list-image-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.product-list-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.product-list-image-cell small {
  color: var(--muted);
  font-size: 0.7rem;
}

.form-panel { margin-bottom: 1rem; }
.form-panel h2 { margin-bottom: 1rem; font-size: 1rem; color: var(--muted); }

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 0.5rem;
  color: var(--text) !important;
}

.checkbox-label input { width: auto; }

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

.read-only-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.5rem;
}

.tab-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}

.tab-btn.active,
.tab-btn:hover {
  background: var(--accent-dim);
  color: #fff;
  border-color: var(--accent-dim);
}

.detail-panel { margin-top: 1.5rem; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.detail-header h2 { font-size: 1.25rem; color: var(--text); }

.detail-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.detail-notes {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  font-size: 0.9rem;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.detail-table th,
.detail-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.detail-totals {
  display: flex;
  gap: 1.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.actions-cell {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.inline-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-label select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  font: inherit;
}

.production-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
}

.modal-wide {
  width: min(760px, 100%);
}

.row-inactive {
  opacity: 0.65;
}

.table-actions {
  white-space: nowrap;
  text-align: right;
}

.modal-customer {
  width: min(960px, 100%);
}

.modal-lead {
  width: min(640px, 100%);
}

.modal-lead .modal-body {
  margin-bottom: 0;
}

.modal-lead .modal-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.customer-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.customer-picker label {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.customer-picker .btn {
  flex: 0 0 auto;
  margin-bottom: 0.15rem;
}

.customer-form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
  align-items: start;
}

@media (max-width: 768px) {
  .customer-form-layout {
    grid-template-columns: 1fr;
  }
}

.customer-form-section {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 1.25rem 0 0.65rem;
}

.customer-form-col > .customer-form-section:first-child {
  margin-top: 0;
}

.customer-form .form-grid-stack {
  margin-bottom: 0.25rem;
}

.customer-form .field-narrow {
  max-width: 9.5rem;
}

.customer-form .checkbox-label {
  margin: 0.5rem 0 0.75rem;
}

#custDeliveryFields.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.modal-customer .modal-header {
  margin-bottom: 0.75rem;
}

.modal-customer .modal-body {
  margin-bottom: 0;
}

.modal-customer .modal-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-body {
  margin-bottom: 1rem;
}

.crud-dl {
  display: grid;
  gap: 0.65rem;
}

.crud-dl-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.crud-dl-row dt {
  color: var(--muted);
  margin: 0;
}

.crud-dl-row dd {
  margin: 0;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell .btn {
  margin-right: 0.25rem;
}

@media (max-width: 960px) {
  .quote-builder-layout {
    grid-template-columns: 1fr;
  }

  .quote-builder-aside {
    position: relative;
    top: auto;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    position: relative;
    max-height: none;
    align-self: stretch;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
  }

  .nav {
    max-height: 42vh;
    overflow-y: auto;
    padding-right: 0.25rem;
  }
}

.hidden { display: none !important; }

.admin-intro,
.muted-text {
  color: var(--muted);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  position: relative;
  z-index: 5;
}

.admin-tab {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  position: relative;
  z-index: 1;
}

.admin-tab.active,
.admin-tab:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.admin-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.company-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.company-section-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.company-section-summary::-webkit-details-marker {
  display: none;
}

.company-section-summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-top: -0.2rem;
}

.company-section[open] > .company-section-summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}

.company-section-summary:hover {
  background: var(--surface-2);
}

.company-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.company-section-body {
  padding: 1.5rem 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

.company-section-body .panel {
  border: none;
  padding: 0;
  background: transparent;
}

.company-section-body .form-panel {
  margin-bottom: 0;
}

.company-subsection-title {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.admin-logo-preview {
  max-width: 180px;
  max-height: 80px;
  margin: 1rem 0;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 0.5rem;
}

.admin-widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.admin-widget-check {
  font-size: 0.875rem;
}

.table-actions {
  white-space: nowrap;
  text-align: right;
  width: 1%;
}

.table-action-trigger {
  display: inline-flex;
  justify-content: flex-end;
}

.row-action-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
}

.row-action-toggle:hover {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.row-action-toggle[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  border-color: var(--accent);
  color: var(--accent);
}

.row-action-chevron {
  font-size: 0.65rem;
  opacity: 0.9;
}

.list-view-menu-item.danger {
  color: #f87171;
}

.list-view-menu-item.danger:hover:not(:disabled) {
  background: color-mix(in srgb, #f87171 14%, var(--surface-2));
}

.admin-dashboard-subhead {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted, #9aa8bc);
}

.stat-card.dashboard-report-widget {
  grid-column: span 2;
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.stat-card.dashboard-report-widget .dashboard-report-body {
  flex: 1;
  margin-top: 0.5rem;
  min-height: 0;
}

.stat-card.dashboard-report-widget .value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.35rem;
}

.table-wrap-compact {
  max-height: 200px;
  overflow: auto;
}

.table-wrap-compact .data-table {
  font-size: 0.8rem;
}

.table-wrap-compact .data-table th,
.table-wrap-compact .data-table td {
  padding: 0.35rem 0.5rem;
}

@media (min-width: 900px) {
  .stat-card.dashboard-report-widget:has(table) {
    grid-column: span 3;
  }
}

.admin-role-dashboards {
  display: grid;
  gap: 1rem;
}

.list-plain {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-plain li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.list-plain li.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.admin-role-panel h3 {
  text-transform: capitalize;
  margin-bottom: 0.5rem;
}

.table-wrap {
  overflow-x: auto;
}

.list-view-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.5rem 0 0.75rem;
}

.list-view-menu {
  position: fixed;
  z-index: 1200;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 0.35rem;
}

.list-view-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
}

.list-view-menu-item:hover {
  background: var(--surface-2);
}

.list-view-chooser-modal {
  max-width: 28rem;
}

.list-view-chooser-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.column-chooser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem 1rem;
}

.column-chooser-item {
  font-size: 0.9rem;
}

.list-view-filters {
  margin-bottom: 0.75rem;
}

.list-view-filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.list-view-search {
  flex: 1 1 14rem;
  min-width: 12rem;
}

.list-view-search input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.list-view-result-count {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: auto;
}

.list-view-field-filters {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.list-view-field-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.65rem 1rem;
}

.list-view-field-filter {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.list-view-field-filter span {
  color: var(--muted);
}

.list-view-field-filter input,
.list-view-field-filter select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

.list-view-menu-item + .list-view-menu-item {
  border-top: 1px solid var(--border);
}

.modal-comments-screen {
  width: min(52rem, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.comments-screen-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}

.comments-screen-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: normal;
}

.comments-screen-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.comments-new-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

.comment-row-num {
  display: inline-block;
  min-width: 1.25rem;
  margin-right: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.comments-screen-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.comments-grid-wrap {
  flex: 1;
  min-height: 12rem;
  max-height: 22rem;
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--bg);
}

.comments-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.comments-grid th,
.comments-grid td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.comments-grid thead tr:first-child th {
  background: var(--surface-2);
  font-weight: 600;
}

.comments-grid-filters th {
  background: var(--surface);
  padding: 0.25rem;
}

.comments-grid-filters input {
  width: 100%;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
}

.comments-grid-empty td {
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

.comment-col-name {
  width: 8rem;
  white-space: nowrap;
}

.comment-col-body {
  min-width: 0;
}

.comment-body-text {
  margin: 0 0 0.35rem;
  white-space: pre-wrap;
}

.comment-saved-at {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.comment-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.comment-attach-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.75rem;
  max-width: 6.5rem;
}

.comment-attach-item:hover {
  border-color: var(--accent, #3b82f6);
}

.comment-attach-image img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: 4px;
}

.comment-attach-file {
  flex-direction: row;
  max-width: none;
  padding: 0.4rem 0.6rem;
}

.comment-attach-pending-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.comment-attach-pending {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.comment-attach-pending-thumb {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: cover;
  border-radius: 4px;
}

.comment-attach-pending-name {
  font-size: 0.8rem;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comments-attach-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.comments-draft {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--bg);
  color: var(--text);
}

.comments-action-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.comments-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  min-height: 4.5rem;
}

.comments-action-btn:hover {
  background: var(--surface);
  border-color: var(--accent, #3b82f6);
}

.comments-action-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.comments-action-save {
  font-weight: 600;
}

.quote-comment-file-list {
  font-size: 0.85rem;
}

.quote-comment-file-list.hidden {
  display: none;
}

.list-view-menu-item.hidden {
  display: none;
}

.list-view-menu-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sync-status {
  display: block;
  margin-top: 0.25rem;
}

.sync-status.running {
  color: var(--accent, #3b82f6);
}

.sync-status.failed,
.sync-status.partial_success {
  color: #b91c1c;
  font-weight: 600;
}

.sync-status.success {
  color: #15803d;
}

.sync-error-msg {
  display: block;
  margin-top: 0.2rem;
  color: #b91c1c;
  font-weight: 500;
}

.sync-failures {
  margin-top: 0.35rem;
  font-size: 0.8rem;
}

.sync-failures summary {
  cursor: pointer;
  color: var(--text-muted, #64748b);
}

.sync-failures ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.sync-failure-group {
  margin-top: 0.5rem;
}

.sync-failure-group + .sync-failure-group {
  margin-top: 0.75rem;
}

.sync-batch-progress {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted, #64748b);
  font-size: 0.8rem;
}

.sync-batch-label {
  display: block;
  margin-bottom: 0.2rem;
}

.sync-batch-bar {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  overflow: hidden;
}

.sync-batch-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #3b82f6);
  transition: width 0.3s ease;
}

.job-card-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.job-card-subsection {
  background: color-mix(in srgb, var(--bg) 50%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.job-card-subsection-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 1px solid transparent;
}

.job-card-subsection[open] > .job-card-subsection-title {
  border-bottom-color: var(--border);
}

.job-card-subsection-title::-webkit-details-marker {
  display: none;
}

.job-card-subsection-title::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-top: -0.2rem;
}

.job-card-subsection[open] > .job-card-subsection-title::after {
  transform: rotate(-135deg);
  margin-top: 0.2rem;
}

.job-card-specs-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.job-card-spec-group {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}

.job-card-spec-group:last-child {
  border-bottom: none;
}

.job-card-spec-options {
  margin-top: 0.35rem;
}

.job-card-spec-options .checkbox-label {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}

.job-card-subsection .quote-panel-body label:not(.checkbox-label),
#qbJobCardSection .quote-panel-body label:not(.checkbox-label) {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.job-card-subsection .quote-panel-body input:not([type="checkbox"]),
.job-card-subsection .quote-panel-body textarea,
#qbJobCardSection .quote-panel-body input:not([type="checkbox"]),
#qbJobCardSection .quote-panel-body textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
}

.job-card-subsection .quote-panel-body input:not([type="checkbox"]):focus,
.job-card-subsection .quote-panel-body textarea:focus,
#qbJobCardSection .quote-panel-body input:not([type="checkbox"]):focus,
#qbJobCardSection .quote-panel-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.job-card-subsection .quote-panel-body textarea,
#qbJobCardSection .quote-panel-body textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.company-section-body .form-grid-stack {
  margin-bottom: 0.75rem;
}

.company-section-body .form-grid-stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.company-section-body .form-grid-stack input,
.company-section-body .form-grid-stack textarea,
.company-section-body .form-grid-stack select {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
}

.company-section-body .form-grid-stack input:focus,
.company-section-body .form-grid-stack textarea:focus,
.company-section-body .form-grid-stack select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.company-section-body .form-grid-stack textarea {
  min-height: 4.5rem;
  resize: vertical;
}

.job-card-admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.job-card-admin-list .company-section {
  margin-bottom: 0;
}

/* Purchase Order Dashboard — single-screen layout */
#view-po-dashboard.view.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 4.5rem);
  max-height: calc(100vh - 4.5rem);
  overflow: hidden;
  margin: -0.25rem 0 0;
}

.po-dashboard-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0.35rem;
}

.po-toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0;
  flex-shrink: 0;
}

.po-search-label {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
}

.po-search-input {
  width: 100%;
  max-width: 200px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
}

.po-dashboard-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.po-dashboard-scaler {
  width: 100%;
}

.po-dashboard-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.72rem;
  line-height: 1.25;
}

.po-dashboard-table th,
.po-dashboard-table td {
  border: 1px solid var(--border);
  padding: 0.2rem 0.25rem;
  vertical-align: middle;
  background: var(--surface);
}

.po-dashboard-table thead th {
  vertical-align: bottom;
}

.po-thead-sticky {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 var(--border);
}

.po-section-row th {
  text-align: center;
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.2rem;
  white-space: normal;
}

.po-header-labels th {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.35rem 0.2rem;
  text-align: center;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  line-height: 1.25;
}

.po-sortable {
  cursor: pointer;
  user-select: none;
}

.po-sortable:hover {
  background: color-mix(in srgb, var(--accent, #2563eb) 8%, var(--surface));
}

.po-sortable[data-sort-dir="asc"]::after {
  content: " ▲";
  font-size: 0.55rem;
  opacity: 0.85;
}

.po-sortable[data-sort-dir="desc"]::after {
  content: " ▼";
  font-size: 0.55rem;
  opacity: 0.85;
}

.po-filter-row th {
  padding: 0.15rem 0.2rem;
  vertical-align: middle;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
}

.po-col-filter {
  width: 100%;
  box-sizing: border-box;
  padding: 0.15rem 0.2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.6rem;
  min-width: 0;
}

.po-col-filter:focus {
  outline: 2px solid color-mix(in srgb, var(--accent, #2563eb) 40%, transparent);
  outline-offset: 0;
}

.po-label-cell {
  text-align: left;
}

.po-field-label {
  display: block;
  font-weight: 600;
  font-size: 0.68rem;
  line-height: 1.3;
  word-break: break-word;
}

.po-section-general { background: color-mix(in srgb, var(--text) 10%, var(--surface)); }
.po-section-factory { background: color-mix(in srgb, #e8a87c 30%, var(--surface)); }
.po-section-client { background: color-mix(in srgb, #7eb8e8 25%, var(--surface)); }
.po-section-comments { background: color-mix(in srgb, #d4a5d9 20%, var(--surface)); }

.po-col-text { width: 6%; }
.po-col-date { width: 6.5%; }
.po-col-factory { width: 6.5%; }
.po-col-check { width: 4.3%; text-align: center; }
.po-col-comment { width: 10%; }

.po-dashboard-table tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.po-date-cell {
  text-align: center;
  vertical-align: middle;
  padding: 0.25rem 0.15rem !important;
}

.po-check-cell {
  text-align: center;
  padding: 0.1rem !important;
}

.po-check-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
}

.po-check-label input[type="checkbox"] {
  width: 0.85rem;
  height: 0.85rem;
  margin: 0;
  cursor: pointer;
}

.po-date-input,
.po-text-input,
.po-factory-select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 0.2rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.65rem;
}

.po-date-input {
  display: block;
  height: 1.65rem;
  margin: 0 auto;
  padding: 0.15rem 0.2rem;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.po-date-cell .po-date-input {
  max-width: 100%;
}

.po-date-input::-webkit-calendar-picker-indicator {
  margin-left: 0;
  cursor: pointer;
  opacity: 0.75;
}

.po-comment-preview,
.po-comment-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.1rem 0.15rem;
  border-radius: 4px;
  font: inherit;
  font-size: 0.65rem;
}

.po-comment-btn {
  text-align: center;
  color: var(--accent);
  font-weight: 700;
}

.po-comment-preview:hover,
.po-comment-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.po-comment-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.po-empty {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
}

.po-detail-body {
  display: grid;
  gap: 0.75rem;
}

.po-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.35rem 1rem;
}

.po-detail-lines {
  margin: 0;
  padding-left: 1.25rem;
}

.po-number-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.modal-backdrop-po-pdf {
  padding: 0.35rem;
  align-items: stretch;
  justify-content: stretch;
}

.modal-backdrop-po-pdf .modal-pdf-viewer {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-backdrop-po-pdf .modal-pdf-viewer .modal-header {
  flex-shrink: 0;
}

.modal-backdrop-po-pdf .modal-pdf-viewer .po-pdf-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-backdrop-po-pdf .modal-pdf-viewer .pdf-viewer-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  display: block;
  background: var(--bg);
}

.po-number-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--accent, #2563eb);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.68rem;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.po-number-link:hover {
  color: color-mix(in srgb, var(--accent, #2563eb) 80%, var(--text));
}

.po-view-btn {
  flex-shrink: 0;
}

.factory-card {
  margin-bottom: 0.75rem;
}

.email-sender-card {
  margin-bottom: 0.75rem;
}

.modal-section-title {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
}
