body {
    font-family: Arial, sans-serif;
    background: #f4f7fb;
    margin: 0;
    padding: 0;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 40px auto;
    background: #fff;
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.login-box {
    max-width: 400px;
    margin-top: 100px;
}

h1 {
    margin-top: 0;
}

label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd3dd;
    border-radius: 6px;
    box-sizing: border-box;
}

button,
.btn-secondary,
.btn-danger,
.btn-console,
.btn-warning {
    display: inline-block;
    padding: 7px 10px;
    margin-top: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
    font-size: 14px;
}

button {
    background: #1f6feb;
}

.btn-secondary {
    background: #6c757d;
}

.btn-warning {
    background: #dc3545;
}
.btn-danger{
    background: #000000;
}
.btn-console{
    background: #00FF00;
}
.disabled
{
    background: #bbbbbb;
}

.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.alert.error {
    background: #f8d7da;
    color: #842029;
}

.alert.success {
    background: #d1e7dd;
    color: #0f5132;
}

.user-form-box {
    background: #f9fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 24px;
}

.user-form-box h2 {
    margin-top: 0;
    font-size: 17px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-row input[disabled] {
    background: #eef0f3;
    color: #6c757d;
}

select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccd3dd;
    border-radius: 6px;
    box-sizing: border-box;
    background: #fff;
}

.hint {
    font-weight: normal;
    font-size: 12.5px;
    color: #6c757d;
}

.server-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px 16px;
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    margin-top: 6px;
    background: #fff;
}

.server-checklist-item {
    display: flex !important;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    margin: 0 !important;
}

.server-checklist-item input {
    width: auto;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-on {
    background: #d1e7dd;
    color: #0f5132;
}

.badge-off {
    background: #e9ecef;
    color: #495057;
}

.qrcode-box {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin: 8px 0;
}

.manual-key {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    letter-spacing: 1px;
    background: #f4f7fb;
    border: 1px dashed #ccd3dd;
    border-radius: 6px;
    padding: 10px 14px;
    display: inline-block;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.recovery-codes code {
    display: block;
    text-align: center;
    background: #f4f7fb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px;
    font-size: 15px;
    letter-spacing: 1px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

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

table th,
table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 12px;
    text-align: left;
}

table th, tr:nth-child(even)
{
    background-color: #e8e8e8;
}

form {
    display: inline;
}

/* ==========================================================================
   Registro de acciones (logs.php)
   ========================================================================== */

.log-filters {
    display: block;
    background: #f9fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 20px;
}

.log-detail {
    background: #0e1116;
    color: #d6e0ea;
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    max-width: 420px;
    white-space: pre-wrap;
    word-break: break-word;
}

details summary {
    cursor: pointer;
    color: #1f6feb;
    font-size: 13px;
}

.badge-error {
    background: #f8d7da;
    color: #842029;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.pagination a {
    display: inline-block;
    min-width: 32px;
    text-align: center;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #ccd3dd;
    color: #1f6feb;
    text-decoration: none;
    font-size: 13px;
}

.pagination a.page-current {
    background: #1f6feb;
    color: #fff;
    border-color: #1f6feb;
}

/* ==========================================================================
   Ajustes generales necesarios antes del responsive
   ========================================================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

/* La regla original "form { display: inline; }" es intencionada para que
   los mini-formularios de acciones (encender/apagar/borrar...) no rompan
   la línea dentro de una celda de tabla. Los formularios "grandes" (login,
   alta/edición de usuario, filtros) necesitan comportarse como bloques. */
.login-box form,
.user-form,
.log-filters {
    display: block;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.action-buttons form {
    margin: 0;
}

.action-buttons button {
    margin-top: 0;
    white-space: nowrap;
}

/* Evita que una tabla ancha reviente el layout en pantallas intermedias,
   incluso antes de pasar al modo "tarjetas" en móvil. */
.table-scroll {
    width: 100%;
    overflow-x: auto;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
    .container {
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding: 16px;
        min-height: 100vh;
    }

    .login-box {
        min-height: auto;
        margin-top: 0;
    }
}

@media (max-width: 720px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .topbar > div {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        width: 100%;
    }

    .topbar > div span {
        width: 100%;
        margin-bottom: 2px;
    }

    .topbar a,
    .topbar button {
        margin-top: 0;
    }

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

    .server-checklist {
        grid-template-columns: 1fr;
        max-height: 260px;
    }

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

    /* Tablas -> tarjetas apiladas. Cada <td> muestra su etiqueta gracias a
       data-label, definido en el PHP de cada pantalla con tabla. */
    table
    {
        border:1px solid #000;
    }
    table thead {
        display: none;
    }

    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }

    table tr {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 8px 12px;
    }

    table td {
        border-bottom: 1px solid #f0f2f5;
        padding: 8px 0;
        text-align: left;
    }

    table td:last-child {
        border-bottom: none;
    }

    table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: #8a93a1;
        margin-bottom: 4px;
    }

    .log-detail {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    h1 {
        font-size: 20px;
    }

    button, .btn-secondary, .btn-danger, .btn-console, .btn-warning {
        width: 100%;
        text-align: center;
    }

    .action-buttons button,
    .action-buttons .btn-secondary,
    .action-buttons .btn-danger,
    .action-buttons .btn-console,
    .action-buttons .btn-warning,
    .topbar button,
    .topbar .btn-secondary {
        width: auto;
    }

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