
/* ==================================================
   RYUKTO Templates
   ================================================== */

.templates-shell {
    width: min(calc(100% - 48px), 1240px);
    margin: 0 auto;
}


/* Hero */

.templates-hero {
    position: relative;
    overflow: hidden;
    color: #ffffff;
    background:
        radial-gradient(
            circle at 78% 28%,
            rgba(24, 207, 228, .16),
            transparent 27%
        ),
        radial-gradient(
            circle at 14% 80%,
            rgba(89, 73, 255, .13),
            transparent 30%
        ),
        linear-gradient(
            135deg,
            #061328 0%,
            #08264c 57%,
            #073c5b 100%
        );
}

.templates-hero-grid {
    position: absolute;
    inset: 0;
    opacity: .16;
    background-image:
        linear-gradient(
            rgba(255,255,255,.06) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255,255,255,.06) 1px,
            transparent 1px
        );
    background-size: 52px 52px;
}

.templates-hero-layout {
    position: relative;
    z-index: 2;
    min-height: 630px;
    padding: 80px 0;
    display: grid;
    grid-template-columns:
        minmax(0, .92fr)
        minmax(430px, 1.08fr);
    align-items: center;
    gap: 80px;
}

.templates-eyebrow {
    color: #39dceb;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .19em;
}

.templates-hero-copy h1 {
    margin: 17px 0 0;
    color: #ffffff;
    font-size: clamp(48px, 5vw, 72px);
    font-weight: 900;
    line-height: 1.12;
    letter-spacing: -.055em;
}

.templates-hero-copy h1 em {
    color: transparent;
    background:
        linear-gradient(
            100deg,
            #2787ff,
            #25d8e8
        );
    background-clip: text;
    -webkit-background-clip: text;
    font-style: normal;
}

.templates-hero-copy > p {
    max-width: 590px;
    margin: 27px 0 0;
    color: #9bb1c8;
    font-size: 15px;
    line-height: 1.95;
}

.templates-hero-points {
    margin-top: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.templates-hero-points span {
    padding: 8px 11px;
    color: #b8cee4;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 999px;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .08em;
}


/* Hero document */

.template-hero-preview {
    position: relative;
    min-height: 450px;
    display: grid;
    place-items: center;
}

.hero-paper {
    position: relative;
    z-index: 3;
    width: min(78%, 390px);
    min-height: 430px;
    padding: 31px;
    color: #17314e;
    background: #ffffff;
    border-radius: 8px;
    box-shadow:
        0 35px 80px rgba(0,0,0,.32);
    transform: rotate(2deg);
}

.hero-paper-back {
    position: absolute;
    z-index: 1;
    min-height: 410px;
    background: #dceafa;
    transform:
        translate(-35px, 18px)
        rotate(-5deg);
    opacity: .72;
}

.hero-paper-head {
    display: flex;
    align-items: center;
    gap: 13px;
}

.hero-paper-logo {
    width: 43px;
    height: 43px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    border-radius: 10px;
    font-weight: 900;
}

.hero-paper-head > div:last-child {
    display: flex;
    flex-direction: column;
}

.hero-paper-head strong {
    color: #0a2850;
    font-size: 18px;
    font-weight: 900;
}

.hero-paper-head small {
    color: #91a5b9;
    font-size: 7px;
    letter-spacing: .12em;
}

.hero-paper-recipient {
    margin-top: 35px;
    padding-bottom: 11px;
    border-bottom: 1px solid #dce5ef;
    font-size: 12px;
    font-weight: 800;
}

.hero-paper-lines {
    margin-top: 27px;
}

.hero-paper-lines i {
    height: 7px;
    margin-top: 9px;
    display: block;
    background: #e3ebf3;
    border-radius: 4px;
}

.hero-paper-lines i:nth-child(1) {
    width: 100%;
}

.hero-paper-lines i:nth-child(2) {
    width: 83%;
}

.hero-paper-lines i:nth-child(3) {
    width: 92%;
}

.hero-paper-total {
    margin-top: 45px;
    padding: 17px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #eef6ff;
    border-radius: 9px;
}

.hero-paper-total span {
    color: #71879e;
    font-size: 10px;
}

.hero-paper-total strong {
    color: #1268e6;
    font-size: 19px;
}

.template-lock-badge {
    position: absolute;
    z-index: 5;
    right: 3%;
    bottom: 10%;
    padding: 10px 13px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #dffcf3;
    background: rgba(4, 27, 51, .88);
    border: 1px solid rgba(84,225,174,.25);
    border-radius: 10px;
    box-shadow:
        0 14px 35px rgba(0,0,0,.25);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .07em;
}

.template-lock-badge span {
    width: 21px;
    height: 21px;
    display: grid;
    place-items: center;
    color: #082c21;
    background: #54e1ae;
    border-radius: 50%;
}


/* Library */

.template-library {
    padding: 110px 0 125px;
    background:
        linear-gradient(
            180deg,
            #ffffff,
            #f4f8fd
        );
}

.template-section-heading {
    max-width: 760px;
    margin: 0 auto 50px;
    text-align: center;
}

.template-section-heading > span {
    color: #176bff;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .18em;
}

.template-section-heading h2 {
    margin: 13px 0 0;
    color: #081c37;
    font-size: clamp(38px, 4vw, 54px);
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -.05em;
}

.template-section-heading p {
    max-width: 650px;
    margin: 18px auto 0;
    color: #6d8298;
    font-size: 14px;
    line-height: 1.9;
}

.template-status-message {
    max-width: 620px;
    margin: -20px auto 35px;
    padding: 13px 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #147456;
    background: #e8faf3;
    border: 1px solid #c8efdf;
    border-radius: 11px;
    font-size: 12px;
    font-weight: 800;
}


/* Type tabs */

.document-type-tabs {
    margin-bottom: 45px;
    padding: 7px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    background: #eaf1f8;
    border-radius: 16px;
}

.document-type-tab {
    min-width: 0;
    min-height: 65px;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #667d95;
    background: transparent;
    border: 0;
    border-radius: 11px;
    transition:
        color .22s ease,
        background .22s ease,
        box-shadow .22s ease,
        transform .22s ease;
}

.document-type-tab strong {
    font-size: 12px;
    font-weight: 900;
}

.document-type-tab small {
    margin-top: 2px;
    font-size: 6px;
    font-weight: 900;
    letter-spacing: .07em;
}

.document-type-tab.is-active {
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    box-shadow:
        0 8px 22px rgba(23,107,255,.20);
}

.document-type-tab:hover {
    transform: translateY(-1px);
}

.custom-tab.is-active {
    background:
        linear-gradient(
            135deg,
            #6045e9,
            #a34ee5
        );
}


/* Panels */

.template-panel {
    display: none;
}

.template-panel.is-active {
    display: block;
}

.template-panel-heading {
    margin-bottom: 27px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 25px;
}

.template-panel-heading > div:first-child > span {
    color: #176bff;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .14em;
}

.template-panel-heading h3 {
    margin: 5px 0 0;
    color: #0a2546;
    font-size: 29px;
    font-weight: 900;
}

.template-panel-heading p {
    margin: 6px 0 0;
    color: #71869b;
    font-size: 12px;
}

.slider-counter {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: #9aadc0;
}

.slider-counter strong {
    color: #176bff;
    font-size: 26px;
    font-weight: 900;
}

.slider-counter span,
.slider-counter small {
    font-size: 10px;
    font-weight: 800;
}


/* Slider shell */

.template-slider {
    position: relative;
}

.template-slider-viewport {
    overflow: hidden;
    border-radius: 24px;
}

.template-slider-track {
    display: flex;
    transition:
        transform .45s cubic-bezier(.2,.8,.2,1);
}

.template-slide {
    min-width: 100%;
    padding: 34px 75px;
    display: grid;
    grid-template-columns:
        minmax(380px, 1.12fr)
        minmax(250px, .88fr);
    align-items: center;
    gap: 70px;
    background:
        radial-gradient(
            circle at 15% 30%,
            rgba(23,107,255,.08),
            transparent 27%
        ),
        #ffffff;
    border: 1px solid #e2eaf3;
    border-radius: 24px;
}

.template-slider-arrow {
    position: absolute;
    z-index: 20;
    top: 50%;
    width: 46px;
    height: 46px;
    padding: 0;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: #0b2748;
    border: 0;
    border-radius: 50%;
    transform: translateY(-50%);
    box-shadow:
        0 10px 25px rgba(7,32,64,.18);
    font-size: 27px;
}

.template-slider-arrow:hover {
    background: #176bff;
}

.template-slider-prev {
    left: 15px;
}

.template-slider-next {
    right: 15px;
}

.template-slider-dots {
    min-height: 42px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 7px;
}

.template-slider-dots button {
    width: 7px;
    height: 7px;
    padding: 0;
    background: #bdcddd;
    border: 0;
    border-radius: 999px;
    transition:
        width .22s ease,
        background .22s ease;
}

.template-slider-dots button.is-active {
    width: 24px;
    background: #176bff;
}


/* Tablet */

@media (max-width: 980px) {

    .templates-hero-layout {
        grid-template-columns: 1fr;
        min-height: 0;
        gap: 45px;
    }

    .template-hero-preview {
        min-height: 480px;
    }

    .document-type-tabs {
        grid-template-columns:
            repeat(4, 1fr);
    }

    .template-slide {
        padding: 35px 65px;
        grid-template-columns: 1fr;
        gap: 35px;
    }
}


/* Mobile */

@media (max-width: 640px) {

    .templates-shell {
        width: calc(100% - 30px);
    }

    .templates-hero-layout {
        padding: 55px 0 70px;
    }

    .templates-hero-copy h1 {
        font-size: 42px;
    }

    .template-hero-preview {
        min-height: 390px;
    }

    .hero-paper {
        width: 85%;
        min-height: 360px;
        padding: 23px;
    }

    .hero-paper-back {
        min-height: 350px;
    }

    .template-library {
        padding: 78px 0 90px;
    }

    .template-section-heading {
        margin-bottom: 36px;
    }

    .template-section-heading h2 {
        font-size: 35px;
    }

    .document-type-tabs {
        grid-template-columns:
            repeat(2, 1fr);
        gap: 5px;
    }

    .document-type-tab {
        min-height: 59px;
    }

    .template-panel-heading {
        align-items: flex-start;
    }

    .template-panel-heading p {
        max-width: 240px;
    }

    .template-slide {
        padding: 25px 18px 30px;
        border-radius: 18px;
    }

    .template-slider-arrow {
        top: 260px;
        width: 39px;
        height: 39px;
    }

    .template-slider-prev {
        left: 6px;
    }

    .template-slider-next {
        right: 6px;
    }
}

/* Template preview */

.template-preview-card {
    position: relative;
    padding: 25px;
    background: linear-gradient(145deg, #edf4fb, #e4eef8);
    border-radius: 19px;
}

.current-template-badge {
    position: absolute;
    z-index: 5;
    top: 13px;
    right: 13px;
    padding: 7px 11px;
    color: #0a6a4d;
    background: #dff9ef;
    border: 1px solid #bcebd9;
    border-radius: 999px;
    font-size: 8px;
    font-weight: 900;
}

.document-preview {
    position: relative;
    width: min(100%, 430px);
    min-height: 510px;
    margin: 0 auto;
    padding: 31px;
    overflow: hidden;
    color: #1b3551;
    background: #ffffff;
    border: 1px solid #dce5ee;
    box-shadow: 0 20px 48px rgba(8, 42, 80, .12);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.preview-brand {
    min-width: 72px;
    padding: 8px 9px;
    color: #ffffff;
    background: #176bff;
    border-radius: 6px;
    text-align: center;
    font-size: 7px;
    font-weight: 900;
}

.preview-company {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.preview-company strong {
    color: #1a3553;
    font-size: 9px;
}

.preview-company small {
    margin-top: 2px;
    color: #899caf;
    font-size: 6px;
}

.preview-title {
    margin-top: 30px;
    color: #102d4f;
    font-size: 25px;
    font-weight: 900;
    letter-spacing: .09em;
}

.preview-recipient {
    margin-top: 25px;
    padding-bottom: 8px;
    color: #263f59;
    border-bottom: 1px solid #b9c9d8;
    font-size: 10px;
    font-weight: 800;
}

.preview-meta {
    margin-top: 12px;
    display: flex;
    justify-content: space-between;
    color: #8396aa;
    font-size: 6px;
}

.preview-table {
    margin-top: 25px;
    border-top: 1px solid #cbd7e2;
}

.preview-table > div {
    min-height: 31px;
    padding: 0 7px;
    display: grid;
    grid-template-columns: 1fr 45px 75px;
    align-items: center;
    border-bottom: 1px solid #e0e7ee;
    font-size: 7px;
}

.preview-table-head {
    color: #ffffff;
    background: #176bff;
    border: 0 !important;
    font-weight: 900;
}

.preview-table > div span:nth-child(2),
.preview-table > div span:nth-child(3) {
    text-align: right;
}

.preview-total {
    width: 55%;
    margin: 20px 0 0 auto;
    padding: 12px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #eef5fc;
    border-radius: 5px;
}

.preview-total span {
    color: #6d8196;
    font-size: 7px;
}

.preview-total strong {
    color: #176bff;
    font-size: 13px;
}

.preview-footer {
    position: absolute;
    right: 31px;
    bottom: 23px;
    left: 31px;
    padding-top: 8px;
    color: #91a2b3;
    border-top: 1px solid #e1e8ef;
    text-align: center;
    font-size: 5px;
}

.preview-report-lines {
    margin-top: 28px;
}

.preview-report-lines i {
    height: 7px;
    margin-top: 11px;
    display: block;
    background: #e4ebf2;
    border-radius: 3px;
}

.preview-report-lines i:nth-child(1) {
    width: 100%;
}

.preview-report-lines i:nth-child(2) {
    width: 94%;
}

.preview-report-lines i:nth-child(3) {
    width: 100%;
}

.preview-report-lines i:nth-child(4) {
    width: 82%;
}

.preview-report-lines i:nth-child(5) {
    width: 90%;
}


/* Modern */

.preview-modern {
    border-top: 8px solid #176bff;
}

.preview-modern::after {
    content: "";
    position: absolute;
    top: -80px;
    right: -80px;
    width: 180px;
    height: 180px;
    background:
        radial-gradient(
            circle,
            rgba(24, 207, 228, .15),
            transparent 68%
        );
    pointer-events: none;
}


/* Classic */

.preview-classic {
    padding: 37px 35px;
    border: 1px solid #c7b99a;
    box-shadow: 0 20px 48px rgba(83, 63, 30, .10);
}

.preview-classic .preview-brand {
    color: #493d2c;
    background: transparent;
    border: 1px solid #9e8a69;
    border-radius: 0;
}

.preview-classic .preview-title {
    color: #342b20;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: .14em;
}

.preview-classic .preview-recipient {
    border-bottom: 2px solid #9e8a69;
}

.preview-classic .preview-table-head {
    background: #75654d;
}

.preview-classic .preview-total {
    background: #f5f1e9;
    border-radius: 0;
}

.preview-classic .preview-total strong {
    color: #574936;
}

.preview-classic .preview-footer {
    border-color: #d7cdbb;
}

/* Compact */

.preview-compact {
    min-height: 470px;
    padding: 24px;
    border-left: 7px solid #12b8a0;
}

.preview-compact .preview-brand {
    background: #12a992;
}

.preview-compact .preview-title {
    margin-top: 20px;
    color: #0c6659;
    font-size: 20px;
}

.preview-compact .preview-recipient {
    margin-top: 18px;
}

.preview-compact .preview-table {
    margin-top: 18px;
}

.preview-compact .preview-table > div {
    min-height: 27px;
}

.preview-compact .preview-table-head {
    background: #12a992;
}

.preview-compact .preview-total {
    margin-top: 14px;
    padding: 9px 11px;
    background: #eaf8f5;
}

.preview-compact .preview-total strong {
    color: #0d947f;
}


/* Simple */

.preview-simple {
    min-height: 480px;
    border-top: 6px solid #596b80;
}

.preview-simple .preview-brand {
    color: #44566a;
    background: #edf1f5;
}

.preview-simple .preview-title {
    color: #34495e;
    font-size: 22px;
    letter-spacing: .04em;
}

.preview-simple .preview-table-head {
    background: #596b80;
}

.preview-simple .preview-total strong {
    color: #4d6175;
}


/* Detailed */

.preview-detailed {
    border-top: 8px solid #6c4be8;
}

.preview-detailed .preview-brand {
    background: #6c4be8;
}

.preview-detailed .preview-title {
    color: #4f36b4;
}

.preview-detailed .preview-table-head {
    background: #6c4be8;
}

.preview-detailed .preview-total {
    background: #f0edfc;
}

.preview-detailed .preview-total strong {
    color: #6c4be8;
}

.preview-detailed .preview-report-lines i:nth-child(odd) {
    height: 10px;
    background: #ebe7fb;
}

.preview-detailed .preview-report-lines i:nth-child(even) {
    background: #ddd5f6;
}


/* Formal */

.preview-formal {
    padding: 38px 36px;
    border: 3px double #263b55;
}

.preview-formal .preview-brand {
    color: #263b55;
    background: transparent;
    border: 1px solid #263b55;
    border-radius: 0;
}

.preview-formal .preview-title {
    color: #1e3148;
    text-align: center;
    font-family: Georgia, "Times New Roman", serif;
    letter-spacing: .12em;
}

.preview-formal .preview-recipient {
    border-bottom: 2px solid #263b55;
}

.preview-formal .preview-table-head {
    background: #263b55;
}

.preview-formal .preview-total {
    background: #f0f3f6;
    border-radius: 0;
}

.preview-formal .preview-total strong {
    color: #263b55;
}

.preview-formal .preview-footer {
    color: #617184;
    border-color: #aeb9c4;
}

/* Template selection information */

.template-slide-info {
    min-width: 0;
}

.template-style-label {
    color: #176bff;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .15em;
}

.template-slide-info h4 {
    margin: 9px 0 0;
    color: #0b2748;
    font-size: 31px;
    font-weight: 900;
    line-height: 1.25;
    letter-spacing: -.035em;
}

.template-slide-info > p {
    margin: 5px 0 0;
    color: #8397aa;
    font-size: 11px;
}

.template-field-count {
    width: fit-content;
    margin-top: 22px;
    padding: 7px 10px;
    color: #55718e;
    background: #edf4fb;
    border: 1px solid #dce8f4;
    border-radius: 7px;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .07em;
}


/* Select button */

.template-slide-info form {
    margin: 0;
}

.template-select-button {
    width: 100%;
    max-width: 310px;
    min-height: 52px;
    margin-top: 30px;
    padding: 0 17px;

    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );

    border: 0;
    border-radius: 11px;

    box-shadow:
        0 12px 28px rgba(23, 107, 255, .20);

    font-size: 11px;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform .22s ease,
        box-shadow .22s ease,
        filter .22s ease;
}

.template-select-button span {
    font-size: 16px;
}

@media (hover: hover) and (pointer: fine) {

    .template-select-button:not(.is-selected):hover {
        transform: translateY(-3px);

        box-shadow:
            0 17px 36px rgba(23, 107, 255, .28);

        filter: brightness(1.04);
    }
}


/* Currently selected */

.template-select-button.is-selected {
    color: #117354;
    background: #e2f8ef;

    border:
        1px solid #bdebd9;

    box-shadow: none;

    justify-content: center;

    cursor: default;
}

.template-select-button.is-selected:disabled {
    opacity: 1;
}


/* Selected preview emphasis */

.template-slide:has(
    .template-select-button.is-selected
) .template-preview-card {
    box-shadow:
        0 0 0 2px rgba(50, 203, 150, .18),
        0 17px 38px rgba(8, 42, 80, .08);
}

.template-slide:has(
    .template-select-button.is-selected
) .current-template-badge {
    color: #086348;
    background: #d9f8ec;
    border-color: #aee7d2;
}


/* Guest selection */

a.template-select-button {
    text-decoration: none;
}


/* Mobile */

@media (max-width: 640px) {

    .template-slide-info {
        padding: 0 5px;
    }

    .template-slide-info h4 {
        font-size: 27px;
    }

    .template-select-button {
        max-width: none;
        min-height: 52px;
        margin-top: 23px;
    }
}

/* ==================================================
   Custom document
   ================================================== */

.custom-template-panel {
    padding: 20px 0;
}

.custom-template-layout {
    position: relative;
    overflow: hidden;

    min-height: 500px;
    padding: 55px 65px;

    display: grid;
    grid-template-columns:
        minmax(0, .9fr)
        minmax(360px, 1.1fr);

    align-items: center;
    gap: 80px;

    color: #ffffff;

    background:
        radial-gradient(
            circle at 80% 20%,
            rgba(165, 78, 229, .20),
            transparent 28%
        ),
        radial-gradient(
            circle at 15% 80%,
            rgba(83, 79, 238, .16),
            transparent 30%
        ),
        linear-gradient(
            135deg,
            #10152d,
            #242052 60%,
            #37235f
        );

    border:
        1px solid rgba(255, 255, 255, .08);

    border-radius: 25px;

    box-shadow:
        0 28px 65px rgba(23, 19, 61, .16);
}

.custom-template-layout::before {
    content: "";
    position: absolute;
    inset: 0;

    opacity: .11;

    background-image:
        linear-gradient(
            rgba(255, 255, 255, .08) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255, 255, 255, .08) 1px,
            transparent 1px
        );

    background-size: 45px 45px;

    pointer-events: none;
}

.custom-template-layout > * {
    position: relative;
    z-index: 2;
}


/* Custom copy */

.custom-template-copy > span {
    color: #c99df5;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .16em;
}

.custom-template-copy h3 {
    margin: 12px 0 0;

    color: #ffffff;

    font-size:
        clamp(37px, 4vw, 52px);

    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -.05em;
}

.custom-template-copy > p {
    max-width: 560px;
    margin: 20px 0 0;

    color: #afa9c9;

    font-size: 13px;
    line-height: 1.9;
}


/* Custom feature list */

.custom-template-copy ul {
    margin: 23px 0 0;
    padding: 0;

    display: grid;
    grid-template-columns:
        repeat(2, 1fr);

    gap: 8px;

    list-style: none;
}

.custom-template-copy li {
    position: relative;

    padding:
        10px
        10px
        10px
        29px;

    color: #d6d1e9;

    background:
        rgba(255, 255, 255, .055);

    border:
        1px solid
        rgba(255, 255, 255, .08);

    border-radius: 8px;

    font-size: 10px;
}

.custom-template-copy li::before {
    content: "✓";

    position: absolute;
    left: 10px;

    color: #c28af1;

    font-weight: 900;
}


/* Custom action */

.custom-document-button {
    min-height: 50px;
    margin-top: 27px;
    padding: 0 18px;

    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #7650ec,
            #b653e7
        );

    border: 0;
    border-radius: 10px;

    box-shadow:
        0 13px 30px
        rgba(125, 75, 225, .25);

    font-size: 11px;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform .22s ease,
        box-shadow .22s ease;
}

.custom-document-button span {
    font-size: 17px;
}

@media (hover: hover) and (pointer: fine) {

    .custom-document-button:hover {
        transform: translateY(-3px);

        box-shadow:
            0 18px 38px
            rgba(125, 75, 225, .34);
    }
}


/* Custom preview */

.custom-template-preview {
    display: grid;
    place-items: center;
}

.custom-preview-paper {
    position: relative;

    width: min(100%, 350px);
    min-height: 390px;

    padding: 31px;

    background: #ffffff;

    border:
        1px solid
        rgba(255, 255, 255, .85);

    border-radius: 7px;

    box-shadow:
        0 30px 65px
        rgba(0, 0, 0, .28);

    transform: rotate(2deg);
}

.custom-preview-paper::before {
    content: "";

    position: absolute;

    top: 0;
    right: 0;
    left: 0;

    height: 7px;

    background:
        linear-gradient(
            90deg,
            #6c4be8,
            #b653e7
        );

    border-radius:
        7px 7px 0 0;
}

.custom-preview-title {
    padding-bottom: 14px;

    color: #302557;

    border-bottom:
        3px solid #8a58e9;

    font-size: 18px;
    font-weight: 900;
}

.custom-preview-field {
    width: 72%;
    height: 35px;

    margin-top: 18px;

    background: #f1edf9;

    border:
        1px solid #e2d9f3;

    border-radius: 6px;
}

.custom-preview-field.wide {
    width: 100%;
}

.custom-preview-add {
    margin-top: 23px;
    padding: 10px;

    color: #7954c9;

    background: #faf8ff;

    border:
        1px dashed #b89ee5;

    border-radius: 6px;

    text-align: center;

    font-size: 8px;
    font-weight: 900;
}


/* Mobile */

@media (max-width: 850px) {

    .custom-template-layout {
        grid-template-columns: 1fr;
        gap: 45px;
    }
}

@media (max-width: 640px) {

    .custom-template-layout {
        min-height: 0;

        padding: 35px 23px;

        border-radius: 19px;
    }

    .custom-template-copy h3 {
        font-size: 35px;
    }

    .custom-template-copy ul {
        grid-template-columns: 1fr;
    }

    .custom-document-button {
        width: 100%;
    }

    .custom-preview-paper {
        min-height: 350px;
        padding: 25px;
    }
}

/* ==================================================
   Company profile
   ================================================== */

.template-company-section {
    padding: 110px 0;
    background: #ffffff;
}

.template-company-layout {
    display: grid;
    grid-template-columns:
        minmax(0, .9fr)
        minmax(390px, 1.1fr);
    align-items: center;
    gap: 90px;
}

.template-company-layout h2 {
    margin: 13px 0 0;

    color: #081c37;

    font-size:
        clamp(38px, 4vw, 54px);

    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -.05em;
}

.template-company-layout p {
    max-width: 570px;
    margin: 20px 0 0;

    color: #71859a;

    font-size: 14px;
    line-height: 1.9;
}

.company-setting-button {
    min-height: 50px;
    margin-top: 27px;
    padding: 0 18px;

    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );

    border: 0;
    border-radius: 10px;

    box-shadow:
        0 13px 30px
        rgba(23, 107, 255, .20);

    font-size: 11px;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform .22s ease,
        box-shadow .22s ease;
}

.company-setting-button span {
    font-size: 16px;
}

@media (hover: hover) and (pointer: fine) {

    .company-setting-button:hover {
        transform: translateY(-3px);

        box-shadow:
            0 18px 38px
            rgba(23, 107, 255, .28);
    }
}


/* Company preview */

.company-document-preview {
    position: relative;
    overflow: hidden;

    min-height: 320px;
    padding: 43px;

    display: flex;
    flex-direction: column;
    justify-content: center;

    background:
        linear-gradient(
            145deg,
            #f6faff,
            #e9f3fc
        );

    border: 1px solid #dce8f3;
    border-radius: 22px;

    box-shadow:
        0 20px 48px
        rgba(8, 44, 89, .07);
}

.company-document-preview::before {
    content: "";

    position: absolute;

    top: -90px;
    right: -70px;

    width: 220px;
    height: 220px;

    background:
        radial-gradient(
            circle,
            rgba(23, 107, 255, .12),
            transparent 68%
        );

    border-radius: 50%;
}

.company-document-preview > * {
    position: relative;
    z-index: 2;
}

.company-logo-placeholder {
    width: 105px;
    height: 54px;
    margin-bottom: 25px;

    display: grid;
    place-items: center;

    color: #176bff;
    background: #ffffff;

    border:
        1px dashed #94bce5;

    border-radius: 9px;

    font-size: 9px;
    font-weight: 900;
    letter-spacing: .10em;
}

.company-document-preview strong {
    color: #102e50;

    font-size: 19px;
    font-weight: 900;
}

.company-document-preview > span {
    margin-top: 7px;

    color: #71869b;

    font-size: 11px;
}


/* ==================================================
   Format rule
   ================================================== */

.template-rule-section {
    padding: 0 0 105px;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #f4f8fd
        );
}

.template-rule-card {
    position: relative;
    overflow: hidden;

    min-height: 330px;
    padding: 55px 65px;

    display: grid;
    grid-template-columns:
        110px 1fr;

    align-items: center;
    gap: 45px;

    color: #ffffff;

    background:
        radial-gradient(
            circle at 90% 15%,
            rgba(24, 207, 228, .18),
            transparent 27%
        ),
        linear-gradient(
            125deg,
            #06162d,
            #0a2c55 60%,
            #09435f
        );

    border-radius: 25px;

    box-shadow:
        0 28px 65px
        rgba(6, 35, 75, .15);
}

.template-rule-card::before {
    content: "";

    position: absolute;

    left: -100px;
    bottom: -150px;

    width: 330px;
    height: 330px;

    background:
        radial-gradient(
            circle,
            rgba(92, 75, 245, .20),
            transparent 68%
        );

    border-radius: 50%;
}

.template-rule-card > * {
    position: relative;
    z-index: 2;
}

.template-rule-icon {
    width: 105px;
    height: 105px;

    display: grid;
    place-items: center;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );

    border:
        1px solid
        rgba(255, 255, 255, .18);

    border-radius: 27px;

    box-shadow:
        0 18px 40px
        rgba(23, 107, 255, .25);

    font-size: 24px;
    font-weight: 900;
}

.template-rule-card > div:last-child > span {
    color: #5be0ef;

    font-size: 9px;
    font-weight: 900;
    letter-spacing: .18em;
}

.template-rule-card h2 {
    margin: 12px 0 0;

    color: #ffffff;

    font-size:
        clamp(36px, 4vw, 51px);

    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -.045em;
}

.template-rule-card p {
    max-width: 720px;
    margin: 18px 0 0;

    color: #9cb3ca;

    font-size: 13px;
    line-height: 1.9;
}


/* ==================================================
   Final responsive adjustments
   ================================================== */

@media (max-width: 900px) {

    .template-company-layout {
        grid-template-columns: 1fr;
        gap: 45px;
    }

    .template-rule-card {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .template-rule-icon {
        width: 80px;
        height: 80px;

        border-radius: 21px;

        font-size: 20px;
    }
}

@media (max-width: 640px) {

    .template-company-section {
        padding: 78px 0;
    }

    .template-company-layout h2 {
        font-size: 35px;
    }

    .company-setting-button {
        width: 100%;
    }

    .company-document-preview {
        min-height: 270px;
        padding: 30px 25px;
        border-radius: 18px;
    }

    .template-rule-section {
        padding-bottom: 78px;
    }

    .template-rule-card {
        min-height: 0;

        padding: 36px 24px;

        border-radius: 20px;
    }

    .template-rule-card h2 {
        font-size: 34px;
    }

    .template-rule-card p {
        font-size: 12px;
    }
}

/* ==================================================
   Custom document builder
   ================================================== */

.custom-builder {
    position: fixed;
    z-index: 12000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.custom-builder.is-open {
    display: flex;
}

.custom-builder-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 10, 24, .78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.custom-builder-dialog {
    position: relative;
    z-index: 2;
    width: min(1180px, 100%);
    max-height: calc(100vh - 48px);
    overflow: hidden;
    color: #183451;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 24px;
    box-shadow: 0 35px 90px rgba(0, 0, 0, .35);
}

.custom-builder-header {
    min-height: 96px;
    padding: 22px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
    color: #ffffff;
    background:
        radial-gradient(
            circle at 85% 0%,
            rgba(24, 207, 228, .20),
            transparent 30%
        ),
        linear-gradient(
            125deg,
            #06162d,
            #0a2c55 65%,
            #09435f
        );
}

.custom-builder-header span {
    color: #58dfef;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .18em;
}

.custom-builder-header h2 {
    margin: 6px 0 0;
    color: #ffffff;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -.035em;
}

.custom-builder-close {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #d9e8f6;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .11);
    border-radius: 11px;
    font-size: 24px;
    cursor: pointer;
}

.custom-builder-body {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
    display: grid;
    grid-template-columns:
        minmax(0, 1.12fr)
        minmax(350px, .88fr);
}

.custom-builder-settings {
    padding: 32px;
    background: #ffffff;
}

.builder-section-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.builder-section-title > span {
    width: 35px;
    height: 35px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    border-radius: 10px;
    font-size: 8px;
    font-weight: 900;
}

.builder-section-title > div {
    display: flex;
    flex-direction: column;
}

.builder-section-title strong {
    color: #102d4e;
    font-size: 14px;
    font-weight: 900;
}

.builder-section-title small {
    margin-top: 2px;
    color: #92a5b8;
    font-size: 7px;
    font-weight: 900;
    letter-spacing: .11em;
}

.fields-title {
    margin-top: 34px;
}

.builder-field {
    margin-top: 19px;
    display: block;
}

.builder-field > span {
    margin-bottom: 7px;
    display: block;
    color: #425d78;
    font-size: 10px;
    font-weight: 900;
}

.builder-field input,
.builder-field textarea {
    width: 100%;
    padding: 12px 13px;
    color: #183451;
    background: #f8fbfe;
    border: 1px solid #d9e5f0;
    border-radius: 9px;
    outline: none;
    font: inherit;
    font-size: 12px;
}

.builder-field textarea {
    resize: vertical;
}

.builder-field input:focus,
.builder-field textarea:focus {
    background: #ffffff;
    border-color: #4c9eff;
    box-shadow: 0 0 0 3px rgba(23, 107, 255, .08);
}


/* Field rows */

.custom-builder-fields {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.custom-field-row {
    padding: 11px;
    display: grid;
    grid-template-columns:
        25px
        minmax(170px, 1fr)
        115px
        60px
        34px;
    align-items: center;
    gap: 8px;
    background: #f5f9fd;
    border: 1px solid #dfe9f3;
    border-radius: 11px;
}

.field-drag {
    color: #9aafc3;
    text-align: center;
    font-size: 16px;
    cursor: grab;
}

.field-main {
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.field-main input,
.custom-field-row select {
    width: 100%;
    min-width: 0;
    height: 37px;
    padding: 0 9px;
    color: #29445f;
    background: #ffffff;
    border: 1px solid #d6e2ed;
    border-radius: 7px;
    outline: none;
    font-size: 10px;
}

.field-main input:focus,
.custom-field-row select:focus {
    border-color: #4c9eff;
}

.field-required {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #5e758c;
    font-size: 9px;
    font-weight: 800;
}

.field-required input {
    accent-color: #176bff;
}

.field-remove {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    color: #9b5361;
    background: #fff1f3;
    border: 1px solid #f4d4da;
    border-radius: 7px;
    cursor: pointer;
}

.add-custom-field {
    min-height: 43px;
    margin-top: 13px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #176bff;
    background: #eef6ff;
    border: 1px dashed #91bff1;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 900;
    cursor: pointer;
}


/* Live preview */

.custom-builder-preview {
    padding: 32px;
    background:
        radial-gradient(
            circle at 80% 10%,
            rgba(23, 107, 255, .10),
            transparent 28%
        ),
        #edf4fb;
}

.builder-preview-label {
    color: #176bff;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .16em;
}

.builder-paper {
    position: relative;
    min-height: 440px;
    margin-top: 15px;
    padding: 29px;
    background: #ffffff;
    border-top: 7px solid #176bff;
    box-shadow: 0 20px 48px rgba(8, 42, 80, .13);
}

.builder-paper-company {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.builder-paper-company > div {
    padding: 8px 9px;
    color: #ffffff;
    background: #176bff;
    border-radius: 6px;
    font-size: 6px;
    font-weight: 900;
}

.builder-paper-company > span {
    color: #71879c;
    font-size: 7px;
    font-weight: 800;
}

.builder-paper h3 {
    margin: 28px 0 0;
    padding-bottom: 12px;
    color: #102d4f;
    border-bottom: 2px solid #176bff;
    font-size: 20px;
    font-weight: 900;
}

.builder-preview-fields {
    margin-top: 21px;
}

.builder-preview-fields > div {
    margin-top: 15px;
}

.builder-preview-fields span {
    display: block;
    color: #506a84;
    font-size: 7px;
    font-weight: 800;
}

.builder-preview-fields i {
    height: 25px;
    margin-top: 5px;
    display: block;
    background: #f0f5fa;
    border: 1px solid #e0e8f0;
    border-radius: 4px;
}

.builder-ai-rule {
    margin-top: 15px;
    padding: 13px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #667d94;
    background: #ffffff;
    border: 1px solid #dce7f1;
    border-radius: 10px;
}

.builder-ai-rule > span {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    border-radius: 9px;
    font-size: 9px;
    font-weight: 900;
}

.builder-ai-rule p {
    margin: 0;
    font-size: 9px;
    line-height: 1.65;
}


/* Footer actions */

.custom-builder-footer {
    min-height: 72px;
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    background: #ffffff;
    border-top: 1px solid #e2eaf2;
}

.builder-cancel,
.builder-save {
    min-height: 44px;
    padding: 0 17px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 900;
    cursor: pointer;
}

.builder-cancel {
    color: #60778e;
    background: #f3f7fb;
    border: 1px solid #dce6ef;
}

.builder-save {
    display: inline-flex;
    align-items: center;
    gap: 24px;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    border: 0;
    box-shadow: 0 10px 24px rgba(23, 107, 255, .20);
}


/* Mobile */

@media (max-width: 850px) {

    .custom-builder {
        padding: 12px;
    }

    .custom-builder-dialog {
        max-height: calc(100vh - 24px);
        border-radius: 18px;
    }

    .custom-builder-body {
        grid-template-columns: 1fr;
        max-height: calc(100vh - 215px);
    }

    .custom-builder-preview {
        border-top: 1px solid #dce7f1;
    }
}

@media (max-width: 640px) {

    .custom-builder {
        padding: 0;
    }

    .custom-builder-dialog {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .custom-builder-header {
        min-height: 76px;
        padding: 16px;
    }

    .custom-builder-header h2 {
        font-size: 19px;
    }

    .custom-builder-body {
        max-height: calc(100vh - 140px);
    }

    .custom-builder-settings,
    .custom-builder-preview {
        padding: 21px 16px;
    }

    .custom-field-row {
        grid-template-columns:
            22px 1fr 32px;
    }

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

    .custom-field-row select {
        grid-column: 2;
    }

    .field-required {
        grid-column: 2;
        justify-content: flex-start;
    }

    .field-remove {
        grid-column: 3;
        grid-row: 1;
    }

    .custom-builder-footer {
        min-height: 64px;
        padding: 10px 14px;
    }

    .builder-cancel,
    .builder-save {
        flex: 1;
    }
}

/* Custom select options */

.field-options {
    grid-column: 2 / -1;
    padding: 9px 10px;
    background: #eef5fc;
    border: 1px solid #d9e6f2;
    border-radius: 8px;
}

.field-options[hidden] {
    display: none;
}

.field-options input {
    width: 100%;
    height: 35px;
    padding: 0 9px;
    color: #29445f;
    background: #ffffff;
    border: 1px solid #d4e1ed;
    border-radius: 6px;
    outline: none;
    font-size: 10px;
}

.field-options input:focus {
    border-color: #4c9eff;
}

.field-options small {
    margin-top: 5px;
    display: block;
    color: #8499ad;
    font-size: 8px;
}

@media (max-width: 640px) {

    .field-options {
        grid-column: 2 / 4;
    }
}

/* Custom field drag reorder */

.field-drag {
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.custom-field-row.is-dragging {
    position: relative;
    z-index: 30;
    opacity: .72;
    background: #eaf4ff;
    border-color: #72adf0;
    box-shadow:
        0 14px 30px
        rgba(23, 107, 255, .14);
}

.custom-field-row.drag-before {
    box-shadow:
        0 -3px 0 #176bff,
        0 10px 24px rgba(8, 42, 80, .07);
}

.custom-field-row.drag-after {
    box-shadow:
        0 3px 0 #176bff,
        0 10px 24px rgba(8, 42, 80, .07);
}

body.custom-field-dragging {
    cursor: grabbing;
}

body.custom-field-dragging * {
    cursor: grabbing !important;
}

/* Custom builder validation */

.validation-errors {
    margin: 20px 0 0;
    padding: 14px 16px;
    color: #8a3545;
    background: #fff1f3;
    border: 1px solid #f0cbd2;
    border-radius: 10px;
}

.validation-errors strong {
    display: block;
    font-size: 11px;
    font-weight: 900;
}

.validation-errors ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.validation-errors li {
    margin-top: 4px;
    font-size: 9px;
    line-height: 1.55;
}

.custom-field-row:has(
    input:invalid
) {
    border-color: #e6a5b0;
}

/* ==================================================
   Saved custom documents
   ================================================== */

.saved-custom-documents {
    margin-bottom: 25px;
    padding: 28px;
    background: #ffffff;
    border: 1px solid #e0e9f2;
    border-radius: 21px;
    box-shadow:
        0 16px 40px
        rgba(8, 44, 89, .06);
}

.saved-custom-heading {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.saved-custom-heading > div {
    display: flex;
    flex-direction: column;
}

.saved-custom-heading > div > span {
    color: #176bff;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .15em;
}

.saved-custom-heading h3 {
    margin: 5px 0 0;
    color: #102d4e;
    font-size: 22px;
    font-weight: 900;
}

.saved-custom-create {
    min-height: 41px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #18cfe4
        );
    border: 0;
    border-radius: 9px;
    font-size: 9px;
    font-weight: 900;
    cursor: pointer;
}

.saved-custom-grid {
    display: grid;
    grid-template-columns:
        repeat(3, 1fr);
    gap: 12px;
}

.saved-custom-card {
    min-width: 0;
    padding: 20px;
    background:
        linear-gradient(
            145deg,
            #fbfdff,
            #f3f8fd
        );
    border: 1px solid #dfe9f3;
    border-radius: 15px;
    transition:
        transform .22s ease,
        box-shadow .22s ease,
        border-color .22s ease;
}

@media (hover: hover) and (pointer: fine) {

    .saved-custom-card:hover {
        transform: translateY(-4px);
        border-color: #b8d5f2;
        box-shadow:
            0 15px 32px
            rgba(8, 44, 89, .09);
    }
}

.saved-custom-card.is-inactive {
    opacity: .62;
}

.saved-custom-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.saved-custom-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #7650ec,
            #b653e7
        );
    border-radius: 11px;
    font-size: 7px;
    font-weight: 900;
}

.saved-custom-status span {
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 7px;
    font-weight: 900;
}

.saved-custom-status .is-active {
    color: #087052;
    background: #def8ee;
}

.saved-custom-status .is-disabled {
    color: #7c8793;
    background: #e9eef3;
}

.saved-custom-card h4 {
    margin: 18px 0 0;
    color: #102c4b;
    font-size: 16px;
    font-weight: 900;
}

.saved-custom-card > p {
    min-height: 38px;
    margin: 7px 0 0;
    color: #7a8fa4;
    font-size: 10px;
    line-height: 1.7;
}

.saved-custom-meta {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.saved-custom-meta > span {
    padding: 5px 7px;
    color: #637b92;
    background: #eaf1f7;
    border-radius: 6px;
    font-size: 7px;
    font-weight: 900;
}

.saved-custom-meta .ai-ready {
    color: #126a52;
    background: #ddf7ed;
}

.saved-custom-field-preview {
    min-height: 55px;
    margin-top: 14px;
    display: flex;
    align-content: flex-start;
    flex-wrap: wrap;
    gap: 5px;
}

.saved-custom-field-preview span {
    padding: 5px 7px;
    color: #536c85;
    background: #ffffff;
    border: 1px solid #dce7f1;
    border-radius: 6px;
    font-size: 7px;
    font-weight: 800;
}

.saved-custom-actions {
    margin-top: 15px;
    padding-top: 13px;
    display: flex;
    gap: 7px;
    border-top: 1px solid #e0e8f0;
}

.saved-custom-actions button {
    flex: 1;
    min-height: 35px;
    padding: 0 8px;
    color: #4d6780;
    background: #ffffff;
    border: 1px solid #d9e4ee;
    border-radius: 7px;
    font-size: 8px;
    font-weight: 900;
    cursor: pointer;
}

.saved-custom-actions button:first-child {
    color: #176bff;
    border-color: #bed8f5;
}

@media (max-width: 900px) {

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

@media (max-width: 600px) {

    .saved-custom-documents {
        padding: 20px 15px;
    }

    .saved-custom-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .saved-custom-create {
        width: 100%;
        justify-content: space-between;
    }

    .saved-custom-grid {
        grid-template-columns: 1fr;
    }
}

/* Saved custom action forms */

.saved-custom-toggle-form {
    flex: 1;
    margin: 0;
}

.saved-custom-toggle-form button {
    width: 100%;
    height: 100%;
}

/* ==================================================
   Template hero real document image
   ================================================== */

.template-hero-preview.template-hero-real-preview {
    position: relative;

    width: 500px;
    height: 500px;

    max-width: 100%;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: visible;

    perspective: none;
}


/* Remove visual effects intended for old CSS paper */

.template-hero-real-preview::before,
.template-hero-real-preview::after {
    content: none !important;
    display: none !important;
}


/* Real transparent WebP */

.template-hero-real-image {
    position: relative;
    z-index: 5;

    width: 500px;
    height: 500px;

    max-width: none;

    display: block;

    object-fit: contain;

    transform:
        translateZ(0)
        scale(1);

    transform-origin: center center;

    transition:
        transform .42s
        cubic-bezier(.2, .7, .2, 1),
        filter .42s ease;

    filter:
        drop-shadow(
            0 22px 30px
            rgba(0, 18, 48, .18)
        );

    will-change: transform;
}


/* 30 percent enlargement */

@media (hover: hover) and (pointer: fine) {

    .template-hero-real-preview:hover {
        z-index: 20;
    }

    .template-hero-real-preview:hover
    .template-hero-real-image {
        transform:
            translateZ(0)
            scale(1.30);

        filter:
            drop-shadow(
                0 30px 42px
                rgba(0, 18, 48, .28)
            );
    }
}


/* Tablet */

@media (max-width: 900px) {

    .template-hero-preview.template-hero-real-preview {
        width: min(500px, 82vw);
        height: min(500px, 82vw);

        margin-inline: auto;
    }

    .template-hero-real-image {
        width: 100%;
        height: 100%;
        max-width: 100%;
    }
}


/* Mobile */

@media (max-width: 650px) {

    .template-hero-preview.template-hero-real-preview {
        width: min(440px, 92vw);
        height: min(440px, 92vw);
    }

    .template-hero-real-image {
        width: 100%;
        height: 100%;

        transform: none;
    }

    .template-hero-real-preview:hover
    .template-hero-real-image {
        transform: none;
    }
}

/* ==================================================
   Template hero real image hover final
   ================================================== */

/* Allow the enlarged preview outside the hero bounds */

.templates-hero {
    overflow: visible;
}

.templates-hero-layout {
    overflow: visible;
}

.templates-shell.templates-hero-layout {
    overflow: visible;
}


/* Scale the complete 500 x 500 preview */

.template-hero-preview.template-hero-real-preview {
    position: relative;
    z-index: 10;

    overflow: visible;

    transform: scale(1);
    transform-origin: center center;

    transition:
        transform .42s cubic-bezier(.2, .7, .2, 1),
        filter .42s ease;

    will-change: transform;
}


/* Image stays fixed inside its container */

.template-hero-real-preview
.template-hero-real-image {
    transform: none !important;

    width: 100%;
    height: 100%;

    object-fit: contain;

    pointer-events: none;
}


/* Desktop: real 30 percent enlargement */

@media (hover: hover) and (pointer: fine) and (min-width: 901px) {

    .template-hero-preview.template-hero-real-preview:hover {
        z-index: 100;

        transform: scale(1.30);

        filter:
            drop-shadow(
                0 32px 45px
                rgba(0, 15, 45, .30)
            );
    }

    .template-hero-preview.template-hero-real-preview:hover
    .template-hero-real-image {
        transform: none !important;
    }
}


/* Tablet and mobile: keep layout stable */

@media (max-width: 900px) {

    .template-hero-preview.template-hero-real-preview,
    .template-hero-preview.template-hero-real-preview:hover {
        transform: none;
    }
}

/* ==================================================
   Independent template selector cards
   ================================================== */

.document-type-tabs {
    display: grid;

    grid-template-columns:
        repeat(7, minmax(0, 1fr));

    gap: 12px;

    padding: 0;

    background: transparent;

    border: 0;
    border-radius: 0;

    overflow: visible;
}


/* Individual buttons */

.document-type-tab {
    position: relative;

    min-width: 0;
    min-height: 78px;

    padding: 15px 10px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: #ffffff;

    border:
        1px solid
        rgba(128, 163, 199, .22);

    border-radius: 15px;

    box-shadow:
        0 7px 20px
        rgba(38, 75, 115, .07);

    color: #173757;

    cursor: pointer;

    transition:
        transform .25s ease,
        background .25s ease,
        border-color .25s ease,
        box-shadow .25s ease,
        color .25s ease;
}


/* Japanese label */

.document-type-tab strong {
    color: inherit;

    font-size: 13px;
    font-weight: 900;

    transition:
        color .25s ease;
}


/* English label */

.document-type-tab small {
    margin-top: 5px;

    color: #7890aa;

    font-size: 7px;
    font-weight: 900;
    letter-spacing: .08em;

    transition:
        color .25s ease;
}


/* Active selection */

.document-type-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #18c6df
        );

    border-color:
        rgba(34, 178, 236, .75);

    box-shadow:
        0 12px 27px
        rgba(23, 107, 255, .22);

    transform: translateY(-2px);
}

.document-type-tab.is-active strong {
    color: #ffffff;
}

.document-type-tab.is-active small {
    color:
        rgba(255, 255, 255, .82);
}


/* ==================================================
   Different hover colors
   ================================================== */

@media (hover: hover) and (pointer: fine) {

    .document-type-tab:hover {
        transform: translateY(-4px);

        box-shadow:
            0 15px 30px
            rgba(32, 72, 112, .14);
    }


    /* Estimate */

    .document-type-tab:nth-child(1):hover {
        color: #0d62cf;

        background: #e8f4ff;

        border-color:
            rgba(23, 119, 255, .32);
    }


    /* Purchase order */

    .document-type-tab:nth-child(2):hover {
        color: #087e71;

        background: #e7faf6;

        border-color:
            rgba(8, 185, 156, .32);
    }


    /* Invoice */

    .document-type-tab:nth-child(3):hover {
        color: #a62ab8;

        background: #faeafb;

        border-color:
            rgba(201, 62, 224, .28);
    }


    /* Delivery note */

    .document-type-tab:nth-child(4):hover {
        color: #c6532e;

        background: #fff0e9;

        border-color:
            rgba(255, 113, 72, .32);
    }


    /* Report */

    .document-type-tab:nth-child(5):hover {
        color: #6040c5;

        background: #f0ecff;

        border-color:
            rgba(110, 67, 237, .30);
    }


    /* Request */

    .document-type-tab:nth-child(6):hover {
        color: #a66a00;

        background: #fff7dc;

        border-color:
            rgba(255, 173, 0, .34);
    }


    /* Custom */

    .document-type-tab:nth-child(7):hover {
        color: #0d7185;

        background: #e8f9fc;

        border-color:
            rgba(24, 198, 223, .34);
    }


    /* Active always keeps strong brand color */

    .document-type-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #176bff,
                #18c6df
            );

        border-color:
            rgba(34, 178, 236, .85);

        transform: translateY(-5px);

        box-shadow:
            0 17px 34px
            rgba(23, 107, 255, .27);
    }

    .document-type-tab.is-active:hover strong {
        color: #ffffff;
    }

    .document-type-tab.is-active:hover small {
        color:
            rgba(255, 255, 255, .86);
    }
}


/* ==================================================
   Tablet
   ================================================== */

@media (max-width: 1000px) {

    .document-type-tabs {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
    }
}


/* ==================================================
   Mobile
   ================================================== */

@media (max-width: 650px) {

    .document-type-tabs {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

    .document-type-tab {
        min-height: 68px;

        padding:
            12px 8px;

        border-radius: 13px;
    }

    .document-type-tab strong {
        font-size: 12px;
    }

    .document-type-tab small {
        font-size: 6px;
    }
}


/* Touch feedback */

@media (hover: none) {

    .document-type-tab:active {
        transform: scale(.97);

        background: #edf6ff;
    }

    .document-type-tab.is-active:active {
        background:
            linear-gradient(
                135deg,
                #176bff,
                #18c6df
            );
    }
}

/* ==================================================
   Template business categories
   ================================================== */

.template-category-selector {
    margin-bottom: 46px;
}


/* Six category cards */

.template-category-tabs {
    display: grid;
    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 18px;
}


.template-category-tab {
    position: relative;

    min-width: 0;
    min-height: 82px;

    padding: 15px 10px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    color: #173757;

    background: #ffffff;

    border:
        1px solid
        rgba(115, 153, 191, .22);

    border-radius: 16px;

    box-shadow:
        0 8px 22px
        rgba(34, 72, 110, .07);

    cursor: pointer;

    transition:
        transform .25s ease,
        background .25s ease,
        border-color .25s ease,
        box-shadow .25s ease,
        color .25s ease;
}


.template-category-tab strong {
    color: inherit;

    font-size: 13px;
    line-height: 1.35;
    font-weight: 900;
}


.template-category-tab small {
    margin-top: 6px;

    color: #7c91a7;

    font-size: 6px;
    line-height: 1.3;
    font-weight: 900;
    letter-spacing: .08em;

    transition:
        color .25s ease;
}


/* Active category */

.template-category-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #16bddb
        );

    border-color:
        rgba(25, 184, 222, .72);

    box-shadow:
        0 15px 32px
        rgba(23, 107, 255, .22);

    transform: translateY(-3px);
}

.template-category-tab.is-active small {
    color:
        rgba(255, 255, 255, .82);
}


/* Category hover variations */

@media (hover: hover) and (pointer: fine) {

    .template-category-tab:hover {
        transform: translateY(-5px);

        box-shadow:
            0 17px 34px
            rgba(34, 72, 110, .14);
    }


    .template-category-tab:nth-child(1):hover {
        color: #1262c8;
        background: #e8f4ff;
        border-color:
            rgba(23, 107, 255, .30);
    }


    .template-category-tab:nth-child(2):hover {
        color: #087d70;
        background: #e7faf6;
        border-color:
            rgba(8, 185, 156, .30);
    }


    .template-category-tab:nth-child(3):hover {
        color: #6840c7;
        background: #f1edff;
        border-color:
            rgba(110, 67, 237, .28);
    }


    .template-category-tab:nth-child(4):hover {
        color: #bd552f;
        background: #fff0e9;
        border-color:
            rgba(255, 113, 72, .30);
    }


    .template-category-tab:nth-child(5):hover {
        color: #a12a91;
        background: #faebf7;
        border-color:
            rgba(210, 69, 184, .28);
    }


    .template-category-tab:nth-child(6):hover {
        color: #167083;
        background: #e9f9fc;
        border-color:
            rgba(22, 189, 219, .30);
    }


    /* Active category always keeps brand gradient */

    .template-category-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #176bff,
                #16bddb
            );

        transform: translateY(-5px);

        box-shadow:
            0 18px 36px
            rgba(23, 107, 255, .27);
    }

    .template-category-tab.is-active:hover small {
        color:
            rgba(255, 255, 255, .86);
    }
}


/* ==================================================
   Expandable document groups
   ================================================== */

.template-category-groups {
    position: relative;
}


.template-category-group {
    max-height: 0;

    opacity: 0;
    visibility: hidden;

    overflow: hidden;

    transform: translateY(-8px);

    transition:
        max-height .38s ease,
        opacity .28s ease,
        transform .38s ease,
        visibility 0s linear .38s;
}


.template-category-group.is-open {
    max-height: 220px;

    opacity: 1;
    visibility: visible;

    overflow: visible;

    transform: translateY(0);

    transition:
        max-height .42s ease,
        opacity .30s ease .05s,
        transform .38s ease,
        visibility 0s;
}


/* Document cards inside a category */

.template-category-group
.document-type-tabs {
    margin: 0;

    display: grid;

    grid-template-columns:
        repeat(
            auto-fit,
            minmax(135px, 1fr)
        );

    gap: 11px;

    padding: 14px;

    background:
        linear-gradient(
            135deg,
            #f5f9fd,
            #edf4fa
        );

    border:
        1px solid
        rgba(116, 153, 190, .16);

    border-radius: 18px;

    overflow: visible;
}


/* Keep document buttons independent */

.template-category-group
.document-type-tab {
    min-height: 67px;

    background: #ffffff;

    border:
        1px solid
        rgba(120, 158, 195, .18);

    border-radius: 12px;

    box-shadow:
        0 5px 14px
        rgba(36, 73, 110, .06);
}


/* Active document */

.template-category-group
.document-type-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #18c6df
        );

    border-color:
        rgba(24, 186, 224, .65);

    box-shadow:
        0 10px 22px
        rgba(23, 107, 255, .20);
}


/* Document interaction */

@media (hover: hover) and (pointer: fine) {

    .template-category-group
    .document-type-tab:hover {
        transform: translateY(-4px);

        background: #edf6ff;

        border-color:
            rgba(23, 107, 255, .28);

        box-shadow:
            0 12px 24px
            rgba(36, 73, 110, .12);
    }

    .template-category-group
    .document-type-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #176bff,
                #18c6df
            );
    }
}


/* ==================================================
   Tablet
   ================================================== */

@media (max-width: 1000px) {

    .template-category-tabs {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .template-category-group.is-open {
        max-height: 360px;
    }
}


/* ==================================================
   Mobile
   ================================================== */

@media (max-width: 650px) {

    .template-category-selector {
        margin-bottom: 34px;
    }

    .template-category-tabs {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

    .template-category-tab {
        min-height: 72px;

        padding: 12px 8px;

        border-radius: 13px;
    }

    .template-category-tab strong {
        font-size: 12px;
    }

    .template-category-group.is-open {
        max-height: 650px;
    }

    .template-category-group
    .document-type-tabs {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 8px;

        padding: 10px;
    }

    .template-category-group
    .document-type-tab {
        min-height: 62px;
    }
}


/* Touch feedback */

@media (hover: none) {

    .template-category-tab:active,
    .template-category-group
    .document-type-tab:active {
        transform: scale(.97);
    }
}

/* ==================================================
   Template business categories
   ================================================== */

.template-category-selector {
    margin-bottom: 46px;
}


/* Category cards */

.template-category-tabs {
    display: grid;
    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 18px;
}


.template-category-tab {
    position: relative;

    min-width: 0;
    min-height: 82px;

    padding: 15px 10px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    color: #173757;
    background: #ffffff;

    border:
        1px solid
        rgba(115, 153, 191, .22);

    border-radius: 16px;

    box-shadow:
        0 8px 22px
        rgba(34, 72, 110, .07);

    cursor: pointer;

    transition:
        transform .25s ease,
        background .25s ease,
        border-color .25s ease,
        box-shadow .25s ease,
        color .25s ease;
}


.template-category-tab strong {
    color: inherit;

    font-size: 13px;
    line-height: 1.35;
    font-weight: 900;
}


.template-category-tab small {
    margin-top: 6px;

    color: #7c91a7;

    font-size: 6px;
    line-height: 1.3;
    font-weight: 900;
    letter-spacing: .08em;

    transition:
        color .25s ease;
}


/* Active category */

.template-category-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #16bddb
        );

    border-color:
        rgba(25, 184, 222, .72);

    box-shadow:
        0 15px 32px
        rgba(23, 107, 255, .22);

    transform: translateY(-3px);
}


.template-category-tab.is-active small {
    color:
        rgba(255, 255, 255, .82);
}


/* Different category hover colors */

@media (hover: hover) and (pointer: fine) {

    .template-category-tab:hover {
        transform: translateY(-5px);

        box-shadow:
            0 17px 34px
            rgba(34, 72, 110, .14);
    }

    .template-category-tab:nth-child(1):hover {
        color: #1262c8;
        background: #e8f4ff;
        border-color:
            rgba(23, 107, 255, .30);
    }

    .template-category-tab:nth-child(2):hover {
        color: #087d70;
        background: #e7faf6;
        border-color:
            rgba(8, 185, 156, .30);
    }

    .template-category-tab:nth-child(3):hover {
        color: #6840c7;
        background: #f1edff;
        border-color:
            rgba(110, 67, 237, .28);
    }

    .template-category-tab:nth-child(4):hover {
        color: #bd552f;
        background: #fff0e9;
        border-color:
            rgba(255, 113, 72, .30);
    }

    .template-category-tab:nth-child(5):hover {
        color: #a12a91;
        background: #faebf7;
        border-color:
            rgba(210, 69, 184, .28);
    }

    .template-category-tab:nth-child(6):hover {
        color: #167083;
        background: #e9f9fc;
        border-color:
            rgba(22, 189, 219, .30);
    }


    /* Active keeps the RYUKTO gradient */

    .template-category-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #176bff,
                #16bddb
            );

        transform: translateY(-5px);

        box-shadow:
            0 18px 36px
            rgba(23, 107, 255, .27);
    }

    .template-category-tab.is-active:hover small {
        color:
            rgba(255, 255, 255, .86);
    }
}


/* ==================================================
   Expandable document groups
   ================================================== */

.template-category-groups {
    position: relative;
}


.template-category-group {
    max-height: 0;

    opacity: 0;
    visibility: hidden;

    overflow: hidden;

    transform: translateY(-8px);

    transition:
        max-height .38s ease,
        opacity .28s ease,
        transform .38s ease,
        visibility 0s linear .38s;
}


.template-category-group.is-open {
    max-height: 220px;

    opacity: 1;
    visibility: visible;

    overflow: visible;

    transform: translateY(0);

    transition:
        max-height .42s ease,
        opacity .30s ease .05s,
        transform .38s ease,
        visibility 0s;
}


/* Document button container */

.template-category-group
.document-type-tabs {
    margin: 0;

    display: grid;

    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 11px;

    padding: 14px;

    background:
        linear-gradient(
            135deg,
            #f5f9fd,
            #edf4fa
        );

    border:
        1px solid
        rgba(116, 153, 190, .16);

    border-radius: 18px;

    overflow: visible;
}


/* Individual document buttons */

.template-category-group
.document-type-tab {
    min-width: 0;
    min-height: 68px;

    padding: 10px 7px;

    color: #173757;

    background: #ffffff;

    border:
        1px solid
        rgba(120, 158, 195, .18);

    border-radius: 12px;

    box-shadow:
        0 5px 14px
        rgba(36, 73, 110, .06);

    transition:
        transform .23s ease,
        background .23s ease,
        border-color .23s ease,
        box-shadow .23s ease,
        color .23s ease;
}


.template-category-group
.document-type-tab strong {
    color: inherit;
}


.template-category-group
.document-type-tab small {
    color: #7890aa;
}


/* Active document */

.template-category-group
.document-type-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff,
            #18c6df
        );

    border-color:
        rgba(24, 186, 224, .65);

    box-shadow:
        0 10px 22px
        rgba(23, 107, 255, .20);
}


.template-category-group
.document-type-tab.is-active strong {
    color: #ffffff;
}


.template-category-group
.document-type-tab.is-active small {
    color:
        rgba(255, 255, 255, .82);
}


/* Document hover */

@media (hover: hover) and (pointer: fine) {

    .template-category-group
    .document-type-tab:hover {
        color: #1262c8;

        transform: translateY(-4px);

        background: #edf6ff;

        border-color:
            rgba(23, 107, 255, .28);

        box-shadow:
            0 12px 24px
            rgba(36, 73, 110, .12);
    }

    .template-category-group
    .document-type-tab:hover small {
        color: #4f7da9;
    }

    .template-category-group
    .document-type-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #176bff,
                #18c6df
            );
    }

    .template-category-group
    .document-type-tab.is-active:hover small {
        color:
            rgba(255, 255, 255, .86);
    }
}


/* Custom group */

.template-category-group
.custom-document-type-tabs {
    grid-template-columns:
        minmax(150px, 220px);
}


/* ==================================================
   Tablet
   ================================================== */

@media (max-width: 1000px) {

    .template-category-tabs {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .template-category-group
    .document-type-tabs {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .template-category-group.is-open {
        max-height: 360px;
    }
}


/* ==================================================
   Mobile
   ================================================== */

@media (max-width: 650px) {

    .template-category-selector {
        margin-bottom: 34px;
    }

    .template-category-tabs {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 9px;
    }

    .template-category-tab {
        min-height: 72px;

        padding: 12px 8px;

        border-radius: 13px;
    }

    .template-category-tab strong {
        font-size: 12px;
    }

    .template-category-group.is-open {
        max-height: 650px;
    }

    .template-category-group
    .document-type-tabs {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 8px;

        padding: 10px;
    }

    .template-category-group
    .document-type-tab {
        min-height: 62px;
    }

    .template-category-group
    .custom-document-type-tabs {
        grid-template-columns: 1fr;
    }
}


/* Touch feedback */

@media (hover: none) {

    .template-category-tab:active,
    .template-category-group
    .document-type-tab:active {
        transform: scale(.97);
    }
}

/* ==================================================
   Orange document buttons
   Separate document level from category level
   ================================================== */

/* Default document button */

.template-category-group
.document-type-tab {
    color: #8f4b16;

    background:
        linear-gradient(
            135deg,
            #fff7ed,
            #ffedd5
        );

    border-color:
        rgba(249, 115, 22, .24);

    box-shadow:
        0 5px 14px
        rgba(194, 92, 20, .08);
}


.template-category-group
.document-type-tab strong {
    color: inherit;
}


.template-category-group
.document-type-tab small {
    color: #b66b32;
}


/* Selected document */

.template-category-group
.document-type-tab.is-active {
    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #f97316,
            #fb923c
        );

    border-color:
        rgba(234, 88, 12, .72);

    box-shadow:
        0 11px 24px
        rgba(234, 88, 12, .24);
}


.template-category-group
.document-type-tab.is-active strong,
.template-category-group
.document-type-tab.is-active small {
    color: #ffffff;
}


/* Desktop hover */

@media (hover: hover) and (pointer: fine) {

    .template-category-group
    .document-type-tab:hover {
        color: #9a410d;

        background:
            linear-gradient(
                135deg,
                #ffedd5,
                #fed7aa
            );

        border-color:
            rgba(249, 115, 22, .46);

        transform: translateY(-4px);

        box-shadow:
            0 13px 26px
            rgba(194, 92, 20, .16);
    }


    .template-category-group
    .document-type-tab:hover small {
        color: #a9571f;
    }


    /* Selected document remains strongly orange */

    .template-category-group
    .document-type-tab.is-active:hover {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #ea580c,
                #f97316
            );

        border-color:
            rgba(194, 65, 12, .78);

        box-shadow:
            0 15px 30px
            rgba(234, 88, 12, .28);
    }


    .template-category-group
    .document-type-tab.is-active:hover strong,
    .template-category-group
    .document-type-tab.is-active:hover small {
        color: #ffffff;
    }
}


/* Touch feedback */

@media (hover: none) {

    .template-category-group
    .document-type-tab:active {
        background: #fed7aa;

        border-color:
            rgba(249, 115, 22, .46);
    }

    .template-category-group
    .document-type-tab.is-active:active {
        color: #ffffff;

        background:
            linear-gradient(
                135deg,
                #ea580c,
                #f97316
            );
    }
}

/* ==================================================
   RYUKTO AI document workspace
   ================================================== */

.ai-document-workspace {
    margin-top: 42px;
    padding: 28px;

    background:
        linear-gradient(
            145deg,
            #f8fbff 0%,
            #ffffff 58%,
            #f8f7ff 100%
        );

    border: 1px solid #dce7f1;
    border-radius: 24px;

    box-shadow:
        0 22px 60px
        rgba(20, 55, 85, .08);
}

.ai-document-workspace[hidden] {
    display: none !important;
}


.ai-document-workspace-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;

    margin-bottom: 22px;
}


.ai-workspace-eyebrow {
    display: block;

    color: #176bff;

    font-size: 8px;
    font-weight: 900;
    letter-spacing: .16em;
}


.ai-document-workspace-head h2 {
    margin: 7px 0 0;

    color: #102d4e;

    font-size: 28px;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: -.035em;
}


.ai-document-workspace-head p {
    max-width: 560px;

    margin: 10px 0 0;

    color: #6f8598;

    font-size: 11px;
    line-height: 1.8;
    font-weight: 650;
}


.ai-workspace-template {
    min-width: 190px;

    padding: 12px 15px;

    background: #ffffff;

    border: 1px solid #dce7f1;
    border-radius: 13px;

    text-align: right;
}


.ai-workspace-template small {
    display: block;

    color: #8a9caf;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .13em;
}


.ai-workspace-template strong {
    display: block;

    margin-top: 5px;

    color: #173651;

    font-size: 12px;
    font-weight: 900;
}


.ai-workspace-template span {
    display: block;

    margin-top: 2px;

    color: #8195a7;

    font-size: 9px;
    font-weight: 700;
}


/* Workspace columns */

.ai-document-workspace-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1.12fr)
        minmax(330px, .88fr);

    gap: 18px;

    align-items: stretch;
}


/* Live document */

.ai-document-live-preview {
    min-width: 0;

    padding: 17px;

    background: #edf3f8;

    border: 1px solid #d8e4ed;
    border-radius: 18px;
}


.ai-preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    margin-bottom: 13px;
}


.ai-preview-toolbar span {
    display: block;

    color: #7f93a6;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .14em;
}


.ai-preview-toolbar strong {
    display: block;

    margin-top: 3px;

    color: #173651;

    font-size: 12px;
    font-weight: 900;
}


.ai-preview-toolbar > small {
    flex: 0 0 auto;

    padding: 6px 9px;

    color: #176bff;
    background: #ffffff;

    border: 1px solid #d5e3ef;
    border-radius: 999px;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .08em;
}


.ai-preview-sheet {
    position: relative;

    min-height: 520px;

    padding: 42px 44px;

    overflow: hidden;

    color: #18344f;
    background: #ffffff;

    border-radius: 12px;

    box-shadow:
        0 12px 30px
        rgba(20, 55, 85, .09);
}


.ai-preview-empty {
    position: absolute;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    padding: 30px;

    text-align: center;
}


.ai-preview-empty strong {
    color: #274764;

    font-size: 17px;
    font-weight: 900;
}


.ai-preview-empty p {
    max-width: 300px;

    margin: 9px 0 0;

    color: #8a9cad;

    font-size: 10px;
    line-height: 1.8;
}


/* AI chat */

.ai-chat-panel {
    min-width: 0;
    min-height: 620px;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #dce7f1;
    border-radius: 18px;

    box-shadow:
        0 10px 30px
        rgba(20, 55, 85, .055);
}


.ai-chat-head {
    min-height: 66px;

    padding: 14px 16px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;

    border-bottom: 1px solid #e6edf3;
}


.ai-chat-head > div {
    display: flex;
    align-items: center;
    gap: 10px;
}


.ai-status-dot {
    width: 9px;
    height: 9px;

    flex: 0 0 auto;

    background: #19b886;

    border-radius: 50%;

    box-shadow:
        0 0 0 5px
        rgba(25, 184, 134, .10);
}


.ai-chat-head strong {
    display: block;

    color: #173651;

    font-size: 11px;
    font-weight: 900;
}


.ai-chat-head small {
    display: block;

    margin-top: 2px;

    color: #8396a8;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .11em;
}


.ai-chat-close {
    width: 32px;
    height: 32px;

    padding: 0;

    color: #8093a4;
    background: #f5f8fa;

    border: 0;
    border-radius: 9px;

    font-size: 20px;
    line-height: 1;

    cursor: pointer;

    transition:
        color .2s ease,
        background .2s ease,
        transform .2s ease;
}


.ai-chat-close:hover {
    color: #173651;
    background: #eaf1f6;
    transform: rotate(5deg);
}


/* Messages */

.ai-chat-messages {
    min-height: 280px;
    max-height: 390px;

    flex: 1 1 auto;

    padding: 18px;

    overflow-y: auto;

    background:
        linear-gradient(
            180deg,
            #fbfdff,
            #f7fafc
        );
}


.ai-message {
    display: flex;
    align-items: flex-start;
    gap: 9px;

    margin-bottom: 14px;
}


.ai-message > span {
    width: 28px;
    height: 28px;

    flex: 0 0 28px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #ffffff;
    background: #176bff;

    border-radius: 9px;

    font-size: 7px;
    font-weight: 900;
}


.ai-message > div {
    max-width: 82%;

    padding: 10px 12px;

    color: #405c73;
    background: #ffffff;

    border: 1px solid #e0e9f0;
    border-radius: 5px 13px 13px 13px;

    font-size: 10px;
    line-height: 1.75;
    font-weight: 650;
}


.ai-message.user {
    justify-content: flex-end;
}


.ai-message.user > span {
    order: 2;

    background: #7254d8;
}


.ai-message.user > div {
    order: 1;

    color: #ffffff;
    background: #176bff;

    border-color: #176bff;
    border-radius: 13px 5px 13px 13px;
}


.ai-message.is-loading > div {
    color: #8194a5;
}


/* Notice */

.ai-chat-notice {
    margin: 12px 16px 0;
    padding: 10px 12px;

    color: #8a5b10;
    background: #fff8e8;

    border: 1px solid #f2dfb6;
    border-radius: 10px;

    font-size: 9px;
    line-height: 1.6;
    font-weight: 750;
}


.ai-chat-notice.is-error {
    color: #a13e4a;
    background: #fff2f4;
    border-color: #f1cbd1;
}


/* Input */

.ai-chat-form {
    padding: 15px 16px 13px;

    border-top: 1px solid #e6edf3;
}


.ai-chat-input-wrap {
    display: block;
}


.ai-chat-input-wrap textarea {
    width: 100%;
    min-height: 88px;

    box-sizing: border-box;

    padding: 12px 13px;

    resize: vertical;

    color: #173651;
    background: #f8fafc;

    border: 1px solid #d9e4ed;
    border-radius: 12px;

    outline: none;

    font: inherit;
    font-size: 10px;
    line-height: 1.7;

    transition:
        border-color .2s ease,
        background .2s ease,
        box-shadow .2s ease;
}


.ai-chat-input-wrap textarea:focus {
    background: #ffffff;
    border-color: #8db6ff;

    box-shadow:
        0 0 0 3px
        rgba(23, 107, 255, .08);
}


.ai-chat-input-wrap textarea::placeholder {
    color: #9aabba;
}


.ai-chat-actions {
    margin-top: 10px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}


.ai-chat-tools {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 8px;
}


.ai-chat-tools small {
    color: #9aa9b7;

    font-size: 7px;
    line-height: 1.4;
}


.ai-voice-button {
    min-width: 42px;
    height: 32px;

    padding: 0 9px;

    color: #8698a8;
    background: #eef3f7;

    border: 1px solid #dce5ec;
    border-radius: 9px;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .08em;
}


.ai-voice-button:disabled {
    cursor: not-allowed;
    opacity: .62;
}


.ai-send-button {
    min-width: 92px;
    height: 36px;

    padding: 0 13px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #178ed8
        );

    border: 0;
    border-radius: 10px;

    font-size: 9px;
    font-weight: 900;

    cursor: pointer;

    box-shadow:
        0 8px 18px
        rgba(23, 107, 255, .17);

    transition:
        transform .2s ease,
        box-shadow .2s ease,
        opacity .2s ease;
}


.ai-send-button:hover {
    transform: translateY(-2px);

    box-shadow:
        0 12px 24px
        rgba(23, 107, 255, .23);
}


.ai-send-button:disabled {
    cursor: wait;
    opacity: .55;
    transform: none;
}


.ai-send-button b {
    font-size: 14px;
}


/* Bottom metadata */

.ai-chat-meta {
    min-height: 32px;

    padding: 0 16px 13px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    color: #8b9cab;

    font-size: 7px;
    font-weight: 800;
}


/* Generic rendered AI document */

.ai-rendered-document {
    color: #173651;
}


.ai-rendered-document-header {
    padding-bottom: 18px;

    border-bottom: 2px solid #173651;
}


.ai-rendered-document-header h3 {
    margin: 0;

    font-size: 24px;
    font-weight: 900;
}


.ai-rendered-field {
    margin-top: 18px;
}


.ai-rendered-field small {
    display: block;

    color: #8497a8;

    font-size: 7px;
    font-weight: 900;
    letter-spacing: .08em;
}


.ai-rendered-field strong {
    display: block;

    margin-top: 4px;

    color: #173651;

    font-size: 12px;
    font-weight: 850;
}


.ai-rendered-items {
    width: 100%;

    margin-top: 24px;

    border-collapse: collapse;

    font-size: 9px;
}


.ai-rendered-items th,
.ai-rendered-items td {
    padding: 8px 6px;

    text-align: left;

    border-bottom: 1px solid #e1e8ee;
}


.ai-rendered-items th {
    color: #74899b;
    background: #f5f8fa;

    font-size: 7px;
    font-weight: 900;
}


.ai-rendered-total {
    margin-top: 20px;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 18px;
}


.ai-rendered-total span {
    color: #73899b;

    font-size: 9px;
    font-weight: 800;
}


.ai-rendered-total strong {
    color: #173651;

    font-size: 21px;
    font-weight: 900;
}


/* Tablet */

@media (max-width: 980px) {

    .ai-document-workspace-grid {
        grid-template-columns: 1fr;
    }

    .ai-chat-panel {
        min-height: 540px;
    }

    .ai-preview-sheet {
        min-height: 460px;
    }
}


/* Mobile */

@media (max-width: 650px) {

    .ai-document-workspace {
        margin-top: 28px;
        padding: 16px;

        border-radius: 18px;
    }

    .ai-document-workspace-head {
        align-items: stretch;
        flex-direction: column;
        gap: 15px;
    }

    .ai-document-workspace-head h2 {
        font-size: 23px;
    }

    .ai-workspace-template {
        min-width: 0;
        text-align: left;
    }

    .ai-document-workspace-grid {
        gap: 13px;
    }

    .ai-document-live-preview {
        padding: 11px;
        border-radius: 14px;
    }

    .ai-preview-sheet {
        min-height: 400px;
        padding: 27px 20px;
    }

    .ai-chat-panel {
        min-height: 520px;
        border-radius: 14px;
    }

    .ai-chat-messages {
        max-height: 340px;
        padding: 14px;
    }

    .ai-message > div {
        max-width: 88%;
    }

    .ai-chat-actions {
        align-items: flex-end;
    }

    .ai-chat-tools small {
        display: none;
    }

    .ai-send-button {
        min-width: 84px;
    }
}

/* ==================================================
   RYUKTO AI start button v1
   ================================================== */

.ai-document-start-button {
    width: min(100%, 420px);
    min-height: 54px;

    margin: 20px auto 4px;
    padding: 0 18px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    color: #ffffff;

    background:
        linear-gradient(
            135deg,
            #176bff 0%,
            #7254d8 100%
        );

    border: 0;
    border-radius: 14px;

    cursor: pointer;

    box-shadow:
        0 12px 28px
        rgba(55, 85, 190, .20);

    transition:
        transform .25s ease,
        box-shadow .25s ease,
        filter .25s ease;
}


.ai-document-start-button > span {
    padding: 5px 7px;

    color: #dce9ff;
    background: rgba(255, 255, 255, .13);

    border: 1px solid
        rgba(255, 255, 255, .20);

    border-radius: 7px;

    font-size: 6.5px;
    font-weight: 900;
    letter-spacing: .10em;
}


.ai-document-start-button > strong {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .01em;
}


.ai-document-start-button > b {
    font-size: 17px;
    line-height: 1;

    transition:
        transform .25s ease;
}


@media (hover: hover) and (pointer: fine) {

    .ai-document-start-button:hover {
        transform: translateY(-5px);

        box-shadow:
            0 18px 36px
            rgba(55, 85, 190, .28);

        filter: saturate(1.08);
    }

    .ai-document-start-button:hover > b {
        transform: translateX(4px);
    }
}


.ai-document-start-button:active {
    transform: translateY(1px);
}


@media (max-width: 650px) {

    .ai-document-start-button {
        width: 100%;
        min-height: 50px;

        margin-top: 15px;
        padding: 0 13px;

        border-radius: 12px;
    }

    .ai-document-start-button > strong {
        font-size: 10px;
    }
}

/* ==================================================
   RYUKTO AI template fields v1
   ================================================== */

.ai-template-field {
    margin-top: 11px;
    padding: 9px 11px;

    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 10px;
    align-items: baseline;

    background: rgba(245, 248, 251, .72);

    border-left: 3px solid
        rgba(23, 107, 255, .30);
}


.ai-template-field small {
    color: #71879a;

    font-size: 7px;
    line-height: 1.5;
    font-weight: 900;
    letter-spacing: .04em;
}


.ai-template-field strong {
    min-width: 0;

    color: #173651;

    font-size: 9px;
    line-height: 1.6;
    font-weight: 800;

    overflow-wrap: anywhere;
}


/* Match the selected document style */

.preview-classic
.ai-template-field {
    background: #fbfaf7;

    border-left-color: #9e8a69;
}


.preview-compact
.ai-template-field {
    margin-top: 7px;
    padding: 6px 8px;

    grid-template-columns: 76px 1fr;

    border-left-color: #12b8a0;
}


.preview-simple
.ai-template-field {
    background: transparent;

    border-left-color: #596b80;
    border-bottom: 1px solid #e2e8ee;
}


.preview-detailed
.ai-template-field {
    border-left-color: #6c4be8;
}


.preview-formal
.ai-template-field {
    background: transparent;

    border-left: 0;
    border-bottom: 1px solid #aeb9c4;
}


@media (max-width: 650px) {

    .ai-template-field {
        grid-template-columns: 72px 1fr;
        gap: 8px;

        padding: 8px 9px;
    }

    .ai-template-field small {
        font-size: 6.5px;
    }

    .ai-template-field strong {
        font-size: 8.5px;
    }
}

/* ==================================================
   RYUKTO AI real template scale v1
   ================================================== */

.ai-preview-sheet
.document-preview {
    width: min(100%, 620px);
    min-height: 720px;

    margin: 0 auto;
    padding: 42px 46px;

    box-sizing: border-box;

    font-size: 1.35em;

    transform: none;
}


.ai-preview-sheet
.document-preview
.preview-header {
    margin-bottom: 38px;
}


.ai-preview-sheet
.document-preview
.preview-title {
    margin-bottom: 28px;

    font-size: 27px;
}


.ai-preview-sheet
.document-preview
.preview-recipient {
    margin-bottom: 20px;

    font-size: 13px;
}


.ai-preview-sheet
.document-preview
.preview-meta {
    margin-bottom: 27px;

    font-size: 9px;
}


.ai-preview-sheet
.document-preview
.preview-table {
    margin-top: 26px;
}


.ai-preview-sheet
.document-preview
.preview-table > div {
    min-height: 38px;
}


.ai-preview-sheet
.document-preview
.preview-table span {
    font-size: 9px;
}


.ai-preview-sheet
.document-preview
.preview-total {
    margin-top: 26px;
    padding: 15px 18px;
}


.ai-preview-sheet
.document-preview
.preview-total strong {
    font-size: 20px;
}


.ai-preview-sheet
.document-preview
.ai-template-field {
    font-size: 1em;
}


.ai-preview-sheet
.document-preview
.preview-footer {
    margin-top: 36px;
}


/* Tablet */

@media (max-width: 980px) {

    .ai-preview-sheet
    .document-preview {
        width: min(100%, 680px);
        min-height: 700px;
    }
}


/* Mobile */

@media (max-width: 650px) {

    .ai-preview-sheet
    .document-preview {
        width: 100%;
        min-height: 520px;

        padding: 27px 22px;

        font-size: 1.05em;
    }

    .ai-preview-sheet
    .document-preview
    .preview-title {
        font-size: 21px;
    }

    .ai-preview-sheet
    .document-preview
    .preview-table span {
        font-size: 7.5px;
    }

    .ai-preview-sheet
    .document-preview
    .preview-total strong {
        font-size: 17px;
    }
}

/* ==================================================
   RYUKTO AI chat full height v1
   ================================================== */

.ai-document-workspace-grid {
    align-items: stretch;
}


.ai-chat-panel {
    height: 100%;
    min-height: 760px;
}


.ai-chat-messages {
    min-height: 0;
    max-height: none;

    flex: 1 1 0;

    overflow-y: auto;
}


.ai-chat-form {
    flex: 0 0 auto;

    margin-top: auto;

    background: #ffffff;
}


.ai-chat-meta {
    flex: 0 0 auto;

    background: #ffffff;
}


/* Tax summary */

.ai-tax-summary {
    width: min(100%, 260px);

    margin: 24px 0 0 auto;

    font-size: 9px;
}


.ai-tax-summary-row {
    padding: 6px 10px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    border-bottom: 1px solid #e1e8ef;
}


.ai-tax-summary-row span {
    color: #71869a;
}


.ai-tax-summary-row strong {
    color: #173651;
    font-weight: 900;
}


.ai-tax-summary-row.total {
    margin-top: 5px;
    padding: 12px 10px;

    border-bottom: 0;

    background: #edf5ff;
}


.ai-tax-summary-row.total strong {
    font-size: 17px;
}


.preview-classic
.ai-tax-summary-row.total {
    background: #f5f1e8;
}


.preview-compact
.ai-tax-summary-row.total {
    background: #ecfaf7;
}


@media (max-width: 980px) {

    .ai-chat-panel {
        min-height: 680px;
    }
}


@media (max-width: 650px) {

    .ai-chat-panel {
        min-height: 620px;
    }

    .ai-tax-summary {
        width: 100%;
    }
}

/* ==================================================
   RYUKTO template release button v1
   ================================================== */

.template-release-form {
    margin-top: 8px;
}


.template-release-button {
    width: 100%;
    min-height: 38px;

    padding: 0 14px;

    color: #7c8d9d;
    background: #ffffff;

    border: 1px solid #d7e1e9;
    border-radius: 10px;

    font-size: 9px;
    font-weight: 850;

    cursor: pointer;

    transition:
        color .2s ease,
        border-color .2s ease,
        background .2s ease,
        transform .2s ease;
}


@media (hover: hover) and (pointer: fine) {

    .template-release-button:hover {
        color: #b44c59;
        background: #fff7f8;
        border-color: #e8b9c0;

        transform: translateY(-2px);
    }
}


.template-release-button:active {
    transform: translateY(1px);
}

/* ==================================================
   RYUKTO document icon toolbar v1
   ================================================== */

.ai-document-actions {
    margin-bottom: 12px;

    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}


.ai-document-action {
    position: relative;

    width: 38px;
    height: 38px;

    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: #60778b;
    background: #ffffff;

    border: 1px solid #d5e1eb;
    border-radius: 10px;

    cursor: pointer;

    box-shadow:
        0 3px 10px
        rgba(24, 54, 82, .045);

    transition:
        color .2s ease,
        background .2s ease,
        border-color .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}


.ai-document-action svg {
    width: 18px;
    height: 18px;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;

    pointer-events: none;
}


.ai-document-action.is-fax {
    color: #7254d8;

    border-color:
        rgba(114, 84, 216, .28);

    background:
        rgba(114, 84, 216, .045);
}


/* Tooltip */

.ai-document-action::before {
    content:
        attr(data-tooltip);

    position: absolute;
    z-index: 30;

    left: 50%;
    bottom: calc(100% + 9px);

    padding: 6px 9px;

    color: #ffffff;
    background: #173651;

    border-radius: 7px;

    font-size: 7px;
    line-height: 1;
    font-weight: 850;
    white-space: nowrap;

    opacity: 0;
    visibility: hidden;

    transform:
        translate(-50%, 4px);

    transition:
        opacity .16s ease,
        visibility .16s ease,
        transform .16s ease;

    pointer-events: none;
}


.ai-document-action::after {
    content: "";

    position: absolute;
    z-index: 29;

    left: 50%;
    bottom: calc(100% + 4px);

    width: 7px;
    height: 7px;

    background: #173651;

    opacity: 0;
    visibility: hidden;

    transform:
        translateX(-50%)
        rotate(45deg);

    transition:
        opacity .16s ease,
        visibility .16s ease;

    pointer-events: none;
}


@media (hover: hover) and (pointer: fine) {

    .ai-document-action:hover {
        color: #ffffff;
        background: #176bff;
        border-color: #176bff;

        transform: translateY(-2px);

        box-shadow:
            0 8px 18px
            rgba(23, 107, 255, .16);
    }

    .ai-document-action.is-fax:hover {
        background: #7254d8;
        border-color: #7254d8;
    }

    .ai-document-action:hover::before,
    .ai-document-action:hover::after {
        opacity: 1;
        visibility: visible;
    }

    .ai-document-action:hover::before {
        transform:
            translate(-50%, 0);
    }
}


.ai-document-action:active {
    transform: translateY(1px);
}


.ai-document-action:focus-visible {
    outline: 3px solid
        rgba(23, 107, 255, .18);

    outline-offset: 2px;
}


/* Mobile touch targets */

@media (max-width: 650px) {

    .ai-document-actions {
        justify-content: center;
        gap: 8px;

        margin-bottom: 14px;
    }

    .ai-document-action {
        width: 44px;
        height: 44px;

        border-radius: 11px;
    }

    .ai-document-action svg {
        width: 19px;
        height: 19px;
    }

    .ai-document-action::before,
    .ai-document-action::after {
        display: none;
    }
}

/* ==================================================
   RYUKTO AI readability and selection row v1
   ================================================== */


/* Selected template actions */

.template-selected-actions {
    width: 100%;

    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;

    align-items: stretch;
}


.template-selected-actions
.template-select-button,
.template-selected-actions
.template-release-form,
.template-selected-actions
.template-release-button {
    width: 100%;
    margin: 0;
}


.template-selected-actions
.template-select-button,
.template-selected-actions
.template-release-button {
    min-height: 42px;
    height: 42px;

    padding: 0 10px;

    display: flex;
    align-items: center;
    justify-content: center;

    box-sizing: border-box;

    font-size: 9px;
    line-height: 1;
}


.template-selected-actions
.template-release-form {
    display: block;
}


/* AI chat readability */

.ai-chat-head {
    min-height: 72px;
    padding: 16px 18px;
}


.ai-chat-head strong {
    font-size: 13px;
}


.ai-chat-head small {
    margin-top: 3px;

    font-size: 8px;
}


.ai-status-dot {
    width: 10px;
    height: 10px;
}


.ai-chat-messages {
    padding: 21px 20px;
}


.ai-message {
    gap: 11px;
    margin-bottom: 17px;
}


.ai-message > span {
    width: 32px;
    height: 32px;

    flex-basis: 32px;

    font-size: 8px;
}


.ai-message > div {
    padding: 12px 14px;

    font-size: 12px;
    line-height: 1.75;
}


.ai-chat-form {
    padding: 18px 18px 15px;
}


.ai-chat-form::before {
    font-size: 15px;
}


.ai-chat-input-wrap textarea {
    min-height: 105px;

    padding: 14px 15px;

    font-size: 12px;
    line-height: 1.7;
}


.ai-chat-input-wrap textarea::placeholder {
    font-size: 11px;
}


.ai-chat-actions {
    margin-top: 12px;
}


.ai-chat-tools {
    gap: 10px;
}


.ai-chat-tools small {
    font-size: 8px;
    line-height: 1.5;
}


.ai-voice-button {
    min-width: 48px;
    height: 36px;

    font-size: 7.5px;
}


.ai-send-button {
    min-width: 102px;
    height: 40px;

    padding: 0 16px;

    font-size: 10px;
}


.ai-send-button b {
    font-size: 16px;
}


.ai-chat-meta {
    min-height: 37px;

    padding: 0 18px 15px;

    font-size: 8px;
}


.ai-chat-notice {
    margin-left: 18px;
    margin-right: 18px;

    padding: 11px 13px;

    font-size: 10px;
}


/* Toolbar icons */

.ai-document-action {
    width: 42px;
    height: 42px;
}


.ai-document-action svg {
    width: 20px;
    height: 20px;
}


/* Larger desktop tooltip */

.ai-document-action::before {
    bottom: calc(100% + 10px);

    padding: 8px 11px;

    font-size: 10px;
    line-height: 1.1;
}


/* Mobile */

@media (max-width: 650px) {

    .template-selected-actions {
        gap: 6px;
    }

    .template-selected-actions
    .template-select-button,
    .template-selected-actions
    .template-release-button {
        min-height: 44px;
        height: 44px;

        font-size: 8.5px;
    }

    .ai-chat-head strong {
        font-size: 12px;
    }

    .ai-message > div {
        font-size: 11px;
    }

    .ai-chat-input-wrap textarea {
        min-height: 110px;
        font-size: 11px;
    }

    .ai-chat-meta {
        font-size: 7.5px;
    }

    .ai-document-action {
        width: 46px;
        height: 46px;
    }
}

/* ==================================================
   RYUKTO readability v2
   ================================================== */


/* Template information */

.template-field-count {
    margin-bottom: 18px !important;

    padding: 7px 11px !important;

    font-size: 9px !important;
    line-height: 1 !important;
    font-weight: 900 !important;
}


.template-selected-actions {
    margin-top: 0;

    gap: 10px;
}


.template-selected-actions
.template-select-button,
.template-selected-actions
.template-release-button {
    min-height: 46px;
    height: 46px;

    font-size: 11px;
    font-weight: 850;
}


/* AI composer */

.ai-chat-form {
    padding-top: 20px;
    padding-bottom: 17px;
}


.ai-chat-actions {
    margin-top: 14px;
}


.ai-chat-tools {
    gap: 12px;
}


.ai-chat-tools small {
    color: #8296a8;

    font-size: 10px !important;
    line-height: 1.5;
    font-weight: 700;
}


.ai-voice-button {
    width: 44px;
    min-width: 44px;
    height: 44px;

    padding: 0;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: #176bff;
    background: #f4f8ff;

    border: 1px solid #cbdfff;
    border-radius: 10px;
}


.ai-voice-button:disabled {
    color: #176bff;

    opacity: .52;
}


.ai-microphone-icon {
    width: 20px;
    height: 20px;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}


.ai-send-button {
    min-width: 110px;
    height: 44px;

    font-size: 11px;
}


.ai-chat-meta {
    min-height: 40px;

    padding:
        0 18px 16px;

    font-size: 10px !important;
    font-weight: 850;
}


.ai-chat-meta span {
    font-size: inherit;
}


.ai-chat-input-wrap textarea {
    font-size: 13px;
}


.ai-chat-input-wrap textarea::placeholder {
    font-size: 12px;
}


/* Document action tooltip */

.ai-document-action::before {
    padding: 8px 12px;

    font-size: 11px;
    font-weight: 850;
}


/* Mobile */

@media (max-width: 650px) {

    .template-field-count {
        margin-bottom: 15px !important;

        font-size: 8.5px !important;
    }

    .template-selected-actions
    .template-select-button,
    .template-selected-actions
    .template-release-button {
        min-height: 44px;
        height: 44px;

        font-size: 10px;
    }

    .ai-chat-tools small {
        display: block;

        font-size: 9px !important;
    }

    .ai-chat-meta {
        font-size: 9px !important;
    }

    .ai-voice-button {
        width: 44px;
        min-width: 44px;
        height: 44px;
    }
}

/* ==================================================
   RYUKTO AI message icon v1
   ================================================== */

.ai-message
.ai-message-icon {
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #176bff,
            #7254d8
        );
}


.ai-message
.ai-message-icon svg {
    width: 18px;
    height: 18px;

    fill: currentColor;
    stroke: none;
}


.ai-message.user
.ai-message-icon {
    background: #7254d8;
}

/* ==================================================
   RYUKTO AI dynamic table v1
   ================================================== */

.ai-dynamic-table
.preview-table-head,
.ai-dynamic-table
.ai-dynamic-table-row {
    display: grid;
}


.ai-dynamic-table
.preview-table-head > span,
.ai-dynamic-table
.ai-dynamic-table-row > span {
    min-width: 0;

    padding-left: 6px;
    padding-right: 6px;

    overflow-wrap: anywhere;
}


.ai-dynamic-table
.ai-dynamic-table-row {
    align-items: center;
}


.ai-dynamic-table
.ai-dynamic-table-row > span {
    font-size: 8.5px;
}


@media (max-width: 650px) {

    .ai-dynamic-table {
        overflow-x: auto;
    }

    .ai-dynamic-table
    .preview-table-head,
    .ai-dynamic-table
    .ai-dynamic-table-row {
        min-width: 520px;
    }

    .ai-dynamic-table
    .ai-dynamic-table-row > span {
        font-size: 7.5px;
    }
}

/* ==================================================
   RYUKTO document print v2
   ================================================== */


/* Disabled output actions */

.ai-document-action:disabled {
    opacity: .34;
    cursor: not-allowed;

    transform: none !important;
    box-shadow: none !important;
}


.ai-document-action[data-ai-load]:disabled {
    opacity: 1;
}


/* Print only the generated document */

@media print {

    @page {
        size: A4;
        margin: 10mm;
    }

    body[data-ryukto-print-mode] * {
        visibility: hidden !important;
    }

    body[data-ryukto-print-mode]
    [data-ai-preview-sheet],
    body[data-ryukto-print-mode]
    [data-ai-preview-sheet] * {
        visibility: visible !important;
    }

    body[data-ryukto-print-mode]
    [data-ai-preview-sheet] {
        position: absolute !important;

        left: 0 !important;
        top: 0 !important;

        width: 100% !important;
        min-height: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        background: #ffffff !important;

        border: 0 !important;
        box-shadow: none !important;
    }

    body[data-ryukto-print-mode]
    [data-ai-preview-sheet]
    > :not(.document-preview) {
        display: none !important;
    }

    body[data-ryukto-print-mode]
    .document-preview {
        position: relative !important;

        width: 190mm !important;
        max-width: 190mm !important;
        min-height: 0 !important;

        margin: 0 auto !important;
        padding: 12mm !important;

        background: #ffffff !important;

        box-sizing: border-box !important;

        box-shadow: none !important;
        transform: none !important;

        break-inside: auto;
        page-break-inside: auto;
    }

    body[data-ryukto-print-mode]
    .ai-dynamic-table {
        overflow: visible !important;
    }

    body[data-ryukto-print-mode]
    .ai-dynamic-table
    .preview-table-head,
    body[data-ryukto-print-mode]
    .ai-dynamic-table
    .ai-dynamic-table-row {
        min-width: 0 !important;
    }
}

/* ==================================================
   RYUKTO FAX modal v1
   ================================================== */

.ai-fax-modal[hidden] {
    display: none !important;
}


.ai-fax-modal {
    position: fixed;
    z-index: 10000;

    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;
}


.ai-fax-backdrop {
    position: absolute;

    inset: 0;

    background:
        rgba(7, 26, 53, .48);

    backdrop-filter:
        blur(4px);
}


.ai-fax-dialog {
    position: relative;
    z-index: 1;

    width: min(100%, 460px);

    overflow: hidden;

    background: #ffffff;

    border: 1px solid #d6e2ec;
    border-radius: 20px;

    box-shadow:
        0 24px 70px
        rgba(7, 26, 53, .22);
}


.ai-fax-dialog-head {
    min-height: 84px;

    padding: 18px 20px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    border-bottom: 1px solid #e1e9f0;
}


.ai-fax-dialog-head span {
    display: block;

    margin-bottom: 5px;

    color: #176bff;

    font-size: 9px;
    font-weight: 950;
    letter-spacing: .11em;
}


.ai-fax-dialog-head h2 {
    margin: 0;

    color: #102f4b;

    font-size: 22px;
    line-height: 1.2;
}


.ai-fax-close {
    width: 38px;
    height: 38px;

    flex: 0 0 38px;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #7890a4;
    background: #f4f7fa;

    border: 0;
    border-radius: 10px;

    font-size: 22px;
    line-height: 1;

    cursor: pointer;
}


.ai-fax-dialog-body {
    padding: 20px;
}


.ai-fax-recipient {
    padding: 14px 15px;

    background: #f5f9fd;

    border: 1px solid #dce8f1;
    border-radius: 12px;
}


.ai-fax-recipient small,
.ai-fax-field > span {
    display: block;

    margin-bottom: 6px;

    color: #71889c;

    font-size: 10px;
    font-weight: 850;
}


.ai-fax-recipient strong {
    color: #173651;

    font-size: 14px;
    line-height: 1.5;
}


.ai-fax-field {
    display: block;

    margin-top: 18px;
}


.ai-fax-field input {
    width: 100%;
    height: 48px;

    padding: 0 14px;

    color: #173651;
    background: #ffffff;

    border: 1px solid #cbdbe7;
    border-radius: 11px;

    box-sizing: border-box;

    font-size: 15px;
    font-weight: 750;

    outline: none;
}


.ai-fax-field input:focus {
    border-color: #176bff;

    box-shadow:
        0 0 0 3px
        rgba(23, 107, 255, .10);
}


.ai-fax-field > small {
    display: block;

    margin-top: 7px;

    color: #8295a5;

    font-size: 9px;
    line-height: 1.6;
}


.ai-fax-summary {
    margin-top: 18px;

    overflow: hidden;

    border: 1px solid #dce6ee;
    border-radius: 12px;
}


.ai-fax-summary > div {
    min-height: 42px;

    padding: 9px 13px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    border-bottom: 1px solid #e8eef3;
}


.ai-fax-summary > div:last-child {
    border-bottom: 0;
}


.ai-fax-summary span {
    color: #71879a;

    font-size: 10px;
}


.ai-fax-summary strong {
    color: #173651;

    font-size: 10px;
    text-align: right;
}


.ai-fax-status {
    margin-top: 15px;
    padding: 11px 13px;

    color: #805c14;
    background: #fff8e7;

    border: 1px solid #f1dba6;
    border-radius: 10px;

    font-size: 10px;
    line-height: 1.6;
}


.ai-fax-status.is-error {
    color: #a23848;
    background: #fff4f5;

    border-color: #efc8ce;
}


.ai-fax-dialog-actions {
    padding: 15px 20px 20px;

    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 10px;
}


.ai-fax-cancel,
.ai-fax-send {
    min-height: 46px;

    padding: 0 16px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    border-radius: 11px;

    font-size: 11px;
    font-weight: 900;

    cursor: pointer;
}


.ai-fax-cancel {
    color: #637a8e;
    background: #ffffff;

    border: 1px solid #d5e1ea;
}


.ai-fax-send {
    color: #ffffff;
    background: #7254d8;

    border: 1px solid #7254d8;
}


.ai-fax-send svg {
    width: 17px;
    height: 17px;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}


@media (hover: hover) and (pointer: fine) {

    .ai-fax-close:hover {
        color: #173651;
        background: #eaf0f5;
    }

    .ai-fax-cancel:hover {
        color: #173651;
        background: #f5f8fa;
    }

    .ai-fax-send:hover {
        background: #6244cc;
        border-color: #6244cc;
    }
}


@media (max-width: 650px) {

    .ai-fax-modal {
        padding: 14px;
    }

    .ai-fax-dialog {
        width: 100%;

        border-radius: 16px;
    }

    .ai-fax-dialog-head,
    .ai-fax-dialog-body {
        padding-left: 16px;
        padding-right: 16px;
    }

    .ai-fax-dialog-actions {
        padding-left: 16px;
        padding-right: 16px;
    }

    .ai-fax-field input {
        height: 50px;
        font-size: 16px;
    }
}

/* ==================================================
   RYUKTO isolated A4 print v6
   Real page count / print root only
   ================================================== */


/*
 * Never show the temporary print copy
 * on the normal screen.
 */

[data-ryukto-print-root] {
    display: none;
}


@media print {

    @page {
        size: A4 portrait;
        margin: 8mm;
    }


    html,
    body {
        margin: 0 !important;
        padding: 0 !important;

        background: #ffffff !important;

        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }


    /*
     * Critical:
     * remove every normal application child
     * from print layout.
     *
     * display:none removes its page height too,
     * unlike visibility:hidden.
     */

    body[data-ryukto-print-mode]
    > *:not([data-ryukto-print-root]) {
        display: none !important;
    }


    /*
     * Only the cloned document participates
     * in pagination.
     */

    body[data-ryukto-print-mode]
    > [data-ryukto-print-root] {
        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        margin: 0 !important;
        padding: 0 !important;

        display: block !important;

        background: #ffffff !important;
    }


    /*
     * Do not force an A4-height document.
     *
     * Short content remains one page.
     * Long content flows naturally to page 2,
     * page 3, and so on.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview {
        position: relative !important;

        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        min-height: 0 !important;
        height: auto !important;

        margin: 0 !important;

        padding:
            8mm
            6mm
            10mm !important;

        overflow: visible !important;

        box-sizing: border-box !important;

        color: #1b3551 !important;
        background: #ffffff !important;

        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;

        transform: none !important;
        zoom: 1 !important;

        font-size: 10pt !important;
    }


    /*
     * Screen decoration must not increase
     * printable bounds.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview::before,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview::after {
        max-width: 100% !important;
    }


    /*
     * Header
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-header {
        width: 100% !important;

        margin:
            0
            0
            10mm !important;

        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;

        gap: 10mm !important;

        box-sizing: border-box !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-brand {
        min-width: 26mm !important;

        padding:
            3mm
            4mm !important;

        box-sizing: border-box !important;

        font-size: 8pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-company strong {
        font-size: 10pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-company small {
        font-size: 8pt !important;
    }


    /*
     * Title
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-title {
        width: 100% !important;

        margin:
            0
            0
            9mm !important;

        text-align: center !important;

        font-size: 22pt !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;
    }


    /*
     * Recipient / metadata
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-recipient {
        width: 100% !important;

        margin: 0 !important;

        padding:
            0
            0
            3mm !important;

        box-sizing: border-box !important;

        font-size: 12pt !important;
        line-height: 1.5 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-meta {
        width: 100% !important;

        margin:
            4mm
            0
            0 !important;

        display: flex !important;
        justify-content: space-between !important;

        font-size: 9pt !important;
    }


    /*
     * Additional AI-created fields
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-template-field {
        width: 100% !important;

        margin-top: 4mm !important;

        box-sizing: border-box !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-template-field small {
        font-size: 8pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-template-field strong {
        font-size: 11pt !important;
        line-height: 1.5 !important;
    }


    /*
     * Full-width line-item table.
     *
     * The document is 194mm wide with 6mm
     * internal padding on both sides, leaving
     * approximately 182mm of real content width.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-table,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-dynamic-table {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;

        margin:
            7mm
            0
            0 !important;

        overflow: visible !important;

        box-sizing: border-box !important;
    }


    /*
     * Preserve the dynamic grid generated by
     * the renderer. Every row uses the complete
     * printable content width.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-dynamic-table
    .preview-table-head,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-dynamic-table
    .ai-dynamic-table-row {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;

        min-height: 9mm !important;

        padding:
            0
            2mm !important;

        box-sizing: border-box !important;

        align-items: center !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-dynamic-table
    .preview-table-head > span,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-dynamic-table
    .ai-dynamic-table-row > span {
        min-width: 0 !important;

        padding:
            2.3mm
            1.3mm !important;

        box-sizing: border-box !important;

        font-size: 9pt !important;
        line-height: 1.35 !important;
    }


    /*
     * Keep the table header with the following
     * content where the browser allows it.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-table-head {
        break-after: avoid;
        page-break-after: avoid;
    }


    /*
     * Tax summary / total area.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary {
        width: 48% !important;
        max-width: none !important;

        margin:
            7mm
            0
            0
            auto !important;

        box-sizing: border-box !important;

        font-size: 9pt !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary-row {
        min-height: 8mm !important;

        padding:
            1.7mm
            3mm !important;

        box-sizing: border-box !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary-row span,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary-row strong {
        font-size: 9pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary-row.total {
        min-height: 12mm !important;

        margin-top: 2mm !important;

        padding:
            2.5mm
            3mm !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-tax-summary-row.total strong {
        font-size: 16pt !important;
    }


    /*
     * Legacy total block for document types
     * that do not use ai-tax-summary.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-total {
        width: 48% !important;
        max-width: none !important;

        margin:
            7mm
            0
            0
            auto !important;

        padding:
            3mm
            4mm !important;

        box-sizing: border-box !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-total span {
        font-size: 9pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-total strong {
        font-size: 16pt !important;
    }


    /*
     * Footer participates in normal flow.
     *
     * The screen template uses absolute
     * positioning, which can artificially enlarge
     * printable bounds. Print must not.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-footer {
        position: relative !important;

        inset: auto !important;

        right: auto !important;
        bottom: auto !important;
        left: auto !important;

        width: 100% !important;

        margin:
            12mm
            0
            0 !important;

        padding-top: 3mm !important;

        box-sizing: border-box !important;

        font-size: 8pt !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    /*
     * Natural pagination.
     *
     * Do not force the complete document onto
     * one page. Only logical blocks are protected
     * from being split.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-header,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-title,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-recipient,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-meta,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-template-field {
        break-inside: avoid;
        page-break-inside: avoid;
    }


    /*
     * Remove screen-only transforms and effects.
     * Text remains native browser text in PDF
     * and printer output.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview * {
        transform: none !important;
        filter: none !important;
        text-shadow: none !important;
    }


    /*
     * Preserve template identity.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-modern {
        border-top-width: 3mm !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-classic {
        border: 1px solid #c7b99a !important;
    }

}

/* ==================================================
   RYUKTO isolated print visibility repair v1
   ================================================== */

@media print {

    /*
     * The temporary print root must always be
     * visible and participate in print layout.
     */

    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root] {
        display: block !important;
        visibility: visible !important;

        position: relative !important;

        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        height: auto !important;
        min-height: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        overflow: visible !important;
    }


    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root],
    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root] * {
        visibility: visible !important;
    }


    /*
     * The cloned document itself must also
     * explicitly participate in layout.
     */

    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root]
    > .document-preview {
        display: block !important;
        visibility: visible !important;

        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        height: auto !important;
        min-height: 0 !important;

        opacity: 1 !important;
    }
}

/* ==================================================
   RYUKTO single page bottom total v1
   ================================================== */

@media print {

    /*
     * One-page documents use the complete
     * printable A4 height.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .document-preview {
        min-height: 281mm !important;
        height: 281mm !important;

        display: flex !important;
        flex-direction: column !important;

        box-sizing: border-box !important;
    }


    /*
     * Header and document content remain in
     * normal order at the top.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-header,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-title,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-recipient,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-meta,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .ai-template-field,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-table {
        flex: 0 0 auto !important;
    }


    /*
     * Push the tax/total block toward the
     * bottom of page 1.
     *
     * As table content grows, this automatic
     * space becomes progressively smaller.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .ai-tax-summary {
        flex: 0 0 auto !important;

        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-total {
        flex: 0 0 auto !important;

        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }


    /*
     * If a footer exists, keep it below the
     * total while remaining inside page 1.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-footer {
        flex: 0 0 auto !important;

        margin-top: 8mm !important;
    }


    /*
     * Multi-page documents must not use the
     * artificial full-page flex layout.
     *
     * Their height is determined entirely by
     * content, and totals stay close to the
     * final table rows.
     */

    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-multi-page
    .document-preview {
        display: block !important;

        min-height: 0 !important;
        height: auto !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-multi-page
    .ai-tax-summary,
    body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-multi-page
    .preview-total {
        margin-top: 7mm !important;
        margin-left: auto !important;
        margin-right: 0 !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ==================================================
   RYUKTO AI preview A4 layout sync v1
   Screen only
   ================================================== */

@media screen {

    /*
     * Keep the existing preview width.
     * Only reproduce the proportions and vertical
     * composition of the final printed document.
     */

    [data-ai-preview-sheet]
    .document-preview {
        aspect-ratio: 210 / 297;

        height: auto !important;
        min-height: 0 !important;

        display: flex !important;
        flex-direction: column !important;

        box-sizing: border-box !important;
    }


    /*
     * Normal document content remains at the top.
     */

    [data-ai-preview-sheet]
    .document-preview
    .preview-header,

    [data-ai-preview-sheet]
    .document-preview
    .preview-title,

    [data-ai-preview-sheet]
    .document-preview
    .preview-recipient,

    [data-ai-preview-sheet]
    .document-preview
    .preview-meta,

    [data-ai-preview-sheet]
    .document-preview
    .ai-template-field,

    [data-ai-preview-sheet]
    .document-preview
    .preview-table {
        flex: 0 0 auto;
    }


    /*
     * For short one-page documents, the remaining
     * vertical space becomes the gap between the
     * table and the totals.
     */

    [data-ai-preview-sheet]
    .document-preview
    .ai-tax-summary {
        flex: 0 0 auto;

        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }


    [data-ai-preview-sheet]
    .document-preview
    .preview-total {
        flex: 0 0 auto;

        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }


    /*
     * Footer remains below totals if a template
     * provides one.
     */

    [data-ai-preview-sheet]
    .document-preview
    .preview-footer {
        position: relative !important;

        inset: auto !important;

        flex: 0 0 auto;

        width: 100% !important;

        margin-top: 18px !important;
    }
}


/*
 * Mobile still keeps the A4 composition.
 */

@media screen and (max-width: 650px) {

    [data-ai-preview-sheet]
    .document-preview
    .preview-footer {
        margin-top: 12px !important;
    }
}

/* ==================================================
   RYUKTO company profile modal v1
   ================================================== */

.company-profile-modal[hidden] {
    display: none !important;
}


.company-profile-modal {
    position: fixed;
    z-index: 12000;
    inset: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 28px;

    box-sizing: border-box;
}


.company-profile-backdrop {
    position: absolute;
    inset: 0;

    background:
        rgba(4, 20, 40, .72);

    backdrop-filter:
        blur(8px);
}


.company-profile-dialog {
    position: relative;
    z-index: 1;

    width: min(100%, 860px);
    max-height: calc(100vh - 56px);

    overflow: auto;

    color: #173451;
    background: #ffffff;

    border:
        1px solid
        rgba(188, 205, 220, .85);

    border-radius: 24px;

    box-shadow:
        0 32px 90px
        rgba(3, 24, 48, .28);
}


.company-profile-dialog-head {
    position: sticky;
    z-index: 3;
    top: 0;

    padding:
        28px
        32px
        24px;

    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 24px;

    background:
        rgba(255, 255, 255, .97);

    border-bottom:
        1px solid #e1e9f0;

    backdrop-filter:
        blur(12px);
}


.company-profile-dialog-head > div {
    min-width: 0;
}


.company-profile-dialog-head span {
    display: block;

    margin-bottom: 7px;

    color: #176bff;

    font-size: 11px;
    font-weight: 900;
    letter-spacing: .16em;
}


.company-profile-dialog-head h2 {
    margin: 0;

    color: #102d4f;

    font-size: 27px;
    font-weight: 900;
    line-height: 1.3;
}


.company-profile-dialog-head p {
    margin:
        8px
        0
        0;

    color: #73889d;

    font-size: 13px;
    font-weight: 650;
    line-height: 1.65;
}


.company-profile-close {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: grid;
    place-items: center;

    padding: 0;

    color: #6e8499;
    background: #f5f8fb;

    border:
        1px solid
        #dce6ee;

    border-radius: 50%;

    font-family: inherit;
    font-size: 25px;
    font-weight: 500;
    line-height: 1;

    cursor: pointer;

    transition:
        color .2s ease,
        background .2s ease,
        border-color .2s ease,
        transform .2s ease;
}


@media (hover: hover) and (pointer: fine) {

    .company-profile-close:hover {
        color: #ffffff;
        background: #176bff;
        border-color: #176bff;

        transform:
            rotate(5deg);
    }
}


.company-profile-form {
    padding:
        28px
        32px
        32px;
}


.company-profile-message {
    margin-bottom: 22px;
    padding: 13px 16px;

    color: #176bff;
    background: #eef5ff;

    border:
        1px solid
        #cbdfff;

    border-radius: 12px;

    font-size: 13px;
    font-weight: 750;
    line-height: 1.55;
}


.company-profile-message.is-error {
    color: #b54756;
    background: #fff5f6;
    border-color: #efc6cc;
}


/* Logo */

.company-profile-logo-area {
    padding: 22px;

    display: flex;
    align-items: center;

    gap: 22px;

    background:
        linear-gradient(
            135deg,
            #f6faff,
            #eef5fb
        );

    border:
        1px solid
        #dce7f0;

    border-radius: 18px;
}


.company-profile-logo-preview {
    width: 132px;
    height: 88px;

    flex: 0 0 132px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    color: #176bff;
    background: #ffffff;

    border:
        1px dashed
        #afc6db;

    border-radius: 13px;

    font-size: 11px;
    font-weight: 900;
    letter-spacing: .12em;
}


.company-profile-logo-preview img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;

    padding: 8px;

    box-sizing: border-box;
}


.company-profile-logo-copy {
    min-width: 0;
}


.company-profile-logo-copy strong {
    display: block;

    color: #173451;

    font-size: 15px;
    font-weight: 900;
}


.company-profile-logo-copy p {
    margin:
        5px
        0
        12px;

    color: #7a8fa3;

    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
}


.company-profile-logo-button {
    min-height: 38px;

    padding:
        0
        16px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    color: #176bff;
    background: #ffffff;

    border:
        1px solid
        #bdd3ee;

    border-radius: 10px;

    font-size: 12px;
    font-weight: 850;

    cursor: pointer;

    transition:
        color .2s ease,
        background .2s ease,
        border-color .2s ease,
        transform .2s ease;
}


@media (hover: hover) and (pointer: fine) {

    .company-profile-logo-button:hover {
        color: #ffffff;
        background: #176bff;
        border-color: #176bff;

        transform:
            translateY(-2px);
    }
}


/* Sections */

.company-profile-section {
    margin-top: 28px;
}


.company-profile-section-head {
    margin-bottom: 15px;

    display: flex;
    align-items: baseline;

    gap: 10px;
}


.company-profile-section-head span {
    color: #176bff;

    font-size: 10px;
    font-weight: 900;
    letter-spacing: .14em;
}


.company-profile-section-head strong {
    color: #173451;

    font-size: 17px;
    font-weight: 900;
}


.company-profile-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 15px;
}


.company-profile-field {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 7px;
}


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


.company-profile-field > span {
    color: #5f768c;

    font-size: 12px;
    font-weight: 800;
}


.company-profile-field input {
    width: 100%;
    min-width: 0;
    min-height: 46px;

    padding:
        0
        13px;

    box-sizing: border-box;

    color: #173451;
    background: #fbfdff;

    border:
        1px solid
        #d5e1eb;

    border-radius: 11px;

    outline: 0;

    font-family: inherit;
    font-size: 14px;
    font-weight: 650;

    transition:
        border-color .2s ease,
        background .2s ease,
        box-shadow .2s ease;
}


.company-profile-field input:focus {
    background: #ffffff;

    border-color: #176bff;

    box-shadow:
        0 0 0 3px
        rgba(23, 107, 255, .10);
}


/* Actions */

.company-profile-actions {
    position: sticky;
    z-index: 2;
    bottom: -32px;

    margin:
        30px
        -32px
        -32px;

    padding:
        18px
        32px;

    display: flex;
    align-items: center;
    justify-content: flex-end;

    gap: 11px;

    background:
        rgba(255, 255, 255, .97);

    border-top:
        1px solid
        #e1e9f0;

    backdrop-filter:
        blur(12px);
}


.company-profile-cancel,
.company-profile-save {
    min-width: 112px;
    min-height: 44px;

    padding:
        0
        18px;

    border-radius: 11px;

    font-family: inherit;
    font-size: 13px;
    font-weight: 900;

    cursor: pointer;

    transition:
        transform .2s ease,
        background .2s ease,
        color .2s ease,
        border-color .2s ease,
        box-shadow .2s ease;
}


.company-profile-cancel {
    color: #667e94;
    background: #ffffff;

    border:
        1px solid
        #d5e1eb;
}


.company-profile-save {
    color: #ffffff;
    background: #176bff;

    border:
        1px solid
        #176bff;

    box-shadow:
        0 10px 24px
        rgba(23, 107, 255, .20);
}


.company-profile-save:disabled {
    opacity: .55;

    cursor: wait;

    transform: none !important;
}


@media (hover: hover) and (pointer: fine) {

    .company-profile-cancel:hover {
        color: #173451;
        background: #f5f8fb;

        transform:
            translateY(-2px);
    }


    .company-profile-save:hover:not(:disabled) {
        background: #075ce8;
        border-color: #075ce8;

        transform:
            translateY(-2px);

        box-shadow:
            0 14px 30px
            rgba(23, 107, 255, .25);
    }
}


/* Lock page while modal is open */

body.is-company-profile-open {
    overflow: hidden;
}


/* Responsive */

@media (max-width: 700px) {

    .company-profile-modal {
        padding: 12px;
    }


    .company-profile-dialog {
        max-height:
            calc(100vh - 24px);

        border-radius: 18px;
    }


    .company-profile-dialog-head {
        padding:
            22px
            20px
            19px;
    }


    .company-profile-dialog-head h2 {
        font-size: 23px;
    }


    .company-profile-form {
        padding:
            20px
            20px
            24px;
    }


    .company-profile-logo-area {
        align-items: flex-start;
        flex-direction: column;

        padding: 18px;
    }


    .company-profile-logo-preview {
        width: 118px;
        height: 78px;

        flex-basis: 78px;
    }


    .company-profile-grid {
        grid-template-columns: 1fr;
    }


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


    .company-profile-actions {
        bottom: -24px;

        margin:
            26px
            -20px
            -24px;

        padding:
            15px
            20px;
    }


    .company-profile-cancel,
    .company-profile-save {
        flex: 1 1 0;

        min-width: 0;
    }
}

/* ==================================================
   RYUKTO company save confirmation v1
   ================================================== */

.company-profile-action-status {
    margin-right: auto;

    padding:
        9px
        13px;

    color: #176bff;
    background: #eef5ff;

    border:
        1px solid
        #cbdfff;

    border-radius: 10px;

    font-size: 13px;
    font-weight: 900;
    line-height: 1.3;
}


.company-profile-action-status[hidden] {
    display: none !important;
}


.company-profile-action-status.is-success {
    color: #16764a;
    background: #effaf5;
    border-color: #b9e5ce;
}


.company-profile-action-status.is-error {
    color: #b54756;
    background: #fff5f6;
    border-color: #efc6cc;
}


@media (max-width: 700px) {

    .company-profile-actions {
        flex-wrap: wrap;
    }


    .company-profile-action-status {
        width: 100%;

        margin:
            0
            0
            5px;

        box-sizing: border-box;

        text-align: center;
    }
}

/* ==================================================
   RYUKTO external document header v1
   Common layout for outgoing documents
   ================================================== */


/*
 * Document title
 */

.ai-preview-sheet
.document-preview
.preview-title {
    width: 100%;

    margin:
        0
        0
        28px;

    text-align: center;

    box-sizing: border-box;
}


/*
 * Recipient and sender share one row.
 */

.ai-preview-sheet
.preview-parties {
    width: 100%;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(190px, .82fr);

    align-items: start;

    gap: 32px;

    margin:
        0
        0
        24px;

    box-sizing: border-box;
}


/*
 * Recipient
 */

.ai-preview-sheet
.preview-recipient-block {
    min-width: 0;

    padding-top: 8px;
}


.ai-preview-sheet
.preview-party-label {
    display: block;

    margin-bottom: 9px;

    color: #8092a4;

    font-size: 10px;
    font-weight: 850;
    letter-spacing: .12em;
}


.ai-preview-sheet
.preview-recipient-block
.preview-recipient {
    width: 100%;

    margin: 0;
    padding:
        0
        0
        11px;

    box-sizing: border-box;

    color: #173451;

    border-bottom:
        2px solid
        #cfdbe5;

    font-size: 16px;
    font-weight: 850;
    line-height: 1.5;
}


/*
 * Sender company identity
 */

.ai-preview-sheet
.preview-sender {
    min-width: 0;

    display: grid;

    grid-template-columns:
        82px
        minmax(0, 1fr);

    align-items: start;

    gap: 13px;
}


.ai-preview-sheet
.preview-sender-logo {
    width: 82px;
    height: 58px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    box-sizing: border-box;

    color: #176bff;
    background: #ffffff;

    border:
        1px solid
        #d7e2eb;

    border-radius: 8px;

    font-size: 9px;
    font-weight: 900;
    letter-spacing: .1em;
}


.ai-preview-sheet
.preview-sender-logo img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;

    padding: 5px;

    box-sizing: border-box;
}


.ai-preview-sheet
.preview-sender-details {
    min-width: 0;

    display: flex;
    flex-direction: column;

    gap: 3px;

    color: #60758a;

    font-size: 10px;
    font-weight: 650;
    line-height: 1.45;

    overflow-wrap: anywhere;
}


.ai-preview-sheet
.preview-sender-company {
    display: block;

    margin-bottom: 3px;

    color: #173451;

    font-size: 13px;
    font-weight: 900;
    line-height: 1.4;
}


/*
 * Document metadata starts below both parties.
 */

.ai-preview-sheet
.preview-parties
+ .preview-meta {
    width: 100%;

    margin-top: 0;
}


/*
 * Smaller preview widths
 */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns: 1fr;

        gap: 20px;
    }


    .ai-preview-sheet
    .preview-sender {
        grid-template-columns:
            72px
            minmax(0, 1fr);
    }


    .ai-preview-sheet
    .preview-sender-logo {
        width: 72px;
        height: 52px;
    }
}


/*
 * Actual A4 print / PDF.
 */

@media print {

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-title {
        width: 100% !important;

        margin:
            0
            0
            10mm !important;

        text-align: center !important;

        font-size: 22pt !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties {
        width: 100% !important;

        display: grid !important;

        grid-template-columns:
            minmax(0, 1fr)
            72mm !important;

        align-items: start !important;

        gap: 12mm !important;

        margin:
            0
            0
            8mm !important;

        box-sizing: border-box !important;

        break-inside: avoid;
        page-break-inside: avoid;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-recipient-block {
        min-width: 0 !important;

        padding-top: 3mm !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-party-label {
        display: block !important;

        margin-bottom: 2.5mm !important;

        font-size: 8pt !important;
        font-weight: 850 !important;
        letter-spacing: .08em !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-recipient-block
    .preview-recipient {
        width: 100% !important;

        margin: 0 !important;

        padding:
            0
            0
            3mm !important;

        box-sizing: border-box !important;

        font-size: 12pt !important;
        font-weight: 850 !important;
        line-height: 1.5 !important;

        border-bottom-width:
            1.5pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender {
        min-width: 0 !important;

        display: grid !important;

        grid-template-columns:
            24mm
            minmax(0, 1fr) !important;

        align-items: start !important;

        gap: 4mm !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo {
        width: 24mm !important;
        height: 17mm !important;

        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        overflow: hidden !important;

        box-sizing: border-box !important;

        border:
            1px solid
            #d7e2eb !important;

        border-radius:
            2mm !important;

        font-size: 7pt !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo img {
        width: 100% !important;
        height: 100% !important;

        display: block !important;

        object-fit: contain !important;

        padding: 1.5mm !important;

        box-sizing: border-box !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details {
        min-width: 0 !important;

        display: flex !important;
        flex-direction: column !important;

        gap: .8mm !important;

        font-size: 8pt !important;
        font-weight: 650 !important;
        line-height: 1.4 !important;

        overflow-wrap: anywhere !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-company {
        margin-bottom:
            1mm !important;

        font-size: 10pt !important;
        font-weight: 900 !important;
        line-height: 1.4 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties
    + .preview-meta {
        margin-top: 0 !important;
    }
}

/* ==================================================
   RYUKTO sender identity refinement v1
   ================================================== */

@media screen {

    /*
     * Give the sender side more horizontal room.
     */

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns:
            minmax(0, .88fr)
            minmax(230px, 1.12fr);

        gap: 26px;
    }


    /*
     * Sender becomes one vertical identity block:
     *
     * logo
     * company name
     * address
     * phone
     * contact
     */

    .ai-preview-sheet
    .preview-sender {
        display: flex;

        flex-direction: column;
        align-items: flex-start;

        gap: 5px;

        min-width: 0;
    }


    /*
     * Pure logo only.
     * No card, border, background or padding.
     */

    .ai-preview-sheet
    .preview-sender-logo {
        width: 118px;
        height: 48px;

        display: flex;
        align-items: flex-end;
        justify-content: flex-start;

        margin:
            0
            0
            4px;

        padding: 0;

        overflow: visible;

        color: #176bff;
        background: transparent;

        border: 0;
        border-radius: 0;

        box-shadow: none;
    }


    .ai-preview-sheet
    .preview-sender-logo img {
        width: auto;
        max-width: 118px;

        height: auto;
        max-height: 48px;

        display: block;

        object-fit: contain;
        object-position: left bottom;

        padding: 0;

        border: 0;
        border-radius: 0;

        background: transparent;

        box-shadow: none;
    }


    .ai-preview-sheet
    .preview-sender-details {
        width: 100%;
        min-width: 0;

        gap: 3px;

        font-size: 10px;
        line-height: 1.5;
    }


    .ai-preview-sheet
    .preview-sender-details > span {
        width: 100%;

        overflow-wrap: normal;
        word-break: normal;
    }


    .ai-preview-sheet
    .preview-sender-company {
        width: 100%;

        margin:
            0
            0
            4px;

        font-size: 14px;
        line-height: 1.4;
    }
}


/*
 * Print / PDF uses the same composition.
 */

@media print {

    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties {
        grid-template-columns:
            minmax(0, 1fr)
            82mm !important;

        gap: 10mm !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender {
        display: flex !important;

        flex-direction: column !important;
        align-items: flex-start !important;

        gap: 1.2mm !important;

        min-width: 0 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo {
        width: 34mm !important;
        height: 14mm !important;

        display: flex !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;

        margin:
            0
            0
            1.5mm !important;

        padding: 0 !important;

        overflow: visible !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo img {
        width: auto !important;
        max-width: 34mm !important;

        height: auto !important;
        max-height: 14mm !important;

        display: block !important;

        object-fit: contain !important;
        object-position: left bottom !important;

        padding: 0 !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details {
        width: 100% !important;
        min-width: 0 !important;

        gap: .8mm !important;

        font-size: 8.5pt !important;
        line-height: 1.45 !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details
    > span {
        width: 100% !important;

        overflow-wrap: normal !important;
        word-break: normal !important;
    }


    body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-company {
        width: 100% !important;

        margin:
            0
            0
            1mm !important;

        font-size: 10.5pt !important;
        line-height: 1.4 !important;
    }
}


/*
 * Narrow screen fallback.
 */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns: 1fr;

        gap: 20px;
    }


    .ai-preview-sheet
    .preview-sender-logo {
        width: 108px;
        height: 44px;
    }


    .ai-preview-sheet
    .preview-sender-logo img {
        max-width: 108px;
        max-height: 44px;
    }
}

/* ==================================================
   RYUKTO unified external A4 v1
   Screen + print share one visual composition
   ================================================== */


/* --------------------------------------------------
   SCREEN
   -------------------------------------------------- */

@media screen {

    /*
     * Keep the preview responsive while preserving
     * the A4 page ratio.
     */

    .ai-preview-sheet
    .document-preview {
        width: 100% !important;
        max-width: none !important;

        aspect-ratio: 210 / 297 !important;

        height: auto !important;
        min-height: 0 !important;

        box-sizing: border-box !important;

        padding:
            7.5%
            8.5%
            7% !important;
    }


    /*
     * Remove decorative template artwork that does
     * not belong to the business document itself.
     */

    .ai-preview-sheet
    .document-preview::before,
    .ai-preview-sheet
    .document-preview::after {
        display: none !important;

        content: none !important;

        background: none !important;
        box-shadow: none !important;
    }


    /*
     * Title.
     */

    .ai-preview-sheet
    .preview-title {
        margin:
            0
            0
            24px !important;

        text-align: center !important;
    }


    /*
     * Recipient / sender.
     *
     * Sender gets more room and is aligned against
     * the right page margin.
     */

    .ai-preview-sheet
    .preview-parties {
        width: 100% !important;

        display: grid !important;

        grid-template-columns:
            minmax(0, 1fr)
            minmax(245px, .95fr) !important;

        align-items: start !important;

        gap: 34px !important;

        margin:
            0
            0
            13px !important;

        box-sizing: border-box !important;
    }


    .ai-preview-sheet
    .preview-recipient-block {
        padding-top: 6px !important;
    }


    .ai-preview-sheet
    .preview-sender {
        width: 100% !important;
        min-width: 0 !important;

        justify-self: end !important;

        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;

        gap: 0 !important;
    }


    /*
     * Pure logo above company name.
     */

    .ai-preview-sheet
    .preview-sender-logo {
        width: 112px !important;
        height: 42px !important;

        margin:
            0
            0
            2px !important;

        padding: 0 !important;

        display: flex !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;

        overflow: visible !important;
    }


    .ai-preview-sheet
    .preview-sender-logo img {
        width: auto !important;
        max-width: 112px !important;

        height: auto !important;
        max-height: 42px !important;

        padding: 0 !important;

        object-fit: contain !important;
        object-position: left bottom !important;

        background: transparent !important;

        border: 0 !important;
        box-shadow: none !important;
    }


    /*
     * Compact company information.
     */

    .ai-preview-sheet
    .preview-sender-details {
        width: 100% !important;

        gap: 0 !important;

        font-size: 8.5px !important;
        font-weight: 650 !important;
        line-height: 1.28 !important;

        overflow-wrap: normal !important;
        word-break: normal !important;
    }


    .ai-preview-sheet
    .preview-sender-details > span {
        margin: 0 !important;
        padding: 0 !important;

        line-height: 1.28 !important;

        overflow-wrap: normal !important;
        word-break: normal !important;
    }


    .ai-preview-sheet
    .preview-sender-company {
        margin:
            0
            0
            2px !important;

        font-size: 10.5px !important;
        font-weight: 900 !important;
        line-height: 1.25 !important;
    }


    /*
     * Document number on the left and issue date
     * against the right page margin.
     */

    .ai-preview-sheet
    .preview-meta {
        width: 100% !important;

        display: flex !important;
        align-items: center !important;

        margin:
            0
            0
            8px !important;

        padding: 0 !important;

        box-sizing: border-box !important;
    }


    .ai-preview-sheet
    .preview-document-number {
        margin-right: auto !important;
    }


    .ai-preview-sheet
    .preview-issue-date {
        margin-left: auto !important;

        text-align: right !important;

        white-space: nowrap !important;

        font-size: 9px !important;
        line-height: 1.3 !important;
    }


    /*
     * Fields such as delivery date/location should
     * begin immediately below the issue date.
     */

    .ai-preview-sheet
    .preview-meta
    + .ai-template-field {
        margin-top: 0 !important;
    }


    .ai-preview-sheet
    .ai-template-field {
        margin-top: 6px !important;
        margin-bottom: 0 !important;

        min-height: 0 !important;

        padding:
            8px
            11px !important;
    }


    .ai-preview-sheet
    .ai-template-field small,
    .ai-preview-sheet
    .ai-template-field strong {
        line-height: 1.3 !important;
    }


    /*
     * Reduce the gap before the line-item table.
     */

    .ai-preview-sheet
    .preview-table {
        margin-top: 18px !important;
    }


    /*
     * One-page screen preview follows the same
     * vertical composition as print.
     *
     * Totals use the remaining page space rather
     * than overflowing below the visible page.
     */

    .ai-preview-sheet
    .document-preview {
        display: flex !important;
        flex-direction: column !important;
    }


    .ai-preview-sheet
    .preview-title,
    .ai-preview-sheet
    .preview-parties,
    .ai-preview-sheet
    .preview-meta,
    .ai-preview-sheet
    .ai-template-field,
    .ai-preview-sheet
    .preview-table {
        flex:
            0
            0
            auto !important;
    }


    .ai-preview-sheet
    .ai-tax-summary,
    .ai-preview-sheet
    .preview-total {
        flex:
            0
            0
            auto !important;

        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }


    .ai-preview-sheet
    .preview-footer {
        flex:
            0
            0
            auto !important;

        margin-top: 12px !important;
    }
}


/* --------------------------------------------------
   PRINT / PDF
   -------------------------------------------------- */

@media print {

    /*
     * A4 portrait.
     */

    @page {
        size: A4 portrait;
        margin: 8mm;
    }


    /*
     * 210mm - 16mm page margins = 194mm.
     * Every external document uses the complete
     * printable width.
     */

    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root] {
        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        margin: 0 !important;
        padding: 0 !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root]
    > .document-preview {
        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        margin: 0 !important;

        padding:
            12mm
            10mm
            8mm !important;

        box-sizing: border-box !important;

        transform: none !important;
        zoom: 1 !important;
    }


    /*
     * Remove all template decorative artwork.
     * This also removes the blue gradient visible
     * in the upper-right print preview.
     */

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview::before,

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview::after {
        display: none !important;

        content: none !important;

        background: none !important;
        background-image: none !important;

        box-shadow: none !important;

        opacity: 0 !important;
    }


    /*
     * Title.
     */

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-title {
        margin:
            0
            0
            8mm !important;

        text-align: center !important;
    }


    /*
     * Recipient / sender with symmetric outer
     * page margins.
     */

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties {
        width: 100% !important;

        grid-template-columns:
            minmax(0, 1fr)
            78mm !important;

        gap: 12mm !important;

        margin:
            0
            0
            4mm !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender {
        width: 78mm !important;

        justify-self: end !important;

        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;

        gap: 0 !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo {
        width: 31mm !important;
        height: 11mm !important;

        margin:
            0
            0
            .8mm !important;

        padding: 0 !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;

        overflow: visible !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-logo img {
        width: auto !important;
        max-width: 31mm !important;

        height: auto !important;
        max-height: 11mm !important;

        padding: 0 !important;

        object-fit: contain !important;
        object-position: left bottom !important;

        border: 0 !important;
        box-shadow: none !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details {
        width: 100% !important;

        gap: 0 !important;

        font-size: 7.3pt !important;
        font-weight: 650 !important;
        line-height: 1.2 !important;

        overflow-wrap: normal !important;
        word-break: normal !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details
    > span {
        margin: 0 !important;
        padding: 0 !important;

        line-height: 1.2 !important;

        overflow-wrap: normal !important;
        word-break: normal !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-company {
        margin:
            0
            0
            .7mm !important;

        font-size: 9pt !important;
        line-height: 1.2 !important;
    }


    /*
     * Issue date.
     */

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-meta {
        width: 100% !important;

        display: flex !important;
        align-items: center !important;

        margin:
            0
            0
            2mm !important;

        padding: 0 !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-document-number {
        margin-right: auto !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-issue-date {
        margin-left: auto !important;

        text-align: right !important;

        white-space: nowrap !important;

        font-size: 8pt !important;
        line-height: 1.25 !important;
    }


    /*
     * Compact delivery date/location fields.
     */

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-meta
    + .ai-template-field {
        margin-top: 0 !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .ai-template-field {
        margin-top: 1.5mm !important;
        margin-bottom: 0 !important;

        min-height: 0 !important;

        padding:
            2.5mm
            3mm !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-table {
        width: 100% !important;

        margin-top: 5mm !important;

        box-sizing: border-box !important;
    }


    /*
     * Keep the established single-page total
     * behavior.
     */

    /* RYUKTO_PRINT_SINGLE_PAGE_HEIGHT_SAFE_V1
       Keep one-page documents inside printable A4 height.
       Preserve natural overflow for longer content.
    */
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .document-preview {
        min-height: 279mm !important;
        height: auto !important;

        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .ai-tax-summary,

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root].is-single-page
    .preview-total {
        margin-top: auto !important;
        margin-left: auto !important;
        margin-right: 0 !important;
    }
}


/* --------------------------------------------------
   NARROW SCREEN
   -------------------------------------------------- */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .document-preview {
        padding:
            7%
            7%
            6% !important;
    }


    .ai-preview-sheet
    .preview-parties {
        grid-template-columns:
            1fr !important;

        gap: 16px !important;
    }


    .ai-preview-sheet
    .preview-sender {
        width: 100% !important;
    }
}

/* ==================================================
   RYUKTO sender right alignment v1
   ================================================== */


/* --------------------------------------------------
   SCREEN
   -------------------------------------------------- */

@media screen {

    /*
     * The two party columns span the complete
     * document content width.
     */

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 1fr) !important;

        column-gap: 44px !important;
    }


    /*
     * Recipient remains attached to the left edge.
     */

    .ai-preview-sheet
    .preview-recipient-block {
        width: 100% !important;

        justify-self: start !important;
    }


    /*
     * Sender is a compact block attached to the
     * right edge instead of filling its grid cell.
     */

    .ai-preview-sheet
    .preview-sender {
        width: 185px !important;
        max-width: 100% !important;

        justify-self: end !important;

        margin-left: auto !important;
        margin-right: 0 !important;

        align-items: flex-start !important;
    }


    .ai-preview-sheet
    .preview-sender-details {
        width: 185px !important;
        max-width: 100% !important;
    }
}


/* --------------------------------------------------
   PRINT / PDF
   -------------------------------------------------- */

@media print {

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 1fr) !important;

        column-gap: 12mm !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-recipient-block {
        width: 100% !important;

        justify-self: start !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender {
        width: 58mm !important;
        max-width: 100% !important;

        justify-self: end !important;

        margin-left: auto !important;
        margin-right: 0 !important;

        align-items: flex-start !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details {
        width: 58mm !important;
        max-width: 100% !important;
    }
}


/* --------------------------------------------------
   NARROW SCREEN
   -------------------------------------------------- */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns:
            1fr !important;
    }


    .ai-preview-sheet
    .preview-sender {
        width: 100% !important;

        justify-self: start !important;

        margin-left: 0 !important;
    }


    .ai-preview-sheet
    .preview-sender-details {
        width: 100% !important;
    }
}

/* ==================================================
   RYUKTO sender flush right v1
   ================================================== */


/* --------------------------------------------------
   SCREEN
   -------------------------------------------------- */

@media screen {

    /*
     * Use the complete available content width.
     */

    .ai-preview-sheet
    .preview-parties {
        width: 100% !important;

        grid-template-columns:
            minmax(0, 1fr)
            185px !important;

        column-gap: 32px !important;

        box-sizing: border-box !important;
    }


    /*
     * Sender occupies the fixed right column and
     * touches its right edge.
     */

    .ai-preview-sheet
    .preview-sender {
        width: 185px !important;
        max-width: 185px !important;

        grid-column: 2 !important;

        justify-self: stretch !important;

        margin:
            0
            0
            0
            auto !important;

        transform:
            translateX(0) !important;
    }


    .ai-preview-sheet
    .preview-sender-details {
        width: 185px !important;
        max-width: 185px !important;
    }
}


/* --------------------------------------------------
   PRINT / PDF
   -------------------------------------------------- */

@media print {

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-parties {
        width: 100% !important;

        grid-template-columns:
            minmax(0, 1fr)
            58mm !important;

        column-gap: 10mm !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender {
        width: 58mm !important;
        max-width: 58mm !important;

        grid-column: 2 !important;

        justify-self: stretch !important;

        margin:
            0
            0
            0
            auto !important;

        transform:
            translateX(0) !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .preview-sender-details {
        width: 58mm !important;
        max-width: 58mm !important;
    }
}


/* --------------------------------------------------
   NARROW SCREEN
   -------------------------------------------------- */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .preview-parties {
        grid-template-columns:
            1fr !important;
    }


    .ai-preview-sheet
    .preview-sender {
        width: 100% !important;
        max-width: 100% !important;

        grid-column: 1 !important;

        margin-left: 0 !important;
    }


    .ai-preview-sheet
    .preview-sender-details {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ==================================================
   RYUKTO internal business layout v1
   ================================================== */


/* --------------------------------------------------
   SCREEN
   -------------------------------------------------- */

@media screen {

    /*
     * Internal documents use the same A4 page
     * geometry as the established document preview.
     */

    .ai-preview-sheet
    .layout-family-internal_business {
        width: 100% !important;
        max-width: none !important;

        aspect-ratio: 210 / 297 !important;

        height: auto !important;
        min-height: 0 !important;

        display: flex !important;
        flex-direction: column !important;

        box-sizing: border-box !important;

        padding:
            7.5%
            8.5%
            7% !important;
    }


    /*
     * Internal document title.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .preview-title {
        width: 100% !important;

        margin:
            0
            0
            22px !important;

        text-align: center !important;

        font-size: 22px !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;

        letter-spacing: .08em !important;
    }


    /*
     * Company identity.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .internal-document-header {
        width: 100% !important;

        display: flex !important;
        align-items: flex-end !important;
        justify-content: space-between !important;

        gap: 24px !important;

        margin:
            0
            0
            18px !important;

        padding:
            0
            0
            12px !important;

        box-sizing: border-box !important;

        border-bottom:
            1px solid
            #d8e2eb !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-identity {
        min-width: 0 !important;

        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;

        gap: 3px !important;
    }


    /*
     * Pure logo.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-logo {
        width: 110px !important;
        height: 40px !important;

        display: flex !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;

        margin:
            0
            0
            2px !important;

        padding: 0 !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;

        overflow: visible !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-logo img {
        width: auto !important;
        max-width: 110px !important;

        height: auto !important;
        max-height: 40px !important;

        display: block !important;

        padding: 0 !important;

        object-fit: contain !important;
        object-position: left bottom !important;

        background: transparent !important;

        border: 0 !important;
        box-shadow: none !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-name {
        color: #173451 !important;

        font-size: 11px !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;
    }


    /*
     * Department / contact / telephone / extension.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-contact {
        max-width: 54% !important;

        display: flex !important;
        flex-wrap: wrap !important;

        align-items: center !important;
        justify-content: flex-end !important;

        column-gap: 14px !important;
        row-gap: 3px !important;

        color: #60758a !important;

        font-size: 9px !important;
        font-weight: 650 !important;
        line-height: 1.3 !important;

        text-align: right !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-contact > span {
        white-space: nowrap !important;
    }


    /*
     * Internal documents do not use the external
     * recipient/sender party presentation.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .preview-parties {
        display: none !important;
    }


    /*
     * Keep metadata and actual document fields
     * compact so the page is useful for office work.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .preview-meta {
        width: 100% !important;

        margin:
            0
            0
            8px !important;

        padding: 0 !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .ai-template-field {
        margin:
            6px
            0
            0 !important;

        min-height: 0 !important;

        padding:
            9px
            11px !important;

        box-sizing: border-box !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .ai-template-field small,
    .ai-preview-sheet
    .layout-family-internal_business
    .ai-template-field strong {
        line-height: 1.35 !important;
    }


    /*
     * Internal tables such as expense details use
     * the complete content width.
     */

    .ai-preview-sheet
    .layout-family-internal_business
    .preview-table {
        width: 100% !important;

        margin-top: 16px !important;

        box-sizing: border-box !important;
    }


    /*
     * Remove decorative template artwork.
     */

    .ai-preview-sheet
    .layout-family-internal_business::before,
    .ai-preview-sheet
    .layout-family-internal_business::after {
        display: none !important;

        content: none !important;

        background: none !important;
        background-image: none !important;

        box-shadow: none !important;
    }
}


/* --------------------------------------------------
   PRINT / PDF
   -------------------------------------------------- */

@media print {

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business {
        width: 194mm !important;
        min-width: 194mm !important;
        max-width: 194mm !important;

        margin: 0 !important;

        padding:
            12mm
            10mm
            8mm !important;

        box-sizing: border-box !important;

        transform: none !important;
        zoom: 1 !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .preview-title {
        width: 100% !important;

        margin:
            0
            0
            8mm !important;

        text-align: center !important;

        font-size: 20pt !important;
        font-weight: 900 !important;
        line-height: 1.3 !important;

        letter-spacing: .08em !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-document-header {
        width: 100% !important;

        display: flex !important;
        align-items: flex-end !important;
        justify-content: space-between !important;

        gap: 8mm !important;

        margin:
            0
            0
            5mm !important;

        padding:
            0
            0
            3mm !important;

        box-sizing: border-box !important;

        border-bottom:
            .5pt solid
            #d8e2eb !important;

        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-identity {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;

        gap: .8mm !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-logo {
        width: 31mm !important;
        height: 11mm !important;

        margin:
            0
            0
            .8mm !important;

        padding: 0 !important;

        background: transparent !important;

        border: 0 !important;
        border-radius: 0 !important;

        box-shadow: none !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-logo img {
        width: auto !important;
        max-width: 31mm !important;

        height: auto !important;
        max-height: 11mm !important;

        padding: 0 !important;

        object-fit: contain !important;
        object-position: left bottom !important;

        border: 0 !important;
        box-shadow: none !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-name {
        font-size: 9pt !important;
        font-weight: 900 !important;
        line-height: 1.25 !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-contact {
        max-width: 105mm !important;

        display: flex !important;
        flex-wrap: wrap !important;

        justify-content: flex-end !important;

        column-gap: 4mm !important;
        row-gap: 1mm !important;

        font-size: 7.5pt !important;
        font-weight: 650 !important;
        line-height: 1.25 !important;

        text-align: right !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .internal-company-contact
    > span {
        white-space: nowrap !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .preview-parties {
        display: none !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .ai-template-field {
        margin:
            1.5mm
            0
            0 !important;

        min-height: 0 !important;

        padding:
            2.5mm
            3mm !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business
    .preview-table {
        width: 100% !important;

        margin-top: 5mm !important;

        box-sizing: border-box !important;
    }


    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business::before,

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .layout-family-internal_business::after {
        display: none !important;

        content: none !important;

        background: none !important;
        background-image: none !important;

        box-shadow: none !important;
    }
}


/* --------------------------------------------------
   NARROW SCREEN
   -------------------------------------------------- */

@media screen and (max-width: 760px) {

    .ai-preview-sheet
    .layout-family-internal_business
    .internal-document-header {
        align-items: flex-start !important;
        flex-direction: column !important;

        gap: 12px !important;
    }


    .ai-preview-sheet
    .layout-family-internal_business
    .internal-company-contact {
        max-width: 100% !important;

        justify-content: flex-start !important;

        text-align: left !important;
    }
}


/* RYUKTO_AI_CREDIT_BALANCE_J82C */
.ai-credit-balance {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.ai-credit-balance a {
    color: #4f46e5;
    text-decoration: underline;
}

@media screen and (max-width: 760px) {
    .ai-credit-balance {
        font-size: 9px;
    }
}


/* RYUKTO_J86C_AI_NOTICE_SPACING */

.ai-chat-notice:not([hidden]) {
    margin-top: 8px;
    margin-bottom: 12px;
}

.ai-chat-notice[hidden] {
    display: none !important;
}

/* ================================================
   RYUKTO_J166E_FULL_PREVIEW
   Screen preview only
   Preserve original print CSS
   ================================================ */

@media screen {

    .ai-document-live-preview {
        min-height: 0;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .ai-preview-sheet {
        min-height: 520px;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .ai-preview-sheet .document-preview {
        height: auto;
        min-height: 0;
        max-height: none;
        overflow: visible;
    }

    .ai-preview-sheet .document-preview
    .preview-content {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .ai-preview-sheet .document-preview
    .preview-fields {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .ai-preview-sheet .document-preview
    .preview-footer {
        position: relative;
        bottom: auto;
    }

}



/* RYUKTO_WORK_INSTRUCTION_FOOTER_FIX_V1
   Work instruction only.
   Preserve footer text and existing pagination.
*/
@media print {
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-work_instruction
    .preview-footer {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        break-inside: avoid !important;
    }
}


/* RYUKTO_SPECIFICATION_SPACING_FIX_V1
   Specification only. Preserve text and footer.
*/
@media print {
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-specification
    .ai-template-field {
        margin-top: 1mm !important;
        margin-bottom: 0 !important;
        padding: 2mm 3mm !important;
    }

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-specification
    .preview-footer {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        break-inside: avoid !important;
    }
}


/* RYUKTO_INSPECTION_PAGINATION_FIX_V1
   Inspection report only.
   Preserve all table rows and footer text.
*/
@media print {
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-inspection_report
    .ai-template-field {
        margin-top: 1mm !important;
        margin-bottom: 0 !important;
        padding: 2mm 3mm !important;
    }

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-inspection_report
    .preview-footer {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        break-inside: avoid !important;
    }

    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root]
    > .document-preview.document-type-inspection_report {
        padding-bottom: 7mm !important;
    }
}


/* RYUKTO_EXAMINATION_PAGINATION_FIX_V1
   Examination report only.
   Keep the complete examination table together.
*/
@media print {
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-examination_report
    .ai-template-field {
        margin-top: 1mm !important;
        margin-bottom: 0 !important;
        padding: 2mm 3mm !important;
    }

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-examination_report
    .preview-footer {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        break-inside: avoid !important;
    }

    html body[data-ryukto-print-mode]
    > [data-ryukto-print-root]
    > .document-preview.document-type-examination_report {
        padding-bottom: 7mm !important;
    }

    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-type-examination_report
    .preview-table {
        break-before: page !important;
        page-break-before: always !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}


/* RYUKTO_ESTIMATE_FOOTER_FIX_V1
   Estimate only. Preserve totals and footer text.
*/
@media print {
    html body[data-ryukto-print-mode]
    [data-ryukto-print-root]
    .document-preview.document-type-estimate
    .preview-footer {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
}


/* RYUKTO_ESTIMATE_SCREEN_FOOTER_FIX_V1
   Estimate A4 screen preview only.
*/
@media screen {
    .ryukto-a4-pages
    .document-type-estimate
    .preview-footer {
        position: static !important;
        inset: auto !important;
        margin-top: 12px !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
}
