:root {
    --background: #f6f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d7dce5;
    --primary: #111827;
    --primary-hover: #374151;
    --danger: #b91c1c;
    --danger-hover: #991b1b;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
    --blue-soft: #dbeafe;
    --blue-text: #1d4ed8;
    --green: #16a34a;
    --green-soft: #dcfce7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.topbar p {
    margin: 6px 0 0;
    color: var(--muted);
}

.topbar-actions,
.table-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar-actions {
    flex-direction: column;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
}

.app-version-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #f9fafb;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.page {
    padding: 22px;
    display: grid;
    gap: 16px;
}

.toolbar,
.table-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.toolbar {
    padding: 16px;
}

.toolbar label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.search-row {
    display: flex;
    gap: 10px;
}

.lines-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: end;
    gap: 16px;
}

.lines-toolbar-search {
    min-width: 0;
}

.date-filter-row {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.date-filter-field {
    min-width: 150px;
    margin: 0;
}

.date-filter-field span {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
}

.date-filter-row button {
    min-height: 37px;
}

input,
select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: #ffffff;
}

input:disabled,
select:disabled {
    background: #eef0f4;
    color: #6b7280;
}

input:focus,
select:focus {
    outline: 2px solid #c7d2fe;
    border-color: #818cf8;
}

.table-card {
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.table-header h2 {
    margin: 0;
    font-size: 18px;
}

.table-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-size-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.page-size-label select {
    width: 82px;
    padding: 7px 9px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1180px;
}

th,
td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 13px;
    vertical-align: middle;
}

th {
    background: #f9fafb;
    font-weight: 700;
    white-space: nowrap;
    padding-top: 8px;
    padding-bottom: 7px;
}

td {
    color: #374151;
    line-height: 1.15;
}


.ip-address-link {
    color: var(--blue-text);
    font-weight: 700;
    text-decoration: none;
}

.ip-address-link:hover {
    text-decoration: underline;
}


.column-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: 13px;
}

.column-button:hover {
    color: var(--blue-text);
}

.filter-button {
    display: block;
    margin-top: 4px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 10px;
}

.filter-button:hover {
    background: #d1d5db;
}

.sort-indicator {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 700;
    color: var(--blue-text);
}

.sort-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--blue-soft);
    font-size: 9px;
    color: var(--blue-text);
}

.filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: transparent;
}

.filter-dot.active {
    background: var(--blue-text);
}

.actions-header {
    text-align: center;
}

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

.icon-action-button {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
}

.icon-action-button svg {
    width: 15px;
    height: 15px;
    stroke-width: 2.2;
}

button {
    border: 0;
    border-radius: 12px;
    padding: 9px 13px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

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

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

.secondary-button {
    background: #e5e7eb;
    color: #111827;
}

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

.danger-button {
    background: var(--danger);
    color: #ffffff;
}

.danger-button:hover {
    background: var(--danger-hover);
}

.icon-button {
    background: transparent;
    color: var(--text);
    font-size: 28px;
    padding: 2px 8px;
}

.small-icon-button {
    font-size: 22px;
    line-height: 1;
}

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

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 16px;
    border-top: 1px solid var(--border);
}

.pagination-left,
.pagination-right {
    display: flex;
    align-items: center;
    gap: 9px;
}

.pagination-right button {
    padding: 8px 11px;
}

#pageInfo {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.hidden {
    display: none !important;
}

.switch-field,
.grid-switch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
}

.switch-field input,
.grid-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-slider {
    width: 42px;
    height: 23px;
    border-radius: 999px;
    background: #cbd5e1;
    position: relative;
    transition: background 0.18s ease;
    flex: 0 0 auto;
}

.switch-slider::after {
    content: "";
    width: 19px;
    height: 19px;
    border-radius: 999px;
    background: #ffffff;
    position: absolute;
    top: 2px;
    left: 2px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
    transition: transform 0.18s ease;
}

.switch-field input:checked + .switch-slider,
.grid-switch input:checked + .switch-slider {
    background: var(--green);
}

.switch-field input:checked + .switch-slider::after,
.grid-switch input:checked + .switch-slider::after {
    transform: translateX(19px);
}

.switch-text {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.grid-switch {
    justify-content: center;
}

.grid-switch .switch-slider {
    width: 38px;
    height: 21px;
}

.grid-switch .switch-slider::after {
    width: 17px;
    height: 17px;
}

.grid-switch input:checked + .switch-slider::after {
    transform: translateX(17px);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.62);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 20;
}

.modal {
    width: min(880px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.modal-header,
.filter-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

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

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

.field label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

.compact-field {
    margin-top: 14px;
}

.modal-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.form-message {
    margin-top: 14px;
    padding: 12px;
    background: #fee2e2;
    color: #7f1d1d;
    border-radius: 12px;
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #111827;
    color: #ffffff;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    z-index: 30;
    max-width: min(680px, calc(100vw - 28px));
}

.filter-popover {
    position: fixed;
    top: 120px;
    left: 120px;
    width: min(360px, calc(100vw - 28px));
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 14px;
    z-index: 25;
}

.filter-popover-header {
    margin-bottom: 10px;
}

.filter-actions-row {
    display: flex;
    gap: 8px;
    margin: 10px 0;
}

.filter-actions-row button,
.filter-footer button {
    padding: 8px 10px;
    font-size: 13px;
}

.filter-options {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    gap: 8px;
    padding: 6px 2px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14px;
}

.checkbox-line input {
    width: auto;
}

.filter-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

.filter-help {
    margin-top: 8px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

@media (max-width: 720px) {
    .topbar,
    .table-header,
    .pagination-bar {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .topbar-actions,
    .table-header-actions,
    .pagination-left,
    .pagination-right {
        flex-direction: column;
        align-items: stretch;
    }

    .app-version-label {
        align-self: flex-end;
    }

    .page {
        padding: 14px;
    }

    .search-row,
    .date-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .lines-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .date-filter-field {
        width: 100%;
    }

    .page-size-label {
        justify-content: space-between;
    }

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

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

    .modal-actions button,
    .topbar button,
    .table-header button,
    .pagination-bar button {
        width: 100%;
    }

    .toast {
        left: 14px;
        right: 14px;
        bottom: 14px;
    }

    .filter-popover {
        left: 14px !important;
        right: 14px;
        top: 90px !important;
        width: auto;
    }
}


.nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    text-decoration: none;
    padding: 9px 13px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 13px;
}

.form-grid-switch {
    min-height: 37px;
}

.lines-table {
    min-width: 1120px;
}

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.login-card h1 {
    margin: 0;
    font-size: 25px;
}

.login-card p {
    margin: 8px 0 22px;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 15px;
}

.login-button {
    width: 100%;
    margin-top: 4px;
}

.login-error {
    background: #fee2e2;
    color: #7f1d1d;
    padding: 11px 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 14px;
}


/* Fix definitivo switch in modale */
.modal-switch input:checked + .switch-slider,
.form-grid-switch input:checked + .switch-slider {
    background: var(--green) !important;
}

.modal-switch input:checked + .switch-slider::after,
.form-grid-switch input:checked + .switch-slider::after {
    transform: translateX(17px);
}

.users-table {
    min-width: 900px;
}


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

.missing-list {
    display: grid;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    margin-top: 14px;
}

.missing-item {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f9fafb;
    color: var(--text);
    font-weight: 700;
}

.missing-item:hover {
    background: var(--blue-soft);
    color: var(--blue-text);
}

.config-toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.config-toolbar-row h2 {
    margin: 0;
    font-size: 18px;
}

.config-toolbar-row p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.config-sections {
    display: grid;
    gap: 16px;
}

.config-card table {
    min-width: 880px;
}

.config-table td:first-child {
    width: 260px;
    white-space: nowrap;
}

.config-table td:nth-child(2) {
    width: 360px;
}

.config-table code {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 12px;
}

.config-switch {
    justify-content: flex-start;
}

.config-help {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 720px) {
    .config-toolbar-row {
        align-items: stretch;
        flex-direction: column;
    }

    .config-toolbar-row button {
        width: 100%;
    }
}

.keepalive-action-button {
    color: var(--blue-text);
}

.keepalive-steps {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.keepalive-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f9fafb;
    color: var(--muted);
    font-weight: 700;
}

.keepalive-step-icon {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    color: #374151;
    flex: 0 0 auto;
}

.keepalive-step.step-active {
    color: var(--blue-text);
    background: var(--blue-soft);
}

.keepalive-step.step-success {
    color: #166534;
    background: var(--green-soft);
}

.keepalive-step.step-success .keepalive-step-icon {
    background: var(--green);
    color: #ffffff;
}

.keepalive-step.step-error {
    color: #7f1d1d;
    background: #fee2e2;
}

.keepalive-step.step-error .keepalive-step-icon {
    background: var(--danger);
    color: #ffffff;
}

.keepalive-logs-table {
    min-width: 1580px;
}

.log-text-cell {
    max-width: 360px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover td {
    background: #f9fafb;
}

.log-detail-content {
    white-space: pre-wrap;
    word-break: break-word;
    background: #0f172a;
    color: #e5e7eb;
    border-radius: 14px;
    padding: 16px;
    max-height: 62vh;
    overflow: auto;
    font-size: 12px;
    line-height: 1.45;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 76px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 11px;
    font-weight: 800;
}

.status-ok {
    background: var(--green-soft);
    color: #166534;
}

.status-no_response,
.status-http_error,
.status-json_error,
.status-ftf_id_mismatch,
.status-no_ip,
.status-not_found {
    background: #fee2e2;
    color: #7f1d1d;
}

.alert-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    padding: 16px;
}

.alert-layout-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}

.alert-layout-header {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
}

.alert-layout-header h3 {
    margin: 0;
    font-size: 16px;
}

.alert-layout-header p {
    margin: 7px 0 9px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.alert-layout-header code {
    display: block;
    background: #eef0f4;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: #374151;
}

.alert-layout-frame {
    width: 100%;
    height: 520px;
    border: 0;
    background: #f3f4f6;
}

.hamburger-menu {
    position: relative;
    display: inline-flex;
    justify-content: flex-end;
}

.hamburger-menu summary {
    list-style: none;
}

.hamburger-menu summary::-webkit-details-marker {
    display: none;
}

.hamburger-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    border-radius: 12px;
    padding: 9px 13px;
    background: #e5e7eb;
    color: #111827;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.hamburger-button:hover {
    background: #d1d5db;
}

.hamburger-icon {
    font-size: 20px;
    line-height: 1;
}

.hamburger-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 260px;
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--shadow);
    z-index: 40;
}

.hamburger-dropdown .secondary-button,
.hamburger-dropdown .nav-button {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

.log-type-pill {
    min-width: 92px;
}

.log-type-keepalive {
    background: var(--blue-soft);
    color: var(--blue-text);
}

.log-type-email_test,
.status-error {
    background: #fef3c7;
    color: #92400e;
}

.smtp-transcript-content {
    min-height: 260px;
}

@media (max-width: 720px) {
    .hamburger-menu {
        width: 100%;
    }

    .hamburger-button {
        justify-content: center;
        width: 100%;
    }

    .hamburger-dropdown {
        left: 0;
        right: 0;
        width: auto;
    }
}

.scheduler-status-line {
    margin-top: 6px;
    color: var(--blue-text);
    font-weight: 700;
}

.quick-filter-button.quick-filter-active {
    background: var(--blue-soft);
    color: var(--blue-text);
    border-color: #93c5fd;
}

.scheduler-summary-card {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.scheduler-summary-card > div {
    display: grid;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f9fafb;
}

.scheduler-summary-card strong {
    font-size: 15px;
    color: var(--text);
}

.summary-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-label {
    font-weight: 700;
    margin-bottom: 4px;
}

.config-description {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

@media (max-width: 980px) {
    .scheduler-summary-card {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 620px) {
    .scheduler-summary-card {
        grid-template-columns: 1fr;
    }
}

.firmware-warning-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.45;
}

.firmware-form {
    padding: 18px;
    display: grid;
    gap: 16px;
}

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

.firmware-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 12px;
    align-items: center;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f9fafb;
    font-weight: 700;
}

.checkbox-line input {
    width: auto;
}

.danger-checkbox {
    border-color: #fecaca;
    background: #fff7f7;
    color: var(--danger);
}

.firmware-confirmation {
    padding: 14px;
    border: 1px solid #fecaca;
    border-radius: 14px;
    background: #fff7f7;
}

.firmware-confirmation label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--danger);
}

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

.firmware-log-output {
    margin: 0;
    padding: 16px;
    min-height: 260px;
    max-height: 520px;
    overflow: auto;
    background: #111827;
    color: #f9fafb;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
}

@media (max-width: 760px) {
    .firmware-form-grid,
    .firmware-options-grid {
        grid-template-columns: 1fr;
    }
}

.firmware-version-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.firmware-update-button {
    border: 0;
    border-radius: 999px;
    background: #dc2626;
    color: #ffffff;
    font-weight: 800;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(220, 38, 38, 0.22);
}

.firmware-update-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.firmware-modal-log {
    margin: 16px 0 0;
    padding: 14px;
    max-height: 360px;
    overflow: auto;
    border-radius: 14px;
    background: #111827;
    color: #f9fafb;
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.firmware-setup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 18px;
    padding: 18px;
}

.firmware-setup-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.firmware-setup-card h3 {
    margin: 0 0 14px;
}

.firmware-config-summary,
.firmware-config-summary-card {
    display: grid;
    gap: 10px;
}

.firmware-config-summary-card {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: #f9fafb;
}

.firmware-config-summary div,
.firmware-config-summary-card div {
    display: grid;
    gap: 3px;
}

.firmware-config-summary strong,
.firmware-config-summary-card strong {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.firmware-config-summary span,
.firmware-config-summary-card span {
    font-weight: 700;
    color: var(--text);
    overflow-wrap: anywhere;
}

.firmware-setup-form {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .firmware-setup-grid,
    .firmware-config-summary-card {
        grid-template-columns: 1fr;
    }
}

.firmware-local-upload-row,
.firmware-config-file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.firmware-file-path-display {
    background: #f9fafb;
}

.firmware-local-upload-button,
.firmware-config-file-button {
    white-space: nowrap;
}

@media (max-width: 760px) {
    .firmware-local-upload-row,
    .firmware-config-file-row {
        grid-template-columns: 1fr;
    }
}

textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: #ffffff;
    resize: vertical;
    font-family: Arial, Helvetica, sans-serif;
}

textarea:focus {
    outline: 2px solid #c7d2fe;
    border-color: #818cf8;
}

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

.grid-logo-select {
    min-width: 150px;
    max-width: 230px;
    padding: 6px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.logo-library-card table,
.logo-table {
    min-width: 1240px;
}

.logo-table th,
.logo-table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.logo-grid-row {
    min-height: 98px;
}

.logo-image-cell {
    width: 190px;
}

.logo-grid-image {
    display: block;
    width: 160px;
    height: 80px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #000000;
    padding: 8px;
}

.logo-preview-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #000000;
}

.logo-preview-image {
    max-width: 320px;
    max-height: 160px;
    object-fit: contain;
}

.logo-code-cell {
    font-weight: 700;
    color: var(--blue-text);
}

.logo-path-cell {
    max-width: 320px;
    word-break: break-all;
    color: var(--muted);
    font-size: 12px;
}

.grid-logo-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.logo-upload-button {
    border: 0;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 800;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}

.logo-upload-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.operations-monitor-card {
    margin-bottom: 18px;
}

.operations-monitor {
    padding: 16px;
    display: grid;
    gap: 14px;
}

.operations-monitor h3 {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--muted);
}

.operation-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #ffffff;
    padding: 14px;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.operation-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.operation-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.operation-message {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 700;
}

.operation-log-preview {
    margin: 12px 0 0;
    padding: 12px;
    max-height: 180px;
    overflow: auto;
    border-radius: 12px;
    background: #0f172a;
    color: #e5e7eb;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
}

.operation-empty-log {
    color: var(--muted);
    font-size: 13px;
    padding: 8px 0;
}

.status-running {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-warning {
    background: #fef3c7;
    color: #92400e;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

/* V11 layout guard: evita barra orizzontale della pagina, mantenendo lo scroll solo dentro la griglia */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.page,
.table-card,
.toolbar {
    max-width: 100%;
    min-width: 0;
}

.table-scroll {
    max-width: 100%;
}

.logo-pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.logo-pending-yes {
    background: #fee2e2;
    color: #991b1b;
}

.logo-pending-no {
    background: #e5e7eb;
    color: #4b5563;
}

.config-details-card {
    width: 100%;
}

.config-details-grid {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    margin-top: 18px;
}

.config-details-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.config-json-box {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 360px;
    overflow: auto;
}

@media (max-width: 1100px) {
    .config-details-grid {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 720px) {
    .config-details-grid {
        grid-template-columns: 1fr;
    }
}

.grid-ftf-link {
    color: var(--blue-text);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.grid-ftf-link:hover {
    color: var(--blue);
}

/* V31 griglia device compatta leggibile */
.device-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.device-table th,
.device-table td {
    padding: 5px 6px;
    font-size: 13px;
    line-height: 1.12;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.device-table th {
    padding-top: 6px;
    padding-bottom: 5px;
    vertical-align: bottom;
    white-space: normal;
}

.device-table .column-button {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 2px 4px;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.05;
    white-space: normal;
}

.device-table .column-button .header-line {
    display: block;
    width: 100%;
}

.device-table .sort-indicator,
.device-table .filter-dot {
    flex: 0 0 auto;
}

.device-table .filter-button {
    margin-top: 2px;
    padding: 2px 5px;
    font-size: 9px;
}

.device-table .grid-logo-cell {
    display: block;
    min-width: 0;
}

.device-table .grid-logo-select {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 4px 5px;
    border-radius: 8px;
    font-size: 12px;
}

.device-table .logo-upload-button {
    padding: 4px 7px;
    font-size: 11px;
}

.device-table .logo-pending-badge {
    min-width: 26px;
    padding: 3px 6px;
    font-size: 11px;
}

.device-table .grid-date-cell {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    max-width: 100%;
    font-size: 11px;
    line-height: 1.08;
    white-space: nowrap;
}

.device-table .actions {
    gap: 4px;
    flex-wrap: nowrap;
}

.device-table .icon-action-button {
    width: 26px;
    height: 26px;
    padding: 5px;
}

.device-table .grid-switch {
    min-width: 34px;
}

.device-table .switch-slider {
    width: 32px;
    height: 18px;
}

.device-table .switch-slider::after {
    width: 14px;
    height: 14px;
    top: 2px;
    left: 2px;
}

.device-table .grid-switch input:checked + .switch-slider::after {
    transform: translateX(14px);
}

.device-table th:nth-child(1),
.device-table td:nth-child(1) { width: 7%; }
.device-table th:nth-child(2),
.device-table td:nth-child(2) { width: 5%; }
.device-table th:nth-child(3),
.device-table td:nth-child(3) { width: 4%; }
.device-table th:nth-child(4),
.device-table td:nth-child(4) { width: 8%; }
.device-table th:nth-child(5),
.device-table td:nth-child(5) { width: 8%; }
.device-table th:nth-child(6),
.device-table td:nth-child(6) { width: 6%; }
.device-table th:nth-child(7),
.device-table td:nth-child(7) { width: 6%; }
.device-table th:nth-child(8),
.device-table td:nth-child(8) { width: 6%; }
.device-table th:nth-child(9),
.device-table td:nth-child(9) { width: 6%; }
.device-table th:nth-child(10),
.device-table td:nth-child(10) { width: 9%; }
.device-table th:nth-child(11),
.device-table td:nth-child(11) { width: 9%; }
.device-table th:nth-child(12),
.device-table td:nth-child(12) { width: 5%; }
.device-table th:nth-child(13),
.device-table td:nth-child(13) { width: 4%; }
.device-table th:nth-child(14),
.device-table td:nth-child(14) { width: 7%; }
