/* ══════════════════════════════════════════════════════════
            TOKENS  (sama persis dengan dashboard)
        ══════════════════════════════════════════════════════════ */
:root {
    --bg: #f0f4fa;
    --bg-2: #e8eef8;
    --surface: #ffffff;
    --surface-2: #f5f8fd;
    --border: #dde5f2;
    --border-h: #b8ccec;

    --txt: #0f1f3d;
    --txt-mid: #4a6080;
    --txt-faint: #92a5be;

    --blue: #1a56b0;
    --blue-md: #2468c8;
    --blue-lt: #e8f0fb;
    --blue-glow: rgba(26, 86, 176, .18);

    --gold: #d4a017;
    --gold-md: #f5bc2f;
    --gold-lt: #fef8e6;

    --green: #16803c;
    --green-lt: #dcfce7;
    --red: #c0152a;
    --red-lt: #ffe4e6;
    --orange: #c2570a;
    --orange-lt: #ffedd5;
    --teal: #0e7490;
    --teal-lt: #cffafe;

    --tb-bg: #0f2858;
    --tb-h: 62px;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;

    --shadow-sm: 0 1px 3px rgba(15, 31, 61, .06), 0 1px 2px rgba(15, 31, 61, .04);
    --shadow-md: 0 4px 16px rgba(15, 31, 61, .09), 0 1px 4px rgba(15, 31, 61, .05);

    --font: 'Plus Jakarta Sans', sans-serif;
    --mono: 'DM Mono', monospace;
}

/* ══════════════════════════════════════════════════════════
            BASE
        ══════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--bg);
    color: var(--txt);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: var(--font);
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
            TOPBAR  (identik dashboard)
        ══════════════════════════════════════════════════════════ */
.topbar {
    height: var(--tb-h);
    background: var(--tb-bg);
    border-bottom: 3px solid var(--gold-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(15, 31, 61, .25);
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.tb-logo {
    width: 38px;
    height: 38px;
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, .12);
    border: 1.5px solid rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.tb-logo img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.tb-logo .ico {
    font-size: 18px;
    color: var(--gold-md);
    display: none;
}

.tb-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tb-sub {
    font-size: 10.5px;
    color: rgba(255, 255, 255, .5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.tb-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, .15);
    flex-shrink: 0;
}

/* topbar right actions */
.tb-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    border-radius: var(--r-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    border: 1.5px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .75);
    transition: all .17s ease;
    white-space: nowrap;
    cursor: pointer;
}

.nav-btn i {
    font-size: 13px;
    line-height: 1;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .3);
    color: #fff;
    transform: translateY(-1px);
}

.nav-btn.gold {
    background: var(--gold-md);
    border-color: var(--gold-md);
    color: var(--tb-bg);
    font-weight: 700;
}

.nav-btn.gold:hover {
    background: #f5cc50;
    border-color: #f5cc50;
    box-shadow: 0 4px 14px rgba(245, 188, 47, .4);
}

.nav-btn.danger {
    background: rgba(192, 21, 42, .85);
    border-color: rgba(192, 21, 42, .6);
    color: #fff;
}

.nav-btn.danger:hover {
    background: var(--red);
    border-color: var(--red);
    box-shadow: 0 4px 14px rgba(192, 21, 42, .35);
}

@media (max-width: 640px) {
    .topbar {
        padding: 0 14px;
        gap: 8px;
    }

    .tb-sep {
        display: none;
    }

    .nav-btn .btn-label {
        display: none;
    }

    .nav-btn {
        padding: 7px 10px;
    }

    .tb-sub {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════
            PAGE BODY
        ══════════════════════════════════════════════════════════ */
.page-body {
    flex: 1;
    padding: 20px 24px 52px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

@media (max-width: 768px) {
    .page-body {
        padding: 14px 12px 48px;
    }
}

@media (max-width: 480px) {
    .page-body {
        padding: 10px 10px 40px;
    }
}

/* center column */
.form-col {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── PAGE HEADING ── */
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 4px;
}

.page-heading-left {
    min-width: 0;
}

.page-heading h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--txt);
    letter-spacing: -.3px;
    line-height: 1.2;
}

.page-heading p {
    font-size: 12px;
    color: var(--txt-mid);
    margin-top: 3px;
}

.heading-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════
            SECTION CARD
        ══════════════════════════════════════════════════════════ */
.sec-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sec-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px 11px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.sec-hdr-left {
    display: flex;
    align-items: center;
    gap: 9px;
    /* gold left accent */
    border-left: 3px solid var(--gold-md);
    padding-left: 10px;
}

.sec-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--blue-lt);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.sec-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--txt);
}

.sec-body {
    padding: 18px 20px;
}

@media (max-width: 480px) {
    .sec-hdr {
        padding: 10px 14px;
    }

    .sec-body {
        padding: 14px 14px;
    }
}

/* ══════════════════════════════════════════════════════════
            FORM ELEMENTS
        ══════════════════════════════════════════════════════════ */
.field-grid {
    display: grid;
    gap: 14px 16px;
}

.field-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.field-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.field-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.field-grid.cols-1 {
    grid-template-columns: 1fr;
}

@media (max-width: 768px) {
    .field-grid.cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .field-grid.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .field-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {

    .field-grid.cols-4,
    .field-grid.cols-3,
    .field-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--txt-mid);
    letter-spacing: .2px;
}

.field label .req {
    color: var(--red);
    margin-left: 2px;
}

/* inputs */
.f-input,
.f-select,
.f-textarea {
    width: 100%;
    font-family: var(--font);
    font-size: 13px;
    color: var(--txt);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    padding: 0 13px;
    height: 40px;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.f-textarea {
    height: auto;
    min-height: 88px;
    padding: 10px 13px;
    resize: vertical;
    line-height: 1.55;
}

.f-input:focus,
.f-select:focus,
.f-textarea:focus {
    border-color: var(--blue-md);
    box-shadow: 0 0 0 3px rgba(36, 104, 200, .12);
    background: #fff;
}

.f-input:disabled,
.f-input[disabled] {
    background: var(--surface-2);
    color: var(--txt-faint);
    cursor: not-allowed;
}

/* priority pill */
.priority-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--mono);
    border: 1.5px solid var(--border);
    background: var(--surface-2);
    color: var(--txt-faint);
    letter-spacing: .3px;
    transition: all .2s;
    width: 100%;
}

.priority-pill.P1 {
    background: var(--red-lt);
    color: var(--red);
    border-color: rgba(192, 21, 42, .25);
}

.priority-pill.P2 {
    background: var(--orange-lt);
    color: var(--orange);
    border-color: rgba(194, 87, 10, .25);
}

.priority-pill.P3 {
    background: var(--blue-lt);
    color: var(--blue);
    border-color: rgba(26, 86, 176, .2);
}

.priority-pill.P4 {
    background: var(--green-lt);
    color: var(--green);
    border-color: rgba(22, 128, 60, .2);
}

/* custom select arrow */
.select-wrap {
    position: relative;
}

.select-wrap::after {
    content: '\F282';
    font-family: 'bootstrap-icons';
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--txt-faint);
    font-size: 12px;
    pointer-events: none;
}

.select-wrap .f-select {
    padding-right: 30px;
}

/* ══════════════════════════════════════════════════════════
            DYNAMIC TABLE (Symptoms, Response, RCA, CAPA…)
        ══════════════════════════════════════════════════════════ */
.dyn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.dyn-table thead th {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 8px 12px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--txt-faint);
    white-space: nowrap;
}

.dyn-table tbody td {
    border: 1px solid var(--border);
    padding: 7px 8px;
    vertical-align: top;
}

.dyn-table tbody tr:hover td {
    background: var(--blue-lt);
}

/* inputs inside table */
.dyn-table input[type="text"],
.dyn-table input[type="time"],
.dyn-table input[type="date"],
.dyn-table textarea {
    width: 100%;
    font-family: var(--font);
    font-size: 12px;
    color: var(--txt);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 9px;
    outline: none;
    transition: border-color .14s, box-shadow .14s;
    resize: vertical;
}

.dyn-table input[type="file"] {
    width: 100%;
    font-size: 12px;
    color: var(--txt-mid);
    padding: 4px 0;
}

.dyn-table textarea {
    min-height: 60px;
}

.dyn-table input:focus,
.dyn-table textarea:focus {
    border-color: var(--blue-md);
    box-shadow: 0 0 0 2px rgba(36, 104, 200, .1);
}

/* ── btn add-row ── */
.btn-add-row {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    border-radius: var(--r-sm);
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--font);
    border: 1.5px solid rgba(26, 86, 176, .25);
    background: var(--blue-lt);
    color: var(--blue);
    cursor: pointer;
    transition: all .15s ease;
    white-space: nowrap;
}

.btn-add-row:hover {
    background: var(--blue-md);
    border-color: var(--blue-md);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--blue-glow);
}

/* ── btn remove-row ── */
.btn-rm {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1.5px solid rgba(192, 21, 42, .2);
    background: var(--red-lt);
    color: var(--red);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: all .14s;
}

.btn-rm:hover {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
    transform: scale(1.08);
}

/* ══════════════════════════════════════════════════════════
            BUTTONS  (form actions)
        ══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all .17s ease;
    white-space: nowrap;
}

.btn i {
    font-size: 14px;
    line-height: 1;
}

/* primary save */
.btn-save {
    background: var(--gold-md);
    border-color: var(--gold-md);
    color: var(--tb-bg);
}

.btn-save:hover {
    background: #f5cc50;
    border-color: #f5cc50;
    box-shadow: 0 4px 16px rgba(245, 188, 47, .45);
    transform: translateY(-1px);
}

/* cancel */
.btn-cancel {
    background: var(--surface);
    border-color: var(--border-h);
    color: var(--txt-mid);
}

.btn-cancel:hover {
    background: var(--red-lt);
    border-color: rgba(192, 21, 42, .3);
    color: var(--red);
    transform: translateY(-1px);
}

/* dashboard nav */
.btn-dash {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .2);
    color: rgba(255, 255, 255, .8);
}

/* ══════════════════════════════════════════════════════════
            DIVIDER
        ══════════════════════════════════════════════════════════ */
.form-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ══════════════════════════════════════════════════════════
            TABLE OVERFLOW WRAPPER  (horizontal scroll on mobile)
        ══════════════════════════════════════════════════════════ */
.tbl-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-sm);
}

.tbl-wrap::-webkit-scrollbar {
    height: 4px;
}

.tbl-wrap::-webkit-scrollbar-thumb {
    background: var(--border-h);
    border-radius: 99px;
}

/* ══════════════════════════════════════════════════════════
            ANIMATIONS
        ══════════════════════════════════════════════════════════ */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sec-card {
    animation: fadeUp .35s ease both;
}

.sec-card:nth-child(2) {
    animation-delay: .04s;
}

.sec-card:nth-child(3) {
    animation-delay: .08s;
}

.sec-card:nth-child(4) {
    animation-delay: .12s;
}

.sec-card:nth-child(5) {
    animation-delay: .16s;
}

.sec-card:nth-child(6) {
    animation-delay: .20s;
}

.sec-card:nth-child(7) {
    animation-delay: .24s;
}

.sec-card:nth-child(8) {
    animation-delay: .28s;
}