:root {
  color-scheme: light;
  --primary: #111111;
  --primary-dark: #000000;
  --primary-contrast: #ffffff;
  --accent: #f1f1f1;
  --accent-dark: #dcdcdc;
  --secondary: #f5f5f5;
  --surface: #ffffff;
  --surface-muted: #f2f2f2;
  --text: #111111;
  --muted: #555555;
  --border: #d9d9d9;
  --shadow-color: 0, 0, 0;
  --success: #1f1f1f;
  --danger: #2c2c2c;
  font-family: "Lato", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--secondary);
  color: var(--text);
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

.site-header {
  position: relative;
  z-index: 10;
  box-shadow: 0 8px 22px rgba(var(--shadow-color), 0.08);
}

.top-info {
  background: var(--primary);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-info-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
}

.top-info-highlight {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-contrast);
  font-weight: 700;
  text-decoration: none;
}

.top-info-highlight span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--primary-contrast);
  font-size: 0.8rem;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.top-links a {
  color: rgba(255, 255, 255, 0.76);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.top-links a:hover {
  color: #ffffff;
}


.main-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.main-header-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(1rem, 4vw, 2.5rem);
  padding: 1.1rem 0;
}

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

.brand img {
  display: block;
  max-height: clamp(56px, 7vw, 72px);
  width: auto;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.main-nav-buttons {
  display: inline-flex;
  gap: 0.5rem;
  background: var(--surface-muted);
  padding: 0.35rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.nav-button,
.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 0.5rem 1.35rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.login-button {
  background: var(--surface-muted);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.02);
  font-size: 0.85rem;
}

.nav-button:hover,
.nav-button:focus-visible,
.login-button:hover,
.login-button:focus-visible {
  outline: none;
  background: rgba(17, 17, 17, 0.08);
  color: var(--primary);
  transform: translateY(-1px);
}

.nav-button.active,
.login-button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 10px 20px rgba(var(--shadow-color), 0.14);
  transform: translateY(-1px);
}

.category-bar {
  background: var(--primary);
  color: var(--primary-contrast);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.category-bar-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.65rem 0;
  overflow-x: auto;
}

.category-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  cursor: pointer;
  font-family: inherit;
}

.category-pill.is-highlight {
  background: var(--primary-contrast);
  color: var(--primary);
  border-color: transparent;
}

.category-pill:hover,
.category-pill:focus-visible {
  outline: none;
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
  transform: translateY(-1px);
}

main {
  padding: clamp(2.5rem, 4vw, 3.5rem) 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}


.card {
  background: var(--surface);
  border-radius: 24px;
  padding: clamp(1.45rem, 4vw, 2rem);
  margin-bottom: 2.4rem;
  border: 1px solid rgba(7, 10, 12, 0.05);
  box-shadow: 0 24px 55px rgba(var(--shadow-color), 0.09);

}

h2 {
  margin-top: 0;
  font-size: clamp(1.65rem, 3vw, 1.9rem);
  letter-spacing: 0.02em;
}

h3 {
  margin-top: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.35rem);
  letter-spacing: 0.01em;
}

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

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-with-action {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.field-with-action > input,
.field-with-action > textarea,
.field-with-action > select {
  flex: 1 1 12rem;
}

.contifico-lookup-status {
  min-height: 1rem;
  margin: 0;
}

.contifico-lookup-status.info {
  color: var(--muted);
}

.contifico-lookup-status.success {
  color: var(--success);
}

.contifico-lookup-status.error {
  color: var(--danger);
}

label {
  font-weight: 600;
  color: var(--muted);
}

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

input[type="text"],
input[type="password"],
textarea,
select {
  background: var(--surface);
  border: 1px solid rgba(7, 10, 12, 0.12);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.18);
}

textarea {
  resize: vertical;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

button.primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
  padding: 0.75rem 1.6rem;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(var(--shadow-color), 0.12);
}

button.secondary {
  background: transparent;
  border: 1px solid rgba(7, 10, 12, 0.16);
  color: var(--primary);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  width: fit-content;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

button.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

button.danger {
  background: var(--danger);
  color: var(--primary-contrast);
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-weight: 600;
}

button.danger:hover {
  filter: brightness(0.9);
}

button.danger.ghost {
  background: rgba(17, 17, 17, 0.12);
  color: var(--danger);
}

button.danger.ghost:hover {
  background: rgba(17, 17, 17, 0.2);
}

button.full-width {
  width: 100%;
  background: var(--primary);
  border: none;
  color: var(--primary-contrast);
  padding: 0.8rem;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(var(--shadow-color), 0.18);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

button.full-width:hover,
button.full-width:focus-visible {
  background: var(--primary-dark);
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(var(--shadow-color), 0.22);
}

button.full-width:disabled {
  background: rgba(17, 17, 17, 0.3);
  color: rgba(255, 255, 255, 0.75);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.link-button {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  padding: 0;
  margin-left: 0.5rem;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

button.link-button:hover {
  color: var(--primary-dark);
}

a.link-button {
  color: var(--primary);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a.link-button:hover {
  color: var(--primary-dark);
}

button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.input-group {
  display: flex;
  gap: 0.75rem;
}

.input-group input {
  flex: 1;
}

.field-with-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.field-with-action select {
  flex: 1;
}

.field-with-action input {
  flex: 1;
}

.field-with-action .link-button {
  margin-left: 0;
  white-space: nowrap;
}

.order-result {
  margin-top: 1.6rem;
  padding: 1.6rem;
  border-radius: 18px;
  border: 1px solid rgba(7, 10, 12, 0.08);
  background: var(--surface-muted);
  line-height: 1.6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.order-result.hidden {
  display: none;
}

.order-result strong {
  display: inline-block;
  min-width: 140px;
}

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

.dashboard-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(7, 10, 12, 0.08);
  padding-bottom: 0.5rem;
}

.dashboard-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.dashboard-tab:hover,
.dashboard-tab:focus-visible {
  outline: none;
  color: var(--primary);
}

.dashboard-tab.active {
  color: var(--primary);
  border-color: var(--primary);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-header h3 {
  margin: 0;
}

.panel-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 48ch;
}

.panel-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.75rem;
}

.panel-actions button {
  white-space: nowrap;
}

.customer-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.customer-panel-header > :first-child {
  flex: 1 1 0;
}

.customer-panel-header h3 {
  margin: 0;
}

.customer-panel-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 38ch;
}

.customer-panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 1rem;
}

.customer-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.customer-search label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.customer-search input {
  width: min(280px, 100%);
}

.customer-create {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 16px;
  padding: 1.35rem;
  background: var(--surface-muted);
  margin-bottom: 1.5rem;
  box-shadow: 0 16px 32px rgba(var(--shadow-color), 0.08);
}

.modal-content.customer-create {
  margin-bottom: 0;
}

.users-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.users-panel-header h3 {
  margin: 0;
}

.users-panel-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 48ch;
}

.users-panel-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0.75rem;
}

.users-panel-actions button {
  white-space: nowrap;
}

.user-create,
.user-edit {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 16px;
  padding: 1.35rem;
  background: var(--surface-muted);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-create h4,
.user-edit h4 {
  margin: 0;
}

.user-create p,
.user-edit p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-create .button-row,
.user-edit .button-row {
  margin-top: 0.5rem;
}

.user-create-header,
.user-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.user-create-header .link-button,
.user-edit-header .link-button {
  margin-left: 0;
  color: var(--muted);
}

.customer-create-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.customer-create-header h4 {
  margin: 0;
}

.customer-create-header .link-button {
  margin-left: 0;
  color: var(--muted);
}

.customer-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.customer-detail {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 18px;
  padding: 1.6rem;
  background: var(--surface-muted);
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-content.customer-detail {
  margin-top: 0;
}

.customer-detail-row td {
  padding: 0;
  border: none;
  background: transparent;
}

.customer-detail-cell {
  padding: 0;
}

.customer-detail-cell .customer-detail {
  margin: 0;
}

.customer-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.customer-detail-header h4 {
  margin: 0;
}

.customer-detail-header p {
  margin: 0.4rem 0 0;
}

.customer-order-history h5 {
  margin: 0;
  font-size: 1rem;
}

.customer-order-history-list {
  margin-top: 0.75rem;
  border: 1px dashed rgba(7, 10, 12, 0.12);
  border-radius: 14px;
  padding: 0.85rem;
  background: var(--surface);
}

.customer-order-history-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.customer-order-history-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.customer-order-history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.customer-order-history-item-header strong {
  font-size: 1rem;
}

.customer-order-history-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.customer-order-history-item-actions .customer-order-history-open {
  margin: 0;
  font-size: 0.85rem;
}

.customer-order-history-item-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.customer-order-history-item-invoice {
  margin: 0;
  font-weight: 600;
  color: var(--primary-dark);
}

.customer-invoices {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.customer-invoices-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.customer-invoices-header h5 {
  margin: 0;
}

.customer-invoices-table {
  width: 100%;
}

.customer-invoices-table th,
.customer-invoices-table td {
  white-space: nowrap;
}

.customer-invoices-table td:last-child {
  white-space: normal;
}

.invoice-orders {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.invoice-order-pill {
  background: rgba(17, 17, 17, 0.08);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-error {
  color: var(--danger);
}

.status-success {
  color: var(--success);
}

.invoice-lookup-details {
  margin-top: 0.45rem;
  transition: color 0.2s ease;
}

.invoice-lookup-details .invoice-lookup-summary {
  font-weight: 600;
}

.invoice-lookup-details .invoice-lookup-number {
  font-weight: 700;
}

.invoice-lookup-details .invoice-lookup-meta {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.invoice-lookup-details .invoice-lookup-meta li {
  background: rgba(17, 17, 17, 0.08);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-weight: 600;
  color: inherit;
}

.invoice-lookup-details.status-error .invoice-lookup-meta li {
  background: rgba(210, 54, 105, 0.16);
}

.invoice-lookup-details.status-success .invoice-lookup-meta li {
  background: rgba(31, 31, 31, 0.12);
}


.tag.muted-tag {
  background: rgba(89, 90, 90, 0.18);
  color: var(--muted);
}

@media (max-width: 600px) {
  .top-info-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    text-align: left;
  }

  .top-links {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .main-header-inner {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .brand {
    justify-content: center;

  }

  .main-nav {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .main-nav-buttons {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .nav-button,
  .login-button {
    width: 100%;
  }

  .category-bar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .dashboard-subnav {
    width: 100%;
    overflow-x: auto;
    border-bottom: none;
    padding-bottom: 0;
    gap: 0.75rem;
  }

  .dashboard-tab {
    flex: 0 0 auto;
    padding: 0.5rem 0.75rem;
  }

  .customer-panel-header > :first-child {
    flex-basis: 100%;
  }

  .customer-panel-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .customer-panel-actions > button {
    width: 100%;
  }

  .users-panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .users-panel-actions > button {
    width: 100%;
  }

  .order-panel-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .order-search {
    width: 100%;
  }

  .order-search input {
    width: 100%;
  }

  .table-pagination {
    width: 100%;
    align-items: flex-start;
  }

  .pagination-controls {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .pagination-buttons {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pagination-button {
    flex: 1 1 auto;
    text-align: center;
  }

  .pagination-info {
    width: 100%;
    text-align: center;
  }

  .toast {
    left: clamp(1rem, 6vw, 2rem);
    right: clamp(1rem, 6vw, 2rem);
  }
}

.order-detail {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 0 0 16px 16px;
  padding: 1.6rem;
  background: var(--surface-muted);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.order-detail.kanban-mode {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.order-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.order-detail-header h4 {
  margin: 0;
}

.order-detail-header p {
  margin: 0.2rem 0 0;
}

.order-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.order-detail-meta p {
  margin: 0;
}

.order-detail .measurement-tags {
  margin-top: 0;
}

.order-detail-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.order-detail-heading {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.order-detail-heading h2 {
  margin: 0;
}

.order-detail-heading .muted {
  margin: 0;
}

.order-detail-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.order-detail-status-message {
  margin-top: 1.25rem;
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.95rem;
  border: 1px solid rgba(7, 10, 12, 0.06);
}

.order-detail-status-message.loading {
  background: rgba(17, 17, 17, 0.08);
  border-color: rgba(17, 17, 17, 0.2);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.order-detail-status-message.loading::before {
  content: '';
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  display: inline-block;
  animation: order-detail-loading-spin 0.75s linear infinite;
}

.order-detail-status-message.error {
  background: rgba(44, 44, 44, 0.12);
  border-color: rgba(44, 44, 44, 0.24);
  color: var(--danger);
}

.order-detail-status-message.success {
  background: rgba(31, 31, 31, 0.12);
  border-color: rgba(31, 31, 31, 0.24);
  color: var(--success);
}

@keyframes order-detail-loading-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.order-detail-content {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.order-detail-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-detail-section h3 {
  margin: 0;
}

.order-detail-summary-grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.order-detail-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.order-detail-summary-item dt {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.order-detail-summary-item dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.order-detail-customer-button {
  font: inherit;
  font-weight: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: default;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.order-detail-customer-button.is-interactive {
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

.order-detail-customer-button.is-interactive:hover,
.order-detail-customer-button.is-interactive:focus-visible {
  text-decoration-thickness: 0.12em;
}

.order-detail-customer-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.order-detail-customer-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.order-detail-notes {
  margin: 0;
  line-height: 1.6;
  white-space: pre-wrap;
}

.order-detail-task-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-detail-task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-detail-task {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 14px;
  background: var(--surface-muted);
  padding: 0.95rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.order-detail-task.is-completed {
  border-color: rgba(31, 31, 31, 0.25);
  background: rgba(31, 31, 31, 0.08);
}

.order-detail-task.is-pending {
  border-color: rgba(17, 17, 17, 0.18);
  background: rgba(17, 17, 17, 0.05);
}

.order-detail-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.order-detail-task-description {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
}

.order-detail-task-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.order-detail-error {
  color: var(--danger);
  font-weight: 600;
}

@media (max-width: 600px) {
  .order-detail-summary-grid {
    grid-template-columns: 1fr;
  }
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.order-panel-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.order-panel-controls p {
  margin: 0;
  max-width: 48ch;
}

.orders-controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.order-create-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.order-create-toolbar button {
  align-self: flex-start;
}

.orders-controls-info h3 {
  margin-bottom: 0.35rem;
}

.orders-controls-info p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

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

.orders-controls-actions > * {
  flex: 0 0 auto;
}

.orders-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid rgba(7, 10, 12, 0.12);
  background: rgba(7, 10, 12, 0.04);
}

.orders-view-toggle button {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.orders-view-toggle button:hover,
.orders-view-toggle button:focus-visible {
  outline: none;
  color: var(--primary);
}

.orders-view-toggle button.active {
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 18px 32px rgba(var(--shadow-color), 0.12);
}

#ordersCreateButton {
  box-shadow: 0 20px 44px rgba(var(--shadow-color), 0.16);
}

.orders-view-panel {
  margin-bottom: 2rem;
}

.orders-view-panel:last-of-type {
  margin-bottom: 0;
}

.kanban-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.kanban-header h3 {
  margin-bottom: 0.25rem;
}

.kanban-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kanban-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.kanban-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.kanban-search label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.kanban-search input {
  width: min(280px, 100%);
}

.kanban-status {
  margin-bottom: 1rem;
}

.kanban-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.kanban-detail {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid rgba(7, 10, 12, 0.08);
  padding: 1.5rem;
  box-shadow: 0 18px 40px rgba(var(--shadow-color), 0.08);
  max-height: 72vh;
  overflow-y: auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  z-index: 1400;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 12, 0.45);
}

.modal-dialog {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 28px 68px rgba(var(--shadow-color), 0.2);
  width: min(720px, 100%);
  max-height: calc(100vh - clamp(2rem, 10vh, 5rem));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
  outline: none;
}

.modal-content {
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.customer-modal {
  gap: 1.25rem;
}

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

.customer-modal-info {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
}

.customer-modal-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.customer-modal-info-item dt {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.customer-modal-info-item dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.customer-modal-info-item input[type='text'] {
  width: 100%;
  font-weight: 400;
  color: var(--text);
}

.customer-modal-note {
  display: block;
  margin-top: 0.35rem;
}

#orderDetailCustomerHint {
  margin: 0;
}

.contifico-modal {
  gap: 1rem;
}

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

.contifico-modal-header h4 {
  margin: 0;
}

.contifico-modal .table-wrapper,
.contifico-modal .contifico-invoice-details {
  max-height: min(60vh, 480px);
  overflow: auto;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 768px) {
  .modal-overlay {
    align-items: stretch;
    padding: 0;
  }

  .modal-dialog {
    border-radius: 0;
    max-height: 100vh;
  }

  .modal-content {
    padding: clamp(1rem, 4vw, 1.5rem);
  }
}

.kanban-detail .muted {
  margin: 0;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.kanban-detail-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  z-index: 1200;
}

.kanban-detail-overlay.hidden {
  display: none !important;
}

.kanban-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 10, 12, 0.45);
}

.kanban-detail-dialog {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 28px 68px rgba(var(--shadow-color), 0.2);
  width: min(960px, 100%);
  max-height: calc(100vh - clamp(2rem, 10vh, 5rem));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
  outline: none;
}

.kanban-detail-content {
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow-y: auto;
  flex: 1 1 auto;
}

.kanban-detail-content .muted {
  margin: 0;
}

body.kanban-detail-open {
  overflow: hidden;
}

.kanban-column {
  background: var(--surface-muted);
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 16px;
  min-width: clamp(220px, 24vw, 280px);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  box-shadow: 0 16px 38px rgba(var(--shadow-color), 0.08);
}

.kanban-column-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.kanban-column-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.kanban-column-count {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}

.kanban-column-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

.kanban-column-body.is-empty {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.kanban-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 0.95rem 1.05rem;
  box-shadow: 0 18px 40px rgba(var(--shadow-color), 0.08);
  border: 1px solid rgba(7, 10, 12, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  color: inherit;
  font: inherit;
}

.kanban-card.is-clickable {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kanban-card.is-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px rgba(var(--shadow-color), 0.12);
}

.kanban-card.is-clickable:focus-visible {
  outline: 3px solid rgba(17, 17, 17, 0.35);
  outline-offset: 3px;
  transform: translateY(-2px);
  box-shadow: 0 22px 55px rgba(var(--shadow-color), 0.16);
}

.kanban-card.is-active {
  border-color: var(--primary);
  box-shadow: 0 22px 55px rgba(var(--shadow-color), 0.18);
}


.kanban-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.kanban-card-order {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  word-break: break-word;
}

.kanban-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.kanban-card-meta-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  line-height: 1.4;
}

.kanban-card-meta-label {
  font-weight: 600;
  color: var(--muted);
}

.kanban-card-meta-value {
  color: var(--text);
}

.kanban-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.kanban-card-delivery {
  font-weight: 600;
}

.kanban-card-updated {
  margin-left: auto;
  font-size: 0.8rem;
}

.kanban-card-updated time {
  font-style: normal;
}

@media (max-width: 768px) {
  .kanban-header {
    flex-direction: column;
    align-items: stretch;
  }

  .kanban-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .kanban-actions button {
    width: 100%;
  }

  .kanban-controls {
    align-items: stretch;
  }

  .kanban-board {
    padding-bottom: 1rem;
  }

  .kanban-detail-overlay {
    padding: clamp(0.75rem, 4vw, 1.25rem);
    align-items: stretch;
  }

  .kanban-detail-dialog {
    width: 100%;
    max-height: calc(100vh - clamp(1.5rem, 6vh, 3rem));
    border-radius: 16px;
  }
}

@media (max-width: 540px) {
  .kanban-detail-overlay {
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
  }

  .kanban-detail-dialog {
    height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: none;
    border-radius: 0;
  }

  .kanban-detail-content {
    padding: clamp(1rem, 6vw, 1.5rem);
  }
}

@media (min-width: 1024px) {
  .kanban-detail-overlay {
    align-items: center;
  }
}

@media (min-width: 1024px) {
  .kanban-content {
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  }

  .kanban-detail {
    position: sticky;
    top: 1rem;
  }
}

.order-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.order-search label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.order-search input {
  width: min(260px, 100%);
}

.table-pagination {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  min-width: 200px;
}

.table-pagination label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.pagination-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.pagination-controls select {
  min-width: 90px;
}

.pagination-buttons {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-button {
  border: 1px solid rgba(7, 10, 12, 0.12);
  background: var(--surface);
  color: var(--primary);
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.pagination-button:hover:not(:disabled) {
  background: rgba(17, 17, 17, 0.08);
  border-color: rgba(17, 17, 17, 0.2);
  color: var(--primary);
  transform: translateY(-1px);
}

.pagination-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 0.9rem;
  color: var(--muted);
}

.user-info {
  color: var(--muted);
  font-size: 0.95rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.measurement-set-list,
.measurement-option-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.measurement-set {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface);
  box-shadow: 0 16px 32px rgba(var(--shadow-color), 0.07);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.measurement-set-header,
.measurement-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.measurement-option {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 14px;
  padding: 1rem;
  background: var(--surface-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.measurement-option .measurement-tags {
  margin-top: 0;
}

.measurement-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.table-wrapper {
  overflow-x: auto;
}

.table-wrapper.compact table {
  font-size: 0.9rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  vertical-align: top;
}

th {
  text-align: left;
  background: rgba(17, 17, 17, 0.05);
}

.order-row {
  transition: background 0.2s ease;
}

.order-row.is-selected {
  background: rgba(17, 17, 17, 0.05);
}

.order-row.is-selected td {
  border-bottom-color: transparent;
}

.customer-row {
  transition: background 0.2s ease;
}

.customer-row.is-selected {
  background: rgba(17, 17, 17, 0.05);
}

.customer-row.is-selected td {
  border-bottom-color: transparent;
}

.user-row {
  transition: background 0.2s ease;
}

.user-row.is-editing {
  background: rgba(17, 17, 17, 0.05);
}

.user-row.is-editing td {
  border-bottom-color: transparent;
}


.customer-order-count-cell {
  text-align: center;
}

.customer-order-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.12);
  color: var(--primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.order-detail-row td {
  padding: 0;
  border: none;
  background: transparent;
}

.order-detail-cell {
  padding: 0;
}

.table-wrapper input,
.table-wrapper textarea,
.table-wrapper select {
  width: 100%;
}

.due-soon {
  color: var(--danger);
  text-decoration: underline;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: 600;
}

.overdue {
  color: var(--danger);
  font-weight: 700;
}

.measurement-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.order-task-suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.order-task-suggestions .link-button {
  padding-left: 0;
  padding-right: 0;
}

.measurement-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) auto;
  gap: 0.5rem;
}

.measurement-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.measurement-row input {
  width: 100%;
}

.measurement-row button {
  border: none;
}

.measurement-row.is-highlighted {
  animation: measurementRowFlash 1.5s ease-out;
  border-radius: 12px;
}

@keyframes measurementRowFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(17, 17, 17, 0.35);
  }
  60% {
    box-shadow: 0 0 0 9px rgba(17, 17, 17, 0);
  }
  100% {
    box-shadow: none;
  }
}

.measurement-tag-button {
  border: none;
  background: rgba(17, 17, 17, 0.14);
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.measurement-tag-button:hover {
  background: rgba(17, 17, 17, 0.2);
  transform: translateY(-1px);
}

.measurement-tag-button:focus-visible {
  outline: 3px solid rgba(17, 17, 17, 0.35);
  outline-offset: 2px;
  background: rgba(17, 17, 17, 0.26);
}

.job-catalog-table th,
.job-catalog-table td {
  vertical-align: top;
}

.job-catalog-table td {
  max-width: 28ch;
  word-break: break-word;
}

.order-task-input-label {
  font-weight: 600;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.12);
  color: var(--primary);
  margin: 0.15rem;
  font-size: 0.85rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  background: rgba(17, 17, 17, 0.12);
  color: var(--primary);
  text-align: center;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
  max-width: 100%;
}


.status-badge.status-neutral {
  background: rgba(120, 120, 120, 0.26);
  color: var(--primary-contrast);
}

.status-badge.status-info {
  background: rgba(0, 0, 0, 0.12);
  color: var(--primary);
}

.status-badge.status-success {
  background: rgba(17, 17, 17, 0.45);
  color: var(--primary-contrast);
}

.status-badge.status-warning {
  background: rgba(0, 0, 0, 0.08);
  color: var(--primary);
}

.status-badge.status-danger {
  background: rgba(17, 17, 17, 0.6);
  color: var(--primary-contrast);
}

.table-wrapper pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Fira Code", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 0.6rem;
}

.contifico-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.contifico-preview-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.contifico-preview-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 18px;
  border: 1px solid rgba(7, 10, 12, 0.08);
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.contifico-preview-card-header h4 {
  margin: 0;
  font-size: 1.1rem;
}

.contifico-preview-card-header p {
  margin: 0.35rem 0 0;
}

.contifico-preview-form input[type="number"] {
  max-width: 160px;
}

.contifico-preview-submit {
  align-items: flex-start;
}

.contifico-preview-actions {
  display: flex;
  justify-content: flex-end;
}

.contifico-preview-status {
  min-height: 1.25rem;
  margin: 0;
}

.contifico-preview-status.loading {
  color: var(--muted);
}

.contifico-preview-status.error {
  color: var(--danger);
}

.contifico-preview-status.success {
  color: var(--primary);
}

.contifico-preview-detail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contifico-preview-detail-list {
  display: grid;
  grid-template-columns: minmax(0, 160px) minmax(0, 1fr);
  gap: 0.35rem 1rem;
  margin: 0;
}

.contifico-preview-detail-list dt {
  font-weight: 600;
  color: var(--muted);
}

.contifico-preview-detail-list dd {
  margin: 0;
  word-break: break-word;
}

.contifico-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.contifico-progress-track {
  position: relative;
  height: 0.5rem;
  background: rgba(7, 10, 12, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.contifico-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.4s ease;
}

.contifico-progress-label {
  margin: 0;
}

.contifico-invoice-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contifico-invoice-detail-list {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr);
  gap: 0.35rem 1rem;
  padding: 0;
  margin: 0;
}

.contifico-invoice-detail-list dt {
  font-weight: 600;
  color: var(--muted-strong);
}

.contifico-invoice-detail-list dd {
  margin: 0;
  color: var(--text-primary);
}

.contifico-invoice-preview-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(7, 10, 12, 0.04);
  transition: background 0.2s ease;
}

.contifico-invoice-preview-result.empty {
  background: none;
  padding: 0;
}

.contifico-preview-card details {
  font-size: 0.85rem;
}

.contifico-preview-card summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
}

.contifico-preview-card details pre {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: rgba(7, 10, 12, 0.04);
  border-radius: 12px;
  overflow: auto;
}

.contifico-invoice-raw summary {
  margin-bottom: 0.25rem;
}

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

.public-order-card {
  border: 1px solid rgba(7, 10, 12, 0.08);
  border-radius: 18px;
  padding: 1.3rem;
  background: var(--surface);
  box-shadow: 0 18px 36px rgba(var(--shadow-color), 0.08);
}

.public-order-card header {
  margin-bottom: 0.75rem;
}

.public-order-card h3 {
  margin: 0 0 0.4rem 0;
}

.public-order-card p {
  margin: 0.3rem 0;
}

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

.text-center {
  text-align: center;
}

.small {
  font-size: 0.85rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 0.9rem 1.2rem;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(var(--shadow-color), 0.18);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.footer {
  padding-bottom: 2rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 768px) {
  .input-group {
    flex-direction: column;
  }

  .measurement-row {
    grid-template-columns: 1fr 1fr;
  }

  th,
  td {
    padding: 0.6rem;
  }

  .orders-controls {
    gap: 1rem;
  }

  .orders-controls-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .orders-view-toggle {
    width: 100%;
    justify-content: space-between;
  }

  .orders-view-toggle button {
    flex: 1 1 0;
  }

  .orders-controls-actions > * {
    width: 100%;
  }

  #ordersCreateToggleButton {
    width: 100%;
  }
}

@media (min-width: 960px) {
  .orders-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .orders-controls-info {
    flex: 1 1 auto;
    max-width: 60ch;
  }

  .orders-controls-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .table-wrapper {
    overflow-x: visible;
  }

  .table-wrapper table {
    border: 0;
  }

  .table-wrapper thead {
    display: none;
  }

  .table-wrapper tbody {
    display: block;
  }

  .table-wrapper tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid rgba(7, 10, 12, 0.08);
    border-radius: 16px;
    margin-bottom: 1rem;
    box-shadow: 0 18px 32px rgba(var(--shadow-color), 0.08);
    overflow: hidden;
  }

  .table-wrapper tbody tr:last-of-type {
    margin-bottom: 0;
  }

  .table-wrapper tbody tr td {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-bottom: 1px solid var(--border);
  }

  .table-wrapper tbody tr td:last-child {
    border-bottom: none;
  }

  .table-wrapper tbody tr td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    text-transform: uppercase;
  }

  .table-wrapper tbody tr td[data-label='Acciones'] button {
    width: 100%;
  }

  .customer-order-count-cell {
    text-align: left;
  }

  .order-row.is-selected,
  .customer-row.is-selected {
    border-color: var(--primary);
    box-shadow: 0 20px 36px rgba(var(--shadow-color), 0.12);
    margin-bottom: 0;
  }

  .order-detail-row,
  .customer-detail-row {
    display: block;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
  }

  .order-detail-row td,
  .customer-detail-row td {
    display: block;
    padding: 0;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 16px 16px;
    background: var(--surface-muted);
    box-shadow: 0 20px 36px rgba(var(--shadow-color), 0.12);
  }

  .order-detail,
  .customer-detail {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 1.5rem 1.25rem;
    box-shadow: none;
    margin: 0;
  }

  .order-detail .button-row,
  .customer-detail .button-row {
    flex-direction: column;
  }
}
