.form-container {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    margin-bottom: 10px;
}

.form-header {
    background: #f1f3f6;
    padding: 12px 12px;
    border-bottom: 1px solid #dcdcdc;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-circle {
    width: 28px;
    height: 28px;
    background-color: #0d1b2a;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.header-title {
    font-size: 15px;
    font-weight: 600;
}

.form-body {
    background: #f8f9fb;
    padding: 10px;
}

.row {
    display: flex;
}

.field {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: 10px;
}

/* Row 3 badge strip */
.badge-row {
    display: flex;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0;
}

.badge-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    gap: 6px;
    border-right: 1px solid #f0f0f0;
}

.badge-item:last-child {
    border-right: none;
}

.badge-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
}

.badge-icon.doc,
.badge-icon.insp {
    color: #555;
}

.badge-icon.good {
    color: #2a9d4e;
}

.badge-icon.rework {
    color: #d97706;
}

.badge-icon.reject {
    color: #dc2626;
}

.badge-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #555;
    text-transform: uppercase;
}

/* Quality yield */
.yield-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 2px 0;
    font-size: 12px;
    color: #555;
}

.yield-bar-wrap {
    flex: 1;
    height: 4px;
    background: #e0e0e0;
    border-radius: 4px;
    margin: 0 12px;
    overflow: hidden;
}

.yield-bar-fill {
    height: 100%;
    background: #2a9d4e;
    border-radius: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 14px;
    background: #fff;
    border-radius: 6px 6px 0 0;
    padding: 0 10px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;

    &.active {
        color: #0d1b2a;
        border-bottom-color: #0d1b2a;
        font-weight: 600;
    }
}

/* Table */
.param-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    font-size: 12px;

    thead tr {
        background: #f1f3f6;
    }

    th {
        padding: 9px 10px;
        text-align: center;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.05em;
        color: #555;
        border-right: 1px solid #e8e8e8;
    }

    td {
        padding: 7px 10px;
        border-right: 1px solid #f0f0f0;
    }

    tbody tr {
        border-top: 1px solid #f0f0f0;
    }
}

.td-param {
    font-size: 13px;
    color: #1a1a2e;
}

.td-uom {
    color: #888;
    font-size: 11px;
    text-align: center;
}

.td-range {
    color: #555;
    font-size: 11px;
    text-align: center;
}

.td-avg,
.result-icon {
    text-align: center;
    color: #888;
}

/* Visual cards */
.visual-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.visual-card {
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;

    &.pass-active {
        border-color: #86efac;
        background: #f0fdf4;
    }

    &.rework-active {
        border-color: #fcd34d;
        background: #fffbeb;
    }
}

.card-title {
    font-size: 12px;
    color: #555;
    text-align: center;
}

.card-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.btn-pass {
    background: #dcfce7;
    color: #16a34a;
    border: none;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

.btn-fail {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

.btn-rework {
    background: #d97706;
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

.card-note {
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 5px 8px;
    font-size: 12px;
    width: 100%;
}

/* ── Sections 5 & 6 side by side ── */
.section-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.section-half {
    flex: 1;
    min-width: 0;
}

/* ── Section 4: Defect table ── */
.defect-table {
    .td-sl {
        text-align: center;
        color: #555;
        font-size: 13px;
        width: 36px;
    }

    .td-defect-name {
        font-weight: 600;
        font-size: 13px;
        color: #1a1a2e;
    }

    .td-category {
        color: #2563eb;
        font-size: 13px;
    }
}

.td-spinner {
    padding: 4px 8px !important;
}

.spinner-wrap {
    display: flex;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    overflow: hidden;
    width: fit-content;
    background: #fff;
}

.spinner-input {
    width: 36px;
    border: none;
    outline: none;
    text-align: center;
    font-size: 13px;
    padding: 4px 2px;

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }
}

.spinner-btns {
    display: flex;
    flex-direction: column;
    border-left: 1px solid #e5e7eb;

    button {
        border: none;
        background: #f9fafb;
        cursor: pointer;
        font-size: 8px;
        padding: 2px 5px;
        line-height: 1;
        color: #555;

        &:hover {
            background: #e5e7eb;
        }

        &:first-child {
            border-bottom: 1px solid #e5e7eb;
        }
    }
}

.td-remove {
    text-align: center;
    width: 30px;
}

.btn-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;

    &:hover {
        background: #fee2e2;
    }
}

.defect-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.defect-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
    color: #555;
    background: #fff;
    min-width: 220px;
    cursor: pointer;
}

.btn-add-defect {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 13px;
    color: #1a1a2e;
    cursor: pointer;
    font-weight: 500;

    &:hover {
        background: #f1f3f6;
    }
}

/* ── Section 5: Inspectors ── */
.inspector-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 13px;
    font-weight: 500;
}

.chip-remove {
    background: none;
    border: none;
    color: #3730a3;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
    line-height: 1;

    &:hover {
        color: #dc2626;
    }
}

.inspector-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inspector-select {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: #555;
    background: #fff;
    cursor: pointer;
}

.btn-add-inspector {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    cursor: pointer;

    &:hover {
        background: #f1f3f6;
    }
}

/* ── Section 6: Overall Result ── */
.result-row {
    display: flex;
    gap: 16px;
    margin-bottom: 14px;
}

.result-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}

.required {
    color: #dc2626;
    margin-left: 2px;
}

.result-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 13px;
    color: #1a1a2e;
    background: #fff;
    cursor: pointer;
    width: 100%;
}

.remarks-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.remarks-textarea {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: #555;
    resize: vertical;
    width: 100%;
    font-family: inherit;

    &::placeholder {
        color: #aaa;
    }

    &:focus {
        outline: none;
        border-color: #93c5fd;
    }
}

@media screen and (max-width: 1024px) {

  .FormOverView {
    overflow-x: hidden;
  }

  .row {
    flex-wrap: wrap;
    row-gap: 10px;
  }

  .field {
    flex: 1 1 45%;
    min-width: 200px;
    margin-left: 0;
    margin-right: 10px;
  }

  .field:nth-child(2n) {
    margin-right: 0;
  }

  ::ng-deep .automanual[style*="padding-left: 250px"] {
    padding-left: 0 !important;
    margin-top: 4px !important;
  }

  .badge-row {
    flex-wrap: wrap;
  }

  .badge-item {
    flex: 1 1 33%;
    border-bottom: 1px solid #f0f0f0;
  }

  .visual-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-row {
    flex-wrap: wrap;
  }

  .section-half {
    flex: 1 1 100%;
  }

  .result-row {
    flex-wrap: wrap;
  }

  .result-field {
    flex: 1 1 100%;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .param-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    thead, tbody, tr {
      display: table;
      width: 100%;
      table-layout: fixed;
    }
  }

  ::ng-deep gb-formgrid {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media screen and (max-width: 768px) {

  .form-header {
    padding: 10px;
  }

  .header-title {
    font-size: 14px;
  }

  .form-body {
    padding: 8px;
  }

  .row {
    flex-direction: column;
    row-gap: 10px;
  }

  .field {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
  }

  ::ng-deep .automanual[style*="padding-left: 250px"] {
    padding-left: 0 !important;
    margin-top: 4px !important;
  }

  ::ng-deep gb-input,
  ::ng-deep gb-date,
  ::ng-deep gb-newpicklist,
  ::ng-deep gb-combobox,
  ::ng-deep gb-textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .badge-row {
    flex-wrap: wrap;
  }

  .badge-item {
    flex: 1 1 50%;
  }

  .badge-icon {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  .badge-label {
    font-size: 9px;
  }

  .yield-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .yield-bar-wrap {
    order: 3;
    flex: 1 1 100%;
    margin: 4px 0 0;
  }

  .visual-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 6px;
  }

  .tab-btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  .section-row {
    flex-direction: column;
    gap: 12px;
  }

  .section-half {
    width: 100%;
  }

  .result-row {
    flex-direction: column;
    gap: 10px;
  }

  .inspector-add-row,
  .defect-add-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .defect-select,
  .inspector-select {
    width: 100%;
    min-width: 0;
  }

  .btn-add-defect,
  .btn-add-inspector {
    width: 100%;
    text-align: center;
  }

  .param-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  ::ng-deep gb-formgrid {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .step-circle {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
}

/* ---------- Small mobile (≤480px) ---------- */
@media screen and (max-width: 480px) {

  .badge-item {
    flex: 1 1 100%;
    border-right: none;
  }

  .card-btns {
    flex-wrap: wrap;
  }

  .btn-pass,
  .btn-fail,
  .btn-rework {
    flex: 1 1 auto;
    text-align: center;
  }

  .chip {
    font-size: 12px;
    padding: 4px 10px;
  }

  .result-select,
  .remarks-textarea {
    font-size: 13px;
  }

  .tab-btn {
    padding: 7px 10px;
    font-size: 11px;
  }
}