* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    padding-bottom: 72px;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #fff;
    color: #222;
}

a {
    text-decoration: none;
}

/* =========================
   COMMON HEADER
   Matches supplied PDF:
   title on first row;
   logo + mode buttons on second row.
   ========================= */

.site-header {
    width: 94%;
    max-width: 1600px;
    margin: 0 auto;
}

.header-top {
    height: 205px;
    display: grid;
    grid-template-columns: 1fr 1.6fr 1fr;
    grid-template-rows: 92px 113px;
    align-items: center;
    column-gap: 20px;
}

.header-title {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    text-align: center;
    color: #555;
    font-size: 38px;
    line-height: 1.1;
    font-weight: 700;
}

.header-logo {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    justify-self: start;
}

.header-logo a {
    display: block;
}

.header-logo img {
    width: 270px;
    max-width: 100%;
    height: auto;
    display: block;
}

.header-switch {
    grid-column: 3;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    display: flex;
    gap: 30px;
}

.header-line {
    border-bottom: 3px solid #555;
}

/* =========================
   MAIN PAGE
   ========================= */

.page {
    width: 94%;
    max-width: 1600px;
    margin: 0 auto 45px;
}

.tool-page {
    padding-top: 18px;
}

.program-theme {
    color: #087989;
}

.organisation-theme {
    color: #087989;
}

/* =========================
   SECTION HEADER
   PDF layout:
   left = title/template/example
   right = Version then Login
   divider below both.
   ========================= */

.section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    column-gap: 35px;
    align-items: start;
    border-bottom: 3px solid currentColor;
    padding: 0 0 25px;
}

.section-content h1 {
    margin: 0 0 12px;
    font-size: 25px;
    line-height: 1.15;
    font-weight: 700;
    text-decoration: underline;
}

.section-content p {
    margin: 6px 0;
    font-size: 19px;
    line-height: 1.25;
}

.section-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-height: 105px;
}

.section-side .version {
    margin: 2px 0 31px;
    font-size: 18px;
    line-height: 1;
    font-weight: 700;
}

.login-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    white-space: nowrap;
    font-size: 17px;
    font-weight: 400;
}

.mode-btn,
.login-links a,
.convert-btn,
.admin-actions button {
    border: 0;
    border-radius: 8px;
    padding: 13px 25px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.mode-btn {
    min-width: 205px;
    text-align: center;
    background: #087989;
    color: #fff;
}

.active-program {
    background: #087989;
}

.active-organisation {
    background: #087989;
}

.login-links a {
    background: #087989;
    color: #fff;
    min-width: 105px;
    text-align: center;
}

.organisation-theme .login-links a {
    background: #087989;
}

/* =========================
   NAMING INPUTS
   ========================= */

.rows {
    margin-top: 45px;
    overflow-x: auto;
}

.naming-row {
    width: 100%;
    max-width: 1350px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 36px;
}

.naming-row label {
    font-size: 17px;
    line-height: 1.2;
    text-align: center;
}

.naming-row input,
.naming-row select {
    width: 100%;
    height: 40px;
    margin-top: 8px;
    padding: 0 12px;
    border: 0;
    border-radius: 0;
    background: #c6e1e6;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
}

.program-theme .naming-row input,
.program-theme .naming-row select,
.organisation-theme .naming-row input,
.organisation-theme .naming-row select {
    background: #c6e1e6;
}

.naming-row select {
    cursor: pointer;
}

/* =========================
   CONVERSION
   ========================= */

.convert-btn {
    display: block;
    min-width: 225px;
    margin: 42px auto 30px;
    background: #087989;
    color: #fff;
}

.program-theme .convert-btn,
.organisation-theme .convert-btn {
    background: #087989;
}

.note {
    margin: 72px 0 26px;
    text-align: center;
    font-size: 21px;
    line-height: 1.25;
}

.result-box {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    margin: 0 7%;
    padding: 8px 62px 8px 22px;
    border-radius: 28px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .10);
    border: 1px solid rgba(0, 0, 0, .08);
    background: #a8d0d7;
    color: #111;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
    word-break: break-word;
    text-align: center;
}

.program-theme .result-box,
.organisation-theme .result-box {
    background: #a8d0d7;
}

.copy-btn {
    position: absolute;
    right: 10px;
    width: 38px;
    height: 38px;
    border: 1px solid #555;
    border-radius: 10px;
    background: #eee;
    cursor: pointer;
    font-size: 23px;
}

/* =========================
   FOOTER
   ========================= */

.site-footer {
    position: fixed;
    left: 3%;
    right: 3%;
    bottom: 0;
    z-index: 1000;
    width: 94%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 14px 0;
    border-top: 1px solid #ccc;
    background: #fff;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    column-gap: 30px;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

.footer-left {
    text-align: left;
}

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

.footer-right {
    text-align: right;
}

/* =========================
   MANAGEMENT PAGES
   ========================= */

.auth-page,
.management-page {
    width: min(1050px, 94%);
    margin: 40px auto;
}

.card {
    padding: 28px;
    border-radius: 10px;
    background: #f5f5f5;
    box-shadow: 0 3px 15px rgba(0, 0, 0, .08);
}

.card h1 {
    margin-top: 0;
}

.form-grid {
    display: grid;
    gap: 14px;
    max-width: 520px;
}

.form-grid input,
.form-grid select {
    padding: 11px;
    border: 1px solid #bbb;
    border-radius: 5px;
    font-size: 16px;
}

.btn {
    padding: 10px 18px;
    border: 0;
    border-radius: 6px;
    background: #829f79;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.btn.danger {
    background: #a94442;
}

.btn.secondary {
    background: #666;
}

.message {
    padding: 10px 14px;
    margin-bottom: 15px;
    border-left: 4px solid #5b8c5a;
    background: #e7f5e7;
}

.error {
    padding: 10px 14px;
    margin-bottom: 15px;
    border-left: 4px solid #a94442;
    background: #fde8e8;
}

.management-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.management-section {
    min-width: 0;
}

.add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.add-form input {
    flex: 1;
    min-width: 0;
    padding: 10px;
    border: 1px solid #bbb;
    border-radius: 5px;
    font-size: 15px;
}

.data-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.data-table th {
    background: #eee;
}

.inline-form {
    display: inline;
}

.actions {
    white-space: nowrap;
}

.actions input {
    width: 170px;
    padding: 7px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

.actions .btn {
    padding: 7px 12px;
    margin-left: 4px;
}

.hidden {
    display: none !important;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 1100px) {
    .naming-row {
        max-width: 100%;
        gap: 24px;
    }

    .header-top {
        height: 190px;
        grid-template-rows: 80px 110px;
    }

    .header-title {
        font-size: 32px;
    }

    .header-logo img {
        width: 230px;
    }

    .header-switch {
        gap: 14px;
    }

    .mode-btn {
        min-width: 170px;
        padding: 11px 18px;
        font-size: 14px;
    }

    .section-heading {
        grid-template-columns: minmax(0, 1fr) 300px;
    }

    .section-content p {
        font-size: 17px;
    }

    .naming-row {
        gap: 24px;
    }
}

@media (max-width: 800px) {
    .header-top {
        height: auto;
        min-height: 220px;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 70px 80px 70px;
    }

    .header-title {
        grid-column: 1;
        grid-row: 1;
        font-size: 30px;
    }

    .header-logo {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }

    .header-logo img {
        width: 210px;
    }

    .header-switch {
        grid-column: 1;
        grid-row: 3;
        justify-self: center;
    }

    .section-heading {
        grid-template-columns: 1fr;
    }

    .section-side {
        align-items: flex-start;
        min-height: auto;
        margin-top: 20px;
    }

    .section-side .version {
        margin-bottom: 18px;
    }

    .login-links {
        justify-content: flex-start;
    }

    .site-footer {
        grid-template-columns: 1fr;
        row-gap: 8px;
    }

    .footer-left,
    .footer-center,
    .footer-right {
        text-align: center;
    }

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

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: none;
}

.naming-row input:focus,
.naming-row select:focus { outline: 2px solid rgba(8, 121, 137, .25); outline-offset: 1px; }
.naming-row input,
.naming-row select { transition: box-shadow .15s ease, outline-color .15s ease; }
.program-theme .result-box { box-shadow: 0 3px 12px rgba(0, 0, 0, .12); }
.organisation-theme .result-box { box-shadow: 0 3px 12px rgba(8, 121, 137, .12); }

.mode-btn:hover,
.login-links a:hover,
.convert-btn:hover {
    filter: brightness(0.92);
}

.naming-row input:focus,
.naming-row select:focus {
    outline: 2px solid rgba(8, 121, 137, 0.35);
    outline-offset: 1px;
}

/* =========================================================
   FINAL RESPONSIVE LAYOUT
   File Naming Convention
   Mobile + Tablet + Desktop
   ========================================================= */

/* ---------------------------------------------------------
   GENERAL RESPONSIVE SAFETY
   --------------------------------------------------------- */

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
}

.page,
.tool-page,
.section-heading,
.section-content,
.section-side,
.rows,
.naming-row {
    min-width: 0;
}


/* ---------------------------------------------------------
   TABLET
   768px - 991px
   --------------------------------------------------------- */

@media (min-width: 768px) and (max-width: 991px) {

    .site-header,
    .page {
        width: 92%;
    }

    /* Header */

    .header-top {
        height: auto;
        min-height: 185px;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        row-gap: 12px;
        padding: 15px 0;
    }

    .header-title {
        grid-column: 1;
        grid-row: 1;
        font-size: 30px;
    }

    .header-logo {
        grid-column: 1;
        grid-row: 2;
        justify-self: center;
    }

    .header-logo img {
        width: 220px;
    }

    .header-switch {
        grid-column: 1;
        grid-row: 3;
        justify-self: center;
        width: 100%;
        justify-content: center;
        gap: 15px;
    }

    .mode-btn {
        min-width: 190px;
    }

    /* Section heading */

    .section-heading {
        grid-template-columns: minmax(0, 1fr) 220px;
        column-gap: 25px;
        padding-bottom: 22px;
    }

    .section-content h1 {
        font-size: 24px;
    }

    .section-content p {
        font-size: 17px;
    }

    .section-side {
        align-items: flex-end;
    }

    .login-links {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .login-links a {
        min-width: 90px;
        padding: 12px 16px;
    }

    /* Naming fields:
       2 columns on tablet */

    .rows {
        margin-top: 35px;
        overflow-x: visible;
    }

    .naming-row {
        width: 100%;
        max-width: 720px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 28px;
    }

    .naming-row label {
        font-size: 17px;
    }

    .naming-row input,
    .naming-row select {
        height: 46px;
        font-size: 16px;
    }

    /* Make Version occupy normal width */

    .naming-row label:last-child {
        grid-column: span 1;
    }

    .convert-btn {
        min-width: 240px;
        min-height: 48px;
        margin-top: 38px;
    }

    .note {
        margin-top: 55px;
        font-size: 19px;
    }

    .result-box {
        margin-left: 3%;
        margin-right: 3%;
    }

    /* Footer */

    .site-footer {
        left: 4%;
        right: 4%;
        width: 92%;
    }
}


/* ---------------------------------------------------------
   MOBILE
   Below 768px
   --------------------------------------------------------- */

@media (max-width: 767px) {

    body {
        padding-bottom: 0;
    }

    .site-header,
    .page {
        width: 92%;
        max-width: none;
    }

    /* -----------------------------------------------------
       HEADER
       ----------------------------------------------------- */

    .header-top {
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 16px 0 18px;
    }

    .header-title {
        order: 1;
        font-size: 25px;
        line-height: 1.2;
        text-align: center;
    }

    .header-logo {
        order: 2;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .header-logo img {
        width: 185px;
        max-width: 70vw;
    }

    .header-switch {
        order: 3;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .mode-btn {
        min-width: 0;
        width: 100%;
        padding: 12px 8px;
        font-size: 14px;
        line-height: 1.2;
        text-align: center;
    }

    .header-line {
        border-bottom-width: 2px;
    }


    /* -----------------------------------------------------
       MAIN SECTION HEADER
       ----------------------------------------------------- */

    .tool-page {
        padding-top: 18px;
    }

    .section-heading {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding-bottom: 20px;
    }

    .section-content h1 {
        margin-bottom: 14px;
        font-size: 24px;
        line-height: 1.15;
    }

    .section-content p {
        margin: 8px 0;
        font-size: 17px;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .section-side {
        align-items: stretch;
        min-height: 0;
        margin-top: 20px;
    }

    .section-side .version {
        margin: 0 0 16px;
        font-size: 17px;
    }

    .login-links {
        width: 100%;
        display: grid;
        grid-template-columns: auto 1fr 1fr;
        gap: 8px;
        align-items: center;
        white-space: normal;
        font-size: 16px;
    }

    .login-links span {
        white-space: nowrap;
    }

    .login-links a {
        min-width: 0;
        width: 100%;
        padding: 12px 8px;
        font-size: 15px;
    }


    /* -----------------------------------------------------
       NAMING FORM
       One field per row on mobile
       ----------------------------------------------------- */

    .rows {
        margin-top: 28px;
        overflow-x: visible;
    }

    .naming-row {
        width: 100%;
        max-width: none;
        margin: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .naming-row label {
        display: block;
        width: 100%;
        font-size: 16px;
        line-height: 1.25;
        text-align: left;
    }

    .naming-row input,
    .naming-row select {
        display: block;
        width: 100%;
        height: 48px;
        margin-top: 7px;
        padding: 0 13px;
        font-size: 16px;
        border-radius: 4px;
    }

    .naming-row select {
        appearance: auto;
    }


    /* -----------------------------------------------------
       CONVERT BUTTON
       ----------------------------------------------------- */

    .convert-btn {
        width: min(100%, 320px);
        min-width: 0;
        min-height: 50px;
        margin: 32px auto 24px;
        padding: 13px 20px;
        font-size: 16px;
    }


    /* -----------------------------------------------------
       NOTE
       ----------------------------------------------------- */

    .note {
        margin: 42px 5px 20px;
        font-size: 17px;
        line-height: 1.4;
    }


    /* -----------------------------------------------------
       RESULT
       ----------------------------------------------------- */

    .result-box {
        width: 100%;
        min-height: 54px;
        margin: 0;
        padding: 12px 58px 12px 15px;
        border-radius: 18px;
        font-size: 15px;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    .copy-btn {
        right: 8px;
        width: 40px;
        height: 40px;
    }


    /* -----------------------------------------------------
       FOOTER
       Do not keep it fixed on mobile.
       ----------------------------------------------------- */

    .site-footer {
        position: static;
        width: 92%;
        margin: 45px auto 0;
        padding: 18px 0;
        display: flex;
        flex-direction: column;
        gap: 8px;
        border-top: 1px solid #ccc;
        font-size: 13px;
    }

    .footer-left,
    .footer-center,
    .footer-right {
        width: 100%;
        text-align: center;
    }
}


/* ---------------------------------------------------------
   SMALL MOBILE
   320px - 479px
   --------------------------------------------------------- */

@media (max-width: 479px) {

    .site-header,
    .page {
        width: 90%;
    }

    .header-top {
        gap: 13px;
        padding-top: 12px;
    }

    .header-title {
        font-size: 22px;
    }

    .header-logo img {
        width: 165px;
    }

    .header-switch {
        gap: 8px;
    }

    .mode-btn {
        padding: 11px 5px;
        font-size: 13px;
    }

    .section-content h1 {
        font-size: 22px;
    }

    .section-content p {
        font-size: 16px;
        line-height: 1.4;
    }

    .section-side {
        margin-top: 16px;
    }

    .login-links {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .login-links span {
        grid-column: 1 / -1;
    }

    .login-links a {
        font-size: 14px;
        padding: 11px 6px;
    }

    .rows {
        margin-top: 24px;
    }

    .naming-row {
        gap: 18px;
    }

    .naming-row label {
        font-size: 15px;
    }

    .naming-row input,
    .naming-row select {
        height: 46px;
        font-size: 16px;
    }

    .convert-btn {
        width: 100%;
        max-width: none;
        margin-top: 28px;
    }

    .note {
        margin-top: 38px;
        font-size: 16px;
    }

    .result-box {
        font-size: 14px;
        padding-left: 12px;
        padding-right: 55px;
    }

    .site-footer {
        width: 90%;
        font-size: 12px;
    }
}


/* ---------------------------------------------------------
   TOUCH DEVICES
   --------------------------------------------------------- */

@media (hover: none) and (pointer: coarse) {

    .mode-btn,
    .login-links a,
    .convert-btn,
    .copy-btn {
        -webkit-tap-highlight-color: transparent;
    }

    .mode-btn,
    .login-links a,
    .convert-btn {
        min-height: 46px;
    }

    .naming-row input,
    .naming-row select {
        min-height: 46px;
    }
}
