/* =========================================================
   Root Theme Variables
========================================================= */

:root {
    --navy: #0f172a;
    --blue: #0f3172;
    --green: #1d9e75;
    --gold: #b8952a;
    --red: #c0392b;
    --orange: #d97706;

    --bg: #f6f7f9;
    --card: #ffffff;
    --text: #172033;
    --muted: #687386;
    --border: #d9dee8;
    --soft: #eef4ff;

    --success: #e8f7f1;
    --warning: #fff3e5;
    --danger-bg: #fdecea;

    --radius: 16px;
    --shadow: 0 8px 25px rgba(15, 49, 114, 0.08);
}


/* =========================================================
   Global Reset
========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img,
video {
    max-width: 100%;
}


/* =========================================================
   Header and Branding
========================================================= */

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: linear-gradient(135deg, #111827, var(--blue));
    color: #ffffff;
    padding: 10px 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo {
    width: auto;
    height: 56px;
    max-width: 130px;
    background: #ffffff;
    border-radius: 12px;
    padding: 4px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-copy {
    min-width: 0;
    flex: 1;
}

.brand-copy h1 {
    margin: 0;
    font-size: 17px;
    line-height: 1.2;
}

.brand-copy p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.86;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout {
    margin-left: auto;
    color: var(--blue);
    background: #ffffff;
    border-radius: 999px;
    padding: 8px 12px;
    text-decoration: none;
    font-weight: 800;
    white-space: nowrap;
}


/* =========================================================
   Top Action Buttons
========================================================= */

.top-actions {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    margin-top: 10px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.top-actions button,
.panel button,
.file-button,
.btn {
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    color: var(--blue);
    font-weight: 900;
    padding: 9px 12px;
    white-space: nowrap;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.top-actions .primary,
.primary,
.panel .full.primary {
    background: var(--green);
    color: #ffffff;
}

.top-actions .danger,
.danger {
    background: var(--red);
    color: #ffffff;
}

.gold {
    background: var(--gold) !important;
    color: #ffffff !important;
}


/* =========================================================
   Main App Layout
========================================================= */

.app-shell {
    max-width: 1300px;
    margin: 0 auto;
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 14px;
}


/* =========================================================
   Panels and Cards
========================================================= */

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 14px;
}

.panel h2 {
    margin: 0 0 12px;
    color: var(--blue);
    font-size: 18px;
}

.panel p {
    color: var(--muted);
    margin: 4px 0 0;
}


/* =========================================================
   Forms
========================================================= */

label {
    display: block;
    margin-bottom: 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 900;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    margin-top: 5px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px;
    background: #ffffff;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.two,
.three {
    display: grid;
    gap: 9px;
}

.two {
    grid-template-columns: 1fr 1fr;
}

.three {
    grid-template-columns: 1fr 1fr 1fr;
}


/* =========================================================
   Info Boxes
========================================================= */

.info-box {
    background: #fff8df;
    border: 1px solid #efd071;
    color: #5b4300;
    border-radius: 13px;
    padding: 11px;
    font-size: 13px;
    line-height: 1.45;
    margin: 10px 0;
}


/* =========================================================
   Full Width Buttons and Hidden Inputs
========================================================= */

.full,
.file-button {
    display: block;
    width: 100%;
    margin: 8px 0;
}

.file-button input,
.hidden {
    display: none !important;
}


/* =========================================================
   Section Headers and Pills
========================================================= */

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.pill {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--blue);
    font-weight: 900;
    font-size: 12px;
    white-space: nowrap;
}

.pill.pass {
    background: var(--success);
    color: #12664d;
}

.pill.issue {
    background: var(--warning);
    color: #8a4b00;
}

.pill.high,
.pill.extreme {
    background: var(--danger-bg);
    color: #9b1c1c;
}


/* =========================================================
   Tabs
========================================================= */

.tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    position: sticky;
    top: 111px;
    background: var(--bg);
    z-index: 20;
    padding: 9px 0;
    margin-top: 6px;
}

.tab {
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--blue);
    padding: 10px 13px;
    border-radius: 999px;
    font-weight: 900;
    white-space: nowrap;
    cursor: pointer;
}

.tab.active {
    background: var(--blue);
    color: #ffffff;
    border-color: var(--blue);
}


/* =========================================================
   Inspection Component Groups
========================================================= */

.group-title {
    margin: 18px 4px 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 900;
}

.component {
    border: 1px solid var(--border);
    border-radius: 15px;
    margin-bottom: 8px;
    overflow: hidden;
    background: #ffffff;
}

.component-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px;
    cursor: pointer;
    background: #fbfcff;
}

.component-top:hover {
    background: #f2f6ff;
}

.chev {
    font-weight: 900;
    color: var(--blue);
    transition: transform 0.2s ease;
}

.component.open .chev {
    transform: rotate(90deg);
}

.comp-title {
    flex: 1;
    font-weight: 900;
}

.comp-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

.component-body {
    border-top: 1px solid var(--border);
    padding: 13px;
    display: none;
}

.component.open .component-body {
    display: block;
}


/* =========================================================
   Status Buttons
========================================================= */

.status-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    margin-bottom: 10px;
}

.status-row button {
    background: #f7f8fb;
    border: 1px solid var(--border);
    color: var(--text);
}

.status-row .on.pass {
    background: var(--success);
    color: #12664d;
    border-color: var(--green);
}

.status-row .on.issue {
    background: var(--danger-bg);
    color: var(--red);
    border-color: var(--red);
}

.status-row .on.na {
    background: #eeeeee;
    color: #555555;
    border-color: #bbbbbb;
}


/* =========================================================
   Field and Media Actions
========================================================= */

.field-actions,
.media-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.mini {
    padding: 8px 10px !important;
    background: #f3f8ff !important;
    border: 1px solid var(--border) !important;
    color: var(--blue) !important;
}

.mini.danger {
    background: var(--danger-bg) !important;
    color: var(--red) !important;
}


/* =========================================================
   Media Grid and Thumbnails
========================================================= */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.thumb {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #eef2f7;
    min-height: 92px;
}

.thumb img,
.thumb video {
    display: block;
    width: 100%;
    height: 240px;
    object-fit: cover;
}

.thumb span {
    display: block;
    padding: 5px 7px;
    font-size: 11px;
    text-align: center;
    color: var(--muted);
    background: #ffffff;
}

.thumb button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 0;
}


/* =========================================================
   Summary Table and Risk Colours
========================================================= */

.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.summary-table th,
.summary-table td {
    border: 1px solid var(--border);
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.summary-table th {
    background: var(--soft);
    color: var(--blue);
}

.risk-low {
    color: #12664d;
    font-weight: 800;
}

.risk-moderate {
    color: #8a5a00;
    font-weight: 800;
}

.risk-high,
.risk-extreme {
    color: #9b1c1c;
    font-weight: 800;
}


/* =========================================================
   Floating Action Buttons
========================================================= */

.floating-actions {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
}

.floating-actions button {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: var(--blue);
    color: #ffffff;
    box-shadow: var(--shadow);
    font-size: 20px;
}


/* =========================================================
   Modals
========================================================= */

.modal,
.image-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 60;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal.on,
.image-modal.on {
    display: flex;
}

.modal-box {
    background: #ffffff;
    border-radius: 18px;
    max-width: 760px;
    width: 100%;
    max-height: 88vh;
    overflow: auto;
    padding: 18px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.check {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 9px 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 14px;
    color: var(--text);
}

.check input {
    width: auto;
    margin-top: 3px;
}

.image-modal {
    background: rgba(0, 0, 0, 0.82);
    z-index: 90;
}

.image-modal img {
    max-width: 96vw;
    max-height: 88vh;
    border-radius: 12px;
    background: #ffffff;
}


/* =========================================================
   Toast Message
========================================================= */

.toast {
    display: none;
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    background: #111827;
    color: #ffffff;
    border-radius: 999px;
    padding: 11px 15px;
    font-weight: 900;
    z-index: 100;
}

.toast.on {
    display: block;
}


/* =========================================================
   Login Page
========================================================= */

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8f7f4, #eef6ff);
    padding: 20px;
}

.login-card {
    max-width: 430px;
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.login-logo {
    display: block;
    max-width: 240px;
    width: 80%;
    margin: 0 auto 14px;
}

.login-card h1,
.login-card p {
    text-align: center;
}

.login-card h1 {
    color: var(--blue);
    margin: 0;
}

.login-card p {
    color: var(--muted);
}

.login-card button {
    width: 100%;
    margin-top: 16px;
    padding: 13px;
    border: 0;
    border-radius: 12px;
    background: var(--green);
    color: #ffffff;
    font-weight: 900;
}

.alert {
    background: #fef3f2;
    color: #b42318;
    border-radius: 12px;
    padding: 10px;
    margin: 12px 0;
}

.small {
    font-size: 12px !important;
    margin-top: 13px !important;
    color: var(--muted);
    text-align: center;
}


/* =========================================================
   Phrase Library
========================================================= */

.phrase-group {
    margin-top: 14px;
}

.phrase-group h3 {
    margin: 10px 0 8px;
    color: var(--blue);
    font-size: 15px;
}

.phrase-list {
    display: grid;
    gap: 8px;
}

.phrase-item {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
    text-align: left;
    white-space: normal;
    line-height: 1.4;
    font-weight: 600;
}

.phrase-item:hover {
    background: var(--soft);
    color: var(--blue);
}


/* =========================================================
   Tablet and Small Laptop Layout
========================================================= */

@media (max-width: 920px) {

    .app-shell {
        display: block;
        padding: 10px;
    }

    .app-logo {
        height: 44px;
        max-width: 110px;
    }

    .brand-row {
        gap: 8px;
    }

    .brand-copy h1 {
        font-size: 14px;
    }

    .brand-copy p {
        font-size: 11px;
    }

    .logout {
        padding: 7px 10px;
        font-size: 12px;
    }

    .tabs {
        top: 103px;
    }

    .two,
    .three,
    .status-row {
        grid-template-columns: 1fr;
    }

    .top-actions button {
        font-size: 12px;
        padding: 8px 10px;
    }

    .floating-actions {
        right: 10px;
        bottom: 10px;
    }

    .floating-actions button {
        width: 44px;
        height: 44px;
    }
}


/* =========================================================
   Mobile Phone Layout
========================================================= */

@media (max-width: 520px) {

    .app-header {
        padding: 8px 10px;
    }

    .brand-row {
        align-items: flex-start;
    }

    .app-logo {
        height: 40px;
        max-width: 95px;
    }

    .brand-copy h1 {
        font-size: 13px;
    }

    .section-head {
        flex-direction: column;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    }

    .thumb img,
    .thumb video {
        height: 180px;
    }
}


/* =========================================================
   Print Styling
========================================================= */

@media print {

    body {
        background: #ffffff;
    }

    .app-header,
    .details-panel,
    .tabs,
    .floating-actions,
    .field-actions,
    .media-actions,
    .modal,
    .toast,
    .no-print {
        display: none !important;
    }

    .app-shell {
        display: block;
        padding: 0;
    }

    .panel {
        box-shadow: none;
        border: 0;
        padding: 0;
    }

    .component:not(.has-data) {
        display: none;
    }

    .component-body {
        display: block !important;
    }
}