:root {
    color-scheme: dark;
    --bg: #0b0d10;
    --panel: #11151b;
    --panel-strong: #161b22;
    --border: #252c36;
    --text: #edf1f7;
    --muted: #8f9baa;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.12);
    --accent-border: rgba(59, 130, 246, 0.38);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(239, 68, 68, 0.38);
    --warning: #eab85d;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: #3b4654 #0c1016;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
    background: #0c1016;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    border: 2px solid #0c1016;
    border-radius: 999px;
    background: #3b4654;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
    background: #4b5868;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.content {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px 32px;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 18px;
}

h1:focus {
    outline: none;
}

.worker-page {
    display: grid;
    gap: 24px;
}

.worker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.worker-header h1 {
    margin: 0;
    color: var(--text);
    font-size: 2.25rem;
    font-weight: 650;
}

.worker-header p {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 10px !important;
    color: var(--accent) !important;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: var(--panel);
    white-space: nowrap;
}

.status-badge.running {
    color: #bfdbfe;
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

.status-badge.stopped {
    color: #fecaca;
    border-color: var(--danger-border);
    background: var(--danger-soft);
}

.status-badge.stopping {
    color: #ffe2ad;
    border-color: rgba(234, 184, 93, 0.35);
    background: rgba(234, 184, 93, 0.12);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 128px;
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-strong);
    cursor: pointer;
}

.action-button:hover:not(:disabled) {
    border-color: #3b4654;
    background: #1b222c;
}

.action-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.action-button span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.action-button.start span {
    background: var(--accent);
}

.action-button.stop span {
    background: var(--danger);
}

.action-button.save span {
    background: var(--accent);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric,
.activity-panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
}

.metric {
    min-height: 50px;
    padding: 14px 16px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.metric strong {
    display: block;
    margin-top: 8px;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.activity-panel {
    padding: 20px;
}

.table-panel {
    display: grid;
    gap: 18px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
}

.table-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.table-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 650;
}

.table-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.reload-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-strong);
    cursor: pointer;
}

.reload-button:hover {
    border-color: #3b4654;
    background: #1b222c;
}

.reload-icon {
    position: relative;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent);
    border-right-color: transparent;
    border-radius: 999px;
}

.reload-icon::after {
    content: "";
    position: absolute;
    right: -3px;
    top: 0;
    width: 6px;
    height: 6px;
    border-top: 2px solid var(--accent);
    border-right: 2px solid var(--accent);
    transform: rotate(45deg);
}

.table-scroll {
    max-height: min(52vh, 560px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #3b4654 #0c1016;
}

.table-scroll::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-scroll::-webkit-scrollbar-track {
    background: #0c1016;
    border-radius: 999px;
}

.table-scroll::-webkit-scrollbar-thumb {
    border: 2px solid #0c1016;
    border-radius: 999px;
    background: #3b4654;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: #4b5868;
}

.filters-grid {
    display: grid;
    grid-template-columns: 160px repeat(3, minmax(0, 1fr)) auto;
    gap: 14px;
    align-items: end;
}

.filters-grid.laudos-filters {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 18px 20px;
    align-items: end;
}

.filters-grid.laudos-filters .filters-actions {
    align-items: stretch;
}

.filters-grid.laudos-filters .filters-actions .pagination-button {
    width: 100%;
    min-height: 42px;
}

.filters-grid label {
    display: grid;
    gap: 8px;
}

.filters-grid label span {
    color: var(--muted);
    font-size: 0.85rem;
}

.filters-grid input,
.filters-grid select {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.filters-grid input:focus,
.filters-grid select:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.filters-actions {
    display: flex;
    align-items: end;
}

.filters-actions .pagination-button {
    min-height: 42px;
}

.migration-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.migration-table.laudos-table {
    min-width: 1400px;
}

.migration-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
}

.migration-table th,
.migration-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.migration-table th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.migration-table td {
    color: var(--text);
}

.migration-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.migration-table tbody tr:last-child td {
    border-bottom: 0;
}

.empty-table {
    color: var(--muted) !important;
    text-align: center !important;
}

.pagination-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-top: 2px;
}

.page-size label {
    display: grid;
    gap: 8px;
}

.page-size label span,
.pagination-controls span {
    color: var(--muted);
    font-size: 0.85rem;
}

.page-size input {
    width: 132px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.page-size input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pagination-button {
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-strong);
    cursor: pointer;
}

.pagination-button:hover:not(:disabled) {
    border-color: #3b4654;
    background: #1b222c;
}

.pagination-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.table-danger-button {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--danger-border);
    border-radius: 8px;
    color: #fecaca;
    background: var(--danger-soft);
    cursor: pointer;
    white-space: nowrap;
}

.table-danger-button:hover:not(:disabled) {
    border-color: rgba(239, 68, 68, 0.68);
    background: rgba(239, 68, 68, 0.18);
}

.table-danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.62);
}

.modal-panel {
    width: min(520px, 100%);
    display: grid;
    gap: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 650;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--panel-strong);
    cursor: pointer;
}

.modal-close:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.modal-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.modal-form label {
    display: grid;
    gap: 8px;
}

.modal-form label span {
    color: var(--muted);
    font-size: 0.85rem;
}

.modal-form input {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.modal-form input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-form select {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.modal-form select:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.modal-form.laudos-import-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.activity-line {
    display: flex;
    align-items: center;
    gap: 14px;
}

.activity-line strong {
    display: block;
    margin-bottom: 4px;
}

.activity-line p {
    margin: 0;
    color: var(--muted);
}

.activity-pulse {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    border-radius: 999px;
    background: #5c6673;
}

.activity-pulse.running {
    background: var(--accent);
    box-shadow: 0 0 0 6px var(--accent-soft);
}

.activity-pulse.stopping {
    background: var(--warning);
    box-shadow: 0 0 0 6px rgba(234, 184, 93, 0.1);
}

.settings-panel {
    display: grid;
    gap: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.settings-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 650;
}

.settings-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.settings-header > span {
    color: #bfdbfe;
    white-space: nowrap;
}

.settings-form {
    display: grid;
    grid-template-columns: 1fr 180px 260px;
    gap: 14px;
}

.settings-group-heading {
    grid-column: 1 / -1;
    display: grid;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.settings-group-heading:first-child {
    padding-top: 0;
    border-top: 0;
}

.settings-group-heading h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
}

.settings-group-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.settings-form label {
    display: grid;
    gap: 8px;
}

.settings-form label span {
    color: var(--muted);
    font-size: 0.85rem;
}

.settings-form input,
.settings-form textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.settings-form .checkbox-field {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 23px;
}

.settings-form .checkbox-field input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    padding: 0;
    flex: 0 0 18px;
}

.settings-form textarea {
    resize: vertical;
}

.settings-form input:focus,
.settings-form textarea:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
}

.login-page {
    width: 100%;
    display: grid;
    place-items: center;
}

.login-panel {
    width: min(420px, 100%);
    display: grid;
    gap: 18px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
}

.login-panel h1 {
    margin: 0;
    font-size: 2rem;
}

.login-panel p {
    margin: 8px 0 0;
    color: var(--muted);
}

.login-panel label {
    display: grid;
    gap: 8px;
}

.login-panel label span {
    color: var(--muted);
    font-size: 0.85rem;
}

.login-panel input {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #0c1016;
    outline: none;
}

.login-panel input:focus {
    border-color: var(--accent-border);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-error {
    padding: 10px 12px;
    border: 1px solid var(--danger-border);
    border-radius: 8px;
    color: #fecaca;
    background: var(--danger-soft);
}

.blazor-error-boundary {
    padding: 1rem;
    color: white;
    background: #7f1d1d;
}

.blazor-error-boundary::after {
    content: "Ocorreu um erro.";
}

@media (max-width: 900px) {
    .status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .settings-form {
        grid-template-columns: 1fr;
    }

    .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-grid.laudos-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-actions {
        align-items: stretch;
    }

    .filters-actions .pagination-button {
        width: 100%;
    }

    .pagination-bar {
        display: grid;
        align-items: stretch;
    }

    .table-header {
        display: grid;
    }

    .reload-button {
        width: fit-content;
    }

    .table-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 32px 18px;
    }

    .worker-header {
        display: grid;
    }

    .worker-header h1 {
        font-size: 1.8rem;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .action-button {
        width: 100%;
    }

    .settings-header {
        display: grid;
    }

    .settings-actions {
        justify-content: stretch;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filters-grid.laudos-filters {
        grid-template-columns: 1fr;
    }

    .pagination-controls {
        justify-content: space-between;
    }

    .reload-button {
        width: 100%;
    }

    .modal-form {
        grid-template-columns: 1fr;
    }

    .modal-form.laudos-import-form {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        display: grid;
    }
}
