* {
    box-sizing: border-box;
}

:root {
    --sidebar: #101828;
    --sidebar-hover: #1d2939;
    --text: #17202a;
    --muted: #667085;
    --muted-2: #98a2b3;
    --border: #eaecf0;
    --surface: #ffffff;
    --background: #f5f7fa;
    --primary: #101828;
    --danger: #b42318;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--background);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    background: var(--sidebar);
    color: white;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
}

.brand-mark,
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: white;
    color: var(--sidebar);
    font-size: 20px;
    font-weight: 800;
}

.brand strong {
    display: block;
    font-size: 16px;
}

.brand span {
    display: block;
    margin-top: 2px;
    color: #98a2b3;
    font-size: 12px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 9px;
    color: #d0d5dd;
    font-size: 14px;
    transition: 0.15s;
}

.menu a:hover,
.menu a.active {
    background: var(--sidebar-hover);
    color: white;
}

.menu-icon {
    width: 18px;
    color: #98a2b3;
    text-align: center;
}

.menu a.active .menu-icon,
.menu a:hover .menu-icon {
    color: white;
}

.menu-badge {
    margin-left: auto;
    padding: 3px 6px;
    border: 1px solid #344054;
    border-radius: 99px;
    color: #98a2b3;
    font-size: 9px;
}

.menu-divider {
    height: 1px;
    margin: 12px 5px;
    background: #344054;
}

.sidebar-user {
    margin-top: auto;
    padding: 16px 8px 0;
    border-top: 1px solid #344054;
}

.sidebar-user-data {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-text {
    min-width: 0;
}

.avatar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #344054;
    color: white;
    font-size: 13px;
    font-weight: 700;
}

.avatar-light {
    width: 38px;
    height: 38px;
    background: #eef2f6;
    color: #344054;
}

.sidebar-user strong {
    display: block;
    margin-bottom: 4px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user span {
    display: block;
    overflow: hidden;
    color: #98a2b3;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-button {
    width: 100%;
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--sidebar-hover);
    color: #d0d5dd;
    cursor: pointer;
}

.logout-button:hover {
    background: #344054;
    color: white;
}

.content {
    width: calc(100% - 272px);
    margin-left: 272px;
    padding: 38px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}

.eyebrow {
    display: block;
    margin-bottom: 8px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.09em;
}

.page-header h1 {
    margin: 0;
    font-size: 29px;
    letter-spacing: -0.6px;
}

.page-header p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}

.back-link:hover {
    color: var(--text);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.card,
.stat-card,
.welcome-card,
.preview-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat-card {
    padding: 24px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.stat-card strong {
    display: block;
    margin: 13px 0 5px;
    font-size: 32px;
}

.stat-card small {
    color: var(--muted-2);
}

.welcome-card {
    margin-top: 20px;
    padding: 24px;
}

.welcome-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.welcome-card p {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    font-size: 14px;
}

.info-box {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid #d8e3f0;
    border-radius: 12px;
    background: #f8fbff;
}

.info-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #e8f1fb;
    color: #345b82;
    font-size: 12px;
    font-weight: 800;
}

.info-box strong {
    font-size: 13px;
}

.info-box p {
    margin: 4px 0 0;
    color: #53677d;
    line-height: 1.55;
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    background: #fcfcfd;
    color: var(--muted);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 13px;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover {
    background: #fcfcfd;
}

.actions-column {
    width: 1%;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.field-name-cell,
.employee-cell {
    display: flex;
    align-items: center;
    gap: 11px;
}

.field-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f2f4f7;
    color: #475467;
    font-size: 12px;
    font-weight: 800;
}

.field-name-cell strong,
.employee-cell strong {
    display: block;
    color: #344054;
    font-size: 13px;
}

.field-name-cell small,
.employee-cell small {
    display: block;
    margin-top: 3px;
    color: var(--muted-2);
    font-size: 11px;
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
}

.status-active {
    background: #ecfdf3;
    color: #067647;
}

.status-inactive {
    background: #f2f4f7;
    color: #667085;
}

.muted {
    color: var(--muted-2);
}

.image-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #475467;
    font-size: 12px;
}

.image-chip img {
    width: 42px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    object-fit: contain;
    background: white;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.search-form {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 620px;
}

.search-form input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    outline: none;
    background: white;
}

.search-form input:focus,
.form-group input:focus {
    border-color: #667085;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.12);
}

.empty-state {
    padding: 62px 20px;
    text-align: center;
}

.empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 14px;
    background: #f2f4f7;
    color: #475467;
    font-size: 22px;
}

.empty-state h2 {
    margin: 0;
    font-size: 17px;
}

.empty-state p {
    max-width: 440px;
    margin: 8px auto 18px;
    color: var(--muted);
    line-height: 1.55;
    font-size: 13px;
}

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

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 20px;
    align-items: start;
}

.form-card {
    padding: 24px;
}

.form-section-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 22px;
}

.form-section-header.compact {
    margin-bottom: 16px;
}

.section-step {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: #f2f4f7;
    color: #344054;
    font-size: 12px;
    font-weight: 800;
}

.form-section-header h2 {
    margin: 1px 0 4px;
    font-size: 16px;
}

.form-section-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    outline: none;
    background: white;
    transition: 0.15s;
}

.form-help {
    display: block;
    margin-top: 7px;
    color: var(--muted-2);
    line-height: 1.4;
    font-size: 11px;
}

.form-help.center {
    text-align: center;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 5px;
}

.preview-card {
    position: sticky;
    top: 38px;
    padding: 22px;
}

.preview-card h3 {
    margin: 0 0 18px;
    font-size: 15px;
}

.preview-card>p {
    margin: 16px 0 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 12px;
}

.mini-form-preview {
    padding: 16px;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    background: #fcfcfd;
}

.mini-form-preview>span {
    display: block;
    margin-bottom: 7px;
    color: #344054;
    font-size: 12px;
    font-weight: 600;
}

.fake-input {
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: white;
    color: #98a2b3;
    font-size: 12px;
}

.employee-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 20px;
    align-items: start;
}

.form-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-sidebar {
    min-width: 0;
}

.sticky-card {
    position: sticky;
    top: 30px;
}

.inline-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    background: #fcfcfd;
}

.inline-empty strong {
    display: block;
    font-size: 13px;
}

.inline-empty p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.upload-box {
    display: block;
    cursor: pointer;
}

.upload-box input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.upload-preview {
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px dashed #cfd5dd;
    border-radius: 12px;
    background: #fafbfc;
    transition: 0.15s;
}

.upload-box:hover .upload-preview {
    border-color: #98a2b3;
    background: #f8f9fb;
}

.upload-preview.has-image {
    padding: 12px;
    border-style: solid;
    background: white;
}

.upload-preview img {
    display: block;
    width: 100%;
    max-height: 230px;
    object-fit: contain;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: #667085;
    text-align: center;
}

.upload-placeholder>span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    margin-bottom: 4px;
    border-radius: 50%;
    background: #f2f4f7;
    font-size: 18px;
}

.upload-placeholder strong {
    font-size: 12px;
}

.upload-placeholder small {
    color: #98a2b3;
    font-size: 10px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 20px -38px -38px;
    padding: 15px 38px;
    border-top: 1px solid var(--border);
    background: rgba(245, 247, 250, 0.96);
    backdrop-filter: blur(8px);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 39px;
    padding: 10px 16px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 650;
    transition: 0.15s;
}

.button-primary {
    background: var(--primary);
    color: white;
}

.button-primary:hover {
    background: #1d2939;
}

.button-secondary {
    border: 1px solid #d0d5dd;
    background: white;
    color: #344054;
}

.button-secondary:hover {
    background: #f9fafb;
}

.button-ghost {
    background: transparent;
    color: #667085;
}

.button-ghost:hover {
    background: #f2f4f7;
    color: #344054;
}

.button-danger-ghost {
    background: transparent;
    color: #b42318;
}

.button-danger-ghost:hover {
    background: #fef3f2;
}

.button-small {
    min-height: 32px;
    padding: 7px 10px;
    border-radius: 7px;
    font-size: 11px;
}

.button-full {
    width: 100%;
}

.alert {
    margin-bottom: 20px;
    padding: 12px 15px;
    border-radius: 9px;
    font-size: 13px;
}

.alert-error {
    border: 1px solid #fecdca;
    background: #fef3f2;
    color: #b42318;
}

.alert-success {
    border: 1px solid #abefc6;
    background: #ecfdf3;
    color: #067647;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background:
        radial-gradient(circle at top left, #e9efff, transparent 35%),
        var(--background);
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: white;
    box-shadow: 0 20px 60px rgba(16, 24, 40, 0.08);
}

.login-brand {
    margin-bottom: 30px;
    text-align: center;
}

.login-logo {
    margin: 0 auto 18px;
    background: var(--sidebar);
    color: white;
}

.login-brand h1 {
    margin: 0;
    font-size: 24px;
}

.login-brand p {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-alert {
    position: fixed;
    top: 20px;
    width: calc(100% - 40px);
    max-width: 430px;
}

@media (max-width: 1050px) {

    .form-layout,
    .employee-form-grid {
        grid-template-columns: 1fr;
    }

    .preview-card,
    .sticky-card {
        position: static;
    }
}

@media (max-width: 900px) {
    .sidebar {
        width: 218px;
    }

    .content {
        width: calc(100% - 218px);
        margin-left: 218px;
        padding: 24px;
    }

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

    .sticky-actions {
        margin: 20px -24px -24px;
        padding: 15px 24px;
    }
}

@media (max-width: 700px) {
    .sidebar {
        display: flex;
    }

    .content {
        width: 100%;
        margin: 0;
        padding: 20px;
    }

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

    .page-header .button {
        width: 100%;
    }

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

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form {
        flex-wrap: wrap;
    }

    .search-form input {
        flex-basis: 100%;
    }

    .sticky-actions {
        margin: 20px -20px -20px;
        padding: 15px 20px;
    }
}


/* =========================================
   V3 — Font Awesome + Template Builder
   ========================================= */

.menu-icon {
    width: 18px;
    color: #ffffff !important;
    text-align: center;
    font-size: 14px;
}

.menu a:hover .menu-icon,
.menu a.active .menu-icon {
    color: #ffffff !important;
}

.logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.brand-mark i {
    font-size: 18px;
}

.textarea {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    padding: 11px 13px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    outline: none;
    background: white;
    font: inherit;
    line-height: 1.5;
    transition: 0.15s;
}

.textarea:focus {
    border-color: #667085;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.12);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 18px;
}

.template-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    transition: 0.16s;
}

.template-card:hover {
    border-color: #d0d5dd;
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
    transform: translateY(-1px);
}

.template-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.template-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f2f4f7;
    color: #475467;
}

.template-card h2 {
    margin: 0;
    color: #344054;
    font-size: 16px;
}

.template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    color: #98a2b3;
    font-size: 11px;
}

.template-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
    padding-top: 15px;
    border-top: 1px solid #f2f4f7;
}

.template-actions form {
    margin: 0;
}

.template-editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 22px;
    align-items: start;
}

.template-builder-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.template-preview-column {
    min-width: 0;
}

.template-preview-card {
    position: sticky;
    top: 28px;
    padding: 20px;
}

.preview-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.preview-toolbar h2 {
    margin: 0;
    font-size: 16px;
}

.preview-employee-select {
    min-width: 175px;
}

.preview-employee-select label {
    display: block;
    margin-bottom: 5px;
    color: #667085;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.preview-employee-select select {
    width: 100%;
    padding: 8px 30px 8px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: white;
    color: #344054;
    font-size: 12px;
}

.preview-no-employee {
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid #eaecf0;
    border-radius: 10px;
    background: #fcfcfd;
    color: #667085;
}

.preview-no-employee i {
    margin-right: 6px;
}

.preview-no-employee strong {
    font-size: 12px;
}

.preview-no-employee p {
    margin: 5px 0 0 22px;
    line-height: 1.45;
    font-size: 11px;
}

.signature-preview {
    min-height: 330px;
    padding: 24px;
    overflow: auto;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background:
        linear-gradient(#ffffff, #ffffff) padding-box,
        repeating-linear-gradient(45deg,
            #fafafa,
            #fafafa 8px,
            #f6f6f6 8px,
            #f6f6f6 16px) border-box;
    color: #1f2937;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

.signature-preview-free-text {
    margin-bottom: 10px;
    white-space: normal;
    line-height: 1.45;
}

.signature-preview-after {
    margin-top: 10px;
    margin-bottom: 0;
}

.signature-preview-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.signature-preview-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 20px;
    gap: 0;
}

.signature-preview-item {
    display: inline;
    white-space: pre-wrap;
}

.signature-preview-image-wrap {
    display: inline-flex;
    max-width: 100%;
}

.signature-preview-image {
    display: block;
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
}

.signature-preview-image-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    border: 1px dashed #d0d5dd;
    border-radius: 8px;
    background: #f9fafb;
    color: #98a2b3;
    font-size: 11px;
}

.signature-preview-empty {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #98a2b3;
    text-align: center;
}

.signature-preview-empty i {
    margin-bottom: 10px;
    font-size: 24px;
}

.signature-preview-empty strong {
    color: #667085;
    font-size: 13px;
}

.signature-preview-empty span {
    margin-top: 4px;
    font-size: 11px;
}

.builder-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.builder-lines {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.builder-line {
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #fcfcfd;
    transition: 0.15s;
}

.builder-line.is-dragging {
    opacity: 0.45;
}

.builder-line.drag-over {
    border-color: #98a2b3;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.08);
}

.builder-line-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #eaecf0;
}

.builder-line-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #344054;
    font-size: 12px;
    font-weight: 700;
}

.builder-line-title small {
    color: #98a2b3;
    font-size: 10px;
    font-weight: 500;
}

.drag-handle,
.icon-button,
.chip-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #98a2b3;
    cursor: pointer;
}

.drag-handle {
    width: 24px;
    height: 24px;
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.icon-button {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.icon-button:hover {
    background: #f2f4f7;
    color: #475467;
}

.icon-button.danger:hover {
    background: #fef3f2;
    color: #b42318;
}

.builder-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 72px;
    padding: 14px;
    transition: 0.12s;
}

.builder-items.item-drop-zone {
    background: #f8fafc;
    box-shadow: inset 0 0 0 2px #d0d5dd;
}

.builder-items-empty {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 38px;
    border: 1px dashed #e4e7ec;
    border-radius: 8px;
    color: #98a2b3;
    font-size: 11px;
}

.builder-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 8px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    background: #ffffff;
    color: #344054;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
    cursor: grab;
    font-size: 11px;
    font-weight: 600;
}

.builder-chip:active {
    cursor: grabbing;
}

.builder-chip.is-dragging {
    opacity: 0.35;
}

.builder-chip.item-drag-over {
    border-color: #667085;
    transform: translateX(3px);
}

.builder-chip>i {
    color: #667085;
}

.builder-chip-text {
    background: #fffaf0;
    border-color: #f2dca9;
}

.builder-chip-text>i {
    color: #a56b13;
}

.builder-chip-text strong {
    font-weight: 700;
}

.chip-drag {
    color: #c0c6d0;
}

.chip-button {
    width: 21px;
    height: 21px;
    border-radius: 6px;
}

.chip-button:hover {
    background: #f2f4f7;
    color: #344054;
}

.builder-line-actions {
    display: flex;
    gap: 7px;
    padding: 0 14px 13px;
}

.builder-small-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 6px 9px;
    border: 1px solid #e4e7ec;
    border-radius: 7px;
    background: #ffffff;
    color: #667085;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.builder-small-action:hover {
    border-color: #d0d5dd;
    color: #344054;
}

.builder-add-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 12px;
    padding: 11px;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    background: #fcfcfd;
    color: #667085;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.builder-add-line:hover {
    border-color: #98a2b3;
    background: #f9fafb;
    color: #344054;
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(16, 24, 40, 0.55);
    opacity: 0;
    transition: opacity 0.12s;
}

.modal-backdrop.is-open {
    opacity: 1;
}

.modal-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 22px;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(16, 24, 40, 0.24);
    transform: translateY(8px) scale(0.99);
    transition: transform 0.12s;
}

.modal-backdrop.is-open .modal-card {
    transform: translateY(0) scale(1);
}

.modal-card-small {
    width: min(520px, 100%);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 19px;
}

.field-picker-section+.field-picker-section {
    margin-top: 22px;
}

.field-picker-section h3 {
    margin: 0 0 10px;
    color: #667085;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.field-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.field-picker-option {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    background: #ffffff;
    color: #344054;
    text-align: left;
    cursor: pointer;
    transition: 0.12s;
}

.field-picker-option:hover {
    border-color: #98a2b3;
    background: #fcfcfd;
}

.field-picker-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #f2f4f7;
    color: #475467;
}

.field-picker-option strong {
    display: block;
    font-size: 12px;
}

.field-picker-option small {
    display: block;
    margin-top: 3px;
    color: #98a2b3;
    font-size: 10px;
}

.modal-empty {
    padding: 14px;
    border: 1px dashed #d0d5dd;
    border-radius: 9px;
    color: #98a2b3;
    font-size: 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

@media (max-width: 1200px) {
    .template-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .template-editor-layout {
        grid-template-columns: 1fr;
    }

    .template-preview-card {
        position: static;
    }
}

@media (max-width: 700px) {
    .template-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .builder-section-heading {
        flex-direction: column;
    }

    .builder-section-heading>.button {
        width: 100%;
    }

    .field-picker-grid {
        grid-template-columns: 1fr;
    }

    .preview-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .preview-employee-select {
        width: 100%;
    }
}


/* =========================================
   V4 — line spacing/alignment + HTML editor
   ========================================= */

.editor-mode-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 720px;
    margin-bottom: 20px;
}

.editor-mode-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid #d0d5dd;
    border-radius: 11px;
    background: #ffffff;
    color: #667085;
    text-align: left;
    cursor: pointer;
    transition: 0.15s;
}

.editor-mode-button>i {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #f2f4f7;
}

.editor-mode-button strong,
.editor-mode-button small {
    display: block;
}

.editor-mode-button strong {
    color: #344054;
    font-size: 12px;
}

.editor-mode-button small {
    margin-top: 3px;
    color: #98a2b3;
    font-size: 10px;
}

.editor-mode-button:hover {
    border-color: #98a2b3;
}

.editor-mode-button.active {
    border-color: #344054;
    box-shadow: 0 0 0 2px rgba(52, 64, 84, 0.08);
}

.editor-mode-button.active>i {
    background: #101828;
    color: #ffffff;
}

.builder-main-card {
    margin: 20px 0;
}

.builder-line-header-actions {
    display: flex;
    align-items: center;
    gap: 3px;
}

.line-style-summary {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #98a2b3;
    font-size: 9px;
    font-weight: 600;
}

.preview-ruler {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    background: #f8fafc;
    color: #98a2b3;
    line-height: 1.35;
    font-size: 10px;
}

.preview-ruler i {
    margin-top: 1px;
}

.signature-preview {
    padding: 0 !important;
}

.signature-preview-free-text {
    padding: 0;
}

.signature-preview-body {
    gap: 0;
}

.signature-preview-line {
    min-height: 0;
}

.html-editor-panel {
    display: block;
}

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

.html-helper {
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    background: #fcfcfd;
}

.html-helper-heading strong,
.html-helper-heading small {
    display: block;
}

.html-helper-heading strong {
    color: #344054;
    font-size: 12px;
}

.html-helper-heading small {
    margin-top: 3px;
    color: #98a2b3;
    font-size: 10px;
}

.html-token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
}

.html-token {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 31px;
    padding: 6px 9px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #475467;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.html-token:hover {
    border-color: #98a2b3;
    background: #f9fafb;
    color: #344054;
}

.html-code-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.html-code-label label {
    margin-bottom: 0;
}

.code-editor {
    width: 100%;
    min-height: 440px;
    resize: vertical;
    padding: 15px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    outline: none;
    background: #101828;
    color: #e4e7ec;
    font-family:
        "Cascadia Code",
        "Fira Code",
        Consolas,
        monospace;
    font-size: 12px;
    line-height: 1.55;
    tab-size: 4;
}

.code-editor:focus {
    border-color: #667085;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.12);
}

.html-preview-frame {
    width: 100%;
    min-height: 330px;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #ffffff;
}

.template-mode {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 4px 7px;
    border-radius: 7px;
    background: #f8fafc;
    color: #667085;
    font-size: 10px;
    font-weight: 650;
}

.settings-section+.settings-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #f2f4f7;
}

.settings-label {
    display: block;
    margin-bottom: 9px;
    color: #344054;
    font-size: 12px;
    font-weight: 700;
}

.settings-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tiny-link {
    padding: 0;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.tiny-link:hover {
    color: #344054;
    text-decoration: underline;
}

.segmented-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 3px;
    border: 1px solid #e4e7ec;
    border-radius: 9px;
    background: #f9fafb;
}

.segmented-control button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 7px;
    border-radius: 7px;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
}

.segmented-control button:hover {
    color: #344054;
}

.segmented-control button.active {
    background: #ffffff;
    color: #101828;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.09);
}

.padding-control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.padding-control-grid>label>span {
    display: block;
    margin-bottom: 5px;
    color: #667085;
    font-size: 10px;
    font-weight: 600;
}

.number-with-unit {
    display: flex;
    align-items: center;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.number-with-unit:focus-within {
    border-color: #667085;
    box-shadow: 0 0 0 3px rgba(102, 112, 133, 0.1);
}

.number-with-unit input {
    min-width: 0;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #344054;
    font-size: 12px;
}

.number-with-unit small {
    flex: 0 0 auto;
    padding: 0 10px;
    color: #98a2b3;
    font-size: 10px;
}

.standalone-number {
    max-width: 150px;
}

@media (max-width: 700px) {
    .editor-mode-switch {
        grid-template-columns: 1fr;
    }

    .padding-control-grid {
        grid-template-columns: 1fr;
    }

    .segmented-control {
        grid-template-columns: 1fr;
    }

    .line-style-summary {
        display: none;
    }
}


/* =========================================
   V5 — Preview fiel: nenhum espaço automático
   ========================================= */

/*
 * O preview não pode inventar espaçamento.
 * Tudo deve vir exclusivamente das configurações
 * das linhas ou do conteúdo informado pelo usuário.
 */
.signature-preview {
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible;
    border-radius: 0;
    background: #ffffff;
    line-height: normal;
}

.signature-preview-free-text {
    margin: 0 !important;
    padding: 0 !important;
    line-height: normal;
}

.signature-preview-after {
    margin: 0 !important;
    padding: 0 !important;
}

.signature-preview-body {
    display: flex;
    flex-direction: column;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.signature-preview-line {
    display: flex;
    flex-wrap: wrap;
    min-height: 0 !important;
    margin: 0 !important;
    border: 0;
    line-height: normal;
}

.signature-preview-item,
.signature-preview-image-wrap {
    margin: 0 !important;
    padding: 0 !important;
}

.signature-preview-image {
    display: block;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
}

.signature-preview-empty {
    min-height: 240px;
}

/*
 * A borda visual fica num container externo, não
 * interfere no conteúdo da assinatura.
 */
.signature-canvas {
    overflow: hidden;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #ffffff;
}

.preview-ruler {
    display: none !important;
}


.html-preview-frame {
    display: block;
    width: 100%;
    min-height: 330px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-radius: 0 !important;
    background: #ffffff;
}


/* =========================================
   V6 — Preview por tabela, zero espaço implícito
   ========================================= */

.signature-canvas {
    padding: 0 !important;
}

.signature-preview {
    display: block;
    width: 100%;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    line-height: 1 !important;
}

.signature-preview-table {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    table-layout: auto;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1 !important;
}

.signature-preview-table,
.signature-preview-table tbody,
.signature-preview-table tr,
.signature-preview-table td {
    margin: 0 !important;
    border: 0 !important;
    border-spacing: 0 !important;
}

.signature-preview-table tr {
    padding: 0 !important;
}

.signature-preview-fixed-row {
    padding: 0 !important;
    line-height: 1 !important;
}

.signature-preview-row-content {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.signature-preview-row-content>* {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.signature-preview-item {
    display: inline-block;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.signature-preview-image-wrap {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
    vertical-align: top;
}

.signature-preview-image {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    vertical-align: top;
}



/* =========================================
   V7 — template-only + formatting per item
   ========================================= */

#builder-editor[hidden],
#html-editor[hidden] {
    display: none !important;
}

.builder-main-card {
    margin-top: 20px;
    margin-bottom: 0;
}

.builder-chip {
    max-width: 100%;
}

.builder-chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.builder-chip-style {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #667085;
    font-size: 8px;
    font-weight: 700;
    white-space: nowrap;
}

.builder-chip-text .builder-chip-style {
    background: #fff3d6;
    color: #8a5a0a;
}

.format-settings-first {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.format-button-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.format-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    background: #ffffff;
    color: #667085;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    transition: 0.12s;
}

.format-toggle-button:hover {
    border-color: #98a2b3;
    color: #344054;
}

.format-toggle-button.active {
    border-color: #344054;
    background: #101828;
    color: #ffffff;
}

.font-size-control {
    display: grid;
    grid-template-columns: 38px minmax(0, 150px) 38px;
    gap: 7px;
    align-items: stretch;
}

.font-size-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #475467;
    cursor: pointer;
}

.font-size-step:hover {
    background: #f9fafb;
    border-color: #98a2b3;
}

.format-live-preview {
    margin-top: 20px;
    padding: 14px;
    overflow: hidden;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    background: #fcfcfd;
}

#format-live-preview-text {
    min-height: 52px;
    display: flex;
    align-items: center;
    overflow: auto;
    color: #17202a;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1;
}

.signature-preview-table {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    table-layout: auto;
}

.signature-preview-table>tbody>tr,
.signature-preview-table>tbody>tr>td {
    margin: 0 !important;
    border: 0 !important;
}

.signature-preview-inner-table {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

.signature-preview-inner-table td {
    margin: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    border: 0 !important;
}

.signature-preview-item {
    margin: 0 !important;
    padding: 0 !important;
}

.signature-preview-image {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

@media (max-width: 700px) {
    .format-button-group {
        grid-template-columns: 1fr;
    }
}


/* =========================================
   V8 — item defaults: 8px + Arial 14px
   ========================================= */

.settings-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    outline: none;
    background: #ffffff;
    color: #344054;
    font: inherit;
    font-size: 12px;
}

.settings-select:focus {
    border-color: #667085;
    box-shadow:
        0 0 0 3px rgba(102, 112, 133, 0.10);
}

#format-live-preview-text {
    box-sizing: border-box;
    width: fit-content;
    max-width: 100%;
    min-height: 0;
    background: #ffffff;
    border: 1px dashed #d0d5dd;
}


/* =========================================
   V9 — Imagem + conversão HTML + copiar assinatura
   ========================================= */

.image-size-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.image-size-grid>div>label {
    display: block;
    margin-bottom: 6px;
    color: #667085;
    font-size: 10px;
    font-weight: 700;
}

.signature-copy-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.signature-picker-card {
    padding: 20px;
}

.signature-picker-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.signature-copy-result {
    overflow: hidden;
}

.signature-copy-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    border-bottom: 1px solid #eaecf0;
}

.signature-copy-result-header h2 {
    margin: 0;
    font-size: 17px;
}

.signature-copy-result-header p {
    margin: 5px 0 0;
    color: #667085;
    font-size: 11px;
}

.signature-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 50px 20px;
    color: #98a2b3;
    font-size: 12px;
}

.signature-loading.is-hidden,
.signature-preview-shell.is-hidden,
.signature-copy-error.is-hidden {
    display: none !important;
}

.signature-copy-error {
    margin: 20px;
    padding: 12px 14px;
    border: 1px solid #fecdca;
    border-radius: 9px;
    background: #fef3f2;
    color: #b42318;
    font-size: 12px;
}

.signature-preview-shell {
    padding: 20px;
    background: #ffffff;
}

.signature-preview-shell iframe {
    display: block;
    width: 100%;
    height: 60px;
    margin: 0;
    padding: 0;
    border: 1px solid #eaecf0;
    border-radius: 10px;
    background: #ffffff;
    overflow: hidden;
}

#copy-signature-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#copy-signature-button.copied {
    background: #067647;
}

@media (max-width: 700px) {

    .signature-picker-grid,
    .image-size-grid {
        grid-template-columns: 1fr;
    }

    .signature-copy-result-header {
        align-items: stretch;
        flex-direction: column;
    }

    #copy-signature-button {
        width: 100%;
    }
}


/* =========================================
   V10 — ações de cópia separadas
   ========================================= */

.signature-copy-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

#copy-html-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#copy-html-button.copied {
    border-color: #067647;
    background: #ecfdf3;
    color: #067647;
}

@media (max-width: 700px) {
    .signature-copy-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .signature-copy-actions .button {
        width: 100%;
    }
}


/* =========================================
   V11 — imagem literal + módulo de usuários
   ========================================= */

/*
 * Se largura e altura forem informadas, o preview do
 * builder deve representar literalmente esses valores.
 * Nada de preservar proporção via object-fit: contain.
 */
.signature-preview-image {
    max-width: none !important;
    max-height: none !important;
    object-fit: fill !important;
}

.signature-canvas {
    overflow: auto;
}

.user-form-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.current-user-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #eef4ff;
    color: #3538cd;
    font-size: 9px;
    font-weight: 800;
    vertical-align: middle;
}

.self-protection-note {
    display: inline-flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 7px;
    background: #f2f4f7;
    color: #98a2b3;
    font-size: 10px;
    font-weight: 700;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #98a2b3;
    cursor: pointer;
}

.password-toggle:hover {
    background: #f2f4f7;
    color: #475467;
}

.password-requirements {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 9px;
    background: #f8fafc;
    color: #667085;
    font-size: 10px;
    line-height: 1.4;
}

.password-requirements i {
    color: #475467;
}

@media (min-width: 1100px) {
    .stats-grid {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));
    }
}


/* =========================================
   V12 — iPad / tablet / mobile
   ========================================= */

.mobile-topbar,
.sidebar-backdrop,
.sidebar-close-button {
    display: none;
}

/* Evita qualquer estouro horizontal causado por grids/iframes. */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

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

.content,
.card,
.form-card,
.template-builder-column,
.template-preview-column,
.signature-copy-page,
.signature-copy-result,
.signature-preview-shell {
    min-width: 0;
}

/* iPad landscape / tablets */
@media (max-width: 1100px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app {
        display: block;
        min-height: 100vh;
    }

    .mobile-topbar {
        position: fixed;
        inset: 0 0 auto 0;
        z-index: 1001;
        display: flex;
        align-items: center;
        gap: 12px;
        height: 64px;
        padding: 0 20px;
        border-bottom: 1px solid #e4e7ec;
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(10px);
    }

    .mobile-menu-button {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border: 1px solid #d0d5dd;
        border-radius: 10px;
        background: #ffffff;
        color: #344054;
        cursor: pointer;
        font-size: 16px;
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 9px;
        min-width: 0;
    }

    .mobile-brand-mark {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 9px;
        background: #101828;
        color: #ffffff;
        font-size: 14px;
    }

    .mobile-brand strong,
    .mobile-brand small {
        display: block;
    }

    .mobile-brand strong {
        color: #101828;
        font-size: 13px;
    }

    .mobile-brand small {
        margin-top: 1px;
        color: #98a2b3;
        font-size: 9px;
    }

    .sidebar {
        display: flex !important;
        z-index: 1003;
        width: min(310px, 86vw);
        transform: translateX(-105%);
        box-shadow: 20px 0 50px rgba(16, 24, 40, 0.20);
        transition: transform 0.22s ease;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close-button {
        position: absolute;
        top: 18px;
        right: 16px;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: 1px solid #344054;
        border-radius: 9px;
        background: transparent;
        color: #ffffff;
        cursor: pointer;
    }

    .sidebar .brand {
        padding-right: 44px;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1002;
        display: block;
        background: rgba(16, 24, 40, 0.48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition:
            opacity 0.18s ease,
            visibility 0.18s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .content {
        width: 100%;
        margin-left: 0;
        padding: 92px 24px 32px;
    }

    .page-header {
        margin-bottom: 22px;
    }

    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .employee-form-grid,
    .form-layout,
    .template-editor-layout {
        grid-template-columns: 1fr !important;
    }

    .form-sidebar,
    .template-preview-column {
        width: 100%;
    }

    .sticky-card,
    .preview-card,
    .template-preview-card,
    .signature-help-card {
        position: static !important;
        top: auto !important;
    }

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

    .signature-copy-result-header {
        align-items: flex-start;
    }

    .table-wrap {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 760px;
    }

    .builder-line {
        max-width: 100%;
    }

    .builder-items {
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    .signature-canvas,
    .signature-preview-shell {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* iPad portrait / tablets menores */
@media (max-width: 820px) {
    .content {
        padding:
            86px 18px 28px;
    }

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

    .page-header>.button,
    .page-header>a.button {
        align-self: flex-start;
    }

    .page-header h1 {
        font-size: 26px;
    }

    .page-header p {
        font-size: 13px;
    }

    .form-grid-2,
    .signature-picker-grid,
    .padding-control-grid,
    .field-picker-grid {
        grid-template-columns: 1fr !important;
    }

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

    .template-editor-layout {
        gap: 16px;
    }

    .preview-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .preview-employee-select {
        width: 100%;
        min-width: 0;
    }

    .builder-section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .builder-section-heading .button {
        width: 100%;
    }

    .signature-copy-result-header {
        align-items: stretch;
        flex-direction: column;
    }

    .signature-copy-actions {
        justify-content: flex-start;
    }

    .modal-card {
        width: min(680px, 100%);
        max-height: calc(100dvh - 28px);
        padding: 18px;
    }

    .sticky-actions {
        margin:
            20px -18px -28px;
        padding:
            13px 18px calc(13px + env(safe-area-inset-bottom));
    }
}

/* Mobile */
@media (max-width: 600px) {
    .mobile-topbar {
        height: 58px;
        padding:
            0 12px;
    }

    .mobile-menu-button {
        width: 38px;
        height: 38px;
    }

    .mobile-brand-mark {
        width: 32px;
        height: 32px;
    }

    .content {
        padding:
            76px 12px 22px;
    }

    .page-header {
        margin-bottom: 18px;
    }

    .page-header h1 {
        font-size: 23px;
        letter-spacing: -0.35px;
    }

    .eyebrow {
        margin-bottom: 6px;
        font-size: 9px;
    }

    .page-header>.button,
    .page-header>a.button {
        width: 100%;
    }

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

    .stat-card,
    .welcome-card,
    .form-card,
    .template-preview-card,
    .signature-picker-card {
        padding: 16px;
    }

    .card,
    .stat-card,
    .welcome-card,
    .preview-card {
        border-radius: 12px;
    }

    .form-section-header {
        margin-bottom: 17px;
    }

    .form-section-header h2 {
        font-size: 15px;
    }

    .section-step {
        width: 28px;
        height: 28px;
    }

    .toolbar,
    .search-form {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form {
        max-width: none;
    }

    .search-form .button {
        width: 100%;
    }

    .table {
        min-width: 680px;
    }

    .row-actions {
        justify-content: flex-start;
    }

    .template-card {
        padding: 16px;
    }

    .template-actions {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .template-actions .button,
    .template-actions form,
    .template-actions form .button {
        width: 100%;
    }

    .editor-mode-switch {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .builder-line-header {
        align-items: flex-start;
    }

    .builder-line-title {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .builder-line-header-actions {
        flex: 0 0 auto;
    }

    .builder-items {
        align-items: stretch;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .builder-chip {
        width: 100%;
        justify-content: flex-start;
    }

    .builder-chip-label {
        flex: 1;
    }

    .builder-line-actions {
        flex-wrap: wrap;
    }

    .builder-small-action {
        flex: 1 1 calc(50% - 7px);
        justify-content: center;
    }

    .signature-preview {
        font-size: 13px;
    }

    .signature-preview-shell {
        padding: 12px;
    }

    .signature-copy-result-header {
        padding: 16px;
    }

    .signature-copy-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .signature-copy-actions .button {
        width: 100%;
    }

    .image-size-grid,
    .format-button-group,
    .segmented-control {
        grid-template-columns: 1fr !important;
    }

    .font-size-control {
        grid-template-columns:
            38px minmax(0, 1fr) 38px;
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal-card,
    .modal-card-small {
        width: 100%;
        max-width: none;
        max-height: 90dvh;
        padding:
            18px 16px calc(18px + env(safe-area-inset-bottom));
        border-radius:
            16px 16px 0 0;
    }

    .modal-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .modal-actions .button {
        width: 100%;
    }

    .sticky-actions {
        gap: 8px;
        margin:
            18px -12px -22px;
        padding:
            12px 12px calc(12px + env(safe-area-inset-bottom));
    }

    .sticky-actions .button {
        flex: 1;
    }

    .auth-page {
        align-items: flex-start;
        padding:
            24px 12px;
    }

    .login-card {
        width: 100%;
        max-width: 430px;
    }
}

/* Telefones bem estreitos */
@media (max-width: 390px) {
    .content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .builder-small-action {
        flex-basis: 100%;
    }

    .sticky-actions {
        margin-left: -10px;
        margin-right: -10px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .sticky-actions {
        flex-direction: column-reverse;
    }

    .sticky-actions .button {
        width: 100%;
    }
}