@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/poppins-400.ttf") format("truetype");
}

@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/poppins-500.ttf") format("truetype");
}

@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/poppins-600.ttf") format("truetype");
}

@font-face {
    font-family: "Poppins";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/poppins-700.ttf") format("truetype");
}

:root {
    --bg: #f5faf6;
    --bg-soft: #eef5ef;
    --panel: rgba(255, 255, 255, 0.97);
    --panel-border: rgba(11, 107, 61, 0.1);
    --shadow: 0 18px 44px rgba(15, 36, 28, 0.08);
    --shadow-soft: 0 12px 28px rgba(15, 36, 28, 0.06);
    --text: #183327;
    --muted: #61756a;
    --primary: #0e9f53;
    --primary-dark: #0b6b3d;
    --accent: #1aa8c6;
    --line: rgba(11, 107, 61, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Poppins", sans-serif;
    background:
        radial-gradient(circle at 8% 10%, rgba(14, 159, 83, 0.14), transparent 24%),
        radial-gradient(circle at 92% 14%, rgba(26, 168, 198, 0.08), transparent 20%),
        linear-gradient(180deg, #fbfdfb 0%, var(--bg-soft) 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(rgba(11, 107, 61, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(11, 107, 61, 0.03) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.22), transparent 72%);
    pointer-events: none;
}

.js body.app-booting {
    overflow: hidden;
}

img {
    display: block;
    max-width: 100%;
}

button,
input {
    font: inherit;
}

code {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(11, 107, 61, 0.08);
    color: var(--primary-dark);
    font-family: "Poppins", sans-serif;
    font-size: 0.88em;
    font-weight: 600;
}

.page {
    width: min(1320px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 42px;
}

.js body.app-booting .page {
    opacity: 0;
    pointer-events: none;
}

.intro-screen {
    display: none;
}

.js .intro-screen {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 40%, rgba(14, 159, 83, 0.08), transparent 22%),
        linear-gradient(180deg, #f8fcf8 0%, #edf4ef 100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.js body.app-booting .intro-screen {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.intro-card {
    opacity: 0;
}

.stage-logo .intro-card-logo {
    opacity: 1;
}

.intro-logo-only {
    display: grid;
    place-items: center;
}

.intro-logo-image {
    width: min(320px, 64vw);
    height: auto;
}

.page-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 22px 24px;
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 249, 0.96)),
        var(--panel);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.page-header::after {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    width: 280px;
    background: linear-gradient(135deg, rgba(14, 159, 83, 0.08), rgba(26, 168, 198, 0.02));
    pointer-events: none;
}

.brand-lockup {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-logo {
    width: 156px;
    height: auto;
    flex: 0 0 auto;
}

.brand-copy {
    display: grid;
    gap: 6px;
}

.brand-kicker {
    margin: 0;
    color: var(--primary-dark);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.74rem;
    font-weight: 700;
}

.brand-copy strong {
    font-size: 1.28rem;
    font-weight: 700;
}

.brand-copy > span {
    color: var(--muted);
    font-size: 0.96rem;
}

.brand-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.brand-tags span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(14, 159, 83, 0.08);
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.header-actions {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
    justify-items: end;
}

.switch-stack {
    display: grid;
    gap: 8px;
    justify-items: end;
}

.switch-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.mode-switch,
.type-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px;
    border: 1px solid rgba(14, 159, 83, 0.08);
    border-radius: 999px;
    background: rgba(14, 159, 83, 0.08);
}

.mode-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 162px;
    min-height: 48px;
    padding: 0 22px;
    border-radius: 999px;
    background: transparent;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.mode-button.is-active {
    background: linear-gradient(135deg, var(--primary), #2ab861);
    color: #fff;
    box-shadow: 0 12px 24px rgba(10, 159, 73, 0.2);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(400px, 520px) minmax(380px, 1fr);
    gap: 28px;
    align-items: start;
}

.control-stack {
    display: grid;
    gap: 18px;
}

.mode-panel[hidden] {
    display: none !important;
}

.panel {
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(249, 252, 250, 0.97)),
        var(--panel);
    box-shadow: var(--shadow);
}

.form-panel,
.preview-panel,
.error-panel,
.bulk-panel {
    padding: 28px;
}

.panel h1,
.panel h2 {
    margin: 0;
    font-family: "Poppins", sans-serif;
    font-weight: 700;
    line-height: 1.08;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    font-size: 1.95rem;
}

.panel-head-preview {
    margin-bottom: 18px;
}

.eyebrow,
.preview-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 700;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary-dark);
}

.preview-status {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(14, 159, 83, 0.08);
    color: var(--primary-dark);
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    font-size: 0.93rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.field input {
    width: 100%;
    min-height: 56px;
    padding: 15px 16px;
    border: 1px solid rgba(10, 115, 58, 0.16);
    border-radius: 18px;
    background: rgba(248, 251, 249, 0.96);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
    border-color: rgba(10, 159, 73, 0.45);
    box-shadow: 0 0 0 4px rgba(10, 159, 73, 0.12);
}

.field input[readonly] {
    color: rgba(23, 50, 39, 0.6);
    background: rgba(235, 244, 238, 0.92);
}

.field-wide {
    grid-column: 1 / -1;
}

.tips {
    margin: 18px 0 0;
    padding: 16px 18px;
    border: 1px solid rgba(14, 159, 83, 0.08);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(10, 159, 73, 0.08), rgba(21, 170, 196, 0.03));
    color: var(--muted);
}

.tips p {
    margin: 0;
}

.tips p + p {
    margin-top: 8px;
}

.bulk-upload-box {
    padding: 18px;
    border: 1px dashed rgba(10, 159, 73, 0.28);
    border-radius: 24px;
    background:
        linear-gradient(180deg, rgba(10, 159, 73, 0.05), rgba(21, 170, 196, 0.03)),
        rgba(255, 255, 255, 0.82);
}

.bulk-upload-label {
    display: grid;
    gap: 10px;
    color: var(--primary-dark);
    font-size: 0.95rem;
    font-weight: 700;
}

.bulk-upload-input {
    width: 100%;
    padding: 14px;
    border: 1px solid rgba(10, 115, 58, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
}

.bulk-upload-file {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.bulk-tips {
    margin-top: 16px;
}

.action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 22px;
}

.primary-button,
.secondary-button,
.ghost-button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0 20px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), #2ab861);
    color: #fff;
    box-shadow: 0 14px 28px rgba(10, 159, 73, 0.2);
}

.secondary-button {
    background: rgba(21, 170, 196, 0.1);
    color: #075b68;
}

.ghost-button,
.button-link.ghost-button {
    border: 1px solid rgba(11, 107, 61, 0.08);
    background: rgba(11, 107, 61, 0.08);
    color: var(--primary-dark);
}

.preview-panel {
    position: sticky;
    top: 20px;
}

.certificate-frame {
    padding: 20px;
    border: 1px solid rgba(13, 110, 49, 0.08);
    border-radius: 26px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(241, 248, 242, 0.9)),
        linear-gradient(145deg, rgba(21, 170, 196, 0.04), rgba(215, 179, 77, 0.04));
}

.certificate-sheet {
    --certificate-bleed: 0px;
    position: relative;
    width: 100%;
    aspect-ratio: 210 / 297;
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    container-type: inline-size;
    box-shadow: 0 22px 46px rgba(18, 74, 33, 0.12);
}

.certificate-sheet-landscape {
    aspect-ratio: 297 / 210;
}

.certificate-bg {
    position: absolute;
    inset: calc(var(--certificate-bleed) * -1);
    width: calc(100% + (var(--certificate-bleed) * 2));
    height: calc(100% + (var(--certificate-bleed) * 2));
    max-width: none;
    object-fit: cover;
}

.certificate-name,
.certificate-location,
.certificate-number,
.certificate-valid-date,
.certificate-valid-label {
    position: absolute;
    z-index: 1;
    text-align: center;
    color: #101010;
}

.certificate-name {
    top: 40.1%;
    left: 22%;
    width: 56%;
    padding: 0 1%;
    font-family: "Poppins", sans-serif;
    font-size: 4.2cqw;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.045em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.certificate-name.name-short {
    top: 40.25%;
    left: 24%;
    width: 52%;
    font-size: 4.8cqw;
}

.certificate-name.name-medium {
    top: 40.15%;
    left: 22%;
    width: 56%;
    font-size: 4.25cqw;
}

.certificate-name.name-long {
    top: 39.95%;
    left: 20%;
    width: 60%;
    font-size: 3.55cqw;
    line-height: 1.06;
}

.certificate-name.name-xlong,
.certificate-name.name-placeholder {
    top: 39.8%;
    left: 18%;
    width: 64%;
    font-size: 3.05cqw;
    line-height: 1.08;
}

.certificate-location {
    top: 57.65%;
    left: 23.8%;
    width: 61.6%;
    font-family: "Poppins", sans-serif;
    font-size: 2.2cqw;
    font-weight: 500;
    line-height: 1.18;
    text-wrap: balance;
}

.certificate-number {
    top: 63.1%;
    left: 24%;
    width: 61.4%;
    font-family: "Poppins", sans-serif;
    font-size: 1.95cqw;
    font-weight: 500;
    line-height: 1.14;
    text-wrap: balance;
}

.certificate-valid-date {
    top: 79.9%;
    left: 18.8%;
    width: 33.8%;
    font-family: "Poppins", sans-serif;
    font-size: 2.15cqw;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.certificate-valid-label {
    display: none;
}

.certificate-date-line {
    position: absolute;
    z-index: 1;
    top: 84.2%;
    left: 26.35%;
    width: 23.7%;
    height: 0.28cqw;
    border-radius: 999px;
    background: #0a9f49;
}

.certificate-sheet-dealer .certificate-name {
    top: 40.75%;
    left: 21%;
    width: 58%;
    padding: 0 1%;
    font-family: "Poppins", sans-serif;
    font-size: 4.55cqw;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.04em;
}

.certificate-sheet-dealer .certificate-name.name-short {
    top: 40.85%;
    left: 22%;
    width: 56%;
    font-size: 4.8cqw;
}

.certificate-sheet-dealer .certificate-name.name-medium {
    top: 40.8%;
    left: 21%;
    width: 58%;
    font-size: 4.35cqw;
}

.certificate-sheet-dealer .certificate-name.name-long {
    top: 40.6%;
    left: 19%;
    width: 62%;
    font-size: 3.7cqw;
    line-height: 1.08;
}

.certificate-sheet-dealer .certificate-name.name-xlong,
.certificate-sheet-dealer .certificate-name.name-placeholder {
    top: 40.4%;
    left: 17%;
    width: 66%;
    font-size: 3.18cqw;
    line-height: 1.1;
}

.certificate-sheet-dealer .certificate-location {
    top: 60.65%;
    left: 19%;
    width: 62%;
    font-family: "Poppins", sans-serif;
    font-size: 2.75cqw;
    font-weight: 500;
    line-height: 1.18;
}

.certificate-sheet-dealer .certificate-number {
    top: 64.45%;
    left: 19%;
    width: 62%;
    font-family: "Poppins", sans-serif;
    font-size: 2.7cqw;
    font-weight: 500;
    line-height: 1.16;
}

.certificate-sheet-dealer .certificate-valid-date {
    top: 81.15%;
    left: 19.2%;
    width: 33.8%;
    font-family: "Poppins", sans-serif;
    font-size: 2.5cqw;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.certificate-sheet-dealer .certificate-valid-label {
    display: block;
    top: 84.55%;
    left: 19.2%;
    width: 33.8%;
    font-family: "Poppins", sans-serif;
    font-size: 2.2cqw;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.certificate-sheet-dealer .certificate-date-line {
    top: 83.75%;
    left: 27.05%;
    width: 18.1%;
    height: 0.28cqw;
}

.certificate-sheet-distributor .certificate-name {
    top: 35.8%;
    left: 28.5%;
    width: 42.5%;
    padding: 0 1%;
    font-family: "Poppins", sans-serif;
    font-size: 3.25cqw;
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.03em;
}

.certificate-sheet-distributor .certificate-name.name-short {
    top: 35.9%;
    left: 29%;
    width: 41.5%;
    font-size: 3.4cqw;
}

.certificate-sheet-distributor .certificate-name.name-medium {
    top: 35.85%;
    left: 28.5%;
    width: 42.5%;
    font-size: 3.18cqw;
}

.certificate-sheet-distributor .certificate-name.name-long {
    top: 35.7%;
    left: 27%;
    width: 45.5%;
    font-size: 2.75cqw;
    line-height: 1.08;
}

.certificate-sheet-distributor .certificate-name.name-xlong,
.certificate-sheet-distributor .certificate-name.name-placeholder {
    top: 35.45%;
    left: 25.5%;
    width: 48.5%;
    font-size: 2.38cqw;
    line-height: 1.1;
}

.certificate-sheet-distributor .certificate-location {
    top: 60.25%;
    left: 24%;
    width: 51%;
    font-family: "Poppins", sans-serif;
    font-size: 1.95cqw;
    font-weight: 500;
    line-height: 1.18;
}

.certificate-sheet-distributor .certificate-number {
    top: 67.2%;
    left: 24%;
    width: 51%;
    font-family: "Poppins", sans-serif;
    font-size: 1.88cqw;
    font-weight: 500;
    line-height: 1.16;
}

.certificate-sheet-distributor .certificate-valid-date {
    top: 74.35%;
    left: 11.2%;
    width: 17.8%;
    font-family: "Poppins", sans-serif;
    font-size: 1.7cqw;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.certificate-sheet-distributor .certificate-valid-label {
    display: block;
    top: 78.05%;
    left: 11.2%;
    width: 17.8%;
    font-family: "Poppins", sans-serif;
    font-size: 1.55cqw;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.certificate-sheet-distributor .certificate-date-line {
    display: none;
}

.screen-only {
    display: flex;
}

.error-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.error-panel {
    max-width: 620px;
}

.error-list {
    margin: 18px 0 22px;
    padding-left: 20px;
    color: var(--muted);
}

.print-page {
    background: #fff;
}

.print-page .certificate-sheet,
.export-page .certificate-sheet {
    --certificate-bleed: 4mm;
}

.page-print {
    width: min(100vw, 210mm);
    padding: 12px 0 20px;
}

.page-print-landscape {
    width: min(100vw, 297mm);
}

.print-toolbar {
    justify-content: space-between;
    margin-bottom: 12px;
}

@page certificate-portrait {
    size: A4 portrait;
    margin: 0;
}

@page certificate-landscape {
    size: A4 landscape;
    margin: 0;
}

.certificate-sheet:not(.certificate-sheet-landscape) {
    page: certificate-portrait;
}

.certificate-sheet-landscape {
    page: certificate-landscape;
}

@media (max-width: 980px) {
    .page-header,
    .workspace {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions,
    .switch-stack {
        justify-items: stretch;
    }

    .brand-lockup {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-panel {
        position: static;
    }
}

@media (max-width: 640px) {
    .page {
        width: min(100% - 20px, 100%);
        padding-top: 22px;
    }

    .page-header,
    .panel-head {
        padding-bottom: 16px;
    }

    .field-grid,
    .action-row {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: auto;
    }

    .form-panel,
    .preview-panel,
    .error-panel,
    .bulk-panel {
        padding: 22px;
    }

    .page-header,
    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .header-actions {
        justify-items: stretch;
    }

    .intro-logo-image {
        width: min(240px, 70vw);
    }

    .brand-logo {
        width: 132px;
    }

    .brand-copy strong {
        font-size: 1.05rem;
    }

    .mode-switch {
        width: 100%;
        justify-content: stretch;
    }

    .type-switch {
        width: 100%;
        justify-content: stretch;
    }

    .mode-button {
        flex: 1 1 0;
        min-width: 0;
    }
}

@media print {
    body {
        background: #fff;
    }

    .screen-only,
    .page-header,
    .form-panel,
    .bulk-panel,
    .preview-status {
        display: none !important;
    }

    .page,
    .page-print {
        width: 210mm;
        margin: 0;
        padding: 0;
    }

    .page-print-landscape {
        width: 297mm;
    }

    .panel,
    .certificate-frame {
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 0;
    }

    .certificate-sheet {
        width: 210mm;
        height: 297mm;
        border-radius: 0;
        box-shadow: none;
    }

    .certificate-sheet-landscape {
        width: 297mm;
        height: 210mm;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
