.orders-page {
  .action-buttons {
    display: flex;
    gap: 0.1rem;
  }

  .amount {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-align: end;
  }

  .mono {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
  }
}

.order-form {
  overflow-x: hidden;

  .form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.25rem;
    border-inline-start: 3px solid var(--color-accent, #f5a623);
    background: var(--color-surface-muted);
    padding: 1rem;
    border-radius: 6px;

    .form-field {
      display: flex;
      flex-direction: column;
      gap: 0.375rem;

      label {
        font-weight: 700;
        font-size: 0.65rem;
        color: var(--color-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.03em;
      }

      input,
      textarea {
        width: 100%;
      }

      &.span-2 {
        grid-column: span 2;
      }
    }
  }

  .lines-section {
    border: 1px solid var(--color-surface-border);
    border-radius: 8px;
    overflow: hidden;

    .lines-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 0;
      padding: 0.6rem 0.75rem;
      background: var(--module-color, var(--color-brand));

      h3 {
        margin: 0;
        color: #fff;
        font-size: 0.8rem;
        font-weight: 700;
      }
    }

    ::ng-deep .header-add-btn.p-button {
      color: #fff !important;
      border-color: rgba(255,255,255,0.5) !important;
    }

    .barcode-row {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      margin-bottom: 0.5rem;
      .barcode-icon { font-size: 1.2rem; color: #64748b; }
      .barcode-input { flex: 1; max-width: 350px; font-family: monospace; }
    }

    .row-barcode {
      font-size: 0.65rem;
      font-family: monospace;
      color: #94a3b8;
      margin-top: 1px;
    }

    .lines-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.75rem;
      table-layout: fixed;

      thead th {
        background: var(--color-surface-hover);
        padding: 0.4rem 0.25rem;
        text-align: start;
        font-weight: 700;
        font-size: 0.68rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--color-text-secondary);
        border-bottom: 2px solid var(--color-surface-border);
        white-space: nowrap;
      }

      tbody td {
        padding: 0.25rem 0.2rem;
        border-bottom: 1px solid var(--color-surface-hover);
        vertical-align: middle;
        overflow: hidden;
        transition: background 0.15s ease;

        input { width: 100%; }
      }

      tbody tr:hover td {
        background: rgba(245, 166, 35, 0.04);
      }

      :host ::ng-deep {
        .p-select { font-size: 0.75rem; }
        .p-select .p-select-label { padding: 0.3rem 0.4rem; font-size: 0.75rem; }
        .p-inputnumber-input { padding: 0.3rem 0.35rem; font-size: 0.75rem; }
      }

      .col-product { width: 28%; }
      .col-unit { width: 12%; }
      .col-qty { width: 8%; }
      .col-price { width: 12%; }
      .col-discount { width: 8%; }
      .col-tax { width: 13%; }
      .col-total { width: 11%; text-align: end; }
      .col-action { width: 32px; }

      .line-total-cell {
        font-family: 'Courier New', monospace;
        font-weight: 600;
        text-align: end;
        padding-inline-end: 0.75rem;
        color: var(--module-color, var(--color-brand));
      }

      .amount {
        font-family: 'Courier New', monospace;
        font-weight: 600;
        text-align: end;
      }
    }

    .no-items {
      text-align: center;
      padding: 1.5rem;
      color: var(--color-text-muted);
      font-size: 0.875rem;
    }
  }

  .totals-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    margin: 1.25rem 0;
    padding: 1rem;
    background: var(--color-surface-muted);
    border-radius: 8px;

    .totals-row {
      display: flex;
      justify-content: space-between;
      width: 280px;
      font-size: 0.875rem;

      .totals-label {
        color: var(--color-text-secondary);
        font-weight: 600;
      }

      .totals-value {
        font-family: 'Courier New', monospace;
        font-weight: 600;
        color: var(--color-text-primary);

        &.discount {
          color: var(--color-danger);
        }
      }

      &.grand-total {
        border-top: 2px solid var(--module-color, var(--color-brand));
        padding-top: 0.5rem;
        font-size: 1rem;

        .totals-label {
          color: var(--module-color, var(--color-brand));
        }

        .totals-value {
          color: var(--module-color, var(--color-brand));
          font-size: 1.1rem;
        }
      }
    }
  }
}

.dialog-custom-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-surface-border);
}

.view-order {
  .view-header-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-surface-border);

    .info-item {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;

      label {
        font-size: 0.75rem;
        color: var(--color-text-muted);
        font-weight: 600;
        text-transform: uppercase;
      }
      span {
        font-size: 0.8125rem;
      }
      .mono {
        font-family: 'Courier New', monospace;
        font-weight: 600;
      }
    }
  }

  .view-description {
    margin-bottom: 1rem;
    label {
      font-size: 0.75rem;
      color: var(--color-text-muted);
      font-weight: 600;
      text-transform: uppercase;
      display: block;
      margin-bottom: 0.25rem;
    }
    p {
      margin: 0 0 0.5rem;
      color: var(--color-text-primary);
    }
  }

  .view-lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;

    thead th {
      background: var(--color-surface-muted);
      padding: 0.5rem;
      text-align: start;
      font-weight: 600;
      font-size: 0.8rem;
      color: var(--color-text-secondary);
      border-bottom: 1px solid var(--color-surface-border);
    }

    tbody td {
      padding: 0.4rem 0.5rem;
      border-bottom: 1px solid var(--color-surface-hover);
    }

    tfoot td {
      padding: 0.4rem 0.5rem;
      border-top: none;
    }

    .grand-total-row td {
      border-top: 1px solid var(--color-surface-border);
      background: var(--color-surface-muted);
      padding: 0.5rem;
    }

    .amount {
      text-align: end;
      font-family: 'Courier New', monospace;
    }

    .discount {
      color: var(--color-danger);
    }
  }
}
