﻿:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --panel-soft: #edf4fb;
    --text: #19344d;
    --muted: #6b7f92;
    --border: #d6e1ec;
    --primary: #0b4a8b;
    --primary-strong: #093868;
    --primary-rgb: 11, 74, 139;
    --success: #15803d;
    --danger: #b42318;
    --warning: #b45309;
    --shadow: 0 18px 40px rgba(11, 74, 139, 0.08);
    --radius: 18px;
    --content-max: 1520px;
    --sidebar-width: clamp(220px, 16vw, 280px);
    --page-space: clamp(12px, 0.95vw, 20px);
    --panel-space: clamp(14px, 0.9vw, 20px);
    --control-height: clamp(40px, 2vw, 46px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-size: clamp(13px, 0.12vw + 12.4px, 15px);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.12), transparent 30%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
}

.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(18px);
    border-right: 1px solid rgba(213, 226, 222, 0.9);
    padding: var(--page-space);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    scrollbar-gutter: stable;
}

.sidebar-scrim {
    display: none;
}

.brand,
.hero-card,
.group-card,
.topbar,
.confirm-panel,
.file-card,
.loader-card {
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.66rem;
    font-weight: 700;
}

.brand-logo {
    display: block;
    width: clamp(150px, 11vw, 220px);
    max-width: 100%;
    height: auto;
    margin: 0 0 10px;
}

.brand h1,
.topbar h2,
.hero-card h3,
.confirm-panel h3 {
    margin: 0;
    line-height: 1.1;
    text-wrap: balance;
}

.brand h1 {
    font-size: clamp(1.2rem, 0.8rem + 1.7vw, 2.2rem);
}

.topbar h2 {
    font-size: clamp(1.1rem, 0.78rem + 1.15vw, 1.8rem);
    max-width: 18ch;
}

.subtitle,
.status-message,
.hero-card p,
.file-card p,
.summary-meta,
.legend,
.confirm-panel-copy p:last-of-type {
    color: var(--muted);
}

.sidebar-tools,
.list-meta,
.file-card-main,
.input-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.sidebar-tools,
.list-meta {
    margin-top: 14px;
}

.sidebar-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
}

.list-meta {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    font-size: 0.72rem;
}

#file-search,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="email"],
input[type="tel"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    min-height: var(--control-height);
    padding: 9px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

.language-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.language-switch select {
    min-height: var(--control-height);
    width: auto;
    min-width: 78px;
    padding-inline: 12px;
    border-radius: 999px;
}

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

input:focus,
textarea:focus {
    outline: 2px solid rgba(var(--primary-rgb), 0.18);
    border-color: var(--primary);
}

input[readonly],
textarea[readonly] {
    background: #f4f8fc;
    color: var(--muted);
}

.table-row input[readonly] {
    background: #fff;
    color: var(--text);
}

.btn {
    border: none;
    border-radius: 999px;
    min-height: var(--control-height);
    padding: 8px 14px;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.workspace {
    min-width: 0;
    padding: var(--page-space);
}

.workspace > :not(.toast-zone) {
    width: min(100%, var(--content-max));
    margin-inline: auto;
}

.topbar {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(213, 226, 222, 0.8);
    border-radius: var(--radius);
    padding: var(--panel-space);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: flex-start;
}

.topbar-copy {
    min-width: 0;
    display: grid;
    gap: 6px;
}

.topbar-side {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.session-card {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.session-card strong {
    color: var(--text);
}

.logout-form {
    margin: 0;
}

.btn-logout {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 0.78rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    justify-self: end;
    max-width: 44rem;
}

.actions .btn {
    width: auto;
    min-width: 0;
    flex: 0 0 auto;
}

.confirm-panel {
    margin-top: 22px;
    border-radius: var(--radius);
    padding: 20px 22px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(213, 226, 222, 0.85);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
}

.confirm-panel[hidden] {
    display: none;
}

.confirm-panel-copy {
    max-width: 720px;
}

.confirm-panel-copy p:last-of-type {
    margin: 8px 0 0;
    line-height: 1.5;
}

.busy-panel {
    margin-top: 16px;
    border-radius: var(--radius);
    padding: 18px 22px;
    background: rgba(237, 244, 251, 0.96);
    border: 1px solid rgba(var(--primary-rgb), 0.15);
}

.busy-panel[hidden] {
    display: none;
}

.busy-panel-copy {
    display: flex;
    gap: 16px;
    align-items: center;
}

.busy-panel-copy .spinner {
    width: 34px;
    height: 34px;
    margin: 0;
}

.hero-card {
    margin-top: 22px;
    border-radius: var(--radius);
    padding: clamp(18px, 1.2vw, 24px);
    background: linear-gradient(135deg, var(--primary) 0%, #0a2f58 100%);
    color: #fff;
}

.hero-card .eyebrow,
.hero-card p {
    color: rgba(255, 255, 255, 0.86);
}

.form-shell {
    margin-top: 18px;
}

.form-end-actions {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 14px;
    margin-top: 6px;
}

.form-end-actions-left {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
}

.form-end-actions .btn,
.form-end-actions-left .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    min-width: 0;
    white-space: nowrap;
    width: 100%;
    padding-inline: 18px;
}

.signature-group summary {
    align-items: center;
}

.signature-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(0, 936px);
    padding: 0 18px 18px;
}

.signature-card {
    border: 1px solid rgba(213, 226, 222, 0.9);
    border-radius: 16px;
    background: #f8fbff;
    max-width: 936px;
    padding: 14px;
}

.signature-card h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.signature-card p,
.signature-help {
    margin: 0;
    color: var(--muted);
}

.signature-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.signature-canvas {
    display: block;
    width: 100%;
    height: 180px;
    min-height: 0;
    border-radius: 14px;
    border: 1px dashed rgba(99, 122, 117, 0.45);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 249, 253, 0.96)),
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 34px,
            rgba(var(--primary-rgb), 0.05) 34px,
            rgba(var(--primary-rgb), 0.05) 35px
        );
    touch-action: none;
    cursor: crosshair;
}

.signature-help {
    margin-top: 8px;
    font-size: 0.82rem;
}

.group-card {
    margin-bottom: 14px;
    border: 1px solid rgba(213, 226, 222, 0.85);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.94);
    overflow: hidden;
}

.group-card summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.group-card summary::-webkit-details-marker {
    display: none;
}

.form-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    padding: 0 22px 22px;
}

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

.section-note {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

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

.field-check {
    justify-content: flex-end;
    min-height: 66px;
}

.field-check input {
    width: 24px;
    height: 24px;
}

.required {
    color: var(--danger);
}

.prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 14px 0 0 14px;
    background: #f4f8fc;
    color: var(--muted);
}

.input-row input {
    border-radius: 0 14px 14px 0;
}

.file-list {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.file-card {
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid rgba(213, 226, 222, 0.85);
    padding: 12px 13px;
}

.file-card.ready,
.file-card.in_progress {
    cursor: pointer;
}

.file-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.file-card-main {
    align-items: flex-start;
}

.file-card-main strong {
    flex: 1;
    min-width: 0;
    font-size: clamp(0.92rem, 0.06vw + 0.9rem, 1.02rem);
    line-height: 1.25;
    word-break: break-word;
}

.file-card-lines {
    margin: 10px 0 0;
    display: grid;
    gap: 5px;
    padding-top: 8px;
    border-top: 1px solid rgba(213, 226, 222, 0.8);
}

.file-card-lines p {
    margin: 0;
    color: var(--muted);
    font-size: clamp(0.8rem, 0.06vw + 0.79rem, 0.9rem);
    line-height: 1.32;
    font-weight: 500;
    word-break: break-word;
}

.file-card-empty-meta {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.4;
}

.file-card.ready:hover,
.file-card.active {
    border-color: rgba(var(--primary-rgb), 0.45);
    background: linear-gradient(180deg, #ffffff 0%, #eef4fb 100%);
}

.file-card.invalid {
    border-color: rgba(180, 83, 9, 0.35);
    background: #fffaf5;
}

.file-card.in_progress {
    border-color: rgba(180, 83, 9, 0.22);
    background: #fff8f1;
}

.file-card.in_progress:hover {
    border-color: rgba(180, 83, 9, 0.4);
    background: linear-gradient(180deg, #ffffff 0%, #fff4e8 100%);
}

.file-card.locked {
    border-color: rgba(180, 83, 9, 0.28);
    background: #fff8f0;
}

.status-pill {
    border-radius: 999px;
    padding: 5px 8px;
    font-size: 0.68rem;
    font-weight: 700;
}

.status-pill.ok {
    background: rgba(21, 128, 61, 0.12);
    color: var(--success);
}

.status-pill.progress {
    background: rgba(180, 83, 9, 0.14);
    color: var(--warning);
}

.status-pill.error {
    background: rgba(180, 83, 9, 0.12);
    color: var(--warning);
}

.status-pill.locked {
    background: rgba(180, 83, 9, 0.14);
    color: #c26a08;
}

.empty-state {
    padding: 22px;
    text-align: center;
    color: var(--muted);
}

.toast-zone {
    position: fixed;
    right: 22px;
    bottom: 22px;
    display: grid;
    gap: 10px;
    z-index: 1100;
}

.toast {
    min-width: 260px;
    max-width: 420px;
    background: #0a2f58;
    color: #fff;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.toast-success {
    background: #14532d;
}

.toast-error {
    background: #7f1d1d;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 5px solid rgba(var(--primary-rgb), 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

.mobile-only {
    display: none;
}

body.has-active-file {
    background:
        radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.08), transparent 34%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
}

body.has-active-file.sidebar-open {
    overflow: hidden;
}

body.has-active-file .shell {
    display: block;
    min-height: 100vh;
}

body.has-active-file .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: min(88vw, 420px);
    height: 100dvh;
    padding: 16px;
    border-right: 1px solid rgba(213, 226, 222, 0.95);
    border-bottom: none;
    box-shadow: 24px 0 48px rgba(11, 74, 139, 0.18);
    transform: translateX(calc(-100% - 18px));
    transition: transform 0.22s ease;
}

body.has-active-file .sidebar.is-open {
    transform: translateX(0);
}

body.has-active-file .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 990;
    width: 100%;
    min-height: 100dvh;
    padding: 0;
    border: 0;
    background: rgba(9, 56, 104, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

body.has-active-file.sidebar-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
}

body.has-active-file .workspace {
    padding: var(--page-space);
}

body.has-active-file .workspace > :not(.toast-zone) {
    width: min(100%, var(--content-max));
}

body.has-active-file .topbar {
    position: sticky;
    top: var(--page-space);
    z-index: 80;
}

body.has-active-file .topbar-copy {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 10px;
    align-items: center;
}

body.has-active-file #btn-toggle-sidebar {
    grid-row: 1 / span 2;
    grid-column: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    align-self: stretch;
}

body.has-active-file .topbar-copy .eyebrow,
body.has-active-file .topbar-copy h2,
body.has-active-file .topbar-copy .status-message {
    grid-column: 2;
}

body.has-active-file .topbar h2 {
    max-width: none;
}

body.has-active-file .brand-logo {
    width: min(220px, 72vw);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1279px) {
    .shell {
        grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    }

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

    .actions {
        justify-self: stretch;
        max-width: none;
    }

    .topbar-side {
        justify-items: stretch;
    }

    .session-card {
        justify-content: space-between;
        width: 100%;
    }
}

@media (max-width: 1179px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(213, 226, 222, 0.9);
    }

    .workspace {
        padding: 16px;
    }

    .topbar,
    .confirm-panel,
    .busy-panel-copy {
        flex-direction: column;
        align-items: stretch;
    }

    .actions,
    .confirm-actions {
        width: 100%;
    }

    .actions .btn,
    .confirm-actions .btn,
    .signature-card-head .btn {
        min-width: 0;
    }

    .signature-card-head {
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-only {
        display: none;
    }

}

@media (max-width: 860px) {
    :root {
        --page-space: 10px;
        --panel-space: 12px;
        --control-height: 42px;
    }

    body.has-active-file {
        background:
            radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.08), transparent 34%),
            linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
    }

    body.has-active-file.sidebar-open {
        overflow: hidden;
    }

    body.has-active-file .shell {
        display: block;
    }

    body.has-active-file .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1000;
        width: min(88vw, 360px);
        height: 100dvh;
        padding: 14px;
        border-right: 1px solid rgba(213, 226, 222, 0.95);
        border-bottom: none;
        box-shadow: 24px 0 48px rgba(11, 74, 139, 0.18);
        transform: translateX(calc(-100% - 18px));
        transition: transform 0.22s ease;
    }

    body.has-active-file .sidebar.is-open {
        transform: translateX(0);
    }

    body.has-active-file .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 990;
        width: 100%;
        min-height: 100dvh;
        padding: 0;
        border: 0;
        background: rgba(9, 56, 104, 0.28);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

    body.has-active-file.sidebar-open .sidebar-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    body.has-active-file .workspace {
        padding: 10px;
    }

    body.has-active-file .workspace > :not(.toast-zone) {
        width: 100%;
    }

    body.has-active-file .topbar {
        position: sticky;
        top: 8px;
        z-index: 80;
        grid-template-columns: 1fr;
        gap: 12px;
        border-radius: 16px;
    }

    body.has-active-file .topbar-copy {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 4px 10px;
        align-items: center;
    }

    body.has-active-file #btn-toggle-sidebar {
        grid-row: 1 / span 2;
        grid-column: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 86px;
        align-self: stretch;
    }

    body.has-active-file .topbar-copy .eyebrow,
    body.has-active-file .topbar-copy h2,
    body.has-active-file .topbar-copy .status-message {
        grid-column: 2;
    }

    body.has-active-file .topbar h2 {
        max-width: none;
        font-size: clamp(1.05rem, 5vw, 1.35rem);
    }

    body.has-active-file .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        justify-content: stretch;
    }

    body.has-active-file .actions .btn,
    body.has-active-file .actions .language-switch {
        width: 100%;
    }

    body.has-active-file .language-switch {
        justify-content: space-between;
        grid-column: 1 / -1;
        padding: 0 2px;
    }

    body.has-active-file .brand-logo {
        width: min(190px, 72vw);
    }

    body.has-active-file .brand h1 {
        font-size: 1.55rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .section-card {
        padding: 12px;
    }

    .section-header,
    .section-header-split {
        align-items: stretch;
        flex-direction: column;
    }

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

    .signature-grid {
        padding: 0;
    }

    .form-end-actions {
        grid-template-columns: 1fr;
    }

    .form-end-actions-left {
        grid-template-columns: 1fr;
    }

    .form-end-actions .btn,
    .form-end-actions-left .btn {
        width: 100%;
    }
}

@media (min-width: 1920px) {
    .actions {
        max-width: 48rem;
    }
}

@media (min-width: 2400px) {
    :root {
        --content-max: 1760px;
        --sidebar-width: clamp(320px, 22vw, 440px);
    }
}
