:root {
  --workspace-header-scroll-offset: 5.5rem;
  color-scheme: light;
  font-family: Arial, sans-serif;
  line-height: 1.5;
  color: #1f2937;
  background: #f5f7fa;
}

html {
  scroll-padding-top: var(--workspace-header-scroll-offset);
}

body {
  margin: 0;
}

[hidden] {
  display: none !important;
}

a {
  color: #0f766e;
}

.skip-link {
  background: #111827;
  color: #ffffff;
  left: 1rem;
  padding: 0.5rem 0.75rem;
  position: fixed;
  top: -3rem;
  z-index: 200;
}

.skip-link:focus {
  top: 0.75rem;
}

.app-header {
  background: #ffffff;
  border-bottom: 1px solid #d8dee6;
}

.app-header-sticky {
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 auto;
  max-width: 1120px;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
}

.brand {
  color: #111827;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-back-button {
  align-items: center;
  background: #eef2f7;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #111827;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: 0.3rem;
  min-height: 2.25rem;
  padding: 0.4rem 0.6rem;
  text-decoration: none;
  white-space: nowrap;
}

.nav-back-button:hover:not(:disabled):not(.is-disabled),
.nav-back-button:focus:not(:disabled):not(.is-disabled) {
  background: #e0f2f1;
  border-color: #99f6e4;
}

.nav-back-button:disabled,
.nav-back-button.is-disabled {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #6b7280;
  cursor: not-allowed;
  opacity: 0.65;
  pointer-events: none;
  user-select: none;
}

.nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}

.nav-menu-toggle {
  display: none;
}

.nav-link {
  border-radius: 4px;
  color: #374151;
  font-weight: 600;
  padding: 0.4rem 0.55rem;
  text-decoration: none;
}

.nav-link:hover,
.nav-link:focus {
  background: #eef2f7;
  color: #111827;
}

.nav-link.is-active {
  background: #0f766e;
  color: #ffffff;
}

.nav-link-notifications {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
}

.nav-badge {
  background: #b91c1c;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  min-width: 1.25rem;
  padding: 0.22rem 0.35rem;
}

.nav-link.is-active .nav-badge {
  background: #ffffff;
  color: #0f766e;
}

.nav-link-system {
  border-left: 1px solid #d8dee6;
  border-radius: 0;
  margin-left: 0.25rem;
  padding-left: 0.8rem;
}

.nav-user {
  align-items: flex-end;
  color: #4b5563;
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  line-height: 1.2;
  min-width: max-content;
}

.nav-user-label {
  color: #6b7280;
}

.nav-user-name {
  color: #111827;
  font-weight: 700;
}

.nav-account-link {
  color: #0f766e;
  font-weight: 700;
  text-decoration: none;
}

.nav-account-link:hover,
.nav-account-link:focus,
.nav-account-link.is-active {
  text-decoration: underline;
}

.nav-logout-form {
  margin: 0;
}

.nav-logout-button {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #374151;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 0.4rem 0.55rem;
}

.nav-logout-button:hover,
.nav-logout-button:focus {
  background: #eef2f7;
  color: #111827;
}

.app-main {
  margin: 0 auto;
  max-width: 1120px;
  padding: 1.5rem 1rem 3rem;
}

.has-sticky-header .app-main,
.has-sticky-header [id] {
  scroll-margin-top: var(--workspace-header-scroll-offset);
}

.messages {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.workspace-page-guard {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #7c2d12;
}

.workspace-page-guard-panel {
  align-items: center;
  display: grid;
  gap: 0.35rem 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0 auto;
  max-width: 1120px;
  padding: 0.75rem 1rem;
}

.workspace-page-guard-title,
.workspace-page-guard-message {
  margin: 0;
}

.workspace-page-guard-title {
  color: #7c2d12;
  font-weight: 700;
}

.workspace-page-guard-message {
  grid-column: 1;
}

.workspace-page-guard-action {
  align-self: center;
  background: #ffffff;
  border: 1px solid #fdba74;
  border-radius: 4px;
  color: #7c2d12;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: 0.45rem 0.7rem;
}

.workspace-page-guard-action:hover,
.workspace-page-guard-action:focus {
  background: #ffedd5;
}

.workspace-page-guard.is-exceeded {
  background: rgba(17, 24, 39, 0.42);
  border: 0;
  bottom: 0;
  color: #111827;
  display: grid;
  left: 0;
  place-items: start center;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 300;
}

.workspace-page-guard.is-exceeded .workspace-page-guard-panel {
  background: #ffffff;
  border: 1px solid #f97316;
  border-radius: 6px;
  box-shadow: 0 18px 45px rgba(17, 24, 39, 0.22);
  margin-top: 5rem;
  max-width: 42rem;
  width: calc(100% - 2rem);
}

.workspace-page-guard.is-exceeded .workspace-page-guard-title {
  color: #9a3412;
}

.message {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-left-width: 4px;
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.message-success {
  border-left-color: #0f766e;
}

.message-info {
  border-left-color: #2563eb;
}

.message-warning {
  border-left-color: #b45309;
}

.message-error {
  border-left-color: #b91c1c;
}

.page-title {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

h1,
h2,
h3 {
  color: #111827;
  margin: 0 0 0.75rem;
}

table {
  background: #ffffff;
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: #4b5563;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.panel {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  margin-bottom: 1rem;
  padding: 1rem;
}

.stats-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 1rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  padding: 1rem;
}

.stat-card strong {
  color: #111827;
  display: block;
  font-size: 2rem;
  line-height: 1.1;
}

.stat-card-note {
  color: #4b5563;
  font-size: 0.9rem;
  margin: 0.75rem 0 0;
}

.meta-grid {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.attachment-preview-frame {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 4px;
  box-sizing: border-box;
  min-height: 28rem;
  width: 100%;
}

.attachment-preview-image {
  border: 1px solid #d8dee6;
  border-radius: 4px;
  display: block;
  height: auto;
  max-height: 32rem;
  max-width: 100%;
}

.field-label {
  color: #6b7280;
  display: block;
  font-size: 0.85rem;
}

.button {
  background: #0f766e;
  border: 0;
  border-radius: 4px;
  color: #ffffff;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.button.secondary {
  background: #4b5563;
}

.button.text-button {
  background: transparent;
  color: #0f766e;
  padding: 0;
}

.back-link {
  color: #0f766e;
  display: inline-flex;
  font-weight: 700;
  margin-bottom: 0.75rem;
  text-decoration: none;
}

.back-link::before {
  content: "←";
  margin-right: 0.35rem;
}

.back-link:hover,
.back-link:focus {
  text-decoration: underline;
}

.empty {
  color: #6b7280;
  margin: 0;
}

.dashboard-panels {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.dashboard-list {
  display: grid;
  gap: 0.85rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-list-item {
  align-items: flex-start;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-bottom: 0.85rem;
}

.dashboard-list-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.dashboard-item-meta {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-align: right;
}

.dashboard-status {
  background: #ecfdf5;
  border-radius: 999px;
  color: #065f46;
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
}

.dashboard-status-alert {
  background: #fff7ed;
  color: #9a3412;
}

.status-pill {
  background: #ecfdf5;
  border-radius: 999px;
  color: #065f46;
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.status-pill-alert {
  background: #fff7ed;
  color: #9a3412;
}

.notification-row-unread {
  background: #f8fafc;
}

.notification-summary {
  color: #4b5563;
  margin: 0.35rem 0 0;
}

.inline-action-form {
  margin: 0;
}

.list-filters {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  margin-bottom: 1rem;
  padding: 1rem;
}

.filter-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.filter-field-wide {
  grid-column: span 2;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.form-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #991b1b;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.form-errors ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.form-row {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-row label {
  color: #111827;
  font-weight: 600;
}

.form-row input,
.form-row select,
.form-row textarea {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font: inherit;
  padding: 0.6rem 0.7rem;
  width: 100%;
}

.form-row input[type="checkbox"] {
  width: auto;
}

.inquiry-source-segmented {
  align-items: stretch;
  background: #eef2f7;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  display: inline-flex;
  gap: 0.2rem;
  max-width: 100%;
  padding: 0.2rem;
  position: relative;
  width: fit-content;
}

.inquiry-source-segmented input[type="checkbox"] {
  border: 0;
  height: 1px;
  left: 50%;
  margin: 0;
  opacity: 0;
  padding: 0;
  pointer-events: none;
  position: absolute;
  top: 50%;
  width: 1px;
}

.inquiry-source-segmented:focus-within {
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.18);
}

.inquiry-source-option {
  align-items: center;
  border-radius: 999px;
  color: #4b5563;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 0.3rem;
  justify-content: center;
  margin: 0;
  min-height: 2.2rem;
  min-width: 4.25rem;
  padding: 0.35rem 0.85rem;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.inquiry-source-option:hover {
  color: #111827;
}

.inquiry-source-segmented input[type="checkbox"]:not(:checked) ~ .inquiry-source-option-no,
.inquiry-source-segmented input[type="checkbox"]:checked ~ .inquiry-source-option-yes {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.12);
  color: #111827;
}

.inquiry-source-segmented input[type="checkbox"]:not(:checked) ~ .inquiry-source-option-no span[aria-hidden="true"] {
  color: #b91c1c;
}

.inquiry-source-segmented input[type="checkbox"]:checked ~ .inquiry-source-option-yes span[aria-hidden="true"] {
  color: #0f766e;
}

.form-row textarea {
  min-height: 6rem;
  resize: vertical;
}

.form-row ul.errorlist {
  color: #b91c1c;
  margin: 0;
  padding-left: 1.25rem;
}

.form-help {
  color: #6b7280;
  font-size: 0.9rem;
  margin: 0;
}

.form-row.has-errors input,
.form-row.has-errors select,
.form-row.has-errors textarea {
  border-color: #dc2626;
}

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

.quick-update-form {
  align-items: end;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(3, minmax(7rem, 1fr)) auto;
  min-width: 32rem;
}

.activity-quick-update-form {
  grid-template-columns: minmax(7rem, 1fr) minmax(11rem, 1fr) auto;
  min-width: 26rem;
}

.quick-update-form label {
  margin: 0;
}

.quick-update-form label span {
  color: #4b5563;
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.quick-update-form input,
.quick-update-form select {
  min-width: 7rem;
  padding: 0.42rem 0.5rem;
  width: 100%;
}

.quick-update-readonly-field {
  color: #111827;
  display: block;
  min-width: 7rem;
}

.quick-update-readonly-field span {
  color: #4b5563;
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.quick-update-readonly-field strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 2.35rem;
  padding: 0.5rem 0;
}

.button.compact {
  min-height: 2.35rem;
  padding: 0.42rem 0.65rem;
}

.type-detail-panel {
  border-top: 1px solid #e5e7eb;
  margin-top: 1rem;
  padding-top: 1rem;
}

.dynamic-form-row {
  border-bottom: 1px solid #eef2f7;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
}

.dynamic-form-row .form-row {
  margin-bottom: 0.5rem;
}

.inquiry-product-row-list {
  display: grid;
  gap: 0.6rem;
}

.inquiry-product-row {
  align-items: center;
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.inline-list {
  display: grid;
  gap: 0.2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.form-pending-note,
.htmx-indicator {
  color: #6b7280;
  display: none;
  font-size: 0.9rem;
  margin: 0;
}

.is-submitting .form-pending-note {
  display: inline;
}

.auth-page {
  background: #eef2f7;
}

.auth-page .app-main {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding-bottom: 2rem;
  padding-top: 2rem;
}

.auth-shell {
  margin: 0 auto;
  max-width: 420px;
  width: 100%;
}

.auth-panel {
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  padding: 1.5rem;
}

.auth-heading {
  margin-bottom: 1.25rem;
}

.auth-kicker {
  color: #0f766e;
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.auth-form .form-actions {
  margin-top: 1.25rem;
}

.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
  display: block;
}

.results-shell {
  display: grid;
  gap: 1rem;
}

.section-header {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}

.section-toggle {
  font-size: 0.95rem;
}

.section-toggle-label {
  pointer-events: none;
}

.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

@media (max-width: 760px) {
  :root {
    --workspace-header-scroll-offset: 11rem;
  }

  .page-title {
    flex-direction: column;
  }

  .nav-user {
    align-items: flex-start;
    order: 4;
    width: 100%;
  }

  .js-enabled .nav-menu-toggle {
    background: #eef2f7;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #111827;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 600;
    margin-left: auto;
    padding: 0.45rem 0.7rem;
  }

  .js-enabled .nav-links {
    display: none;
    margin-left: 0;
    width: 100%;
  }

  .js-enabled .nav-links.is-open {
    display: flex;
  }

  .nav-link-system {
    border-left: 0;
    margin-left: 0;
    padding-left: 0.55rem;
  }

  .filter-field-wide {
    grid-column: span 1;
  }

  .workspace-page-guard-panel {
    grid-template-columns: 1fr;
  }

  .workspace-page-guard-message,
  .workspace-page-guard-action {
    grid-column: 1;
    grid-row: auto;
  }

  .workspace-page-guard-action {
    justify-self: start;
  }
}

.pagination {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1rem;
}

.pagination-summary {
  color: #4b5563;
  font-weight: 700;
}

.pagination-links {
  display: flex;
  gap: 0.5rem;
}

.form-row {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-sizing: border-box;
  font: inherit;
  max-width: 48rem;
  padding: 0.5rem;
  width: 100%;
}

.errorlist {
  color: #b91c1c;
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
}

@media (max-width: 640px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .brand {
    margin-right: 0;
  }

  .nav-back-button {
    justify-content: center;
    width: 100%;
  }

  .nav-links {
    align-items: stretch;
    margin-left: 0;
    width: 100%;
  }

  .nav-link {
    flex: 1 1 auto;
  }

  .nav-link-system {
    border-left: 0;
    margin-left: 0;
    padding-left: 0.55rem;
  }

  .nav-user {
    align-items: flex-start;
  }

  .page-title {
    display: block;
  }

  .filter-field-wide {
    grid-column: span 1;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  th,
  td {
    padding: 0.55rem;
  }

  .quick-update-form {
    grid-template-columns: 1fr;
    min-width: 12rem;
  }

  .inquiry-product-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }
}
