:root {
    color-scheme: light;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #eef5ff;
    --surface: #ffffff;
    --surface-strong: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(148, 163, 184, 0.24);
    --accent: #6366f1;
    --accent-strong: #22d3ee;
    --shadow: 0 24px 72px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.16), transparent 30%),
        linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    color: var(--text);
}

header {
    padding: 20px 18px 24px;
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #f8fafc;
}

header h1 {
    margin: 0;
    font-size: clamp(1.85rem, 2.4vw, 2.4rem);
    letter-spacing: -0.04em;
}

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

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin: 0 0 8px;
    color: #a5b4fc;
    font-size: 0.82rem;
    font-weight: 700;
}

nav {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 999px;
    text-decoration: none;
    color: #e2e8f0;
    background: rgba(226, 232, 240, 0.12);
    border: 1px solid rgba(226, 232, 240, 0.18);
    font-weight: 600;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

nav a:hover,
nav a.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    box-shadow: 0 18px 40px rgba(56, 189, 248, 0.2);
    transform: translateY(-1px);
}

main {
    max-width: 1200px;
    margin: 0 auto 18px;
    padding: 0 18px 18px;
}

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 18px;
}

h2 {
    margin-top: 0;
    margin-bottom: 18px;
    font-size: 1.45rem;
    color: var(--text);
}

form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    color: #334155;
    font-weight: 600;
}

form input,
form textarea,
form select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    padding: 12px 14px;
    font-size: 0.95rem;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    white-space: normal;
    line-height: 1.5;
    text-overflow: ellipsis;
    overflow: hidden;
}

form select option {
    white-space: normal;
}

form input:focus,
form textarea:focus,
form select:focus,
.ts-control input[type="text"]:focus,
.ts-control.focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.6);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.ts-control {
    display: flex;
    align-items: center;
    min-height: 46px;
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.36);
    border-radius: 12px;
    background: #ffffff;
    padding: 0 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ts-control.focus,
.ts-control:hover {
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.ts-control .item {
    display: none;
}

.ts-control > input,
.ts-control input[type="text"],
.ts-control input[type="search"] {
    flex: 1 1 0;
    border: none;
    box-shadow: none;
    padding: 0;
    font-size: 0.95rem;
    min-height: 44px;
    color: var(--text);
    background: transparent;
    margin: 0;
}

.ts-control > input:focus,
.ts-control input[type="text"]:focus,
.ts-control input[type="search"]:focus {
    outline: none;
}

.ts-control .placeholder,
.ts-control .ts-placeholder {
    color: rgba(100, 116, 139, 0.8);
}

.ts-single-selected {
    color: var(--text);
}

.ts-dropdown {
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
    max-height: 260px;
    overflow: auto;
}

.ts-dropdown .ts-option,
.ts-dropdown .option,
.ts-dropdown .create,
.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
    padding: 12px 14px;
    font-size: 0.95rem;
    color: var(--text);
}

.ts-dropdown .ts-option:hover,
.ts-dropdown .option:hover,
.ts-dropdown .ts-option.ts-selected,
.ts-dropdown .option.ts-selected {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
}

.ts-dropdown .optgroup-header {
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.ts-dropdown .no-results,
.ts-dropdown .ts-no-results {
    color: var(--muted);
    padding: 12px 14px;
}

.ts-dropdown {
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
    max-height: 260px;
    overflow: auto;
}

.ts-dropdown .ts-option,
.ts-dropdown .option,
.ts-dropdown .create,
.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
    padding: 14px 16px;
    font-size: 0.95rem;
    color: var(--text);
}

.ts-dropdown .ts-option:hover,
.ts-dropdown .option:hover,
.ts-dropdown .ts-option.ts-selected,
.ts-dropdown .option.ts-selected {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
}

.ts-dropdown .optgroup-header {
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.ts-dropdown .no-results,
.ts-dropdown .ts-no-results {
    color: var(--muted);
    padding: 14px 16px;
}

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

form button,
.btn-salvar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 16px;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

#submit-undo-wrapper {
    display: none;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 18px;
}

#undo-message {
    flex: 1;
    font-weight: 600;
    color: #0f172a;
}

#undo-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: 2px solid rgba(99, 102, 241, 0.65);
    border-radius: 14px;
    background: #ffffff;
    color: #4338ca;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#undo-button:hover {
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.18);
}

form button:hover,
.btn-salvar:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 36px rgba(99, 102, 241, 0.25);
}

.hidden {
    display: none !important;
}

#signature-clear {
    width: 100%;
    border-radius: 16px;
    background: #e2e8f0;
    color: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.small-form,
.movement-form {
    display: grid;
    gap: 14px;
    background: var(--surface-strong);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 22px;
    padding: 18px;
}

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

.form-field {
    margin-bottom: 0;
}

.alert {
    border-left: 4px solid #22d3ee;
    background: rgba(219, 244, 255, 0.9);
    color: #0f172a;
    padding: 18px 22px;
    border-radius: 18px;
    margin-bottom: 24px;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
    margin-top: 16px;
    background: transparent;
    table-layout: auto;
}

thead {
    background: #f8fafc;
}

th,
td {
    padding: 14px 16px;
    text-align: left;
    color: #334155;
    word-break: break-word;
    overflow-wrap: anywhere;
}

th {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

tbody tr {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    outline: 1px solid #000000;
    outline-offset: -1px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, outline-color 0.2s ease;
}

tbody tr td {
    border: none;
}

tbody tr:hover {
    background: #f8fbff;
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    outline-color: #000000;
}

td.signature-cell {
    padding: 14px 18px;
    width: 160px;
    min-width: 160px;
    max-width: 160px;
}

img.img-assinatura-thumbnail {
    width: 110px;
    height: 60px;
    object-fit: contain;
    border-radius: 14px;
    border: 2px solid #000000;
    background: #ffffff;
    cursor: zoom-in;
}

.signature-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 9999;
}

.signature-modal-content {
    position: relative;
    max-width: min(90vw, 720px);
    max-height: min(90vh, 90vh);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.36);
    overflow: hidden;
    border: 2px solid #000000;
}

.signature-modal-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border: 1px solid #000000;
    border-radius: 16px;
    background: #ffffff;
}

.signature-modal-overlay.active {
    display: flex;
}

.signature-modal-content {
    position: relative;
    max-width: min(90vw, 720px);
    max-height: min(90vh, 90vh);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.36);
    overflow: hidden;
}

.signature-modal-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.signature-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
    border: 1px solid rgba(15, 23, 42, 0.12);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

.signature-modal-close:hover {
    background: rgba(15, 23, 42, 0.14);
}

.report-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.report-button,
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.15);
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
    transition: background 0.2s ease, transform 0.2s ease;
}

.report-button:hover,
.page-link:hover,
.report-button.active,
.page-link.active {
    background: rgba(99, 102, 241, 0.12);
    transform: translateY(-1px);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.inline-form label {
    margin: 0;
}

.report-filter-form {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.report-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}

.report-button,
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid rgba(99, 102, 241, 0.18);
    text-decoration: none;
    color: #0f172a;
    background: #eef2ff;
    transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    min-width: 140px;
    text-align: center;
}

.report-button:hover,
.page-link:hover {
    background: rgba(99, 102, 241, 0.14);
    transform: translateY(-1px);
}

.report-button.active,
.page-link.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #ffffff;
    border-color: transparent;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.inline-form label {
    margin: 0;
}

.report-filter-form {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.historico-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    width: 100%;
    margin-bottom: 18px;
}

.historico-filter-form label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    flex: 1 1 220px;
}

.historico-filter-form button {
    align-self: flex-end;
    min-width: 140px;
}

.mailhog-frame-wrapper {
    width: 100%;
    height: min(80vh, 900px);
    min-height: 560px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
}

.mailhog-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #ffffff;
}

@media (max-width: 768px) {
    .mailhog-frame-wrapper {
        height: min(70vh, 720px);
        min-height: 420px;
    }
}

@media print {
        header,
        nav,
        .report-buttons,
        .report-filter-form,
        .inline-form,
        .table-actions,
        .pagination,
        .report-button,
        .page-link,
        button,
        .signature-wrapper,
        .mailhog-frame-wrapper {
            display: none !important;
        }

        body {
            background: #ffffff;
            color: #000000;
        }

        main,
        section,
        table {
            background: #ffffff !important;
            box-shadow: none !important;
            border: none !important;
        }

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

        th,
        td {
            border: 1px solid #000000;
            background: #ffffff !important;
            color: #000000;
        }

        th {
            background: #f0f0f0 !important;
        }

        a,
        button {
            text-decoration: none;
            color: #000000;
        }
    }
}

.signature-wrapper {
    margin-top: 10px;
    border: 2px solid #000000;
    border-radius: 18px;
    overflow: hidden;
    width: 100%;
    min-height: 160px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

#signature-pad {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: crosshair;
    background: #ffffff;
    border: 1px solid #000000;
}

footer {
    text-align: center;
    padding: 12px 0 18px;
    color: #64748b;
}

@media (min-width: 900px) {
    .movement-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .movement-form #field-localidade,
    .movement-form #field-funcionario {
        grid-column: span 2;
    }

    .movement-form #field-localidade {
        display: grid;
        grid-template-columns: repeat(3, minmax(280px, 1fr));
        gap: 14px;
    }

    .movement-form #field-localidade label,
    .movement-form #field-funcionario label {
        width: 100%;
    }

    .movement-form #field-localidade select {
        min-width: 280px;
        max-width: none;
    }

    .movement-form .full-row,
    .movement-form .signature-wrapper,
    .movement-form #signature-clear,
    .movement-form .btn-salvar {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    header {
        padding: 24px 18px 20px;
    }

    main {
        margin-top: -20px;
        padding: 0 18px 22px;
    }

    nav {
        justify-content: center;
    }

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

    .report-buttons,
    .table-actions,
    .pagination,
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .report-button,
    .page-link {
        width: 100%;
    }
}
