:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d1d5db;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #6b7280;
    --secondary-hover: #4b5563;
    --ok: #166534;
    --warn: #b45309;
    --danger: #b91c1c;
    --shadow: 0 4px 14px rgba(0,0,0,0.04);
}

* {
    box-sizing: border-box;
}

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

.contenedor-principal {
    width: min(1200px, 96%);
    margin: 16px auto;
}

.app-header {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.app-titulo {
    margin: 0 0 6px 0;
    font-size: 1.8rem;
}

.app-subtitulo {
    color: var(--muted);
    font-size: 0.95rem;
}

.menu-principal {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.menu-principal a {
    text-decoration: none;
    background: #eef2ff;
    color: #1e3a8a;
    border: 1px solid #c7d2fe;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: bold;
}

.menu-principal a:hover {
    background: #dbeafe;
}

.menu-principal a.activo {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.caja {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

h2, h3 {
    margin-top: 0;
}

label {
    font-weight: bold;
    display: block;
    margin-bottom: 6px;
}

input, select, button, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
}

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

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

.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.campo-completo {
    grid-column: 1 / -1;
}

.acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

button, .boton {
    display: inline-block;
    width: auto;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    background: var(--primary);
    color: #fff;
}

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

.boton-secundario {
    background: var(--secondary);
}

.boton-secundario:hover {
    background: var(--secondary-hover);
}

.mensaje {
    background: #e8f7e8;
    border: 1px solid #93d293;
    color: #1f5f1f;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.error {
    background: #fdeaea;
    border: 1px solid #e5a4a4;
    color: #842029;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
}

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

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

th, td {
    border: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f9fafb;
}

.tarjetas-movil {
    display: none;
}

.tarjeta-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    background: #fff;
    margin-bottom: 12px;
}

.tarjeta-item .titulo {
    font-size: 1.05rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.ok { color: var(--ok); font-weight: bold; }
.warn { color: var(--warn); font-weight: bold; }
.danger { color: var(--danger); font-weight: bold; }

.app-footer {
    text-align: center;
    color: var(--muted);
    padding: 16px 0 30px;
    font-size: 0.92rem;
}

@media (max-width: 900px) {
    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }

    .tabla-wrap {
        display: none;
    }

    .tarjetas-movil {
        display: block;
    }
}

@media (max-width: 640px) {
    .contenedor-principal {
        width: min(100%, 96%);
        margin: 12px auto;
    }

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

    .app-header,
    .caja {
        padding: 14px;
    }

    .app-titulo {
        font-size: 1.45rem;
    }

    input, select, button, .boton, textarea {
        font-size: 16px;
    }

    .boton, button {
        width: 100%;
        text-align: center;
    }

    .acciones {
        flex-direction: column;
    }
}

.boton-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    margin-right: 4px;
    vertical-align: middle;
}

    .boton-icono.secundario {
        background: #6b7280;
    }

    .boton-icono.ok {
        background: #166534;
    }

    .boton-icono.peligro {
        background: #b91c1c;
    }